When we now apply the solution from above to the problem of the OP, then we can build a linear program with inequalities (i) and (ii) for all pairs of variables from the OP's problem and M=4:/* Objective function */min: 1;/* Variable bounds */1 <= x1 <= 4;1 <= x2 <= 4;1 <= x3 <= 4;1 <= x4 <= 4;r_12 <= 1;r_13 <= 1;r_14 <= 1;r_23 <= 1;r_24 <= 1;r_34 <= 1;/* This is done automatically because all x1,..,x4 are different x1 + x2 + x3 + x4 = 10;*//* Apply (i) and (ii) to all pairs of x1,..x4(i) x+1 <= y + Mr(ii) y+1 <= x + M-Mr*/x1 + 1 <= x2 + 4 r_12;x2 + 1 <= x1 + 4 - 4 r_12;x1 + 1 <= x3 + 4 r_13;x3 + 1 <= x1 + 4 - 4 r_13;x1 + 1 <= x4 + 4 r_14;x4 + 1 <= x4 + 4 - 4 r_14;x2 + 1 <= x3 + 4 r_23;x3 + 1 <= x2 + 4 - 4 r_23;x2 + 1 <= x4 + 4 r_24;x4 + 1 <= x2 + 4 - 4 r_24;x3 + 1 <= x4 + 4 r_34;x4 + 1 <= x3 + 4 - 4 r_34;/*x1 < x2;x2 < x3;x3 < x4;*/int r_12;int r_13;int r_14;int r_23;int r_24;int r_34;int x1;int x2;int x3;int x4;解决上述MILP会提供一个解决方案,其中所有x1,..,x4均不同:Solving the MILP above renders a solution with all x1,..,x4 different:x1=3x2=1x3=2x4=4 这篇关于如何在lpsolve中公式化x!= y的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-11 22:45