Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  most efficient way of updating objective function expression

    Posted 06/08/14 03:21 AM

    Originally posted by: Falcon_G


    Hi everybody

    I am running an iterative solution method within which I have to change my objective function very frequently.

    It seems like when the number of variables increases the $IloObjective::SetExpression$ becomes very inefficient. It may take up to several minutes (in debug mode) to update the objective expression

    The same results hold when I do the following:

    m_model.remove(obj);
      obj = IloMinimize(env, objExpr);
    m_model.add(obj);

    If I do not remove and do not add again and simply do

      obj = IloMinimize(env, objExpr);

    no matter if I reExtract the model in CPLEX or not, I get an exception if I try to make a query for the objective function value.

    What would be the most efficient way to update objective function expression.

     

    Thanks in advance.

    Shahin

     

     

     

     

     


     

     

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: most efficient way of updating objective function expression

    Posted 06/08/14 07:13 AM

    Originally posted by: EhsanN


    I'm not sure whether this is the most efficient way to modify the objective function consecutively, but I've used it for a relatively large objective function expression within a separation method for a lazy constraint callback with no apparent problem.

    //Create the new ObjFunExpr;
    myObj.setExpr(ObjFunExpr);
    ObjFunExpr.end();
    

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: most efficient way of updating objective function expression

    Posted 06/08/14 08:26 AM

    Originally posted by: Falcon_G


    Well, thanks for your comment..

    But apart from the fact that I am not sure if we can modifying a (MI)LP objective in run time/online  (in the course of algorithm) and expect all the bounds etc remain valid, 

    I wish to modify the objective function offline not in the course of (MI)LP resolution.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: most efficient way of updating objective function expression

    Posted 06/09/14 07:47 AM

    Does your objective happen to be quadratic or is it pure linear? Does it help to set IloEnv::setNormalizer(false) while updating the objective?

    I would have expected that this code

    m_model.remove(obj);
    obj = IloMinimize(env, objExpr);
    m_model.add(obj);

    works reasonably fast. Did you time which of those three statements burns most of the time? Note that you should also call obj.end() (or maybe even obj.getExpr().end()) after removing the objective, otherwise you will be leaking memory (which in the long run may also slow down operations).

    This alone

    obj = IloMinimize(env, objExpr);

    does not work since you are not actually changing anything that is extract by CPLEX. You are only creating a new instance of IloObjective and making 'obj' point to that new instance.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: most efficient way of updating objective function expression

    Posted 06/09/14 08:05 AM

    Originally posted by: Falcon_G


    Thank you indeed Daniel.

    Thank you also for your hint about the mem leak

    This m_model.remove(obj); looks very costly.

    It seems like when the model is extracted into the CPLEX instance, then every change needs to be propagated and this sounds to be very costly.

    What I found efficient is the following

            m_cplex.clearModel();

    Therefore, the extracted model is cleared.

    I set the obj expression: m_objective.setExpr(m_obj_expr);

     and extract again.

    This sounds more efficient.

    Daniel, are there any ulities in the Concert to detect and iterate over the roaming objects or garbages that can be potentially deleted to manage the memory?

    My problem is that the CPLEX instance becomes increasingly heavier over iterations. This I can see from the memory used by the executable process.

    I have set env.setDeleter(IloSafeDeleterMode);

    to avoid ending the environment (which is a solution to release the memory) but this does not eliminate the whole leak.

     

     

     

     

     

     

     


     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: most efficient way of updating objective function expression

    Posted 06/23/14 01:29 AM

    You are right, the notifications going back and forth between the Concert layer and the CPLEX engine for modifications of an already extracted model may be time consuming. The first thing to try to counter that is exactly what you need: explicitly clear and re-extract the model. In some cases this is much faster than handling all those notifications.

    To hunt down your leak you may find the IloIterator template class helpful. This allows you to iterate over all Concert objects (potentially restricted to a certain type) that are currently allocated on an IloEnv instance.


    #CPLEXOptimizers
    #DecisionOptimization