0

我正在使用 lp_solve...我想用各种约束来解决这个 MILP

min: Y;

// subject to, constraints are

x1 + z1h1 + (1 - z1)w1 <= x2 + m(x12 + y12);
x1 - z2h2 - (1 - z2)w2 >=x2 - m(1 - x12 + y12);
y1 + z1w1 + (1 - z1)h1 <= y2 + m(1 + x12 - y12);
y1 - z2w2 - (1 - z2)h2 >= y2 - m(2 - x12 - y12);
x1 + z1h1 + (1 - z1)w1 <= x3 + m(x13 + y13);
x1 - z3h3 - (1 - z3)w3 >= x3 - m(1 - x13 + y13);
y1 + z1w1 + (1 - z1)h1 <= y3 + m(1 + x13 - y13);
y1 - z3w3 - (1 - z3)h3 >= y3 - m(2 - x13 - y13);
x1 + z1h1 + (1 - z1)w1 <= x4 + m(x14 + y14);
x1 - z4h4 - (1 - z4)w4 >= x4 - m(1 - x14 + y14);
y1 + z1w1 + (1 - z1)h1 <= y4 + m(1 + x14 - y14);
y1 - z4w4 - (1 - z4)h4 >= y4 - m(2 - x14 - y14);
x2 + z2h2 + (1 - z2)w2 <= x3 + m(x23 + y23);
x2 - z3h3 - (1 - z3)w3 >= x3 - m(1 - x23 + y23);
y2 + z2w2 + (1 - z2)h2 <= y3 + m(1 + x23 - y23);
y2 - z3w3 - (1 - z3)h3 >= y3 - m(2 - x23 - y23);
x2 + z2h2 + (1 - z2)w2 <= x4 + m(x24 + y24);
x2 - z4h4 - (1 - z4)w4 >= x4 - m(1 - x24 + y24);
y2 + z2w2 + (1 - z2)h2 <= y4 + m(1 + x24 - y24);
y2 - z4w4 - (1 - z4)h4 >= y4 - m(2 - x24 - y24);
x3 + z3h3 + (1 - z3)w3 <= x4 + m(x34 + y34);
x3 - z4h4 - (1 - z4)w4 >= x4 - m(1 - x34 + y34);
y3 + z3w3 + (1 - z3)h3 <= y4 + m(1 + x34 - y34);
y3 - z4w4 - (1 - z4)h4 >= y4 - m(2 - x34 - y34);

/* variable type constraints */
x1 >= 0;
x2 >= 0;
x3 >= 0;
x4 >= 0;
y1 >= 0;
y2 >= 0;
y3 >= 0;
y4 >= 0;




x1 + (1-z1)w1 + h1 z1 <= Y;
x2 + (1-z2)w2 + h2 z2 <= Y;
x3 + (1-z3)w3 + h3 z3 <= Y;
x4 + (1-z4)h4 + h4 z4 <= Y;



y1 + (1-z1)h1 + w1z1 <= Y;
y2 + (1-z2)h2 + w2 z2 <= Y;
y3 + (1-z3)h3 + w3 z3 <= Y;
y4 + (1-z4)h4+ w4z4 <= Y;

bin x12, x13, x14, x23, x24, x34;
bin y12, y13, y14, y23, y24, y34;
bin z1, z2, z3, z4;

但我需要为 w1、h1、w2、h2、w3、h3、w4 和 h4、m 的不同值解决这个问题。

是否可以通过 lp_solve 解决?或通过任何其他 lpsolver

我将在每次解决之前手动输入这些值

说我可以得到 w1=3,w2=4,w3=5,w4=8, h1=8,h2=8,h3=6,h4=7,m=23 的解决方案

在以后的情况下,我只需要更改值..我不想每次都为每个值更改约束处的值。我需要该程序将采用这些 w_i 和 h_i &m 的值,这个 lp 每次都可以用这个固定的约束来解决

4

1 回答 1

0

lpsolve (and any general-purpose solver, for that matter) expects a problem in canonical form, i.e. as a set of coefficients. It doesn't care for what extra logic you might have.

So, calculate the specific coefficients you'll have in each case separately and provide them as separate tasks. You can e.g. populate an lprec with data common for all the cases (Y, the last constraints), then clone it for each case with lp_copy and add the case-specific data.

于 2014-10-13T16:22:36.200 回答