Originally posted by: SystemAdmin
I have a equation that uses a sum in all my index, thsi equation has a function that is using the function next(), this is:
sum (i in Sections, j in Range) Something[i][j]*Y[i][j] - Penalty[i][j]*Y
nextc(Sections,i)[j]
For the last index i what is the Y
nextc(Sections,i)[j] value? is it the value of the first i? this is:
Something[1][1]*Y[1][1] - Penalty[1][1]*Y[2][1] + ... + Something[9][1]*Y[9][1] - Penalty[9][1]*Y[1][1] ?
I also have to do a comparison between some indexes. Something like this:
sum (j in Range) Y[1][j]==Y
42[j]
sum (j in Range) Y[2][j]==Y
41[j]
sum (j in Range) Y[3][j]==Y
40[j]
sum (j in Range) Y[4][j]==Y
39[j]
As you can see the in the left side it increases by one and in the right side it decreases by one, starting at 42.
I could do this one by one, would not be much work but I was wondering if it is possible to do with a single line, something like:
forall (i in Sections) sum (j in Range) Y[i][j] == sum (j in Range) Y
item(Sections,43 - ord(Sections,i))[j];
This brings me an error telling CPLEX cannot extract expression. I came up in the error and sorted that the first index for cplex is 0 thus if I have 42 arguments in index i I will have
http://0..41 and my constrain will now be:
forall (i in Sections) sum (j in Range) Y[i][j] == sum (j in Range) Y
item(Sections,41 - ord(Sections,i))[j];
Ofcourse I only have to do i from 0 to 20 (half of the index). But do you see any problem (reduce performance) if I let it like this?
basically I am not much used with cplex and this language and I have a 42x11 binary decision variable matrix (which is constrained to only one 1 per column and I constrains the numbers of total 1 in order to reduce the computing time) thus it requires a lot of time to calculate so I was checking if this is the best way to proceed.
#DecisionOptimization#OPLusingCPLEXOptimizer