1. 程式人生 > >使用+Leapms檢視線性規劃的單純性表,+Leapms的itsme命令

使用+Leapms檢視線性規劃的單純性表,+Leapms的itsme命令

知識點

+Leapms的itsme命令

+Leapms的直接代數模型

檢視線性規劃直接代數模型的單純形表和計算過程

+Leapms的直接代數模型

+Leapms的直接代數模型十分簡單,只是使用了s.r.表示變數的符號限制約束,其餘是常用的模型寫法。

模型關鍵詞相容多種寫法,例如下面的寫法是等價的:

	max z=2x1+3x2
s.t.
	2x1+2x2<=12
	4x1<=16
	5x2<=15
s.r.
	x1>=0,x2>=0
maximize z=2x1+3x2

subject to

	2x1+2x2<=12
	4x1<=16
	5x2<=15

sign restriction

	x1>=0,x2>=0

itme命令和 notme 命令

itme命令是內部命令,有一定風險。啟用後,可以使用standardize命令將模型變成標準型,而後可以多次使用step命令直到取得最優解,其間回顯單純形表。

notme關閉itme命令。

下面的例子依次使用 load, itsme, standardize, step, step, ..., step, notme, 完成檢視單純形表過程。注意在standardize處程式進行過變數代換。

+Leapms>load
 Current directory is "ROOT".
 .........
        P014.leap
        P014_1.leap
        QSD1_11.leap
 .........
please input the filename:p014
================================================================
1:      max z=2x1+3x2
2:  s.t.
3:      2x1+2x2<=12
4:      4x1<=16
5:      5x2<=15
6:  s.r.
7:      x1>=0,x2>=0
8:
================================================================
>>end of the file.
===========================================
number of variables=2
number of constraints=3
===========================================
+Leapms>itsme
 Welcome!
+Leapms>standardize
===========================================
    Maximize z=2*u1+3*u2+0*s1+0*s2+0*s3
s.t.
    2*u1+2*u2+1*s1+0*s2+0*s3 = 12
    4*u1+0*u2+0*s1+1*s2+0*s3 = 16
    0*u1+5*u2+0*s1+0*s2+1*s3 = 15
where
    x1=u1
    x2=u2
===========================================
+Leapms>step
Step 5, z=8
piovt=(2, 1)
-------------------------------------------
w +0*u1-3*u2+0*s1+0.5*s2+0*s3=8 | w=8
   0*u1+2*u2+1*s1-0.5*s2+0*s3=4 | s1=4
   1*u1+0*u2+0*s1+0.25*s2+0*s3=4 | u1=4
   0*u1+5*u2+0*s1+0*s2+1*s3=15 | s3=15
-------------------------------------------
+Leapms>step
Step 6, z=14
piovt=(1, 2)
-------------------------------------------
w +0*u1+0*u2+1.5*s1-0.25*s2+0*s3=14 | w=14
   0*u1+1*u2+0.5*s1-0.25*s2+0*s3=2 | u2=2
   1*u1+0*u2+0*s1+0.25*s2+0*s3=4 | u1=4
   0*u1+0*u2-2.5*s1+1.25*s2+1*s3=5 | s3=5
-------------------------------------------
+Leapms>step
Step 7, z=15
piovt=(3, 4)
-------------------------------------------
w +0*u1+0*u2+1*s1+0*s2+0.2*s3=15 | w=15
   0*u1+1*u2+0*s1+0*s2+0.2*s3=3 | u2=3
   1*u1+0*u2+0.5*s1+0*s2-0.2*s3=3 | u1=3
   0*u1+0*u2-2*s1+1*s2+0.8*s3=4 | s2=4
-------------------------------------------
+Leapms>step
    Optimal reached ....
+Leapms>notme
 ok!
+Leapms>

另一個例子,帶有非約束變數和人工變數:

+Leapms>load
 Current directory is "ROOT".
 .........
        P014.leap
        P014_1.leap
        P014_2.leap
        QSD1_11.leap
 .........
please input the filename:p014_2
================================================================
1:      max z=2x1+3x2
2:
3:  subject to
4:
5:      2x1+2x2<=12
6:      3x1-2x2>=6
7:      4x1<=16
8:      5x2<=15
9:
10:  sign restriction
11:     x1>=0
12:
================================================================
>>end of the file.
===========================================
number of variables=2
number of constraints=4
===========================================
+Leapms>itsme
 Welcome!
+Leapms>standardize
===========================================
    Maximize z=2*u1+3*u2-3*v2+0*s1+0*e2-1M*a2+0*s3+0*s4
s.t.
    2*u1+2*u2+-2*v2+1*s1+0*e2+0*a2+0*s3+0*s4 = 12
    3*u1+-2*u2+2*v2+0*s1+-1*e2+1*a2+0*s3+0*s4 = 6
    4*u1+0*u2+-0*v2+0*s1+0*e2+0*a2+1*s3+0*s4 = 16
    0*u1+5*u2+-5*v2+0*s1+0*e2+0*a2+0*s3+1*s4 = 15
where
    x1=u1
    x2=u2-v2
===========================================
+Leapms>step
Step 5, z=4
piovt=(2, 1)
-------------------------------------------
w +0*u1-4.33333*u2+4.33333*v2+0*s1-0.666667*e2+(0.666667+1M)*a2+0*s3+0*s4=4 | w=
4
   0*u1+3.33333*u2-3.33333*v2+1*s1+0.666667*e2-0.666667*a2+0*s3+0*s4=8 | s1=8
   1*u1-0.666667*u2+0.666667*v2+0*s1-0.333333*e2+0.333333*a2+0*s3+0*s4=2 | u1=2
   0*u1+2.66667*u2-2.66667*v2+0*s1+1.33333*e2-1.33333*a2+1*s3+0*s4=8 | s3=8
   0*u1+5*u2-5*v2+0*s1+0*e2+0*a2+0*s3+1*s4=15 | s4=15
-------------------------------------------
+Leapms>step
Step 6, z=14.4
piovt=(1, 2)
-------------------------------------------
w +0*u1+0*u2+0*v2+1.3*s1+0.2*e2+(-0.2+1M)*a2+0*s3+0*s4=14.4 | w=14.4
   0*u1+1*u2-1*v2+0.3*s1+0.2*e2-0.2*a2+0*s3+0*s4=2.4 | u2=2.4
   1*u1+0*u2+0*v2+0.2*s1-0.2*e2+0.2*a2+0*s3+0*s4=3.6 | u1=3.6
   0*u1+0*u2+0*v2-0.8*s1+0.8*e2-0.8*a2+1*s3+0*s4=1.6 | s3=1.6
   0*u1+0*u2+0*v2-1.5*s1-1*e2+1*a2+0*s3+1*s4=3 | s4=3
-------------------------------------------
+Leapms>step
    Optimal reached ....
+Leapms>notme
 ok!
+Leapms>