ERROR: j is not defined

8 views
Skip to first unread message

Prashanth Cp

unread,
Sep 24, 2017, 7:39:38 PM9/24/17
to AMPL Modeling Language
I am new to AMPL and learning the language along with my course: operations research. This is my code(basic level) :=

set tool;
set machine;
param maxweight=15000;
param profit{tool};
param demand{tool};
param time{tool,machine};
param maxtime{machine};
param weight{tool};
var number{tool};
maximize money: sum{i in tool} profit[i]*number[i];
subject to steel: sum{i in tool} weight[i]*number[i]<=maxweight;
subject to mouldandassemb {i in tool}:
 sum{j in machine} time[i,j]*number[i]<=maxtime[j]; # error j is not defined
subject to totaldemand {i in tool}: tool[i]<=demand[i];

Please point out any syntax or parenthesis mistakes

Thanks,

Robert Fourer

unread,
Sep 25, 2017, 10:53:28 AM9/25/17
to am...@googlegroups.com
In your constraint mouldandassemb, j is only defined within the summation "sum{j in machine} time[i,j]*number[i]". The j in maxtime[j] is not defined. This is an error of logic rather than syntax; you will need to re-think the constraint so that the expression on the right-hand side of <= does not depend on j. Since your constraints are indexed over {i in tool}, most likely this expression should depend on i instead.

Bob Fourer
am...@googlegroups.com

=======
Reply all
Reply to author
Forward
0 new messages