主题:[讨论]关于求解有约束非线性最优化问题
库函数:
function y=opt_fun1(x)
y=exp(x(1))*(4*x(1)* x(1)+2*x(2)*x(2)+4*x(1)*x(2)+2*x(2)+1)
function [c,ceq]=opt_con1(x)
ceq=[ ] c=[x(1)*x(1)-x(1)-x(2)+1.5;-x(1)*x(2)-10]
解:
x0=[-1;1]
LB=[0,0]
UB=[inf;inf]
A=[-1,1,-1;0,-1,0]
B=[0, 0]
AE=[ ]
BE=[ ]
[x, f_opt, c, d]=fmincon(@opt_fun1, x0,A, B, AE, BE, LB, UB,@opt_con1)
结果:
y =
5.0009
ceq =
[]
c =
0.4999
-10.0001
??? Error using ==> fmincon at 541
A has the wrong number of columns.
function y=opt_fun1(x)
y=exp(x(1))*(4*x(1)* x(1)+2*x(2)*x(2)+4*x(1)*x(2)+2*x(2)+1)
function [c,ceq]=opt_con1(x)
ceq=[ ] c=[x(1)*x(1)-x(1)-x(2)+1.5;-x(1)*x(2)-10]
解:
x0=[-1;1]
LB=[0,0]
UB=[inf;inf]
A=[-1,1,-1;0,-1,0]
B=[0, 0]
AE=[ ]
BE=[ ]
[x, f_opt, c, d]=fmincon(@opt_fun1, x0,A, B, AE, BE, LB, UB,@opt_con1)
结果:
y =
5.0009
ceq =
[]
c =
0.4999
-10.0001
??? Error using ==> fmincon at 541
A has the wrong number of columns.