1) 用LP过程求解线性规划
max z=-5*x1+5*x2+13*x3
-x1+x2+3*x3<=20
12*x1+4*x2+10*x3<=90
x1,x2,x3>=0
data lp1;
input _row_$ x1 x2 x3 _type_$ _rhs_;
cards;
object -5 5 13 max .
proc1 -1 1 3 le 20
proc2 12 4 10 le 90
;
proc lp;
run;
x1=0 x2=20 x3=0
2) 用LP过程求解整数线性规划
max 2*x1+3*x2
5*x1+7*x2<=35
4*x1+9*x2<=36
x1,x2>=0 x1,x2为整数
data lp1;
input _row_$ x1 x2 _type_$ _rhs_;
cards;
object 2 3 max .
proc1 5 7 le 35
proc2 4 9 le 36
bound 10 10 upperbd .
inbd 1 2 integer .
;
proc lp;
run;
x1=7 x2=0
3) 用NLP过程求解无约束优化问题
min z=1.5*x1*x1+0.5*x2*x2-x1*x2+2*x1
proc nlp;
min y;
parms x1 x2=-1;
bounds 0<=x1,0<=x2;
y1=1.5*x1*x1;
y2=0.5*x2*x2;
y3=-1*x1*x2;
y4=-2*x1;
y=y1+y2+y3+y4;
run;
x1=x2=1
4) 用NLP过程求解无约束优化问题
min z=-2*x1-x2
25-x1*x1-x2*x2>=0
7-x1*x1+x2*x2>=0
0<=x1<=5
0<=x2<=10
proc nlp;
min y;
parms x1 x2=-1;
bounds 0<=x1<=5,0<=x2<=10;
y1=-2*x1;
y2=-1*x2;
y3=25-x1*x1-x2*x2;
y4=7-x1*X1+x2*x2;
Nlincon y3>=0,
y4>=0;
y=y1+y2+y3+y4;
run
x1=4 x2=3 minz=-11
5) 用NLP过程解非线性规划
min z=2*x1*x1-4*x1*x2+4*x2*x2-6*x1-3*x2
x1+x2<=3
4*x1+x2<=9
x1,x2>=0
min y;
parms x1 x2=-1;
bounds 0<=x1,0<=x2;
y1=2*x1*x1;
y2=-4*x1*x2;
y3=4*x2*x2;
y4=-6*x1-3*x2;
y5=4*x1+x2;
y6=x1+x2;
Nlincon y5<=9,
y6<=3;
y=y1+y2+y3+y4;
run;
x1=1.95 x2=1.05 minz=-11.025
6) 求解下面线性目标规划模型
min z=p1*d11+p2*d22+p3*(5*d31+3*d41)+p4*d12
x1+2*x2+d11-d12=6
x1+2*x2+d21-d22=9
x1-2*x2+d31-d32=4
x2+d41-d42=2
x1,x2,dij>=0 ,i=1,2,3,4 j=1,2
data hua;
input _row_$ x1 x2 d11 d12 d21 d22 d31 d32 d41 d42 _type_$ _rhs_;
cards;
object 0 0 0.99 0.000001 0 0.0099 0.625*0.000099 0 0.375*0.000099 0 min .
con1 1 2 1 -1 0 0 0 0 0 0 eq 6
con2 1 2 0 0 1 -1 0 0 0 0 eq 9
con3 1 -2 0 0 0 0 1 -1 0 0 eq 4
con4 0 1 0 0 0 0 0 0 1 -1 eq 2
;
proc lp;
run;
7) 求解下面0-1规划模型
max z=3*x1+2*x2-5*x3-2*x4+3*x5
x1+x2+x3+2*x4+x5<=4
7*x1+ 3*x3-4*x4+3*x5<=8
11*x1-6*x2 +3*x4-3*x5>=3
xj=0或1 (j=1,...,5)
data cat;
input _row_$ x1-x5 _type_$ _rhs_;
cards;
object 3 2 -5 -2 3 max .
con1 1 1 1 2 1 le 4
con2 7 0 3 -4 3 le 8
con3 11 -6 0 3 -3 ge 3
bound 1 1 1 1 1 upperbd .
inbd 1 2 3 4 5 integer .
proc lp;
run;
本文地址:http://com.8s8s.com/it/it33493.htm