Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Condition contains decision variable??

    Posted 01/28/11 08:13 AM

    Originally posted by: quawarty


    Hi,

    I would like to know how to write the condition below using OPL.

    Thank you for your help.

    /*Parameters*/

    int a;
    int c = 2;
    {int} I = {1,2};
    {int} K = {1, 2, 3};

    /*Decision variable*/

    dvar int+ T[I][K];
    //objective function
    Min Z = a * ( c * (sum (i in I, k in K) (T[i][k] - l[i]));

    /*Condition*/

    a = 1 if T[i][k] >= l[i] forall (i in I, k in K)

    a = 0 otherwise,
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Condition contains decision variable??

    Posted 01/28/11 01:02 PM

    Originally posted by: SystemAdmin


    You could solve your model with CP Optimizer with a constraint like
    a == prod(i in I, k in K) (T[i][k] >= l[i]);
    


    I believe a is a decision variable, right?

    Here is a code sample that may help:
    using CP;
     
    /*Parameters*/
    int  c = 2;
    {int} I = {1,2};
    {int} K = {1, 2, 3};
    int l[I] = [2,4];
     
    /*Decision variable*/
    dvar boolean a;
    dvar int+ T[I][K]; 
    dexpr int Z = a * ( c * (sum (i in I, k in K) (T[i][k] - l[i])));
     
     //objective function
    minimize Z;
    subject to {
      a == prod(i in I, k in K) (T[i][k] >= l[i]);
      // other constraints
    }
    

    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Condition contains decision variable??

    Posted 01/29/11 07:38 PM

    Originally posted by: quawarty


    > Thank you for your reply.

    I would like to use condition instruction.
    
    g = 0 
    
    if  ei =< Ti <= li g = 1 
    
    if Ti >= li:
    


    Could you please tell me if what I did is correct or not?
    Thank you for your help.

    
    
    //Notation// 
    //----------------------------------// 
    
    int n = 3; range V = 1..1; range P = 1..2; range N = 0..n+1;
    /* set of customers and   depots (N.B. depot is represented by the two vertices )*/ 
    //Parameters// 
    //------------------------------------//   
    
    int q[N0][P] =...;   ;  
    /* amount of a product p provided or required by customer */ 
    
    int d[N][N] = ...;
    /* travel distance between customer*/ 
    
    int e[N] = [0, 0, 0, 0, 0]; 
    /* lower bound of the time windows*/ 
    
    int l[N] = [5, 2, 6, 5, 18];
    /* upper bound of the time windows*/ 
    
    int cs = 2; 
    
    int E= -1; 
    
    int g = 0; 
    //--------------------------------------------------// 
    //Decision variables// 
    //--------------------------------------------------// dvar int+   f[N][N][P]; 
    /* load of the vehicle  by product p passing through the arc (i,j)*/ dvar int+   T[N];     
    /*continous variable indicationg the time at which the vehicle strats serving pickup customer*/ dvar 
    
    boolean  x[N][N][P];
    /* = 1 if the arc (i,j)*/ dvar int+    h;   
    //--------------------------------------------------// 
    //Objective fucntion// 
    //--------------------------------------------------// minimize sum (i in N, j in N, p in P) (d[i][j] * x[i][j][p]) +  cs * h + g * E* (sum (i in N)(T[i] - l[i])); 
    /* Minimize the total distance */   
    /* Constraint: customer is  visited exactly once*/ subject to 
    {   forall(i in N) 
    
    if (g == 1) (T[i] >= l[i]); 
    
    else (e[i] <= T[i] <= l[i]);
    

    #DecisionOptimization
    #OPLusingCPLEXOptimizer