I need to use the conditional constraints for a JuMP model with CPLEX, that would be IloIfThen in C++. Like if I have three variables x, y and z, a constraint like:
If (x >= 1) && (y <= 2) then z == 1
I am using JuMP, and have tried to use the indicator constraints, with something like this: @constraint(m, name, ((x >= 1) && (y <= 2)) => { z == 1})
However it does not work, it seems that I can’t use a JuMP decision variable in a logical expression, therefore I can only use a binary decision variable to trigger the constraint instead of a more complex logical expression.
Of course I could linearize the conditional constraints, but that is not possible in my case: I need to implement this model (found in the literature) to benchmark an algorithm I developped. The model uses a lot of conditional constraints, and I fear that the workaround of linearizing everything might affect the performances.
So, is there a way for JuMP to model this constraint ? Otherwise, is it possible to do that using the low-level CPLEX API ? What would be the syntax in this case ?
It sounds like you’re looking to do constraint programming. There is a nice blog post about the relationship between JuMP and this topic here:
In particular, the package ConstraintProgrammingExtensions.jl can interact with CPLEXCP.jl, which wraps the Java interface rather than the C++ version; see, for example, this list of exported functions here.
There is probably some more work to do with introductory tutorials and docs for getting started.