Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  setStartingPoint

    Posted 07/01/16 02:49 AM

    Originally posted by: ToshiyukiMiyamoto


    Hi,

    I want to use the setStartingPoint method. How can I retrieve the solution in the previous run?

     

    Thanks,

    Toshiyuki


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: setStartingPoint

    Posted 07/01/16 10:17 AM

    Hi,

    let me share a small example in OPL

    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.
    float values[i in r] = (i==3)? 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
    {
    cp.param.searchType=26;

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

    You can do the same with other APIs

    regards


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: setStartingPoint

    Posted 07/01/16 11:16 AM

    Originally posted by: ToshiyukiMiyamoto


    Hi Alex

     

    Thank you for your reply. As for the example, I have some questions.

    1. How can I restart search starting from the first solution of 'x'?

    2. Do we need the line 'for(var i=1;i<=10;i++) sol.setValue(thisOplModel.x[i],thisOplModel.values[i]);'? This line means that we have to know variables in the model.

     I'm writing a model independent program using Java. Thus, my program does not know in advance what variable is used in the given model.

     

    Thanks,

    Toshiyuki


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: setStartingPoint

    Posted 07/01/16 11:34 AM

    Hi,

    1) You may also have a look at https://www.ibm.com/developerworks/community/forums/html/topic?id=72359501-c169-4215-9dc0-1c87e653b584&ps=25

    2) Yes you need the loop since the loop will build sol that you use in setStartingPoint

    regards


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: setStartingPoint

    Posted 07/03/16 09:06 PM

    Originally posted by: ToshiyukiMiyamoto


    Hi Alex

    Thank you for your reply.

    I understand that we have to build a solution manually.

    I have another question: What is the difference between three methods of IloCp: setStartingPoint, store, and restore?


    #CPOptimizer
    #DecisionOptimization


  • 6.  Re: setStartingPoint

    Posted 07/04/16 04:18 AM

    Hi

    see http://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.3/ilog.odms.ide.help/refcppopl/html/classes/IloSolution.html

    IloSolution: Instances of this class store solutions to problems.

    Instances of this class store solutions to problems. The fundamental property of IloSolution is its ability to transfer stored values from or to the active objects associated with it. In particular, the member function IloSolution::store stores the values from algorithm variables while the member function IloSolution::restore instantiates the actual variables with stored values. Variables in the solution may be selectively restored. This class also offers member functions to copy and to compare solutions.

    whereas  for starting point

    http://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.3/ilog.odms.ide.help/refcppopl/html/startpoint.html

    There are cases where better solutions can be produced more quickly by providing a starting point, an instance of IloSolution, to the optimizer. Here are some typical use cases:

    1. While the optimizer is solving a problem, the session has to be interrupted and the current best solution sol is stored. Later on, a new session for solving the problem is started and the stored solution sol is specified as the starting point of the new search so as to avoid restarting the search from scratch.
    2. For a particular problem, a heuristic is available to produce an initial solution sol. It would be helpful for this feasible solution to be injected in the engine to accelerate the search. One of the techniques for producing such an initial solution can be to augment the original CP Optimizer model with additional constraints (integer variable assignments, presence, precedence or sequencing constraints) to help generate a solution. A typical example in detailed scheduling is mapping producers to consumers thanks to precedence constraints on a reservoir resource.
    3. A multi-objective optimization problem may involve a lexically ordered set of objective functions (f1,f2,...,fn). It could be, for example, a detailed scheduling problem for which the main objective (f1) is to minimize resource allocation costs whereas a secondary objective (f2) is to minimize the makespan of the schedule given an optimal or good resource allocation. In this case, the problem can be solved in n successive steps: first, minimize objective f1 to produce a solution sol1, then, add a constraint to avoid deteriorating f1 and solve the problem with objective function f2 using sol1 as a starting point to produce a solution sol2, etc. Here, the solution to a given step is a feasible solution for the next step.
    4. Given an optimization problem for which finding a first solution is difficult, a possible first step is to relax the problem to make it easier to solve and minimize the constraint violations. For instance, in a detailed scheduling problem, a relaxation can be made by replacing activity deadlines by due dates and minimizing tardiness cost or by setting all activities as optional and minimizing the number of unscheduled activities. If this first step is able to produce a solution with no violations, this feasible solution can be re-injected as starting point to the original optimization problem.
    5. Some applications require solving successive models that are very similar. For instance, in dynamic scheduling, a new request has to be integrated in an existing schedule that was computed in a previous step (notion of work-in-progress). In on-line scheduling, it is necessary to react to various uncertainties of the environment and reschedule when a perturbation occurs (resource breakdown, late activity); here, the new model is similar to the previous one except for the perturbations. In these applications, the previous solution could be used as a starting point to guide the search of the new solve process. Note that here, the previous solution is generally not a feasible solution for the new problem.
    6. Some problems are too complex or too large to be solved in a single model and a hierarchical approach is necessary. A simplification of the original problem involving some relaxation or approximation of some constraints can be solved in a first step in order to fix or to restrict the possible values of some key decision variables of the original problem. Working on a simplified problem allows providing a good solution to the key aspects of the problem without focusing on other, less important details. In a second step, the decisions from this first step can be used as guidelines for solving the original problem by providing the first step decisions as starting point solution.

     

     

    regards

     


    #CPOptimizer
    #DecisionOptimization


  • 7.  Re: setStartingPoint

    Posted 07/08/16 05:13 AM

    Originally posted by: ToshiyukiMiyamoto


    Hi Alex

    Thank you for your information. Still I'm not sure the difference on the search between setStartingPoint and restore.

    By the way, I wrote the attached Java program that calls the sample model "color.mod".

    In the program, we instantiate two IloCPs: cp1 and cp2.

    The second solution of cp1 is stored in IloSolution sol1 and transferred to cp2 by using setStartingPoint or restore methods.

    But, it seems that cp2 does not use the solution. You can see the result in the attached file: run.log.

    Can't we transfer a solution to other IloCP instances?

     

    Thanks,

    Toshiyuki

     


    #CPOptimizer
    #DecisionOptimization


  • 8.  Re: setStartingPoint

    Posted 07/08/16 09:23 AM

    Hi,

    well you see

    Using starting point solution

    in the log

    But CPO may find another solution even though you provide a warmstart.

    This is common in tiny models. For bigger models that is rare.

    regards


    #CPOptimizer
    #DecisionOptimization