can't convert to a number

413 views
Skip to first unread message

Milan Marinkovic

unread,
Nov 24, 2015, 12:09:16 PM11/24/15
to AMPL Modeling Language
In my work when I give command solve there is an error:

Error executing "solve" command:
error processing constraint engines['mo','Y1']:
can't convert 'mo' to a number.

Where is:
set J;
set day;

param G{i in day, j in J};

subject to engines {i in day, j in J}: y[i,j] + G[i,j] + (sum{m in J} x[i,m,j]) - (sum{n in J} x[i,j,n]) = y[(i+1),j];

and 

set J := Y1 Y2 Y3 ;
set day := mo tu we th fr sa su;

param G: Y1 Y2 Y3 :=
mo 8 4 4 
tu 7 4 1
we 4 3 4
th 6 3 1
fr 4 4 1
sa 7 5 4
su 10 4 2;

Or see in attachment whole model and data.


data.dat
model.mod

Victor Zverovich

unread,
Nov 24, 2015, 3:16:04 PM11/24/15
to am...@googlegroups.com
You using an index over set day in an arithmetic expression i+1, but day contains strings, not numbers. A simple solution is to make set day circular or ordered and use next instead of increment:

  set day circular;
  subject to engines {i in day, j in J}: ... = y[next(i),j];

See section 5.6 Ordered sets of the AMPL book for more details.

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 http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages