优化设计 实验报告.docx
《优化设计 实验报告.docx》由会员分享,可在线阅读,更多相关《优化设计 实验报告.docx(49页珍藏版)》请在冰豆网上搜索。
![优化设计 实验报告.docx](https://file1.bdocx.com/fileroot1/2023-8/19/53d091c5-b493-4eb5-9df4-ec03663586c1/53d091c5-b493-4eb5-9df4-ec03663586c11.gif)
优化设计实验报告
一维搜索方法程序
(1)
>>[x,xfval]=fminbnd('x^2-10*x+36',3,7)
x=
5
xfval=
11
(2)
>>[x,xfval]=fminbnd('x^4-5*x^3+4*x^2-6*x+60',2,5)
x=
3.2796
xfval=
22.6590
(3)
>>[x,xfval]=fminbnd('(x+1)*(x-2)^2',1,4)
x=
2.0000
xfval=
4.1884e-011
无约束优化方法程序
(1)
>>[x,fval]=fminsearch(@(x)4*(x
(1)-5)^2+(x
(2)-6)^2,[8;9])
x=
5.0000
6.0000
fval=
1.5825e-009
>>
(2)
[x,fval]=fminsearch(@(x)(x
(1)^2+x
(2)-11)^2+(x
(1)+x
(2)^2-7)^2,[1;1])
x=
3.0000
2.0000
fval=
2.2339e-008
>>
(3)
[x,fval]=fminsearch(@(x)(1.5-x
(1)*(1-x
(2))^2)^2+(2.25-x
(1)*(1-x
(2))^2)^2+(2.625-x
(1)*(1-x
(2))^3)^2,[2;0.2])
x=
0.9567
-0.4000
fval=
0.2813
>>
(4)
[x,fval]=fminsearch(@(x)(x
(1)^2+12*x
(2)-1)^2+(49*x
(1)+49*x
(2)+84*x
(1)+2324*x
(2)-681)^2,[1;1])
x=
0.3363
0.2681
fval=
5.4318
>>
(5)
[x,fval]=fminsearch(@(x)(x
(1)+10*x
(2))^2+5*(x(3)-x(4))^2+(x
(2)-2*x(3))^4+10*(x
(1)-x(4))^4,[3;-1;0;1])
x=
0.0094
-0.0009
0.0166
0.0166
fval=
1.3906e-006
>>
历史窗口
%--14-3-28上午10:
00--%
clear
clc
[x,xfval]=fminbnd('x^2-10*x+36',3,7)
[x,xfval]=fminbnd('x^4-5*x^3+4*x^2-6*x+60',2,5)
[x,xfval]=fminbnd('(x+1)*(x-2)^2',1,4)
clear
clc
[x,fval]=fminsearch(@(x)4*(x
(1)-5)^2+(x
(2)-6)^2,[8;9])
[x,fval]=fminsearch(@(x)(x
(1)^2+x
(2)-11)^2+(x
(1)+x
(2)^2-7)^2,[1;1])
[x,fval]=fminsearch(@(x)(1.5-x
(1)*(1-x
(2))^2)^2+(2.25-x
(1)*(1-x
(2))^2)^2+(2.625-x
(1)*(1-x
(2))^3)^2,[2;0.2])
[x,fval]=fminsearch(@(x)(x
(1)^2+12*x
(2)-1)^2+(49*x
(1)+49*x
(2)+84*x
(1)+2324*x
(2)-681)^2,[1;1])
[x,fval]=fminsearch(@(x)(x
(1)+10*x
(2))^2+5*(x(3)-x(4))^2+(x
(2)-2*x(3))^4+10*(x
(1)-x(4))^4,[3;-1;0;1])
[x,xfval]=fminbnd('x^2-10*x+36',3,7)
[x,fval]=fminsearch(@(x)(x
(1)^2+x
(2)-11)^2+(x
(1)+x
(2)^2-7)^2,[1;1])
约束优化方法的程序
(1)
>>[x,fval]=fmincon(@(x)objfun(x),[3;3],[11],[2],[],[],[],[],@(x)confun(x))
Warning:
Large-scale(trustregion)methoddoesnotcurrentlysolvethistypeofproblem,
switchingtomedium-scale(linesearch).
>Infminconat260
f=
5
c=
6
ceq=
[]
f=
5.0000
c=
6.0000
ceq=
[]
f=
5.0000
c=
6.0000
ceq=
[]
f=
5.0000
c=
2.0000
ceq=
[]
f=
5.0000
c=
2.0000
ceq=
[]
f=
5.0000
c=
2.0000
ceq=
[]
f=
1.0000
c=
9.9341e-009
ceq=
[]
f=
1.0000
c=
3.9736e-008
ceq=
[]
f=
1.0000
c=
-4.9671e-009
ceq=
[]
Optimizationterminated:
first-orderoptimalitymeasurelessthanoptions.TolFun
andmaximumconstraintviolationislessthanoptions.TolCon.
Activeinequalities(towithinoptions.TolCon=1e-006):
lowerupperineqlinineqnonlin
11
x=
1.0000
1.0000
fval=
1.0000
>>
(2)
>>[x,fval]=fmincon(@(x)objfun2(x),[1;5],[31.73205],[6],[],[],[],[],@(x)confun2(x))
Warning:
Large-scale(trustregion)methoddoesnotcurrentlysolvethistypeofproblem,
switchingtomedium-scale(linesearch).
>Infminconat260
f=
-34.7222
c=
4.8333
c=
4.8333-0.1667
c=
4.8333-0.1667-1.0000
c=
4.8333-0.1667-1.0000-5.0000
ceq=
[]
f=
-34.7222
c=
4.8333
c=
4.8333-0.1667
c=
4.8333-0.1667-1.0000
c=
4.8333-0.1667-1.0000-5.0000
ceq=
[]
f=
-34.7222
c=
4.8333
c=
4.8333-0.1667
c=
4.8333-0.1667-1.0000
c=
4.8333-0.1667-1.0000-5.0000
ceq=
[]
f=
-0.0119
c=
-3.2760e-008
c=
-0.0000-1.7738
c=
-0.0000-1.7738-1.8244
c=
-0.0000-1.7738-1.8244-0.3041
ceq=
[]
f=
-0.0119
c=
-3.7291e-008
c=
-0.0000-1.7738
c=
-0.0000-1.7738-1.8244
c=
-0.0000-1.7738-1.8244-0.3041
ceq=
[]
f=
-0.0119
c=
-1.7859e-008
c=
-0.0000-1.7738
c=
-0.0000-1.7738-1.8244
c=
-0.0000-1.7738-1.8244-0.3041
ceq=
[]
f=
-0.0119
c=
0
c=
0-1.7738
c=
0-1.7738-1.8244
c=
0-1.7738-1.8244-0.3041
ceq=
[]
f=
-0.0119
c=
-4.5311e-009
c=
-0.0000-1.7738
c=
-0.0000-1.7738-1.8244
c=
-0.0000-1.7738-1.8244-0.3041
ceq=
[]
f=
-0.0119
c=
1.4901e-008
c=
0.0000-1.7738
c=
0.0000-1.7738-1.8244
c=
0.0000-1.7738-1.8244-0.3041
ceq=
[]
Optimizationterminated:
first-orderoptimalitymeasurelessthanoptions.TolFun
andmaximumconstraintviolationislessthanoptions.TolCon.
Activeinequalities(towithinoptions.TolCon=1e-006):
lowerupperineqlinineqnonlin
11
x=
1.8244
0.3041
fval=
-0.0119
>>
(3)
>>[x,fval]=fmincon(@(x)objfun3(x),[2;2;2],[3.5120.2173.552],[0],[],[],[],[],@(x)confun3(x))
Warning:
Large-scale(trustregion)methoddoesnotcurrentlysolvethistypeofproblem,
switchingtomedium-scale(linesearch).
>Infminconat260
f=
976
c=
-2
c=
-2-2
c=
-2-2-2
ceq=
-13
ceq=
-132
f=
976.0000
c=
-2.0000
c=
-2.0000-2.0000
c=
-2.0000-2.0000-2.0000
ceq=
-13.0000
ceq=
-13.00002.0000
f=
976.0000
c=
-2
c=
-2.0000-2.0000
c=
-2.0000-2.0000-2.0000
ceq=
-13.0000
ceq=
-13.00002.0000
f=
976.0000
c=
-2
c=
-2-2
c=
-2.0000-2.0000-2.0000
ceq=
-13.0000
ceq=
-13.00002.0000
f=
795.9227
c=
6.8107
c=
6.81070.2770
c=
6.81070.2770-16.3378
ceq=
288.3863
ceq=
288.38630.0000
f=
932.7881
c=
2.4054
c=
2.4054-0.8615
c=
2.4054-0.8615-9.1689
ceq=
65.5966
ceq=
65.59661.0000
f=
966.1007
c=
0.2027
c=
0.2027-1.4307
c=
0.2027-1.4307-5.5844
ceq=
8.2741
ceq=
8.27411.5000
f=
973.9770
c=
-0.8987
c=
-0.8987-1.7154
c=
-0.8987-1.7154-3.7922
ceq=
-6.8690
ceq=
-6.86901.7500
f=
973.9770
c=
-0.8987
c=
-0.8987-1.7154
c=
-0.8987-1.7154-3.7922
ceq=
-6.8690
ceq=
-6.86901.7500
f=
973.9770
c=
-0.8987
c=
-0.8987-1.7154
c=
-0.8987-1.7154-3.7922
ceq=
-6.8690
ceq=
-6.86901.7500
f=
973.9770
c=
-0.8987
c=
-0.8987-1.7154
c=
-0.8987-1.7154-3.7922
ceq=
-6.8690
ceq=
-6.86901.7500
f=
972.2917
c=
2.1362
c=
2.1362-2.7450
c=
2.1362-2.7450-4.9513
ceq=
11.6139
ceq=
11.6139-0.0000
f=
972.2917
c=
2.1362
c=
2.1362-2.7450
c=
2.1362-2.7450-4.9513
ceq=
11.6139
ceq=
11.6139-0.0000
f=
972.2917
c=
2.1362
c=
2.1362-2.7450
c=
2.1362-2.7450-4.9513
ceq=
11.6139
ceq=
11.61390.0000
f=
972.2917
c=
2.1362
c=
2.1362-2.7450
c=
2.1362-2.7450-4.9513
ceq=
11.6139
ceq=
11.6139-0.0000
f=
975.5551
c=
1.6687
c=
1.6687-3.0472
c=
1.6687-3.0472-3.8126
ceq=
1.6064
ceq=
1.6064-0.0000
f=
975.5551
c=
1.6687
c=
1.6687-3.0472
c=
1.6687-3.0472-3.8126
ceq=
1.6064
ceq=
1.6064-0.0000
f=
975.5551
c=
1.6687
c=
1.6687-3.0472
c=
1.6687-3.0472-3.8126
ceq=
1.6064
ceq=
1.60640.0000
f=
975.5551
c=
1.6687
c=
1.6687-3.0472
c=
1.6687-3.0472-3.8126
ceq=
1.6064
ceq=
1.60640.0000
f=
975.8815
c=
1.5793
c=
1.5793-3.1050
c=
1.5793-3.1050-3.5949
ceq=
0.0587
ceq=
0.0587-0.0000
f=
975.8815
c=
1.5793
c=
1.5793-3.1050
c=
1.5793-3.1050-3.5949
ceq=
0.0587
ceq=
0.0587-0.0000
f=
975.8815
c=
1.5793
c=
1.5793-3.1050
c=
1.5793-3.1050-3.5949
ceq=
0.0587
ceq=
0.05870.0000
f=
975.8815
c=
1.5793
c=
1.5793-3.1050
c=
1.5793-3.1050-3.5949
ceq=
0.0587
ceq=
0.05870.0000
f=
975.8924
c=
1.5758
c=
1.5758-3.1073
c=
1.5758-3.1073-3.5863
ceq=
9.1415e-005
ceq=
1.0e-004*
0.9142-0.0000
f=
975.8924
c=
1.5758
c=
1.5758-3.1073
c=
1.5758-3.1073-3.5863
ceq=
9.1489e-005
ceq=
1.0e-004*
0.9149-0.0019
f=
975.8924
c=
1.5758
c=
1.5758-3.1073
c=
1.5758-3.1073-3.5863
ceq=
9.1703e-005
ceq=
1.0e-004*
0.91700.0065
f=
975.8924
c=
1.5758
c=
1.5758-3.1073
c=
1.5758-3.1073-3.5863
ceq=
9.1798e-005
ceq=
1.0e-004*
0.91800.0037
f=
975.8924
c=
1.5758
c=
1.5758-3.1073
c=
1.5758-3.1073-3.5863
ceq=
2.2183e-010
ceq=
1.0e-009*
0.2218-0.0022
f=
975.8924
c=
1.5758
c=
1.5758-3.1073
c=
1.5758-3.1073-3.5863
ceq=
7.4225e-008
ceq=
1.0e-006*
0.0742-0.1879
f=
975.8924
c=
1.5758
c=
1.5758-3.1073
c=
1.5758-3.1073-3.5863
ceq=
2.8797e-007
ceq=
1.0e-006*
0.28800.6482
f=
975.8924
c=
1.5758
c=
1.5758-3.1073
c=
1.5758-3.1073-3.5863
ceq=
3.8353e-007
ceq=
1.0e-006*
0.38350.3741
f=
975.8924
c=
1.5758
c=
1.5758-3.1073
c=
1.5758-3.1073-3.5863
ceq=
0
ceq=
00
f=
975.8924
c=
1.5758
c=
1.5758-3.1073
c=
1.5758-3.1073-3.5863
ceq=
1.1092e-010
ceq=
1.0e-009*
0.1109-0.0011
f=
975.8924
c=
1.5758
c=
1.5758-3.1073
c=
1.5758-3.1073-3.5863
ceq=
1.6637e-010
ceq=
1.0e-009*
0.1664-0.0016
f=
975.8924
c=
1.5758
c=
1.5758-3.1073
c=
1.5758-3.1073-3.5863
ceq=
1.9410e-010
ceq=
1.0e-009*
0.1941-0.0019
f=
975.8924
c=
1.5758
c=
1.5758-3.