t=2.3263; 5 i' S l9 b4 V Q6 B! h/ U7 Nk=0.5244;, V' o3 r, s" O+ R7 H8 X0 s
R=0.15;3 m+ \) }6 }1 D+ d, g. T3 G
u=[0.1221,0.1786,0.1452,0.1054,0.1132]';3 n" @( K/ J% X! J+ y8 H4 V
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]; 8 T* V2 |) C r( y! GE=E/10000; 3 O) ^9 v8 k; |- o( j& ac=0.0075; ' A7 ]1 I- F- l4 |options = optimset('Algorithm','active-set'); % run active-set algorithm * g3 B- t8 k4 f8 k* Qaeq=[1+c,1+c,1+c,1+c,1+c]; g/ o( ^/ B% z* [beq=1;$ x2 e7 e; C: v$ x" ^( x
lb=[0,0,0,0,0]'; Z1 A( T, t' p4 K$ b* p' G
ub=[1,1,1,1,1]';" w$ l2 o# B! ^% X* Z& Z5 h2 L
x0=[0.02,0.03,0.05,0.11,0.12]';6 L/ \4 |1 B, @9 E# _- `6 Y6 I+ j s, X
[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) x& H' i9 p9 l+ q3 f6 X 1 V, r% W. r1 h) a" z3 wfunction f = myfun( x,t,E,u,c ) %目标函数! h7 C3 g1 d; S6 e5 z6 P
%UNTITLED3 Summary of this function goes here/ g1 S% ~* N i! c- \
% Detailed explanation goes here , D% f* Y9 |1 E1 ef=t*sqrt(x'*E*x)-(u'-c)*x;7 c5 s D+ \/ j
end * E& l/ h8 Q' \; }6 s: H; w# V" X- u% }1 S& x8 X
function [C,Ceq] = mycon( x,t,k,E,u,c,R ) %非线性约束 - ~! w5 a3 _# p, I9 `%UNTITLED4 Summary of this function goes here+ D+ \# e) h2 L" j) B1 c; ^
% Detailed explanation goes here( d, v5 c: H6 R1 Q, Q
C=t*k*sqrt(x'*E*x)/(t-k)-t*(u'-c)*x/(t-k)+t*R/(t-k);5 M5 Y% Y6 |6 p( w3 v
Ceq=[]; 2 }( V1 [7 O- o0 H$ ]. |end2 C3 c6 H# Z( G; O4 g
0 V3 M, e m( G8 e s4 r9 W' l1 T/ `2 P( l" K& f+ Y
运行结果:: \) `0 U! R- T: P6 v
Solver stopped prematurely.' h" Z3 c# i- ]1 n
fmincon stopped because it exceeded the function evaluation limit,0 s; L# I# m: s9 s1 C. b
options.MaxFunEvals = 500 (the default value).1 @3 L# V# ~8 n) n; H
3 ]! I5 o" k- s. z; dx =' g: [7 f: }5 a9 Q A8 `) q( P
-0.0175 " Y f. u# d; a4 k8 Z 0.4875+ G$ ]( I! }! P# M4 x/ W; w" o
-0.0175 0 M: P% n" [; F' A0 P4 Z 0.30742 D( {6 e! c+ u- k+ f
0.2328 5 u( Y, h* W! ~" U" V" x* z! p/ [$ A2 T+ [7 y
fval = 6 Z9 z3 v& \ h# C2 @ -0.0390' u+ {! ]& d( c& p. z1 h, B( h