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*Y - Penalty*Y + ... + Something*Y - Penalty*Y ?
I also have to do a comparison between some indexes. Something like this:
sum (j in Range) Y[j]==Y42[j]
sum (j in Range) Y[j]==Y41[j]
sum (j in Range) Y[j]==Y40[j]
sum (j in Range) Y[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.
Pinned topic Function Next(), ord() and item() help
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2013-04-05T11:50:40Z at 2013-04-05T11:50:40Z by SystemAdmin
AlexFleischer 270002VCBK1952 Posts
Re: Function Next(), ord() and item() help2013-03-29T09:45:19ZThis is the accepted answer. This is the accepted answer.Hi,
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];
regardsUpdated on 2014-03-26T05:50:02Z at 2014-03-26T05:50:02Z by AlexFleischer