bandpass 发表于 2008-3-12 16:06

fmincon为何没有迭代?

我的程序如下
clear;
PI2=3.1415926*2;
rad1=PI2*10^6;
fun='errortest(x(1), x(2), x(3), x(4), x(5), x(6))';
x0=;
lb=;
ub=;
=fmincon(fun, x0, [], [], [], [], lb, ub)

其中***************************************************errotest.m为:
function =errortest(C1, C2, C3, C4, C5, C6)
PI2=3.1415926*2;
rad1=PI2*10^6;
T=[-2.54, -3.54, -6.14, -7.14, -8.72, -13.22, -15.5, -18.2, -19.8];
   gain1=abs(H(C1, C2, C3, C4, C5, C6, 1*rad1)-T(1));
   gain2=abs(H(C1, C2, C3, C4, C5, C6, 2*rad1)-T(2));
   gain5=abs(H(C1, C2, C3, C4, C5, C6, 5*rad1)-T(3));
   gain7=abs(H(C1, C2, C3, C4, C5, C6, 7*rad1)-T(4));
   gain10=abs(H(C1, C2, C3, C4, C5, C6, 10*rad1)-T(5));
   gain20=abs(H(C1, C2, C3, C4, C5, C6, 20*rad1)-T(6));
   gain30=abs(H(C1, C2, C3, C4, C5, C6, 30*rad1)-T(7));
   gain40=abs(H(C1, C2, C3, C4, C5, C6, 40*rad1)-T(8));
   gain50=abs(H(C1, C2, C3, C4, C5, C6, 50*rad1)-T(9));
   errordB=10*gain1+8*gain2+6*gain5+5*gain7+4*gain10+3*gain20+2*gain30+gain40+gain50;


************************* H.m为
function =H(Z1, Z2, P1, P2, P3, P4, S)
gain=((1+j*(S/Z1))*(1+j*(S/Z2)))/((1+j*(S/P1))*(1+j*(S/P2))*(1+j*(S/P3))*(1+j*(S/P4)));
gaindb=dB(gain);



运算结果如下:
>> optimize_new
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 260
In optimize_new at 20
Optimization terminated: Magnitude of directional derivative in search
direction less than 2*options.TolFun and maximum constraint violation
is less than options.TolCon.
No active inequalities

x =

1.0e+008 *

    0.0785    0.1885    0.0440    0.2827    0.3644    4.3982


fval =

   23.5707


exitflag =

   5


output =

       iterations: 1
      funcCount: 15
         stepsize: 1
      algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'
    firstorderopt: 4.1684e-006
   cgiterations: []
          message:


为什么没有迭代呢? 请赐教,非常感谢。

bandpass 发表于 2008-3-12 16:50

改了一下
clear;
PI2=3.1415926*2;
rad1=PI2*10^6;
options = optimset('TolFun',1e-3);
options=optimset('largescale','off');
ff=optimset;
ff.LargeScale='off';
fun='errortest(x(1), x(2), x(3), x(4), x(5), x(6))';
x0=;
lb=;
ub=;
=fmincon(fun, x0, [], [], [], [], lb, ub,[],ff)

错误提示少了:
Optimization terminated: Magnitude of directional derivative in search
direction less than 2*options.TolFun and maximum constraint violation
is less than options.TolCon.
No active inequalities
x =
1.0e+008 *
    0.0785    0.1885    0.0440    0.2827    0.3644    4.3982

fval =
   23.5707

exitflag =
   5

output =
       iterations: 1
      funcCount: 15
         stepsize: 1
      algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'
    firstorderopt: 4.1684e-006
   cgiterations: []
          message:


但是仍然没有迭代,请赐教,谢谢。
页: [1]
查看完整版本: fmincon为何没有迭代?