优化设计实验报告
无约束非线性规划问题
minf(x)?x?x?x?1ex2532
?sin(?x)fun='(x^5+x^3+x^2-1)/(exp(x^2)+sin(-x))'; ezplot(fun,[-2,2]);
[xopt,fopt,exitflag,output]=fminbnd(fun,-2,2) 输出: xopt =
0.2176 fopt =
-1.1312 exitflag = 1
output =
iterations: 12
funcCount: 13
algorithm: 'golden section search, parabolic interpolation' message: [1x112 char]
二维无约束非线性函数最优解
22minf(X)?e1(4x1?2x2?4x1x2?2x2?1)
xfun='exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1)'; x0=[0,0];
options=optimset('largescale','off','display','iter','tolx',1e-8,'tolfun',1e-8);
[x,fval,exitflag,output,grad,hessian]=fminunc(fun,x0,options) f='exp(x)*(4*x^2+2*y^2+4*x*y+2*y+1)'; ezmesh(f);
First-order Iteration Func-count f(x) Step-size optimality
0 3 1 2 1 9 0.717044 0.125092 1.05 2 15 0.073904 10 1.28 3 21 0.000428524 0.430857 0.0746 4 24 0.000144084 1 0.0435 5 27 1.95236e-008 1 0.000487 6 30 6.63092e-010 1 9.82e-005 7 33 1.46436e-015 1 4.91e-008
Local minimum possible.
fminunc stopped because it cannot decrease the objective function along the current search direction.
Computing finite-difference Hessian using user-supplied objective function. x =
0.5000 -1.0000
fval =
1.4644e-015
exitflag = 5
output =
iterations: 8 funcCount: 36 stepsize: 1
firstorderopt: 4.9136e-008
algorithm: 'medium-scale: Quasi-Newton line search' message: [1x364 char] grad =
1.0e-007 *
-0.4914 -0.4914
hessian =
13.1946 6.5953
6.5953 6.5949
多目标线性规划问题
?maxf1(x)?100x1?90x2?80x3?70x4?minf2(x)?3x2?2x4???s.t.?x1?x2??30 ???x3?x4??30?3x?2x?12013???3x2?2x4?48已知设计变量和分目标的初值x0=[20,10,30,0],分目标的初始值f0=[10000,40],分目标的权重w=[1,2e-4]。 编写函数:
function [f]=fun_opt(x)
f(1)=-(100*x(1)+90*x(2)+80*x(3)+70*x(4)); f(2)=3*x(2)+2*x(4); 输入:、 A=[-1 -1 0 0; 0 0 -1 -1; 3 0 2 0;
0 3 0 2];
b=[-30 -30 120 80]; Aeq=[];beq=[];
lb=zeros(1,4);ub=[]; x0=[20,10,30,0]; f0=[10000,40];
w=[1 2e-4];
[xopt,fopt]=fgoalattain(@fun_opt,x0,f0,w,A,b,Aeq,beq,lb,ub) 输出:
Active inequalities (to within options.TolCon = 1e-006): lower upper ineqlin ineqnonlin 4 1 1 3 2
xopt =
17.7035 12.2965 33.4447 0
fopt =
1.0e+003 *
-5.5526 0.0369