Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Adding range constraints to a model -- C++ concert technology

  • 1.  Adding range constraints to a model -- C++ concert technology

    Posted 02/19/08 07:46 PM

    Originally posted by: SystemAdmin


    [bertrand.cornelusse said:]

    In the model that I develop I have noticed that the algorithm has different behaviors in the following situations (in short) :

    1. I add a constraint to the model without explicitly creating an IloConstraint.
      model.add(expressions[0] == Demand[t]);
    2. I add a constraint to the model by first instantiating an IloRange.
      IloRange range(expressions[0] == Demand[t]);
      model.add(range)

    I am solving a mixed integer linear program (MILP).
    Both implementations end up with a solution, but I have noticed that the first approach yields better results in less time.

    I don't understand why!

    I would prefer to use the second approach because I would like to have access to the constraint for modifying
    its RHS and reoptimizing.

    Is there a conceptual difference between these two approaches?
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Adding range constraints to a model -- C++ concert technology

    Posted 02/20/08 01:57 AM

    Originally posted by: SystemAdmin


    [EdKlotz said:]

    > In the model that I develop I have noticed that the algorithm has different
    > behaviors in the following situations (in short) :

    > 1. I add a constraint to the model without explicitly creating an IloConstraint.
    >  model.add(expressions[0] == Demand[t]);
    > 2. I add a constraint to the model by first instantiating an IloRange.
    >  IloRange range(expressions[0] == Demand[t]);
    >  model.add(range)
    >
    > I am solving a mixed integer linear program (MILP).
    > Both implementations end up with a solution, but I have noticed that the first > approach yields better results in less time.
    >
    > I don't understand why!
    >
    > I would prefer to use the second approach because I would like to have access
    > to the constraint for modifying
    > its RHS and reoptimizing.
    >
    > Is there a conceptual difference between these two approaches?

    There is a slight conceptual difference, but that difference is neither better nor worse regarding run time.  Rather, these two approaches may change the order of the constraints in the model CPLEX ultimately solves.  That would be
    enough to potentially change the path of the optimization.  But, neither order
    is better than the other.

    Specifically, in the first approach above, you are using the operator==
    to create your constraint.  If you look in the docs, this operator returns an
    IloConstraint, not an IloRange.  So, your first method adds an IloConstraint to
    the model.  Your second method creates the same IloConstraint, but then
    converts it to an IloRange when adding it to the model.  If CPLEX extracts the
    model by going extracting all IloRanges and all IloConstraints together, this
    could change the ordering of the constraints.  Neither order is better than the
    other, but they can change the optimization run time.

    So, I recommend you go ahead and use method 2.  If the difference in run time
    is significant, then you have a performance tuning issue, and you should take steps to improve performance by tuning parameters or tightening the formulation.
    Look in the Tuning Performance Features in the Mixed Integer Programming section of the ILOG CPLEX User Manual, and also take a look at the document on
    this topic at the CPLEX FAQ web site at

    https://support.ilog.com/public/products/faq.cfm?FAQ=106&Product=CPLEX
    #CPLEXOptimizers
    #DecisionOptimization