Solver stopped prematurely. fmincon stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 3000 (the default value).
Mostra commenti meno recenti
Hi, I am doing an optimisation problem, below shows mine non-linear constraints file
function [c,ceq] = nonlcon(x)
%Inequality constraints
%Viscosity
c(1)= 2-((exp(exp(((x(1)*17.1183+x(2)*8.3177+x(3)*18.2414+x(4)*14.2502)-10.975)/14.534)))-0.8);
c(2)= ((exp(exp(((x(1)*17.1183+x(2)*8.3177+x(3)*18.2414+x(4)*14.2502)-10.975)/14.534)))-0.8)-4.5;
c(3)= 2-((exp(exp(((x(5)*17.1183+x(6)*8.3177+x(7)*18.2414+x(8)*14.2502)-10.975)/14.534)))-0.8);
c(4)= ((exp(exp(((x(5)*17.1183+x(6)*8.3177+x(7)*18.2414+x(8)*14.2502)-10.975)/14.534)))-0.8)-4.5;
c(5)= 2-((exp(exp(((x(9)*17.1183+x(10)*8.3177+x(11)*18.2414+x(12)*14.2502)-10.975)/14.534)))-0.8);
c(6)= ((exp(exp(((x(9)*17.1183+x(10)*8.3177+x(11)*18.2414+x(12)*14.2502)-10.975)/14.534)))-0.8)-4.5;
c(7)= 2-((exp(exp(((x(13)*17.1183+x(14)*8.3177+x(15)*18.2414+x(16)*14.2502)-10.975)/14.534)))-0.8);
c(8)= ((exp(exp(((x(13)*17.1183+x(14)*8.3177+x(15)*18.2414+x(16)*14.2502)-10.975)/14.534)))-0.8)-4.5;
%Flash point
c(9) = 55-((2414/(log10(x(1)*306.0038+x(2)*81.8731+x(3)*154.7322+x(4)*216.3022)+6.1188))+(42.6+273.15));
c(10)= 55-((2414/(log10(x(5)*306.0038+x(6)*81.8731+x(7)*154.7322+x(8)*216.3022)+6.1188))+(42.6+273.15));
c(11)= 55-((2414/(log10(x(9)*306.0038+x(10)*81.8731+x(11)*154.7322+x(12)*216.3022)+6.1188))+(42.6+273.15));
c(12)= 55-((2414/(log10(x(13)*306.0038+x(14)*81.8731+x(15)*154.7322+x(16)*216.3022)+6.1188))+(42.6+273.15));
%equality constraints
%CFPP
ceq(1)= ((((x(1) *1.03)*(464.67^13.45)+(x(2) *1.03)*(477.27^13.45)+(x(3) *1.03)*(464.67^13.45)+(x(4) *1.03)*(498.87^13.45))^(1/13.45))-491.67)*(5/9);
ceq(2)= ((((x(5) *1.03)*(464.67^13.45)+(x(6) *1.03)*(477.27^13.45)+(x(7) *1.03)*(464.67^13.45)+(x(8) *1.03)*(498.87^13.45))^(1/13.45))-491.67)*(5/9)+5;
ceq(3)= ((((x(9) *1.03)*(464.67^13.45)+(x(10)*1.03)*(477.27^13.45)+(x(11)*1.03)*(464.67^13.45)+(x(12)*1.03)*(498.87^13.45))^(1/13.45))-491.67)*(5/9)+10;
ceq(4)= ((((x(13)*1.03)*(464.67^13.45)+(x(14)*1.03)*(477.27^13.45)+(x(15)*1.03)*(464.67^13.45)+(x(16)*1.03)*(498.87^13.45))^(1/13.45))-491.67)*(5/9)+15;
end
Here is my script to run the optimisation
p1=500 ; p2=900 ; p3=1150 ; p4=2150;
d11=1270; d21=1290; d31=1320; d41=1330;
s1=24 ; s2=20 ; s3=36 ; s4=34;
profit=@(x)-(p1*d11+p2*d21+p3*d31+p4*d41)+((x(1)*3627.3418 + x(5)*6529.2152 + x(9) *8342.8862 + x(13)*15597.5698)*s1+(x(2)*3674.3841 + x(6)*6613.8914 + x(10)*8451.0834 + x(14)*15799.8517)*s2+(x(3)*3794.9865 + x(7)*6830.9758 + x(11)*8728.4691 + x(15)*16318.4422)*s3+(x(4)*3853.1063 + x(8)*6935.5913 + x(12)*8862.1445 + x(16)*16568.3571)*s4);
a1=-68 ;a2=-34 ;a3=-73 ; a4=-73;
b1=12 ;b2=8 ;b3=2 ;b4=8;
c1=-0.867 ;c2=-0.8559 ;c3=-0.8287 ;c4=-0.8162;
d1=0.867 ;d2=0.8559 ;d3=0.8287 ;d4=0.8162;
e1=0.003 ;e2=0.1 ;e3=0.01 ;e4=0.008;
f1=9 ;f2=13 ;f3=4 ;f4=2;
g1=3627.3418 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 0 0 f1 f2 f3 f4 0 0 0 0 ;
0 0 0 0 0 0 0 0 0 0 0 0 f1 f2 f3 f4;
g1 0 0 0 h1 0 0 0 i1 0 0 0 j1 0 0 0 ;
0 g2 0 0 0 h2 0 0 0 i2 0 0 0 j2 0 0 ;
0 0 g3 0 0 0 h3 0 0 0 i3 0 0 0 j3 0 ;
0 0 0 g4 0 0 0 h4 0 0 0 i4 0 0 0 j4;];
a11= -46; a12= 10; a13= -0.82; a14= 0.86; a15= 0.01; a16= 11; a17= 10882.0254; a18= 8818.5218; a19= 9866.9650; a20= 6164.9701;
b= [a11; a11; a11; a11;
a12; a12; a12; a12;
a13; a13; a13; a13;
a14; a14; a14; a14;
a15; a15; a15; a15;
a16; a16; a16; a16;
a17; a18; a19; a20;];
Aeq=[];
beq=[];
x0 =[0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25];
lb = 0.0* ones(16);
ub = 1.0* ones(16);
nonlicon = @nonlcon;
x = fmincon(profit,x0,A,b,Aeq,beq,lb,ub,nonlicon)
After running, i get the error below,
Solver stopped prematurely.
fmincon stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 3000 (the default value).
x = 0.0113 0.2012 0.1928 0.5727 0.0079 0.1961 0.4312 0.3396 0.0057 0.1919 0.6290 0.1455 0.6887 0.2063 0.0429 0.0000
I tried adding the line below just before my fmincon (not sure if this is the way), but the same error occured.
options = optimoptions(@fmincon,'MaxFunctionEvaluations',10000)
Could anyone help me on this? Also, I would love to hear how i could my make code more concise (espeically when defining A and b).
Thank you in advance!
Risposte (0)
Categorie
Scopri di più su Solver Outputs and Iterative Display in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!