Decision Optimization

Expand all | Collapse all

change IP objective and resolve

  • 1.  change IP objective and resolve

    Posted Sat August 22, 2020 03:15 AM
    Hi all,

    Suppose we have an MIP model coded in Python, and we solve it by CPLEX. When the solution procedure is over, I like to resolve the model using a different objective function. Is there a way or syntax to handle this? 

    If yes, the second problem is being solved from scratch or just being reoptimized? 


    Thanks

    ------------------------------
    Amin
    ------------------------------


  • 2.  RE: change IP objective and resolve

    Posted Sat August 22, 2020 09:34 AM

    Hi

    in

    https://www.linkedin.com/pulse/making-optimization-simple-python-alex-fleischer

    see

    https://github.com/AlexFleischerParis/zoodocplex/blob/master/zooobjectivefunction.py


    regards



    ------------------------------
    ALEX FLEISCHER
    ------------------------------



  • 3.  RE: change IP objective and resolve

    Posted Mon August 24, 2020 12:50 AM
    You should specify whether you use docplex or the CPLEX Python API because the syntax is different between the two. Alex's answer is for docplex.

    Yes, the second problem is solved from scratch. There is no way around this because changing the objective is likely to invalidate certain presolve reductions and for sure requires a new tree search. However, since changing the objective only affects optimality and not feasibility, CPLEX will use every solution it found in the first round as MIP start for the second round. This may or may not speed up the second solve.

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 4.  RE: change IP objective and resolve

    Posted Tue August 25, 2020 05:41 PM
    Thanks Daniel!

    I use CPLEX Python API.

    ------------------------------
    Amin
    ------------------------------



  • 5.  RE: change IP objective and resolve

    Posted Wed August 26, 2020 12:21 AM
    In the CPLEX Python API use Cplex.objective.set_linear() and Cplex.objective.set_sense() to modify the objective function.

    ------------------------------
    Daniel Junglas
    ------------------------------