MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB混合编程] fmincon结果错误的问题 (https://www.labfans.com/bbs/showthread.php?t=7713)

china_ie 2009-04-15 15:39

fmincon结果错误的问题
 
1 个附件
一、问题描述:

单目标最小,多约束含非线性条件,由此知,利用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描述,带图片。


所有时间均为北京时间。现在的时间是 10:18

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.