简体   繁体   中英

CPLEX using LP file format: indicator constraints with boolean operators

I am completely new to CPLEX and far from an expert in MIP but I am trying to solve a problem with this technology (CPLEX 12.4). I ahve decided to create the MIP models in an .lp file and give it to CPLEx so I can have a plenty of inputs and test different solvers etc. But I am finding one thing about indicator constraints a bit problematic.

I want something like:

c1: a AND NOT(b)-> i1 - 100 v1 = 0
c2: b AND NOT(a)-> i1 - 120 v1 = 0
c3: a AND b -> i1 - 80 v1 =0

But there is no such thing ans AND or NOT in the LP format (I am not even sure if I could do that on the CPX interface, but I am trying to avoid it).

The only workaround I have found is doing:

ca: a_not_b = 1 <-> a - b = 1
cb: b_not_a = 1 <-> a - b = -1
cab: a_and_b = 1 <-> a + b = 2
c1: a_not_b-> i1 - 100 v1 = 0
c2: b_not_a-> i1 - 120 v1 = 0
c3: a_and_b = 1-> i1 - 80 v1 =0

I would be ok with having this, because I am going to be generating this LP with another program, but does this slow down CPLEX? Is there a better way of doing this?

Thanks

You are pretty much correct. The LP and MILP approach does not directly allow for these sorts of logical constraints. Rather you typically need to create auxiliary variables in your model that can be used to capture those conditions. In many cases those will be boolean or 0/1 integer variables. A large part of the art & craft of writing MILP models is finding good ways to re-write those conditions in the rather restrictive 'language' of LP and MILP models. This can lead to some rather interesting mental gymnastics! Note that this is a limitation of the MILP approach, not just of CPLEX. Modelling languages that support those logical relationships mostly just provide syntactic sugar around these same modelling techniques with auxiliary binary/integer variables.

MILP solvers can handle very large problems with millions of variables and constraints; but that is because of the underlying mathematical structures and assumptions. Techniques like constraint programming do allow such direct modelling of logical and other relationships, but are usually limited to much smaller problem instances.

As to whether this will slow down CPLEX (or any other solver), the answer is probably yes it will. However there may be no alternative if you are using a MILP solver - it is better to solve the correct problem than the wrong one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM