Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Warm start for interval variables

  • 1.  Warm start for interval variables

    Posted Sun November 05, 2017 09:02 PM

    Originally posted by: hzwpku


    Hi,

    Now I want to provide initial values for the interval variables as a warm-start. The OPL example "warmstart" helps me a lot. But how to attach a value to an interval variable?

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Warm start for interval variables

    Posted Mon November 06, 2017 03:12 AM

    Hi,

    if you enjoyed the warmstart example let me start from there.

    With CPO

    using CP;

    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 CP Optimizer search.

    int values[i in r] = (i==5)? 10 : 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] == j;
    }   

    execute
    {
    writeln(x);
    }  

    main
    {
    thisOplModel.generate();
    var sol=new IloOplCPSolution();

    for(var i=1;i<=10;i++) sol.setValue(thisOplModel.x[i],thisOplModel.values[i]);
    cp.solve();
    thisOplModel.postProcess();
    cp.setStartingPoint(sol);
    cp.solve();
    thisOplModel.postProcess();
    }

    gives

    [0 0 0 0 0 10 0 0 0 0]
     [0 0 0 0 10 0 0 0 0 0]

    and then if you move to scheduling

    using CP;

    range r = 1..10;
    dvar interval x[r] size 1;

    dvar interval y[r] size 1;
    // The following array of values (defined as data) will be used as  
    // a starting solution to warm-start the CP Optimizer search.

    int values[i in r] = (i==5)? 10 : 0;     

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

    execute
    {
    for(i in r) write(Opl.startOf(x[i])," ");
    writeln();
    }

    main
    {
    thisOplModel.generate();
    var sol=new IloOplCPSolution();

    for(var i=1;i<=10;i++) sol.setStart(thisOplModel.x[i],thisOplModel.values[i]);
    cp.solve();
    thisOplModel.postProcess();
    cp.setStartingPoint(sol);
    cp.solve();
    thisOplModel.postProcess();
    }

    gives

    0 0 0 0 0 0 0 0 0 10
    0 0 0 0 10 0 0 0 0 0

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Warm start for interval variables

    Posted Mon November 06, 2017 08:33 AM

    Originally posted by: hzwpku


    Thanks for your reply.

    An interval variable should have a start value and an end value. Does the code "sol.setStart(thisOplModel.x[i],thisOplModel.values[i])"  mean the values[i] is attached to the start of the interval x[i]?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Warm start for interval variables

    Posted Mon November 06, 2017 08:36 AM


  • 5.  Re: Warm start for interval variables

    Posted Mon November 06, 2017 08:54 AM

    Originally posted by: hzwpku


    Thanks!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer