我用优化工具箱怎么老是得到的x是和vub一样啊??
麻烦大家看一下,我用优化工具箱怎么老是得到的x是和vub一样啊??function=fun(x)
%x由
%x1是消声片的厚度,单位为m, x2是片间距(m), x3是片高(m), x4是有效片长(m), x5是片数
IL=35;
Q=18;
c=343;
% l=0.26=x4;
f1=10;
% h=0.095=x3;
f2=7000;
vel=8;
alfa=0.072;
bta=1;
kec=alfa+bta*x(4);
density=1.29;
dH=kec*density*vel*vel/2;
lmax=75;
f=x(4)*(x(1)+x(2))*(x(2)+x(3))*(1+Q/c*x(2)*x(3)*x(5))/2*IL*x(2)*x(2)*x(3);
g(1)=x(2)-756.8/f1;
g(2)=10.32/f2-x(1);
g(3)=Q/x(5)*x(2)*x(3)-sqrt(2*dH/kec*density);
g(4)=x(4)-(kec-alfa)/bta;
g(5)=60*log10(Q)-(lmax+13)-50*log10(x(5)*x(2)*x(3));
g(6)=0.4-x(2)/(x(1)+x(2));
g(7)=x(2)/(x(1)+x(2))-0.65;
运行程序:
clear,clc
x0=;
vlb=;
vub=;
x=constr('fun',x0,vlb,vub);
[ 本帖最后由 eight 于 2007-7-17 15:05 编辑 ] 你好象用的很老的Matlab版本.
用新的fmincon吧,很容易处理,看看help文件就能解决.
也可以搜索论坛,已经讨论过多次这种问题了.
麻烦大家看看,这个程序哪里错了??
functionf=confun2(x)l=0.26;
B=0.436;
f=x(1)*x(3)*l*B/(x(2)+x(3))
function=myfun2(x)
l=0.26;
B=0.436;
g(1)=15-1.25*2(x(1)+x(2))*l/(x(1)*x(2));
g(2)=18*x(2)*(3)/x(2)*x(3)*B-10;
g=;
c=[];
clear,clc
x0=;
% A=;
% b=;
% lb=;
% ub=;
% options=optimset('LargeScale','off','Display','iter');
x=fmincon('confun2',x0,[],[],[],[],[],[],'myfun2');
怎么运行出来以后,老是出错啊!!实在是找不到是哪里错了,望各位指教一二,不胜感激!!
错误是:
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 274
In runfun2 at 9
??? Error using ==> fmincon
FMINCON cannot continue because user supplied nonlinear constraint function
failed with the following error:
Error: File: D:\Program Files\MATLAB71\work\ad\myfun2.m Line: 5 Column: 15
Unbalanced or misused parentheses or brackets.
Error in ==> runfun2 at 9
x=fmincon('confun2',x0,[],[],[],[],[],[],'myfun2'); 1。confun2,myfun2写成两个m文件
2。每个文件结尾加“end”
不好意思,我还是有点不太明白您的意思!!
不好意思,我还是有点不太明白您的意思!!您的意思是这样的吗::functionf=confun2(x)
l=0.26;
B=0.436;
f=x(1)*x(3)*l*B/(x(2)+x(3))
end
function=myfun2(x)
l=0.26;
B=0.436;
g(1)=15-1.25*2(x(1)+x(2))*l/(x(1)*x(2));
g(2)=18*x(2)*(3)/x(2)*x(3)*B-10;
g=;
c=[];
end
clear,clc
x0=;
% A=;
% b=;
% lb=;
% ub=;
% options=optimset('LargeScale','off','Display','iter');
x=fmincon('confun2',x0,[],[],[],[],[],[],'myfun2');
您好!!
g(1)=15-1.25*2(x(1)+x(2))*l/(x(1)*x(2));少了一个乘号,
可是改完了之后,
clear,clc
x0=;
A=;
b=;
lb=;
ub=;
options=optimset('LargeScale','off','Display','iter');
x=fmincon('confun2',x0,A,b,[],[],lb,ub,'myfun2',options);
又出现如下的错误:
max Directional First-order
Iter F-count f(x) constraint Step-size derivative optimality Procedure
0 4 0.0068016 0
1 8 0.00517865 0 1 -0.00124 0.144
2 12 0.00517864 0 1 -1.17e-008 0.263Hessian modified twice
Optimization terminated: magnitude of search direction less than 2*options.TolX
and maximum constraint violation is less than options.TolCon.
Active inequalities (to within options.TolCon = 1e-006):
lower upper ineqlin ineqnonlin
1
3
请问:现在的这个要怎么改正呢??
如何才能Active inequalities (to within options.TolCon = 1e-006):
谢谢了 这次语法正确,但是叠代可能不收敛,或者根本无解。
自己定性判断一下方程,特别是将方程进一步简化看看感觉如何
页:
[1]