Solver stopped prematurely. fmincon stopped because it exceeded the function evaluation limit,
35 views (last 30 days)
Show older comments
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);
% 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?
0 Comments
Answers (1)
Matt J
on 20 Nov 2022
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 Comments
See Also
Categories
Find more on Problem-Based Optimization Setup in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!