Solver stopped prematurely. fmincon stopped because it exceeded the function evaluation limit,

35 次查看(过去 30 天)
genp=[0.00375 2 50 500 40 40;
0.0175 1.75 20 200 40 40;
0.0625 1 15 120 40 40;
0.00834 3.25 10 105 20 20;
0.025 3 10 100 20 20;
0.025 3 12 110 20 20;];
a=genp(:,1).*ones(6,24);
b=genp(:,2).*ones(6,24);
Pmin=genp(:,3).*ones(6,24);
Pmax=genp(:,4).*ones(6,24);
RU=genp(:,5).*ones(6,24);
RD=genp(:,6).*ones(6,24);
Demand=[510 530 516 510 515 544 646 686 741 734 748 760 754 700 686 720 714 761 727 714 618 584 578 544];
% Variables
p=optimvar('p',6,24,'lowerbound',0);
x0=zeros(6*24,1);
% Objective
opt=optimproblem;
opt.Objective=sum(sum(a.*p.*p)+sum(b.*p));
% Constraints
opt.Constraints.consmin=optimconstr(6,24);
opt.Constraints.consmax=optimconstr(6,24);
for g=1:6
for t=1:24
opt.Constraints.consmin(g,t)=p(g,t)<=Pmax(g,t);
opt.Constraints.consmax(g,t)=Pmin(g,t)<=p(g,t);
end
end
opt.Constraints.consL = optimconstr(24);
for t=1:24
opt.Constraints.consL(t)=sum(p(:,t))==Demand(t);
end
opt.Constraints.consRU = optimconstr(6,24);
opt.Constraints.consRD = optimconstr(6,24);
for g=1:6
for t=2:24
opt.Constraints.consRU(g,t)=p(g,t)-p(g,t-1)<=RU(g);
opt.Constraints.consRD(g,t)=p(g,t-1)-p(g,t)<=RD(g);
end
end
% Solve
problem=prob2struct(opt,'ObjectiveDerivative','finite-differences','Solver','fmincon');
problem.x0 = x0;
[sol,fval,exitflag,output] = fmincon(problem);
Solver stopped prematurely. fmincon stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 3.000000e+03.
% plot x variables
fval;
g=zeros(6,24);
for t=1:24
g(:,t)=sol(6*(t-1)+1:6*t);
end
plot(g');
f=figure(3);
plot(1:24,Demand,1:24,sum(g))
This is optimization for economic dispatch of 6 generators.
I got an error in [sol,fval,exitflag,output] = fmincon(problem);. How can i fix this?

回答(1 个)

Matt J
Matt J 2022-11-20
It's not an error. It's just telling you that it doesn't think it had a chance to run enough iterations. You can use optimoptions to raise the ceiling on MaxFunEvaluations and MaxIterations.
  2 个评论
Hkl
Hkl 2022-11-20
I doubled MaxFunEvaluations and MaxIterations by options = optimoptions('fmincon','MaxIterations',2000,'MaxFunctionEvaluations',6000).
But it still says options.MaxFunctionEvaluations = 3.000000e+03.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Problem-Based Optimization Setup 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by