expected numeric expression opcode

22 views
Skip to first unread message

forest...@gmail.com

unread,
Jul 3, 2016, 4:10:23 PM7/3/16
to AMPL Modeling Language
please help to fix model

param n integer, := 3;
param g integer, := 4+4*n*(n-1);
param K integer, := 2*n*(n-1);
param f integer, := K div 2;
set Z := {3,5,7,11,13,17,19,23};

var X {1..n, 1..n, Z} binary;
var S {1..K, 1..K} binary;

subject to c1 {i in 1..f} : ((sum {q in Z} (if X[2 - i mod 2, 3 - i mod 3, q] then q)) +
                            (sum {q in Z} (if X[2 - i mod 2 + 1, 3 - i mod 3, q] then q))) =
                            (sum {j in 1..K} (if S[i,j] then 4+2*j));

subject to c2 {i in 1..f} : ((sum {q in Z} (if X[3 - i mod 3, 2 - i mod 2, q] then q)) +
                            (sum {q in Z} (if X[3 - i mod 3, 2 - i mod 2 + 1, q] then q))) =
                            (sum {j in 1..K} (if S[6+i,j] then 4+2*j));

subject to c3 {i in 1..n, j in 1..n} : exactly 1 {q in Z} (X[i,j,q]);
subject to c4 {i in 1..K} : exactly 1 {j in 1..K} (S[i,j]);
subject to c5 {j in 1..K} : exactly 1 {i in 1..K} (S[i,j]);


option solver jacop;
option jacop_options 'version timing=1 outlev=1 outfreq=10 timelimit=60';

#option solver gecode;
#option gecode_options 'outlev=1 outfreq=10 timelimit=60';

#option solver ilogcp;
#option ilogcp_options 'version timing=1 timelimit=300 logperiod=1000000 outlev=verbose';

#option solver locsol;
#option locsol_options 'version verbosity=normal timing=1 time_between_displays=10 timelimit=60';

solve;
display X;


i get this error

jacop 4.1.0: version
timing=1
outlev=1
outfreq=10
timelimit=60
JaCoP 4.1.0 (Windows AMD64), driver(20141107), ASL(20141202)
Error: C:\Users\User\AppData\Local\Temp\at3888.nl:offset 4310: expected numeric expression opcode
exit code 1
<BREAK>

Robert Fourer

unread,
Jul 8, 2016, 5:41:01 PM7/8/16
to am...@googlegroups.com
This formulation seems to be very close to being linearized. I changed

subject to c1 {i in 1..f} : ((sum {q in Z} (if X[2 - i mod 2, 3 - i mod 3, q] then q)) +
(sum {q in Z} (if X[2 - i mod 2 + 1, 3 - i mod 3, q] then q))) =
(sum {j in 1..K} (if S[i,j] then 4+2*j));

to

subject to c1 {i in 1..f} : ((sum {q in Z} (q * X[2 - i mod 2, 3 - i mod 3, q])) +
(sum {q in Z} (q * X[2 - i mod 2 + 1, 3 - i mod 3, q]))) =
(sum {j in 1..K} ((4+2*j) * S[i,j]));

and I changed

subject to c3 {i in 1..n, j in 1..n} : exactly 1 {q in Z} (X[i,j,q]);

to

subject to c3 {i in 1..n, j in 1..n} : sum {q in Z} (X[i,j,q]) = 1;

and similarly for other constraints of the same forms, and then I was able to use a MIP solver as shown in the listing below. I can't guarantee that the result is what you want, but this should give you an idea what you might do.

There seems to be a bug somewhere when JaCoP is used, but I am not sure what it is.

Bob Fourer
am...@googlegroups.com

///////

ampl: option solver gurobi;
ampl: solve;

Gurobi 6.5.1: optimal solution; objective 0
3663 simplex iterations
227 branch-and-cut nodes

ampl: option display_1col 10000, omit_zero_rows 1;
ampl: display X;
X :=
1 1 5 1
1 2 17 1
1 3 7 1
2 1 11 1
2 2 3 1
2 3 5 1
3 1 7 1
3 2 3 1
3 3 23 1
;

ampl: display S;
S :=
1 8 1
2 7 1
3 4 1
4 1 1
5 6 1
6 12 1
7 5 1
8 10 1
9 3 1
10 2 1
11 9 1
12 11 1
;

ampl:

=======

forest...@gmail.com

unread,
Jul 9, 2016, 4:56:59 AM7/9/16
to AMPL Modeling Language, 4...@ampl.com
thanks!

error "
expected numeric expression opcode" is repeated in jacop, gecode, ilogcp and locsol solvers.

maybe it's not error solvers, but error ampl.

Victor Zverovich

unread,
Jul 15, 2016, 1:12:32 PM7/15/16
to am...@googlegroups.com
The error that caused "expected numeric expression opcode" has been fixed in the latest version of AMPL. Thanks for reporting!

HTH,
Victor

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages