简体   繁体   English

具有 OR 逻辑的 LP / MILP 公式

[英]LP / MILP formulation with OR logic

I'm solving a LP / MILP problem using ILOG CPLEX.我正在使用 ILOG CPLEX 解决 LP / MILP 问题。

int n = ...;
range time =1..n;

dvar float+ c[time] in 0..0.3;
dvar float+ d[time] in 0..0.3;
dvar float+ x[time];

int beta[time]=...;
float pc[time]=...;
float pd[time]=...;

//Expressions

dexpr float funtion = sum(t in time) (d[t]*pd[t]-c[t]*pc[t]); 

//Model

maximize function;

subject to {

    x[1] == 0.5;
    c[1] == 0;
    d[1] == 0;

    forall(t in time)
        const1:
            x[t] <= 1;          

    forall(t in time: t!=1)
        const2:
            (x[t] == x[t-1] + c[t] - d[t]);         

    forall(t in time: t!=1)
        const3:         
            ( d[t] <= 0) || (c[t] <= 0); 

As you can see I've forced c[t] and d[t] to never be bigger than 0 at the same time with "const3".正如你所看到的,我已经用“const3”强制 c[t] 和 d[t] 永远不要大于 0。

My question is, how would this constraint be represented in a LP/MILP mathematical formulation?我的问题是,这种约束如何在 LP/MILP 数学公式中表示?

Is adding this new variable enough?添加这个新变量是否足够? :

y[t]≤c[t]+d[t] y[t]≤c[t]+d[t]

y[t]≥c[t] y[t]≥c[t]

y[t]≥d[t] y[t]≥d[t]

0≤y[t]≤M (M is the maximum value of both c or d) 0≤y[t]≤M(M为c或d两者的最大值)

As far as I can tell, the constraints you suggested would allow this setting:据我所知,您建议的约束将允许此设置:

c[t] = 0.1
d[t] = 0.1
y[t] = 0.2

Which has c and d different from 0 simultaneously.其中cd同时不同于 0。

I can see these options to formulate your condition without logical constraints:我可以看到这些选项来制定您的条件而没有逻辑限制:

1) Use an SOS constraint that contains just c[t] and d[t] . 1) 使用仅包含c[t]d[t]的 SOS 约束。 By definition of SOS only one of the two can be non-zero in any feasible solution.根据 SOS 的定义,在任何可行的解决方案中,两者中只有一个可以是非零的。

2) Use a boolean variable y[t] and add constraints 2) 使用boolean变量y[t]并添加约束

c[t] <= M * y[t]
d[t] <= M * (1 - y[t])

3) Again, use boolean y[t] and then indicator constraints 3) 同样,使用 boolean y[t]然后指标约束

(y[t] == 0) => (c[t] == 0);
(y[t] == 1) => (d[t] == 0);

4) You can just state c[t] * d[t] == 0 but that will make the model non-linear. 4)您可以只使用 state c[t] * d[t] == 0但这会使 model 非线性。

In any case, a solver will probably be able to reduce your original formulation to either 2 or 3. So reformulating the constraint may not make things faster but only more obscure.无论如何,求解器可能能够将您的原始公式减少到 2 或 3。因此,重新制定约束可能不会使事情变得更快,而只会变得更加模糊。

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

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