syntax error

43 views
Skip to first unread message

Milan Marinkovic

unread,
Nov 20, 2015, 12:44:07 PM11/20/15
to AMPL Modeling Language
Can anyone tell me where is error on this constrain:

subject to fleet {i in day, j in J}: sum{j in J} y[i,j] <= S;
syntax error


param:
set S;
set J;
set day;

variable:
var y {i in day, j in J} integer;

function:
minimize Z: sum {i in 1..7, j in J, k in J} (F[j,k] * b[i,j,k] + V[j,k] * x[i,j,k]);

Victor Zverovich

unread,
Nov 20, 2015, 1:27:16 PM11/20/15
to am...@googlegroups.com
You have identically named dummy indices "j" in indexing expressions with overlapping scopes, {..., j in J} and {j in J}. Rename one of the indices or remove one of the indexing expression if it is not used, e.g.

  subject to fleet {i in day}: sum{j in J} y[i,j] <= S;

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.

Milan Marinkovic

unread,
Nov 21, 2015, 9:39:43 AM11/21/15
to AMPL Modeling Language
I have one more question, when I input model and data files and try to run it there is an error:

Error executing "solve" command:
error processing param F:
21 invalid subscripts discarded:
F['m1','Y1']
F['m1','Y2']
F['m1','Y3']
and 18 more.
Error executing "solve" command:
error processing param V:
21 invalid subscripts discarded:
V['m1','Y1']
V['m1','Y2']
V['m1','Y3']
and 18 more.
Error executing "solve" command:
error processing param G:
9 invalid subscripts discarded:
G['Y1','Y1']
G['Y1','Y2']
G['Y1','Y3']
and 6 more.
Error executing "solve" command:
error processing objective Z:
no value for F['Y1','Y1']


Can you help me how to solve it?
model.mod
data.dat

Robert Fourer

unread,
Nov 22, 2015, 10:13:10 PM11/22/15
to am...@googlegroups.com
You are seeing "invalid subscripts discarded" error messages because your data does not correspond to the indexing of your variables. For example you have

param F {j in J, k in K};

so the first subscript of F should be from J and the second subscript of F should be from K. In your data the sets are given by

set J := Y1 Y2 Y3 ;
set K := Y1 Y2 Y3 ;
set S := m1 m2 m3 m4 m5 m6 m7;

But the data for F is specified by

param F: Y1 Y2 Y3 :=
m1 6 7 3
m2 5 5 2
m3 5 4 2
m4 4 4 2
m5 5 3 1
m6 7 7 2
m7 5 9 2;

which shows the first subscript coming from S rather than from J.

Bob Fourer
am...@googlegroups.com

=======

Milan Marinkovic

unread,
Nov 23, 2015, 6:11:53 PM11/23/15
to AMPL Modeling Language
I solve that problem, thank you, but there is another one:


Error executing "solve" command:
error processing objective Z:
invalid subscript b[1,'Y1','Y1']

Can you help me with this? 

Robert Fourer

unread,
Nov 24, 2015, 3:06:47 PM11/24/15
to am...@googlegroups.com
It appears that you wrote "set day := 7;" in your data, so that 1 is not a member of set day, and b[1,'Y1','Y1'] is not defined. Try "set day := 1 2 3 4 5 6 7;".

Bob Fourer
am...@googlegroups.com

=======

From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of Milan Marinkovic
Sent: Monday, November 23, 2015 5:12 PM
To: AMPL Modeling Language
Reply all
Reply to author
Forward
0 new messages