求助: fmincon的参数问题
t=2.3263;k=0.5244;
R=0.15;
u=';
E=;
E=E/10000;
c=0.0075;
options = optimset('Algorithm','active-set'); % run active-set algorithm
aeq=;
beq=1;
lb=';
ub=';
x0=';
= fmincon(@(x) myfun( x,t,E,u,c),x0,[],[],aeq,beq,lb,ub,@(x) mycon( x,t,k,E,u,c,R),options)
function f = myfun( x,t,E,u,c ) %目标函数
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
f=t*sqrt(x'*E*x)-(u'-c)*x;
end
function = mycon( x,t,k,E,u,c,R ) %非线性约束
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
C=t*k*sqrt(x'*E*x)/(t-k)-t*(u'-c)*x/(t-k)+t*R/(t-k);
Ceq=[];
end
运行结果:
Solver stopped prematurely.
fmincon stopped because it exceeded the function evaluation limit,
options.MaxFunEvals = 500 (the default value).
x =
-0.0175
0.4875
-0.0175
0.3074
0.2328
fval =
-0.0390
exitflag =
0
output =
iterations: 51
funcCount: 505
lssteplength: 0.1250
stepsize: 0.0812
algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'
firstorderopt: 2.4732
constrviolation: 0.0509
message:
各位大虾,程序如上所述,为什么函数提前就结束了,是不是要改默认参数设置,小弟也试过,但是捣鼓不出来,希望各位高人不吝赐教,小弟先拜谢了 Orz 难哦。。。。。。。。。。。。。。。。。研究研究。。。。。。。。。。。 难哦。。。。。。。。。。。。。。。。。研究研究。。。。。。。。。。。 不会啊,帮不上》》》》》》》》》》》》》》》》》》》》》》》》》》》》 回复 3# zfq12
我也试过把lb,ub上下界去掉,结果程序跑了一个上午都还在busy。。。不知何故啊 我把maxfunevals 改为1000000,maxiter改为100000,仍是过早结束 不错不错,值得学习啊!
页:
[1]