MATLAB 函数解优化问?- 百度文库 ر

fval =

5.4234e-031

exitflag =

1

2 minsearch

øʽ x=fminsearch(fun,x0) x=fminsearch(fun,x0,options) x=fminsearch(fun,x0,options,P1,P2) [x,fval]=fminsearch() [x,fval, exitflag]=fminsearch() [x,fval, exitflag,output]=fminsearch()

[x,fval, exitflag,output,grad]=fminsearch() [x,fval, exitflag,output,grad,hessian]=fminsearch()

˵رͬһϵ⣬fminsearchfminuncЧ

3 ԪС⣺

СѧģΪ

øʽ x=lsqnonlin(fun,x0) x=lsqnonlin(fun,x0,lb,ub)

x=lsqnonlin(fun,x0,options)

x=lsqnonlin(fun,x0,options,P1,P2)

[x,resnorm]=lsqnonlin()

[x,resnorm, residual,exitflag]=lsqnonlin()

[x,resnorm, residual , exitflag,output]=lsqnonlin()

[x,resnorm, residual,exitflag, output,lambda]=lsqnonlin()

[x,resnorm, r esidual,exitflag, output,lambda,jacobian]=lsqnonlin()

˵xؽresnormxвƽֵsum(fun(x).^2)residualxIJвֵfun(x)lambdaذxճӵĽṹjacobianؽxfunſɱȾ

lsqnonlinĬʱѡŻ㷨Lsqnonlinͨoptions.LargeScaleΪoffŻ㷨һά

4 minf=4(x2-x1)2+(x2-4)2 ѡʼx0(1,1)

f ='4*(x(2)-x(1))^2+(x(2)-4)^2' [x,reshorm]=lsqnonlin(f,[1,1]) x =

3.9896 3.9912

reshorm =

5.0037e-009

5

⣺ȱ༭ff5.mļ function f=ff5(x) k=1:10;

f=2+2*k-exp(k*x(1))-exp(k*x(2)); Ȼx0=[0.2,0.3];

[x,resnorm]=lsqnonlin(@ff5,x0)

ѡʼx0(0.2,0.3)

x =

0.2578 0.2578

resnorm =

124.3622

ԼԹ滮⣺

ѧģͣ min F(x)

s.t Gi (x) 0 i=1,,m Gj (x) =0 j=m+1,,n xlxxu

УF(x)ΪԪʵֵG(x)Ϊֵ

ԼԹ滮УͨҪתΪ򵥵⣬ЩΪ̵ĻK-T̽ķK-T̿ɱΪ

̵һĿ꺯Լڽ⴦ݶȵȡݶȡҪճӦiƽĿ꺯ԼݶȼСIJ졣

øʽ: x=fmincon(f,x0,A,b)

x=fmincon(f,x0,A,b,Aeq,beq) x=fmincon(f,x0,A,b,Aeq,beq,lb,ub) x=fmincon(f,x0,A,b,Aeq,beq,lb,ub,nonlcon) x=fmincon(f,x0,A,b,Aeq,beq,lb,ub,nonlcon,options) [x,fval]=fmincon()

[x, fval, exitflag]=fmincon() [x, fval, exitflag, output]=fmincon()

[x, fval, exitflag, output, lambda]=fmincon()

˵x=fmincon(f,x0,A,b)ֵxΪŽУx0Ϊʼ㡣A,bΪʽԼϵҶ

x=fmincon(f,x0,A,b,Aeq,beq) еʽԼ⡣ûвʽԼA=[ ]b=[ ]

x=fmincon(f, x0,A,b,Aeq,beq,lb,ub, nonlcon ,options) lb ,ubΪx½Ͻ磻nonlcon=@fun,Mļfun.mԲʽԼc (x) 0͵ʽԼg(x)=0optionsΪָŻС

6⣺min 100(x2-x12 )2+(1-x1)2 s.t x12;

x22

Ƚff6.mļ

function f=ff6(x)

f=100*(x(2)-x(2)^2)^2+(1-x(1))^2;

Ȼڹռ

x0=[1.1,1.1]; A=[1 0;0 1]; b=[2;2];

[x,fval]=fmincon(@ff6,x0,A,b) x = 1.0000 1.0000

fval =

3.1936e-011

7⣺