Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Function Next(), ord() and item() help

    Posted 03/27/13 08:11 AM

    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]*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.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Function Next(), ord() and item() help

    Posted 03/29/13 05:45 AM
    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];
    


    looks fine

    regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Function Next(), ord() and item() help

    Posted 04/05/13 07:51 AM

    Originally posted by: SystemAdmin


    Thank you.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer