简体   繁体   English

使用LP文件格式的CPLEX:具有布尔运算符的指标约束

[英]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). 我对CPLEX完全陌生,并且距离MIP专家还很远,但是我正在尝试解决此技术(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. 我决定在.lp文件中创建MIP模型,并将其提供给CPLEx,这样我可以有很多输入并测试不同的求解器等。但是我发现有关指标约束的一件事有些问题。

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). 但有没有这样的事情ANS ANDNOT在LP格式(我甚至不知道我是否能做到这一点的CPX接口上,但我想,以避免它)。

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? 我对此感到满意,因为我将使用另一个程序生成此LP,但这会减慢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. LP和MILP方法不能直接考虑这些逻辑约束。 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. 在许多情况下,它们将是布尔值或0/1整数变量。 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. 编写MILP模型的大部分工艺是在用限制性很强的LP和MILP模型的“语言”来寻找重写这些条件的好方法。 This can lead to some rather interesting mental gymnastics! 这可以导致一些相当有趣的精神体操! Note that this is a limitation of the MILP approach, not just of CPLEX. 请注意,这是MILP方法的局限性,而不仅仅是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; MILP求解器可以处理具有数百万个变量和约束的非常大的问题。 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. 关于这是否会减慢CPLEX(或任何其他求解器)的速度,答案可能是肯定的。 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. 但是,如果使用的是MILP求解器,则别无选择-解决正确的问题比解决错误的问题更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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