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]*Ynextc(Sections,i)[j]
For the last index i what is the Ynextc(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]==Y42[j]
sum (j in Range) Y[2][j]==Y41[j]
sum (j in Range) Y[3][j]==Y40[j]
sum (j in Range) Y[4][j]==Y39[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) Yitem(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) Yitem(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.
Topic
This topic has been locked.
2 replies
Latest Post
 20130405T11:50:40Z by SystemAdmin
ACCEPTED ANSWER
Pinned topic Function Next(), ord() and item() help
20130327T12:11:15Z

Answered question
This question has been answered.
Unanswered question
This question has not been answered yet.
Updated on 20130405T11:50:40Z at 20130405T11:50:40Z by SystemAdmin

ACCEPTED ANSWER
Re: Function Next(), ord() and item() help
20130329T09:45:19Z in response to SystemAdminHi,
the documentation says
next Returns the successor, or relative successor, to an element in a set if it exists and raises an error otherwise.
nextc is a circular version of the function next and considers that the successor of the last element of the type is the first element.
So to your question, For the last index i what is the next c, well it is the first element
forall (i in Sections) sum (j in Range) Y[i][j] == sum (j in Range) Y[item(Sections,41  ord(Sections,i))][j];
looks fine
regardsUpdated on 20140326T05:50:02Z at 20140326T05:50:02Z by AlexFleischer 
ACCEPTED ANSWER
Re: Function Next(), ord() and item() help
20130405T11:50:40Z in response to SystemAdminThank you.