Decision Optimization

 View Only
  • 1.  How to suggest to CP Optimizer a starting value for an interval variable in OPL

    Posted Fri February 23, 2024 05:20 PM

    Hello moderators & IBM community:

    I am working on a scheduling formulation in OPL and using CP Optimizer as a solver engine.

    In this context, I have the following interval variable:

    dvar interval itvs[t in Tasks] size t.pt;

    I want to suggest a starting solution for the interval variable itvs to CP Optimizer.

    For instance, I would like to set a "starting point" for each start time of itvs[t] that generates a feasible solution for the problem being solved.

    Could you please provide a small example of how can this be achieved? 



    ------------------------------
    Francisco Yuraszeck
    Yuraszeck
    ------------------------------


  • 2.  RE: How to suggest to CP Optimizer a starting value for an interval variable in OPL

    Posted Mon February 26, 2024 01:48 AM

    Hi,

    I shared an example at https://stackoverflow.com/questions/63911236/how-to-give-to-cp-optimizer-an-initial-feasible-solution

    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();
    }


    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 3.  RE: How to suggest to CP Optimizer a starting value for an interval variable in OPL

    Posted Mon February 26, 2024 05:25 PM

    Thank you Alex for your answer.

    I was wondering if there exists an easy way to do the same. I would like to provide the starting solution to CP Optimizer in the following manner:  

    itvs = [<1 0 0 0> <1 0 186 186> <1 251 425 174> <1 594 732 138> <1 846 968 122> <1 4910 4910 0>];

    Where these values were obtained in a previous execution of the solver.



    ------------------------------
    Francisco Yuraszeck
    Yuraszeck
    ------------------------------



  • 4.  RE: How to suggest to CP Optimizer a starting value for an interval variable in OPL

    Posted Tue February 27, 2024 04:19 AM

    Hi,

    yes with setStartingPoint you can do that as can be seen in https://github.com/AlexFleischerParis/howtowithopl/blob/master/hybrid.mod



    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------