0

I am using lp_solve...I want to solve this MILP with various constraints

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;

but I need to solve this for different values of w1,h1,w2,h2,w3,h3,w4 and h4,m.

is it possible to solve via lp_solve? or via any other lpsolver

where I shall manually put those values each time before solving

say I can get a solution for w1=3,w2=4,w3=5,w4=8, h1=8,h2=8,h3=6,h4=7,m=23

In later case I just need to change the values..I dont want to change the values at constraints every time for each value. I need that program will take these values of w_i and h_i &m, this lp can be solved every time with this fixed constraints

Sangeet Saha
  • 83
  • 1
  • 7
  • Are the "different values" for `w_i`/`h_i`/`m` just a few sets of constants? Or are these variables on their own? In the former case, it's just a few problems instead of one; in the latter, it's not LP. – ivan_pozdeev Oct 13 '14 at 10:16
  • sorry..yes for different values of w_i/h_i/m – Sangeet Saha Oct 13 '14 at 11:35
  • Uhm, LPsolve has about [15 APIs](http://lpsolve.sourceforge.net/5.5/). where are you calling lpsolve from? From the IDE? AFAIK you cannot do this from the IDE.. You could write a script to load the `w_i/h_i/m` and execute LPsolve in a loop.. – Ioannis Oct 13 '14 at 13:44

1 Answers1

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.

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152