您的解決方案制定得很好,並且lpsolve解決得很好。但結果可能不是你所期望的。例如,我得到:z = 0和x187 = 0(A = B = 0)。 事情是,A和B是隻取決於x187的表達式,所以你應該簡化分割表達式!選擇的大M應該更小?
Model name: 'model build from GLP-Solve' - run #1
Objective: Minimize(R0)
SUBMITTED
Model size: 12 constraints, 53 variables, 311 non-zeros.
Sets: 0 GUB, 0 SOS.
Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.
The primal and dual simplex pricing strategy set to 'Devex'.
Relaxed solution 276710632.306 after 23 iter is B&B base.
Feasible solution 276710632.306 after 23 iter, 0 nodes (gap 0.0%)
Optimal solution 276710632.306 after 23 iter, 0 nodes (gap 0.0%).
Excellent numeric accuracy ||*|| = 0
MEMO: lp_solve version 5.5.2.0 for 64 bit OS, with 64 bit REAL variables.
In the total iteration count 23, 17 (73.9%) were bound flips.
There were 0 refactorizations, 0 triggered by time and 0 by density.
... on average 6.0 major pivots per refactorization.
The largest [LUSOL v2.2.1.0] fact(B) had 13 NZ entries, 1.0x largest basis.
The maximum B&B level was 1, 0.5x MIP order, 1 at the optimal solution.
The constraint matrix inf-norm is 1e+06, with a dynamic range of 6.39386e+08.
Time to load data was 0.001 seconds, presolve used 0.000 seconds,
... 0.000 seconds in simplex solver, in total 0.001 seconds.
如果我們將A,B和Z的限制,我們得到了相同的結果:
Model name: 'model build from GLP-Solve' - run #1
Objective: Minimize(R0)
SUBMITTED
Model size: 6 constraints, 50 variables, 299 non-zeros.
Sets: 0 GUB, 0 SOS.
Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.
The primal and dual simplex pricing strategy set to 'Devex'.
Optimal solution 276710632.306 after 22 iter.
Excellent numeric accuracy ||*|| = 0
MEMO: lp_solve version 5.5.2.0 for 64 bit OS, with 64 bit REAL variables.
In the total iteration count 22, 17 (77.3%) were bound flips.
There were 0 refactorizations, 0 triggered by time and 0 by density.
... on average 5.0 major pivots per refactorization.
The largest [LUSOL v2.2.1.0] fact(B) had 7 NZ entries, 1.0x largest basis.
The constraint matrix inf-norm is 1, with a dynamic range of 639.386.
Time to load data was 0.002 seconds, presolve used 0.001 seconds,
... 0.001 seconds in simplex solver, in total 0.004 seconds.
你好josliber,感謝你的幫助。我有問題得到一個運行的例子。我試試這個。 [code] A = -0.275 y0 + 0.15 y1 + 0.15 y2 + 0.236 y3 + 0.14745 y4; B = -0.175 y0 + 0.05 y1 + 0.05 y2 + 0.136 y3 + 0。04745 y4; A <= Mz; B <= Mz; A> = M(z-1); B> = M(z-1); z二進制; [/ code]但我得到解析錯誤。我不明白詳細的邏輯... – ABSimon
@ABSimon'M'應該用一個很大的數字來代替,比如1000000. – josliber
Hello josliber,我還需要在括號中放置「A> = 1000000(z-1) 「和」B> = 1000000(z-1)「。我想我會得到「A> = 1000000 Z - 1000000」和「B> = 1000000 Z - 1000000」。總的來說,我有解決方法「A <= 1000000 z; B <= 1000000 z; A> = 1000000 z - 1000000; B> = 1000000 z - 1000000; bin z;」而不是「A/B> = 0」?謝謝!我認爲這是一個很大的幫助vor每個lp_solve初學者:) – ABSimon