Originally posted by: EdKlotz
>
> Actually, I was curious about this myself. IloLexicographic apparently exists
> in the C++ API to CPLEX but not the Java API. Does it enforce lexical ordering > by adding a bunch of indicator-type constraints (with implicit big-Ms floating
> around)? Or does it enforce lexical ordering by directly modifying the
> branching process? Or by turning into a stack of goals? Inquiring minds want
> to know!
>
> /Paul
>
IloCplex does not extract constraints created via IloLexicographic; only CP
Optimizer does.
In the C++ API reference manual, the description of Logical Constraints states:
In fact, the class IloCplex can extract logical constraints as well as some logical expressions. The logical constraints that IloCplex can extract are these:
IloAnd which can also be represented by the overloaded operator &&
IloOr which can also be represented by the overloaded operator ||;
IloDiff which can also be represented by the overloaded operator !=;
IloNot, negation, which can also be represented by the overloaded operator !;
IloIfThen
== (that is, the equivalence relation)
!= (that is, the exclusive-or relation)
And the list of classes IloCplex can extract are:
*IloNumVar numeric variables
IloSemiContVar semi-continuous or semi-integer variables
IloObjective at most one objective function with linear, piecewise linear, or quadratic expressions
IloRange range constraints with linear or piecewise linear expressions
IloConstraint ranged constraints of the form expr1relationexpr, where expr1 indicates a linear, logical, or quadratic expression and the relation less than or equal to or the relation greater than or equal to; constraints can be combined by logical operators
IloConversion variable type conversions
IloModel submodels
IloSOS1 special ordered sets of type 1
IloSOS2 special ordered sets of type 2
IloAnd constraint clauses*
While IloCplex doesn't extract IloLexicographic directly, I think you can
use the logical constraints it does extract to express the lexicographic
constraints fairly easily. For example, if x and y are the IloIntExprs you want to constraint
to order lexicographically, create an IloBoolVarArray z of the same length as
x and y. Then add the constraints
y[i] <= x[i] i = 1,...,n
IloIfThen(env, y[i] >= x[i], z[i] <= 0)
IloIfThen(env, y[i] + 1 <= x[i], z[i] >= 1)
The two IloIfThen constraints specify that when y[i] = x[i], z[i] = 0
and when y[i] < x[i], z[i] = 1. The latter IloIfThen constraint accomplishes
this because y[i] and x[i] are integer expressions, so they must differ by at
least one when separated by a strict inequality. So, now we just need
to make sure that the elements of z[i] after the first one that takes on a value
of 1 are also all 1:
z
i] <= z{i+1 i = 1,...,n-1
I think that should do it. That reduces Paul's question about how IloCplex
does the linearization to how IloCplex linearizes IloIfThen. Currently that
is indeed based on indicator variables (as can be seen if you export an LP file
from a model containing IloIfThen constraints). However, keep in mind that
this is an undocumented, under the hood feature of CPLEX, so it could change in
the future if we found a better way to perform the linearization.
#CPLEXOptimizers#DecisionOptimization