Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Single Branch and Cut

    Posted 09/30/18 05:38 PM

    Originally posted by: open_ball


    Hi,

    I was wondering if it is possible to intervene the branch and cut processes when a problem is being solved by an iterative method in OPL. 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Single Branch and Cut



  • 3.  Re: Single Branch and Cut

    Posted 10/01/18 09:05 AM

    Originally posted by: open_ball


    Hi Alex,

     

    If I am not wrong, the link that you sent shows how to add a new constraint and solve the problem over again. I do not have any problem with dynamically adding new constraints into the master problem. 

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Single Branch and Cut

    Posted 10/01/18 09:20 AM

    Hi,

    you may use an empty constraint to add any cut in OPL.

    See

    int nbKids=300;
        float costBus40=500;
        float costBus30=400;
         
        dvar int+ nbBus40;
        dvar int+ nbBus30;
        
        
         
        minimize
         costBus40*nbBus40  +nbBus30*costBus30;
         
        subject to
        {
         ctKids:40*nbBus40+nbBus30*30>=nbKids;
         ctEmpty:0<=0;
        }

        execute
        {
        writeln("nbBus40 = ",nbBus40);
        writeln("nbBus30 = ",nbBus30);
        }

        main
        {
        thisOplModel.generate();

        cplex.solve();
        thisOplModel.postProcess();

        //now 350 kids instead of 300
        writeln("now 350 kids instead of 300");
            
        thisOplModel.ctKids.LB=350;

        cplex.solve();
        thisOplModel.postProcess();


        // no more than 4 buses 40 seats
        writeln("no more than 4 buses 40 seats");

        thisOplModel.ctEmpty.setCoef(thisOplModel.nbBus40,1);
        thisOplModel.ctEmpty.UB=4;

        cplex.solve();
        thisOplModel.postProcess();

        

         


        }

     

    So I d say yes to all your questions

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Single Branch and Cut

    Posted 10/01/18 09:25 AM

    Originally posted by: open_ball


    Hi,

     

    How do I check if an integer solution (not optimal, the first integer solution) is found when I call cplex.solve()? Also, how do I ensure that when I add a new constraint, the branch and cut process continues where it stopped and does not start from the scratch? 

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Single Branch and Cut

    Posted 10/01/18 09:32 AM

    Hi,

    1) You can check cplex.status

    Status of the last method invoked on this object. See the section CPLEX solution status in Language User's Manual > ILOG Script for OPL > Introduction to scripting > Preprocessing and postprocessing > Changing option values > Changing CPLEX parameters for details of the solution status codes.

    2) You can check the log

     

        int nbKids=300;
        float costBus40=500;
        float costBus30=400;
         
        dvar int+ nbBus40;
        dvar int+ nbBus30;
        
        
         
        minimize
         costBus40*nbBus40  +nbBus30*costBus30;
         
        subject to
        {
         ctKids:40*nbBus40+nbBus30*30>=nbKids;
         ctEmpty:0<=0;
        }

        execute
        {
        writeln("nbBus40 = ",nbBus40);
        writeln("nbBus30 = ",nbBus30);
        }

        main
        {
        thisOplModel.generate();

        cplex.solve();
        thisOplModel.postProcess();

        //now 350 kids instead of 300
        writeln("now 350 kids instead of 300");
            
        thisOplModel.ctKids.LB=350;

        cplex.solve();
        thisOplModel.postProcess();


        // no more than 7 buses 40 seats
        writeln("no more than 7 buses 40 seats");

        thisOplModel.ctEmpty.setCoef(thisOplModel.nbBus40,1);
        thisOplModel.ctEmpty.UB=7;

        cplex.solve();
        thisOplModel.postProcess();

        

         


        }

     

    and in the log you see

     

    Retaining values of one MIP start for possible repair.
    Found incumbent of value 4800.000000 after 0.00 sec. (0.00 ticks)

    regards

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Single Branch and Cut

    Posted 10/01/18 09:55 AM

    Originally posted by: open_ball


    Okay. Suppose I started solving the master problem. 

     

    masterCplex.solve()

    check cplex status

    masterOpl.postProcess();

     

    In this part, what you are saying is that, I should use cplex.status to check if an incumbent solution is found. If so, I call post process function and  move on with the sub problem (i.e., M1Opl) and solve it.

     

    Then, I add the cut into the master problem. 

    masterData.d1.add(m1Opl.add_d1);

     

    In order to add a constraint, I use the same logic with traveling salesman example. In master problem, I defined the following tuple;

     

      tuple D1{
      int iter;   
      string commodity;
      float amount;   
      }
      {D1} d1 =...;

     

    For each iteration, I have the correspondence constraint. 

     

    After adding a new cut, I should no longer call masterOpl.end() right? At this point, how can I continue the branch and cut? I want to continue masterCplex.solve() from where it was stopped.

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Single Branch and Cut

    Posted 10/01/18 12:39 PM


  • 9.  Re: Single Branch and Cut

    Posted 10/05/18 07:18 PM

    Originally posted by: open_ball


    Hi Alex,

     

    I really appreciate the answer. I have some relative questions.

     

     I send my cuts to the master problem with an iteration number. If I do not end opl model, how am I going to update the constraint set? I'm summarizing below what I do in the master problem to add a new constraint. Do you think that I should change the way I am adding new cuts to the master problem?

     

    tuple dual_temp{

    int iteration_number;

    string _from;

    float amount;

    }

    {dual_temp} sub_variable=...;

    int NumberofCuts=...;

    range CutRange = 0..NumberofCuts;

     

    Constraint Cuts:

    forall(iter in CutRange)

    x>= sum(<iter, _from, amount > in sub_variable) amount;

            

     Suppose I solved the sub problem, obtained a new cut and added into the master problem. In this case, should I warm up the master problem with the previous solution? Is it what you are suggesting me?

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: Single Branch and Cut

    Posted 10/09/18 10:02 AM

    Originally posted by: open_ball


    Hi Alex,

    Without regeneration master problem, is it possible to update the constraint set in the way that I am doing? Also, how should I warm up the model to continue the branch and cut tree where I left? If I send the previous integer solution then, that might cause feasibility. Could you please clarify how to continue the branch and cut process?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 11.  Re: Single Branch and Cut

    Posted 10/09/18 11:31 AM

    Hi,

    at https://www.linkedin.com/pulse/how-opl-alex-fleischer/

    you may read

    • Change some data and solve again without regenerate
    • Change some data and solve again with regenerate

    The first one is incremental and the second one is not. So with the second one you need to warm start since the cplex matrix has changed.

    So whether to go incremental or not is a compromise to find about what is easier:

    - incremental : no need for warm start but you have to manage with modifying coefficient and bounds

    - not incremental : warm start needed but you may change the model as you like.

     

    Best regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 12.  Re: Single Branch and Cut

    Posted 10/09/18 11:42 AM

    Originally posted by: open_ball


    Alex, 

     

    Thanks for answer. 

     

    So I am using the not incremental method in my model. I keep my cuts in a tuple and I expand the tuple with each iteration as I explained above. Therefore, I regenerate my model at every iteration.

     

    I checked out the warm start link that you sent and also the warm start example provided by OPL. I understand that I should use a solution vector to warm start the my model. What is not clear for me is the following; if I use the previous integer solution as a warm start after adding a new cut (my purpose is to continue the branch and cut tree from where I left), it will most likely be an infeasible solution. Am I missing or misinterpreting something?

     

    When I use the not incremental way to change my dataset, how should I manage to continue the branch and cut tree? 

     

    Thanks for your patience. 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 13.  Re: Single Branch and Cut

    Posted 10/09/18 12:32 PM

    Hi,

    as said at https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/mip/para/49_mipStarts.html

    A MIP start may be a feasible solution of the model, but it need not be; it may even be infeasible or incomplete.

    But maybe in your case not relying on mip start could be faster

    Look at the TSP example. No warmstart

    CPLEX_Studio128\opl\examples\opl\models\TravelingSalesmanProblem

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer