数学建模社区-数学中国

标题: 求助: fmincon的参数问题 [打印本页]

作者: 亚瑟王的冬瓜    时间: 2010-5-20 10:10
标题: 求助: fmincon的参数问题
t=2.3263;2 w8 n5 G1 b. ]1 R
k=0.5244;
! T! W6 K( I- U# b$ R) t% t9 XR=0.15;
- \* h3 W, F% G8 W$ f4 Nu=[0.1221,0.1786,0.1452,0.1054,0.1132]';! `& q, O: o! s* y4 h+ N) [
E=[1234,864,-617,-246,987;864,642,586,-198,-815;-617,586,1433,469,-963;-246,-198,469,346,25;987,-815,-963,25,1827];
* {* c9 v% v5 @( g* S' y0 E, O& a; OE=E/10000;7 Z* y/ r: }% ~8 Q6 M
c=0.0075;/ m" B1 G) w4 R
options = optimset('Algorithm','active-set'); % run active-set algorithm& b2 C; Z8 ~2 L
aeq=[1+c,1+c,1+c,1+c,1+c];
8 o& T% M- a. i( j' v! z) K) lbeq=1;
6 J& ]9 [+ ?/ Flb=[0,0,0,0,0]';
" h2 C) N) B9 \& oub=[1,1,1,1,1]';. e- u3 w: ?: H7 V4 M) ]2 q0 P
x0=[0.02,0.03,0.05,0.11,0.12]';
" P  \8 g( Y6 ^. a: w! I$ t4 O[x,fval,exitflag,output] = fmincon(@(x) myfun( x,t,E,u,c),x0,[],[],aeq,beq,lb,ub,@(x) mycon( x,t,k,E,u,c,R),options)
9 B6 u) ^$ `* @6 |1 R9 b( e
1 u  O6 `, }! n2 O; }, X+ Lfunction f = myfun( x,t,E,u,c )    %目标函数
5 [: j" b6 S9 y7 E%UNTITLED3 Summary of this function goes here
& j6 P2 |7 |0 a* l- t, ~%   Detailed explanation goes here1 p) u) a) d" G9 o" e/ l9 v. I4 s
f=t*sqrt(x'*E*x)-(u'-c)*x;
8 f8 k& G, @, Z+ N# ~( j6 T3 e9 M/ H8 pend
/ F- `2 K0 T& P- q2 R. z; Q2 T$ u( ~8 w6 _' \
function [C,Ceq] = mycon( x,t,k,E,u,c,R )  %非线性约束
" G+ [0 L8 R# o" O2 A%UNTITLED4 Summary of this function goes here
/ r; Y  [8 X2 x+ b# }3 u/ V%   Detailed explanation goes here
8 T- n8 E& V" M+ y( @( M/ FC=t*k*sqrt(x'*E*x)/(t-k)-t*(u'-c)*x/(t-k)+t*R/(t-k);' M8 K% `. ?  ]+ U- c
Ceq=[];
" d2 U4 a4 k0 ]; G2 \end1 Z! o7 `3 v5 ]9 }; `7 ]

3 Z% c" m5 d  \- i  b) h7 T. t( w6 q
- ?! ]3 ]: u; O! j# k6 s运行结果:
2 K5 _0 b0 R" F* J- sSolver stopped prematurely.' x  y/ V0 N5 l8 G& }
fmincon stopped because it exceeded the function evaluation limit,+ z( M9 o: b4 ]1 w
options.MaxFunEvals = 500 (the default value).
( G( G$ J3 l3 j" e4 n- G3 T2 E1 E  A1 U  g$ S% ^5 y0 B& {* K
x =  H! x8 }/ d1 m& Y% @$ ?* d
   -0.0175  J0 W. N& o3 J0 R# ~
    0.4875* z  r. i0 B( \$ f3 W
   -0.0175
% o0 O/ u5 I! N/ l+ Q* o3 I    0.30744 |. w8 T2 w* L9 j. e
    0.2328
0 f8 O4 U4 D. _
+ g4 u1 V' x* Hfval =
: ^$ y! P7 b: P   -0.0390* R8 s* p( [: {( j# X2 ?+ M; ]' p

9 ?5 B3 z4 v6 Gexitflag =
$ {$ ?3 ]8 T( ]* C! j4 E, [     0
4 U# G; y1 [( Z( p& p
$ [7 k' Z5 {+ u1 ?output =
9 V: }8 T( Y; B2 V         iterations: 51+ G! F; X4 N0 ~. _9 U
          funcCount: 505/ `5 M/ I8 [: }$ O% e, h
       lssteplength: 0.1250
* m) ]. h" M( ~; J, g, ]' L           stepsize: 0.0812. Y% X" C% l$ T! v8 S
          algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'
1 n- v/ M2 a# M- R+ J      firstorderopt: 2.4732
6 j# Q! B4 f5 Q, P( l/ f    constrviolation: 0.0509% P9 }' Y- G9 A
            message: [1x145 char]7 u, W7 g' g2 w' X9 M4 [
各位大虾,程序如上所述,为什么函数提前就结束了,是不是要改默认参数设置,小弟也试过,但是捣鼓不出来,希望各位高人不吝赐教,小弟先拜谢了  Orz
作者: zfq12    时间: 2010-5-20 17:38
难哦。。。。。。。。。。。。。。。。。研究研究。。。。。。。。。。。
作者: zfq12    时间: 2010-5-20 17:40
难哦。。。。。。。。。。。。。。。。。研究研究。。。。。。。。。。。
作者: zhangal    时间: 2010-5-20 17:49
不会啊,帮不上》》》》》》》》》》》》》》》》》》》》》》》》》》》》
作者: 亚瑟王的冬瓜    时间: 2010-5-20 20:13
回复 3# zfq12
3 E+ s0 }+ }2 [6 ^
# m2 b9 @/ C! R
- }3 s6 U- I+ G  }, `! p    我也试过把lb,ub上下界去掉,结果程序跑了一个上午都还在busy。。。不知何故啊
作者: 火箭发动机    时间: 2011-9-1 20:23
我把maxfunevals 改为1000000,maxiter改为100000,仍是过早结束
作者: alair002    时间: 2012-2-6 08:16
我是新手,所以学习一下,谢了!428456379797383
作者: 韩国福娃    时间: 2012-2-17 01:25
不错不错,值得学习啊!




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5