Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Reading more than one variable in warm-start

  • 1.  Reading more than one variable in warm-start

    Posted Sat March 15, 2014 08:42 AM

    Originally posted by: pareto


    Dear All,

    I intend to read warm-start values for 8 different decision variables. I do that typically as the way presented in the example. But, seemingly, I overwrite the previous vectors each time. Thats what I have tired:

     

    main{ 

    ...

    var data= new IloOplDataSource(dataFileName);

    opl.addDataSource(data);

    opl.generate();

    var vectors = newIloOplCplexVectors();

    vectors.attach(opl.B, opl.position);

    vectors.setVectors(Cplex);

    var vectors2 = newIloOplCplexVectors();

    vectors2.attach(opl.k, opl.value);

    vectors2.setVectors(Cplex);

    ... }

    I have also tried using only one vectors.setVectors(Cplex) in the end, but it still just reads warm-start for only one decision variable family.

    Thanks for help

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Reading more than one variable in warm-start

    Posted Sun March 16, 2014 04:13 AM

    Hi

    have you had a look at the example warmstart.mod in the OPL examples ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Reading more than one variable in warm-start

    Posted Sun March 16, 2014 06:54 AM

    Originally posted by: pareto


    Hello Alex,

    I have looked at it. But there, the warm-start just reads one decision variable (x) family, I also would like to read a warm-start for y variables.

    If I do that like this:

    var vectors = newIloOplCplexVectors();

    vectors.attach(opl.B, opl.position);

    vectors.setVectors(Cplex);

    var vectors2 = newIloOplCplexVectors();

    vectors2.attach(opl.k, opl.value);

    vectors2.setVectors(Cplex);

    ...

    It just considers one warm-start values (I guess it overwrites the vector) or sth else. I want to give initial values for both x and y DV family.

     

    Regards,

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Reading more than one variable in warm-start

    Posted Tue March 18, 2014 08:19 AM

    Hi,

    I changed warmstart.mod in order to take into consideration 2 decision variables:

    range r = 1..10;
    dvar int+ x[r];
    dvar int+ y[r];

    dvar int+ x2[r];
    dvar int+ y2[r];
    // The following array of values (defined as data) will be used as
    // a starting solution to warm-start the CPLEX search.
    float values[i in r] = (i==5)? 10 : 0;
    float values2[i in r] = (i==4)? 10 : 0;


    minimize
      sum( i in r ) x[i] + sum( j in r ) y[j]+sum( i in r ) x2[i] + sum( j in r ) y2[j];
    subject to{
      ctSum:    
        sum( i in r ) x[i] >= 10;
      forall( j in r )
        ctEqual:
          y[j] == j;
          
          ctSum2:    
        sum( i in r ) x2[i] >= 10;
      forall( j in r )
        ctEqual2:
          y2[j] == j;
    }

    main{
      thisOplModel.generate();  
      var def = thisOplModel.modelDefinition;   
      // Default behaviour
      writeln("Default Behaviour");
      var cplex1 = new IloCplex();
      var opl1 = new IloOplModel(def, cplex1);
      opl1.generate();
      cplex1.solve();   
      writeln(opl1.printSolution());
      // Setting initial solution
      writeln("Setting initial solution");
      var cplex2 = new IloCplex();
      var opl2 = new IloOplModel(def, cplex2);
      opl2.generate();
      var vectors = new IloOplCplexVectors();
      // We attach the values (defined as data) as starting solution
      // for the variables x.
      vectors.attach(opl2.x,opl2.values);
      vectors.attach(opl2.x2,opl2.values2);
      vectors.setVectors(cplex2);   
      cplex2.solve();   
      writeln(opl2.printSolution());

      opl1.end();
      cplex1.end();
      opl2.end();
      cplex2.end();
      0;
    }

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Reading more than one variable in warm-start

    Posted Tue March 18, 2014 11:19 AM

    Originally posted by: pareto


    Hello Alex,

    I didnt understand why you have duplicated the decision variables, let me give you a more precise example with a similar model:

    range r = 1..10;
    dvar int+ x[r];
    dvar int+ y[r];
     
    // The following array of values (defined as data) will be used as
    // a starting solution to warm-start the CPLEX search.
    int values[1..10] = [5,2,2,5,2,2,5,5,2,6];
    int values2[1..10] = [1,0,0,1,1,0,0,0,1,0];
     
     
    minimize
      sum( i in r ) x[i] + sum( j in r ) y[j];
    subject to{
      ctSum:    
        sum( i in r ) x[i] >= 10;
      forall( j in r )
        ctEqual:
          y[j] <= x[j];
          
    }
     
    main{
      thisOplModel.generate();  
      var def = thisOplModel.modelDefinition;   
      // Default behaviour
      writeln("Default Behaviour");
      var cplex1 = new IloCplex();
      var opl1 = new IloOplModel(def, cplex1);
      opl1.generate();
      cplex1.solve();   
      writeln(opl1.printSolution());
      // Setting initial solution
      writeln("Setting initial solution");
      var cplex2 = new IloCplex();
      var opl2 = new IloOplModel(def, cplex2);
      opl2.generate();
      var vectors = new IloOplCplexVectors();
      // We attach the values (defined as data) as starting solution
      // for the variables x.
      vectors.attach(opl2.x,opl2.values);
      vectors.attach(opl2.y,opl2.values2);
     
      vectors.setVectors(cplex2);   
      cplex2.solve();   
      writeln(opl2.printSolution());
     
      opl1.end();
      cplex1.end();
      opl2.end();
      cplex2.end();
      0;
    }

    if I write the code like this: 

    MIP start 'm1' defined initial solution with objective 36.0000. (which doesnt take values2(y) into account) . It is just objective value(x) when values are considered.

    If I change the order in main and write:

     vectors.attach(opl2.y,opl2.values2);

    vectors.attach(opl2.x,opl2.values);

    Then;

    MIP start 'm1' defined initial solution with objective 14.0000. (now, it doesnt consider values(x warm-start variables), but y variables ). So, the warm-start is changed.

    Normally, if I give warm-start for both x and y. I should get a MIP start of 40.000

    Maybe I didnt get it completely, but I didnt understand it

     

    Kind Regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Reading more than one variable in warm-start

    Posted Tue March 18, 2014 12:13 PM

    Hi,

    in both cases I get get a MIP start of 40.000

    Which version are you using ? Cplex 12.6 ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Reading more than one variable in warm-start

    Posted Tue March 18, 2014 12:37 PM

    Originally posted by: pareto


    Hello again,

    I use 12.5.1


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Reading more than one variable in warm-start

    Posted Tue March 18, 2014 12:55 PM

    Indeed I have your issue with 12.5.1

    Can you move to 12.6 then ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: Reading more than one variable in warm-start

    Posted Wed March 19, 2014 01:06 PM

    Originally posted by: Preemptive


     

    Hi, 

    F[i][v][t] denotes arrival time  at node i by vehicle v after traversing t-th arc. So, if x[i][j][v][t]==1 than F[j][v][t] must be equal to F[i][v][t-1] + t[i][j] since vehicle v arrives at node i after traversing (t-1) arc. so i have this constraint : 

     

    c17: forall (v in V, i in I, j in ICF1 :j!=i, t in T: t > 0) 
    F[i][v][t-1] + item (TIJ,<i.i,j.j>).temp - F[j][v][t] <= M *( 1 - Xijv[i][j][v][t]); 

     

    c23 : forall ( v in V,i in ID, t in T: t==0)
    F[i][v][t] == 0; 
    the ordre of visit for vehicul is : 02516320 (  (..) lenth of the arc ) 
    0.....(10)........2.......(45) ......5.....(20).......1...... ..(28).......6........(61).... ....3.........(30)........... 2..........(10).......0

    normally : F020= 0  ; F221= 10  ; F522=55   ; F123=75   ; F624=103   ; F326=164   ; F226=194   ; 

    but here he put that fiv equal to the lenth of the arc like : 

    F020= 0  ; F221= 10  ; F522=45   ; F123=20   ; F624=28   ; F326=61   ; F226=30   ; 

     

    Best regards 

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer