看天的男人
2011-04-29, 16:55
我建立的数学模型有六个变量,分别为x1-x6,
优化得到的结果一次为:
x= 2.0000
3.5000
19.1566
17.1106
6.4325
0.9900
favl=565.2628,
目标函数为:
y=(x(1)*x(3)*(1+x(5))+x(2)*x(4)*(1+31.5/x(5)))/(2*cos(x(6)));
现在问题来了,把上面所得x1-x6的优化结果带入目标函数,结果不等于fval所给的结果啊!!这是怎么回事??
另附我的程序
目标函数
function y=objfun(x)
y=(x(1)*x(3)*(1+x(5))+x(2)*x(4)*(1+31.5/x(5)))/(2*cos(x(6)))
约束条件
function [C,Ceq]=confun(x)
C(1)=-3.079*10^(-6)*x(1)^3*x(3)^3*x(5)+cos(x(6))^3;
C(2)=-1.701*10^(-4)*x(2)^3*x(4)^3+x(5)^2*cos(x(6))^2;
C(3)=-9.939*10^(-5)*(1+x(5))*x(1)^3*x(3)^3+cos(x(6))^2;
C(4)=-1.706*10^(-4)*(31.5+x(5))*x(2)^3*x(4)^2+x(5)^2*cos(x(6))^2;
C(5)=x(5)*(2*(x(1)+50)*cos(x(6))^2+x(1)*x(3)*x(5))-x(2)*x(4)*(31.5+x(5));
Ceq=0
主函数
A=[];b=[]; Aeq=[]; beq=[];
lb=[2;3.5;14;16;5.8;0.96];
x0=[3;5;19;17;6.3;0.96];
ub=[5;6;22;22;7;0.99];
options = optimset('LargeScale','on');
[x,fval,exitflag,output]=fmincon('objfun',x0,A,b,Aeq,beq,lb,ub,'confun',options);
x
fval
还有运行完程序,会出现以下警告
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
Optimization completed: The first-order optimality measure, 2.842171e-014, is less
than options.TolFun = 1.000000e-006, and the maximum constraint violation, 0.000000e+000,
is less than options.TolCon = 1.000000e-006.
Optimization Metric Options
first-order optimality = 2.84e-014 TolFun = 1e-006 (default)
max(constraint violation) = 0.00e+000 TolCon = 1e-006 (default)
知道的请告诉我,谢谢,!!在线求教
优化得到的结果一次为:
x= 2.0000
3.5000
19.1566
17.1106
6.4325
0.9900
favl=565.2628,
目标函数为:
y=(x(1)*x(3)*(1+x(5))+x(2)*x(4)*(1+31.5/x(5)))/(2*cos(x(6)));
现在问题来了,把上面所得x1-x6的优化结果带入目标函数,结果不等于fval所给的结果啊!!这是怎么回事??
另附我的程序
目标函数
function y=objfun(x)
y=(x(1)*x(3)*(1+x(5))+x(2)*x(4)*(1+31.5/x(5)))/(2*cos(x(6)))
约束条件
function [C,Ceq]=confun(x)
C(1)=-3.079*10^(-6)*x(1)^3*x(3)^3*x(5)+cos(x(6))^3;
C(2)=-1.701*10^(-4)*x(2)^3*x(4)^3+x(5)^2*cos(x(6))^2;
C(3)=-9.939*10^(-5)*(1+x(5))*x(1)^3*x(3)^3+cos(x(6))^2;
C(4)=-1.706*10^(-4)*(31.5+x(5))*x(2)^3*x(4)^2+x(5)^2*cos(x(6))^2;
C(5)=x(5)*(2*(x(1)+50)*cos(x(6))^2+x(1)*x(3)*x(5))-x(2)*x(4)*(31.5+x(5));
Ceq=0
主函数
A=[];b=[]; Aeq=[]; beq=[];
lb=[2;3.5;14;16;5.8;0.96];
x0=[3;5;19;17;6.3;0.96];
ub=[5;6;22;22;7;0.99];
options = optimset('LargeScale','on');
[x,fval,exitflag,output]=fmincon('objfun',x0,A,b,Aeq,beq,lb,ub,'confun',options);
x
fval
还有运行完程序,会出现以下警告
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
Optimization completed: The first-order optimality measure, 2.842171e-014, is less
than options.TolFun = 1.000000e-006, and the maximum constraint violation, 0.000000e+000,
is less than options.TolCon = 1.000000e-006.
Optimization Metric Options
first-order optimality = 2.84e-014 TolFun = 1e-006 (default)
max(constraint violation) = 0.00e+000 TolCon = 1e-006 (default)
知道的请告诉我,谢谢,!!在线求教