Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  conditional decision variables

    Posted 10/04/19 03:53 PM

    Originally posted by: JPatrick


    I want to create a decision variable that is the upper half of a nxn matrix.  I know I can define dvar x[Size][Size] and then simply force the lower half of the matrix to be zero but that seems wasteful.  Is there no way to conditionally define the decision variable?  I tried the following:

     dvar int x[i in Size][j in Size: i < j] in 0..1;
    but OPL did not like it.

    Jonathan


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: conditional decision variables

    Posted 10/05/19 06:53 AM

    Hi,

    you could use a tuple set in order to deal with half the matrix.

    And then if you need an index with 2 dimensions, you may use a dexpr. (y in my tiny example)

    int Size=4;

    tuple t
    {
    int i;
    int j;
    }

    {t} index={<i,j> | ordered i,j in 1..Size};

    dvar int x[index] in 0..1;
    dexpr int y[i in 1..Size,j in 1..Size]=(i==j)?0:((i<j)?x[<i,j>]:x[<j,i>]);


    subject to
    {
    x[<1,2>]==1;
    y[3][2]==1;

    }

    regards

     

    PS: Many how to with OPL at https://www.linkedin.com/pulse/how-opl-alex-fleischer/


    #DecisionOptimization
    #OPLusingCPLEXOptimizer