fmincon - Converged to an infeasible point.

9 views (last 30 days)
Prathamesh Toraskar
Prathamesh Toraskar on 16 Nov 2020
Edited: Matt J on 16 Nov 2020
Hello, I am trying to use fmincon in its most basic way. I have an objective function which I have to minimise whilst calculating 3 respective values for Tsk, Bst and Tst which satisfy some constraints. However, when I run my code, I get the error -
Converged to an infeasible point.
fmincon stopped because the size of the current step is less than
the value of the step size tolerance but constraints are not
satisfied to within the value of the constraint tolerance.
<stopping criteria details>
I am 100% sure that there is an optimum answer for my question, so there has to be a problem in the code. Can anyone please help me with it?
Thanks.
Tsk = 3;
Bst = 45;
Tst = 2;
x0 = [Tsk,Bst,Tst];
options = optimset('Display','iter','PlotFcns',@optimplotfval);
[xopt,fval,exitflag,output] = fmincon(@objective,x0,[],[],[],[],[],[],@constraint,options);
function Nsk = calcNsk (x)
Tsk = x(1);
Bst = x(2);
Tst = x(3);
Esk = 71.5;
Est = 87.75;
Bskclosed = 35+2*Bst;
Bskopen = 180-Bskclosed;
Bsk1 = 180;
Et1 = (Esk*Tsk);
Et2 = Est*Tst;
Et3 = ((70+(3*Bst))/Bsk1);
Et = Et1+(Et2*Et3);
Nsk = Et * 2.23 * ((Tsk/max([Bskclosed,Bskopen])).^2);
end
function Nst = calcNst (x)
Tsk = x(1);
Bst = x(2);
Tst = x(3);
Esk = 71.5;
Est = 87.75;
Bskclosed = 35+2*Bst;
Bskopen = 180-Bskclosed;
Bsk = max([Bskclosed,Bskopen]);
Et1 = (Esk*Tsk);
Et2 = Est*Tst;
Et3 = ((70+(3*Bst))/Bsk);
Et = Et1+(Et2*Et3);
Nst = Et * 1.65 * ((Tst/Bst) ^ 2);
end
function NxMat = calcNxMat (x)
Tsk = x(1);
Bst = x(2);
Tst = x(3);
Esk = 71.5;
Est = 87.75;
Bsk1 = 180;
Et1 = (Esk*Tsk);
Et2 = Est*Tst;
Et3 = ((70+(3*Bst))/Bsk1);
Et = Et1+(Et2*Et3);
NxMat = Et*0.0045;
end
function Nx_e = calcNx_e (x)
t_sk = x(1);
b_st = x(2);
t_st = x(3);
E_sk = 71.5;
E_st = 87.75;
b_sk = 180;
z1 = (70*t_st*((t_st+t_sk)/2));
z2= (((sqrt(3)*b_st)/2)+(t_sk+t_st))*b_st*t_st ;
z3 = (((sqrt(3)*b_st)/2)+((t_sk+t_st)/2))*b_st*t_st;
znum = E_st*(z1 + z2 + z3);
zden = (E_sk*t_sk*b_sk) + (E_st*t_st * ((3*b_st) + 70));
z = znum/zden;
z_w = ((sqrt(3))*b_st)/4 + ((t_sk+t_st)/2) - z;
EI_w = (E_st*t_st*(b_st^3))/16;
EI1 = ((E_sk*b_sk*t_sk*(z^2))+(E_sk*((t_sk^3)/12)*b_sk));
EI2 = ((E_st*70*t_st)*((z-((t_sk+t_st)/2))^2)) + ((70*E_st*((t_st)^3))/12);
EI3 = (2*EI_w) + (2*E_st*b_st*t_st*(z_w^2));
EI4 = (E_st*b_st*t_st*(((sqrt(3)/2)*b_st)+((t_sk+t_st)/2)-z)^2) + (E_st*b_st*((t_st^3)/12));
EI = EI1+EI2+EI3+EI4;
Nx_e = ((pi^2)*EI)/(b_sk*(800^2));
end
function obj = objective(x)
obj = (x(1)+(x(3)*((70+(3*x(2)))/180)))*10^-3*1600;
end
function [c, ceq] = constraint (x)
ceq1 = 1.978/calcNsk(x) - 1;
c1 = [];
ceq2 = 1.978/calcNst(x) - 1;
c2 = [];
ceq3 = 1.978/calcNxMat(x) - 1 ;
c3 = [] ;
ceq4 = 2.3844/calcNx_e(x) - 1;
c4 = [];
c = [c1; c2; c3; c4];
ceq = [ceq1; ceq2; ceq3; ceq4];
end

Answers (1)

Matt J
Matt J on 16 Nov 2020
Edited: Matt J on 16 Nov 2020
The max() operations in your constraints disqualify fmincon as a valid tool for this problem - the constraint functions are assumed by fmincon to be differentiable. Aside from that, calcNx_e (x) is a polynomial function, so so choosing an initial guess will be delicate. Your constraints will possibly have a number of disjoint regionsin R^3, and you would have to initialize in the correct one.
Because you only have 3 variables, I recommend you just do an exhaustive search on a grid of samples in x1,x2,x3. It should be quite easy to vectorize.
  2 Comments
Prathamesh Toraskar
Prathamesh Toraskar on 16 Nov 2020
Hi Matt, thank you so much for pointing out the problem. I am not sure how I will be able to run an exhaustive serach. It might be too much to ask, but would you be able to put something together for me to start?
I am pretty new to Matlab and I have wasted almost a week on the code above. I am running short on time and trying to start afresh is already freaking me out. No problem if not. Thanks again. :)
Matt J
Matt J on 16 Nov 2020
Edited: Matt J on 16 Nov 2020
As an example, if we ignore the constraints for a moment, we can evaluate your objective function on a 500x500x500 grid of samples between-10 and +10 in all 3 variables as below. We can then use min() to find the minimizing sample point. I urge you to get familiar with ndgrid here so that you can learn to use it more flexibly.
[X1,X2,X3]=ndgrid(linspace(-10,10,500));
Fvals=objective(X1,X2,X3);
idx=find(Fvals(:)==min(Fvals(:)),1);
[x1,x2,x3]=deal( X1(idx), X2(idx), X3(idx) ); %minimizing sample point
function obj = objective(x1,x2,x3)
obj = (x1+(x3.*((70+(3.*x2))/180))).*10^-3.*1600;
end
Notice that I've rewritten your objective function to perform vectorized matrix multiplications .* and so forth. You will have to do a similar kind of thing for your constraint functions.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!