error processing constraint night_morning[1,7,1]: invalid subscript assignment[7,1,1,3]
assignment[7,1,1,3] + assignment[7,2,1,1] <= 1
var assignment {i in I, j in J, k in K, l in L} binary;
ampl: display I,J,K,L; set I := 1 2 3 4 5 6; set J := 1 2 3; set K := 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; set L := 1 2 3;
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1984344618-5888491673-1660939569-1157747738%40helpscout.net.
param needed: 1 2 3 := 1 3 4 2 2 3 4 5 3 4 3 4 4 4 3 3 5 3 4 4 6 3 3 2 ;
Hello Sir! Thank you for the response. I am now getting this error when running my code and data file. Please help. The first photo is my data file and the second photo is the mod file. The last photo is the mathematical code and constraints as our basis Sir.
On Fri, Aug 19, 2022 at 8:05 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
When you try to solve, you are seeing this error message:error processing constraint night_morning[1,7,1]: invalid subscript assignment[7,1,1,3]
According to your definition in the model, constraint night_morning[1,7,1] should be this:assignment[7,1,1,3] + assignment[7,2,1,1] <= 1
But the error message is telling you that the variable assignment[7,1,1,3] does not exist. To see why, observe that "var assignment" is defined as follows,var assignment {i in I, j in J, k in K, l in L} binary;
The four indexing sets are given as follows by the data:ampl: display I,J,K,L; set I := 1 2 3 4 5 6; set J := 1 2 3; set K := 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; set L := 1 2 3;
Thus assignment[7,1,1,3] does not exist because 7 is not in the set I. Maybe you meant to write "assignment[i,3,k,l] + assignment[i+1,1,k,l]".
--
Robert Fourer
am...@googlegroups.com