数学建模实验二Word文档下载推荐.docx
《数学建模实验二Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《数学建模实验二Word文档下载推荐.docx(14页珍藏版)》请在冰豆网上搜索。
ans=
1221
P218
3.求函数f(x)=x^2+4x+4的最小值。
fun='
x^2+4*x+4'
ezplot(fun,[-12,8])
[X,fval,exitflag,output]=fminbnd(fun,-12,8)
>
Untitled8
fun=
x^2+4*x+4
X=
-2
fval=
0
exitflag=
1
output=
iterations:
5
funcCount:
6
algorithm:
'
goldensectionsearch,parabolicinterpolation'
message:
优化已终止:
当前的x满足使用1.000000e-04的OPTIONS.TolX的终止条件
'
4.在区间【-10,10】上,求函数f(x)=(x-2)^4*sin(x)-(x-1)^2*cos(x)的最小值
clear
(x-2)^4*sin(x)-(x-1)^2*cos(x)'
ezplot(fun,[-10,10])
[X,fval,exitflag,output]=fminbnd(fun,-10,10)
Untitled9
(x-2)^4*sin(x)-(x-1)^2*cos(x)
-2.2939
-247.6956
13
14
P222
1.求有约束的线性优化问题:
minf(x)=1/3*(x1+)^3+x2,约束条件为x1-1>
=0,x2>
=0.
min=1/3*(x1+1)^3+x2;
x1>
=1;
end
运行结果:
Localoptimalsolutionfound.
Objectivevalue:
2.666667
Infeasibilities:
0.000000
Extendedsolversteps:
Totalsolveriterations:
44
VariableValueReducedCost
X11.0000000.000000
X20.0000001.000000
RowSlackorSurplusDualPrice
12.666667-1.000000
20.000000-4.000000
2.求有约束的非线性规划问题:
minf(x)=2x1^2+2x2^2-2x1x2-4x1-6x2,
约束条件为:
x1+x2<
=2,
X1+5x2<
=5,
X1>
=0,
X2>
解:
min=2*x1^2+2*x2^2-2*x1*x2-4*x1-6*x2;
=2;
x1+5*x2<
=5;
-7.161290
0.4440892E-15
30
X11.1290320.000000
X20.77419350.000000
1-7.161290-1.000000
20.9677419E-010.000000
30.0000001.032258
二、lingo完成PPT上练习题;
1.
max=5*x1+8*x2;
=6;
5*x1+9*x2<
=45;
=0;
x2>
Globaloptimalsolutionfound.
41.25000
2
X12.2500000.000000
X23.7500000.000000
141.250001.000000
20.0000001.250000
30.0000000.7500000
42.2500000.000000
53.7500000.000000
2.
min=3*x^2+2*y^2+z^2+2*x*y-y*z-0.8*y*z;
x+y+z=1;
1.3*x+1.2*y+1.08*z>
=1.12;
x>
x<
=0.75;
y>
y<
z>
z<
0.2479167
Objectivebound:
93
X0.0000000.000000
Y0.39583330.000000
Z0.60416670.000000
10.2479167-1.000000
20.000000-0.4958333
30.7500000E-020.000000
40.000000-0.2958333
50.75000000.000000
60.39583330.000000
70.35416670.000000
80.60416670.000000
90.14583330.000000
3.
sets:
D/1..7/:
a;
endsets
f=a(7);
a
(1)=1;
a
(2)=1;
@for(D(i)|i#ge#3:
a(i)=a(i-1)+a(i-2));
Feasiblesolutionfound.
VariableValue
F13.00000
A
(1)1.000000
A
(2)1.000000
A(3)2.000000
A(4)3.000000
A(5)5.000000
A(6)8.000000
A(7)13.00000
RowSlackorSurplus
10.000000
20.000000
30.000000
40.000000
50.000000
60.000000
70.000000
80.000000
min=-x1-5*x2;
x1-x2>
=-2;
5*x1+6*x2<
=30;
x1<
=4;
@gin(x1);
@gin(x2);
-17.00000
X12.000000-1.000000
X23.000000-5.000000
1-17.00000-1.000000
21.0000000.000000
32.0000000.000000
42.0000000.000000
52.0000000.000000
63.0000000.000000
max=3*x1-2*x2+5*x3;
x1+2*x2-x3<
x1+4*x2+x3<
=3;
4*x2+x3<
@bin(x1);
@bin(x2);
@bin(x3);
8.000000
X11.000000-3.000000
X20.0000002.000000
X31.000000-5.000000
18.0000001.000000
22.0000000.000000
55.0000000.000000
min=13*x1+9*x2+10*x3+11*x4+12*x5+8*x6;
x1+x4=400;
x2+x5=600;
x3+x6=500;
0.4*x1+1.1*x2+x3<
=800;
0.5*x4+1.2*x5+1.3*x6<
=900;
@gin(x3);
@gin(x4);
@gin(x5);
@gin(x6);
13800.00
X10.00000013.00000
X2600.00009.000000
X30.00000010.00000
X4400.000011.00000
X50.00000012.00000
X6500.00008.000000
113800.00-1.000000
20.0000000.000000
30.0000000.000000
40.0000000.000000
5140.00000.000000
650.000000.000000
4.
cities/s,a1,a2,a3,
b1,b2,c1,c2,t/:
l;
roads(cities,cities)/
s,a1s,a2s,a3
a1,b1a1,b2a2,b1
a2,b2a3,b1a3,b2
b1,c1b1,c2b2,c1b2,c2
c1,tc2,t/:
d;
data:
d=633
658674
6789
56;
enddata
l
(1)=0;
@for(cities(i)|
i#gt#@index(s):
l(i)=@min(
roads(j,i):
l(j)+d(j,i)));
Feasiblesolutionfound.
L(S)0.000000
L(A1)6.000000
L(A2)3.000000
L(A3)3.000000
L(B1)10.00000
L(B2)7.000000
L(C1)15.00000
L(C2)16.00000
L(T)20.00000
D(S,A1)6.000000
D(S,A2)3.000000
D(S,A3)3.000000
D(A1,B1)6.000000
D(A1,B2)5.000000
D(A2,B1)8.000000
D(A2,B2)6.000000
D(A3,B1)7.000000
D(A3,B2)4.000000
D(B1,C1)6.000000
D(B1,C2)7.000000
D(B2,C1)8.000000
D(B2,C2)9.000000
D(C1,T)5.000000
D(C2,T)6.000000
90.000000