Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Question about dvar boolean

    Posted Mon August 26, 2013 08:57 AM

    Originally posted by: LindaKing


    Hi,everybody!

    I define a dvar boolean x. And in one dexpr I need to express multiplying x with a float variable. As follows:

    ...

    float x;

    ...

    dvar boolean y[s][s];

    ...

    dexpr float z = x*y[s][s];

    But there is an error" Operator not available for dvar boolean[][s] * float".

    I knew there is an example in tutorial which is

    
    
    dvar 
    boolean weightInKnapsack1; // Is the object1 in the knapsack ?
    dvar 
    boolean weightInKnapsack2;
    dvar 
    boolean weightInKnapsack3;
    
    int maxWeight=10; // The total weight should be less than maxWeight
    
    int weight1=3;
    int weight2=9;
    int weight3=2;
    
    // Let us try to take as many objects as we can
    maximize (weightInKnapsack1+weightInKnapsack2+weightInKnapsack3);
    
    subject to
    {
       
       weightInKnapsack1*weight1+
       weightInKnapsack2*weight2+
       weightInKnapsack3*weight3<=maxWeight;
    }
    

    ________________________________________________

    Can dvar boolean be multiplied with float type?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Question about dvar boolean

    Posted Mon August 26, 2013 09:19 AM

    You need an index on the dexpr as well. Like so:

    range S = 0..1;
    float x = 0.5;
    dvar boolean y[S][S];
    dexpr float z[s1 in S][s2 in S] = x * y[s1][s2];


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Question about dvar boolean

    Posted Mon August 26, 2013 11:00 PM

    Originally posted by: LindaKing


    Thank you very much. This does help.

    I found that I made a mistake when I indicate the range. 

    But I have another question.

    ......

    int nPoint = ...;
    range Point = 0..(nPoint-1);
    int nSlice = ...;
    range Division = 0..(nDivision-1);

    //Decision Variables

    dvar int+ Start[Division] in Point;
    dvar boolean After[Point][Start];   

    ......

    Here I want to indicate the relationship between sampling points and the division of one day.

    For example, nPoint=48 sampling points (24hr, every 30min one sample).

    The Division is defined by the starting point and other points included in this division. I use "dvar boolean After" to show whether a point is after the starting point of certain division or not.

    But the Start is also a dvar. Is the definition shown above illegal?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Question about dvar boolean

    Posted Thu August 29, 2013 01:53 AM

    You cannot use a decision variable (Start) as an index. I am not exactly clear how that After[] array should look like. Do you want something like this:

    dvar boolean After[Point][Division];
    subject to {
    // After[p][d] is 0 if it is before the Start[d]
    forall (p in Point)
       forall (d in Division)
          (p <= Start[d] - 1) => (After[p][d] == 0);
    // After[p][d] is 1 if it is after Start[d]
    forall (p in Point)
       forall (d in Division)
          (p >= Start[d]) => (After[p][d] == 1);

    }


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Question about dvar boolean

    Posted Thu August 29, 2013 04:08 AM

    Originally posted by: LindaKing


    OK. I will try to solve it as you suggest. Thank you very much.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer