Solver stopped prematurely. fmincon stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 3.000000e+03. Unable to rectify this error. Please Help
Show older comments
F_r and T_r are defined.
[m n ]=size(F_r);
[M N]=size(T_r);
My constraints are lengthy but i have checked it is correct.
My code:
aeq=[];
beq=[];
a=[];
b=[];
lb=zeros(1,42);
for j=1:n+N
if(j<=n)
ub(j)=F_r(1);
else
ub(j)=tmax;
end
end
x0=[F_r T_r];
options.Display = 'iter';
[x,fval]=fmincon(@(x)objective2(x,n),x0,a,b,aeq,beq,lb,ub,@(x)constraint2(x,n,UA_r,F_r,T_r),options);
My objective Function:
function f=objective2(x,n)
f=-x(n+10);
end
My contraints:
%% Constraint
function [c,ceq]=constraint2(x,n,UA_r,F_r,T_r)
ceq(1)=x(2)+x(6)-x(1);
ceq(2)=x(3)-x(2);
ceq(3)=x(15)-x(14);
ceq(4)=x(4)-x(3);
ceq(5)=x(12)-x(11);
ceq(6)=x(5)-x(4);
ceq(7)=x(14)-x(13);
ceq(8)=x(10)-x(5)-x(9);
ceq(9)=x(7)-x(6);
ceq(10)=x(17)-x(16);
ceq(11)=x(8)-x(7);
ceq(12)=x(19)-x(18);
ceq(13)=x(9)-x(8);
ceq(14)=x(21)-x(20);
ceq(15)=x(6)*[0.444*(x(n+7)-x(n+6))+(0.00101/2)*(x(n+7)^2-x(n+6)^2)]-[x(16)*[0.409*(x(n+16)-x(n+17))+(0.00096/2)*(x(n+16)^2-x(n+17)^2)]];
ceq(16)=x(6)*[0.444*(x(n+7)-x(n+6))+(0.00101/2)*(x(n+7)^2-x(n+6)^2)]-[UA_r(4)*[(x(n+16)-x(n+7))-(x(n+17)-x(n+6))]/log((x(n+16)-x(n+7))/(x(n+17)-x(n+6)))];
ceq(17)=x(7)*[0.444*(x(n+8)-x(n+7))+(0.00101/2)*(x(n+8)^2-x(n+7)^2)]-[x(18)*[0.429*(x(n+18)-x(n+19))+(0.00099/2)*(x(n+18)^2-x(n+19)^2)]];
ceq(18)=x(7)*[0.444*(x(n+8)-x(n+7))+(0.00101/2)*(x(n+8)^2-x(n+7)^2)]-[UA_r(5)*[(x(n+18)-x(n+8))-(x(n+19)-x(n+7))]/log((x(n+18)-x(n+8))/(x(n+19)-x(n+7)))];
ceq(19)=x(8)*[0.444*(x(n+9)-x(n+8))+(0.00101/2)*(x(n+9)^2-x(n+8)^2)]-[x(20)*[0.414*(x(n+20)-x(n+21))+(0.00096/2)*(x(n+20)^2-x(n+21)^2)]];
ceq(20)=x(8)*[0.444*(x(n+9)-x(n+8))+(0.00101/2)*(x(n+9)^2-x(n+8)^2)]-[UA_r(5)*[(x(n+20)-x(n+9))-(x(n+21)-x(n+8))]/log((x(n+20)-x(n+9))/(x(n+21)-x(n+8)))];
ceq(21)=x(2)*[0.444*(x(n+3)-x(n+2))+(0.000101/2)*(x(n+3)^2-x(n+2)^2)]-x(14)*[0.414*(x(n+14)-x(n+15))+(0.00096/2)*(x(n+14)^2-x(n+15)^2)];
ceq(22)=x(2)*[0.444*(x(n+3)-x(n+2))+(0.000101/2)*(x(n+3)^2-x(n+2)^2)]-UA_r(1)*[((x(n+14)-x(n+3))-(x(n+15)-x(n+2)))/log((x(n+14)-x(n+3))/(x(n+15)-x(n+2)))];
ceq(23)=x(3)*[0.444*(x(n+4)-x(n+3))+(0.00101/2)*(x(n+4)^2-x(n+3)^2)]-UA_r(2)*[((x(n+11)-x(n+4))-(x(n+12)-x(n+3)))/log((x(n+11)-x(n+4))/(x(n+12)-x(n+3)))];
ceq(24)=x(3)*[0.444*(x(n+4)-x(n+3))+(0.00101/2)*(x(n+4)^2-x(n+3)^2)]-x(11)*[0.446*(x(n+11)-x(n+12))+(0.00101/2)*(x(n+11)^2-x(n+12)^2)];
ceq(25)=x(4)*[0.444*(x(n+5)-x(n+4))+(0.00101/2)*(x(n+5)^2-x(n+4)^2)]-x(13)*[0.414*(x(n+13)-x(n+14))+(0.00096/2)*(x(n+13)^2-x(n+14)^2)];
ceq(26)=x(4)*[0.444*(x(n+5)-x(n+4))+(0.00101/2)*(x(n+5)^2-x(n+4)^2)]-UA_r(3)*[((x(n+13)-x(n+5))-(x(n+14)-x(n+4)))/log((x(n+13)-x(n+5))/(x(n+14)-x(n+4)))];
ceq(27)=x(n+2)-x(n+1);
ceq(28)=x(n+6)-x(n+1);
ceq(29)=x(5)*[0.444*x(n+5)+(0.00101/2)*x(n+5)^2]+x(9)*[0.444*x(n+9)+(0.00101/2)*x(n+9)^2]-x(10)*[0.444*x(n+10)+(0.00101/2)*x(n+10)^2];
c(1)=x(n+6)-x(n+7);
c(2)=x(n+17)-x(n+16);
c(3)=10-x(n+16)+x(n+7);
c(4)=10-x(n+17)+x(n+6);
c(5)=x(n+7)-x(n+8);
c(6)=x(n+19)-x(n+18);
c(7)=10-x(n+18)+x(n+8);
c(8)=10-x(n+19)+x(n+7);
c(9)=x(n+8)-x(n+9);
c(10)=x(n+21)-x(n+20);
c(11)=10-x(n+20)+x(n+9);
c(12)=10-x(n+21)+x(n+8);
c(13)=x(n+2)-x(n+3);
c(14)=x(n+15)-x(n+14);
c(15)=10-x(n+14)+x(n+3);
c(16)=10-x(n+15)+x(n+2);
c(17)=x(n+3)-x(n+4);
c(18)=x(n+12)-x(n+11);
c(19)=10-x(n+11)+x(n+4);
c(20)=10-x(n+12)+x(n+3);
c(21)=x(n+4)-x(n+5);
c(22)=x(n+14)-x(n+13);
c(23)=10-x(n+13)+x(n+5);
c(24)=10-x(n+14)+x(n+4);
if(x(n+10)>x(n+5))
c(25)=x(n+10)-x(n+9);
else
c(26)=x(n+10)-x(n+5);
end
ceq(27)=x(13)-F_r(13);
ceq(28)=x(11)-F_r(11);
ceq(28)=x(16)-F_r(16);
ceq(30)=x(18)-F_r(18);
ceq(31)=x(1)-F_r(1);
ceq(32)=x(20)-F_r(20);
ceq(33)=x(n+1)-T_r(1);
ceq(34)=x(n+2)-T_r(2);
ceq(35)=x(n+6)-T_r(6);
ceq(36)=x(n+11)-T_r(11);
ceq(37)=x(n+13)-T_r(13);
ceq(38)=x(n+16)-T_r(16);
ceq(39)=x(n+18)-T_r(18);
ceq(40)=x(n+20)-T_r(20);
3 Comments
To rectify the error, increase "MaxFunctionEvaluations" in the options structure of "fmincon":
options = optimoptions(@fmincon,'MaxFunctionEvaluations',10000)
But I don't know if this solves the problem since you didn't supply executable code.
By the way: The square brackets in the definition of some ceq-elements produce errors. So don't use them.
Bjorn Gustavsson
on 12 Jul 2019
Couldn't you reduce the number or components in x - at least the first 14 ceq seems to be simple linear equalities. That might help a bit.
...and for any given value of n you only look for the smallest value of component x(n+10), so this might be a problem of only looking at the subspace where your constraints are satisfied, maybe linprog has a better algorithm for this problem.
HTH
Walter Roberson
on 12 Jul 2019
Edited: Walter Roberson
on 12 Jul 2019
Replaces https://www.mathworks.com/matlabcentral/answers/471209-fmincon-stopped-because-it-exceeded-the-function-evaluation-limit-options-maxfunctionevaluations which had a solution for your difficulty.
Answers (1)
Amna Mazen
on 22 Sep 2021
0 votes
If you changed the Step tolerance to a smaller number. Return it back to its default number. I think that was "1e-10" and your problem may be solved.
1 Comment
Walter Roberson
on 23 Sep 2021
The only option the user passed in was 'Display', 'iter', so the step tolerance was at the default value already. The user needed to increase MaxFunctionEvaluations
Categories
Find more on Solver Outputs and Iterative Display 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!