Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  relation between cplex variables in two sets of constraint

    Posted 10/26/11 04:15 PM

    Originally posted by: beckywang


    I have two sets of variables (IloVarArray x, y ). Each set has its own constraints, say constraint(x), and constraint(y). There are some relation between some of the variables x and y, for exampe x[1] = y[2]. My question is : does this relation need to be added to the model as constraint? or simply the statement x[1]=y[2] in the code is enough?
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: relation between cplex variables in two sets of constraint

    Posted 10/27/11 02:42 AM

    Originally posted by: SystemAdmin


    Yes, it must be explicitly added. Be careful here! The two statements
    x[1] = y[2]
    x[1] == y[2]
    

    have very different semantics. The first statement assigns the IloNumVar object at slot 2 in array y to slot 1 in array x. Thereby it overwrites the IloNumVar object stored there. The statement manipulates the arrays in which you store the IloNumVar instances. It does not create any constraint.
    The second statement uses the overloaded operator== to create an equality constraint that requires IloNumVar x[1] to be the same as IloNumVar x[2] in any feasible solution. This is what you need. You need to do
    cplex.add(x[1] == y[2]);
    

    #CPLEXOptimizers
    #DecisionOptimization