Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to start CP Optimizer with an initial solution?

    Posted 03/13/12 05:23 AM

    Originally posted by: UdoKrehler


    Hello,
    I use CP Optimizer 2.3 under C# in Microsoft Visual Studio. I would like to start CP Optimizer with an initial solution that I've previously computed with some heuristics. I use the following simplified code (where the variable position is of type IIntVar[]: position = cp.IntVarArray(numberOfJobs, 0, 100)):

    ISolution startSolution = cp.Solution();

    for (int i = 0; i < numberOfJobs; i++)
    {
    startSolution.SetValue(position[i], positionInitialSolution[i]);
    }

    cp.SetStartingPoint(startSolution);
    cp.Solve();

    The code runs perfectly, but apparently, CP Optimizer completely ignores my initial solution. The first solution CP Optimizer produces is the same regardless of adding the above code lines or leaving them out. Moreover, the first solution CP Optimizer produces is much, much worse than my initial solution (which is definitely feasible, by the way).

    I did NOT use the depth-first search, actually I did not manually change anything w.r.t. the search strategy.

    Does anybody know why CP Optimizer ignores my initial solution? Did I forget something important?
    Thank you very much for your help, Udo.
    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: How to start CP Optimizer with an initial solution?

    Posted 03/13/12 08:59 PM

    Originally posted by: qtbgo


    I wonder if it's possible to start CP Optimizer with an initial solution in an OPL model?
    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: How to start CP Optimizer with an initial solution?



  • 4.  Re: How to start CP Optimizer with an initial solution?

    Posted 03/16/12 08:36 AM

    Originally posted by: UdoKrehler


    Dear Alex,
    thank you very much for your answer, but I have to admit, I don't really know what to do with your answer because I'm not using OPL. I would like to start CP Optimizer 2.3 with an intial starting solution under C# in Microsoft Visual Studio. I tried to use exactly the same code as provided in the example "PlantLocation.cs", see my small example code above. There is no runtime error with this code, but for some strange reason, CP Optimizer simply ignores my starting solution. The first solution CP Optimizer produces is the same regardless of adding the above code lines or leaving them out. Moreover, the first solution CP Optimizer produces is much, much worse than my initial solution (which is definitely feasible, by the way).

    As written above, I did NOT use the depth-first search, actually I did not manually change anything w.r.t. the search strategy.

    Do you know why CP Optimizer ignores my initial solution? Did I forget something important? If so, can you give me a small example that shows how to use the starting point concept for C# in Microsoft Visual Studio?

    Thank you very much for your help!
    Best regards, Udo.
    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: How to start CP Optimizer with an initial solution?

    Posted 03/16/12 10:05 AM

    Originally posted by: ol


    Hello Udo,
    indeed, in CP Optimizer 12.3, it may happen that the starting point solution is ignored when you mix integer and interval variables. This problem has been fixed in the 12.4 version.

    As a workaround with the 12.3 version, it depends on your exact model.
    Nevertheless, a general method should work in any case: you do not use the setStartingPoint() function, instead:
    • you add a boolean variable (useWarmStart),
    • you add constraints: useWarmStart ==> (all the assigments of the warm start: x[i]==vi ... and objective== value of objective in the warm start solution)
    • you define a first search phase which chooses useWarmStart=true whenever possible.

    You will then get the intended behavior: the first step will give the warm start solution, and then the objective bound will force useWarmstart to false, and the normal search will be applied.

    Regards,
    Olivier
    #CPOptimizer
    #DecisionOptimization


  • 6.  Re: How to start CP Optimizer with an initial solution?

    Posted 03/16/12 10:15 AM

    Originally posted by: ol


    Hello Udo,
    indeed, in CP Optimizer 12.3, it may happen that the starting point solution is ignored when you mix integer and interval variables. This problem has been fixed in the 12.4 version.

    As a workaround with the 12.3 version, it depends on your exact model.
    Nevertheless, a general method should work in any case: you do not use the setStartingPoint() function, instead:
    • you add a boolean variable (useWarmStart),
    • you add constraints: useWarmStart ==> (all the assigments of the warm start: x[i]==vi ... and objective== value of objective in the warm start solution)
    • you define a first search phase which chooses useWarmStart=true whenever possible.

    You will then get the intended behavior: the first step will give the warm start solution, and then the objective bound will force useWarmstart to false, and the normal search will be applied.

    Regards,
    Olivier
    #CPOptimizer
    #DecisionOptimization


  • 7.  Re: How to start CP Optimizer with an initial solution?

    Posted 03/16/12 11:21 AM

    Originally posted by: UdoKrehler


    Dear Olivier,

    thank you very much for your help! Indeed, I use a mixture of integer variables and interval variables. Now I finally know that it's not my fault! Unfortunately, I cannot upgrade right now, so I have to use CP Optimizer 2.3 at least for the next few months. Therefore, I'm now very much interested in your workaround. I'm not very familiar with CP Optimizer, therefore I would like to ask whether it would be possible for you to give a small example code for your workaround? Sorry for the inconvenience, but that would actually help me a lot to understand your idea with using a warm start! Thank you so much! Best regards, Udo.
    #CPOptimizer
    #DecisionOptimization