知识点
+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命令查看单纯形表
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>