声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 793|回复: 1

[综合讨论] fmincon为何没有迭代?

[复制链接]
发表于 2008-3-12 16:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
我的程序如下
clear;
PI2=3.1415926*2;
rad1=PI2*10^6;
  fun='errortest(x(1), x(2), x(3), x(4), x(5), x(6))';
  x0=[1.25*rad1,3*rad1,0.7*rad1,4.5*rad1,5.8*rad1,70*rad1];
  lb=[1*rad1 1*rad1 0.5*rad1 1*rad1 2*rad1  10*rad1];
  ub=[2*rad1 4*rad1 2*rad1   5*rad1 10*rad1 100*rad1];
  [x,fval, exitflag,output]=fmincon(fun, x0, [], [], [], [], lb, ub)

其中***************************************************errotest.m为:
function [errordB]=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 [gaindb]=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: [1x172 char]


为什么没有迭代呢? 请赐教,非常感谢。
回复
分享到:

使用道具 举报

 楼主| 发表于 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=[1.25*rad1,3*rad1,0.7*rad1,4.5*rad1,5.8*rad1,70*rad1];
  lb=[1*rad1 1*rad1 0.5*rad1 1*rad1 2*rad1  10*rad1];
  ub=[2*rad1 4*rad1 2*rad1   5*rad1 10*rad1 100*rad1];
  [x,fval, exitflag,output]=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: [1x172 char]


但是仍然没有迭代,请赐教,谢谢。
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-18 08:40 , Processed in 0.060050 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表