登录论坛

查看完整版本 : [MATLAB混合编程] fmincon结果错误的问题


china_ie
2009-04-15, 15:39
一、问题描述:

单目标最小,多约束含非线性条件,由此知,利用fmincon可以解决该问题。
编写目标函数表达:myfun.m

function f=myfun(x)
f=0.00004717/(x(1)*x(2)+x(1)*x(3)+x(3))+0.059825+0.00595/(x(1)*x(5)+x(1)*2*sqrt(x(4)^2+(x(2)/2-x(5)/2)^2));

由于含有非线性等值约束,需要mycon1.m
function [c,ceq] = mycon1(x)
c =[];
ceq = x(1)*x(2)+x(1)*x(3)+x(3)-0.006;

编写主函数:hgxrun.m
function hgxrun
clc
lbM=[10 5e-5 5e-6 5e-5 0];
ubM=[300 1e-3 1e-3 1e-3 1e-3];
x0=[10 5e-4 8e-4 5e-4 5e-4];
[x,fval] = fmincon('myfun',x0,[0 -1 0 0 1],0,[],[],lbM,ubM,'mycon1')

结果为:
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
Optimization terminated: first-order optimality measure less
than options.TolFun and maximum constraint violation is less
than options.TolCon.
Active inequalities (to within options.TolCon = 1e-006):

lower
upper
ineqlin
ineqnonlin

2
4
1
3


x =
109.0000
0.0001
0.0000
0.0010
0.0001

fval =
0.0943

从结果可以看出:x(3)=0,和条件不吻合。所以结果是错误的。
从第一个等式条件计算一下,也可以看出结果是错误的。

请各位帮忙,分析一下原因.
附件内位word描述,带图片。