MATLAB: Fmincon error. Converged to an infeasible point.

fmincon

The attachment is a matlab code which tries to do some optimization work.
However, the errors has occurred as below,
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>
Optimization stopped because the relative changes in all elements of x are
less than options.StepTolerance = 1.000000e-10, but the relative maximum constraint
violation, 1.000000e+00, exceeds options.ConstraintTolerance = 1.000000e-06.
I wonder how to fix this problem? or any other tools rather than fmincon are better to do this work?
thanks a lot!

Best Answer

First, you need to fix
R_max = -(sum(log(1 + Sp.* Pn./(Ne * Pn + Ni)))/Nx);
You will not get far with the / you have instead of the ./ that is needed.
You have a nonlinear equality function on a function of one variable. That equality does not involve any periodic functions such as sin() or mod(), so there is only a single value that can satisfy it, with Mu approximately 38915.2378117378 . However, that Mu cannot satisfy the nonlinear inequalities -- not even one of them, with several generating imaginary quantities when evaluated at a Mu that small.
If you remove that nonlinear equality constraint, there are solutions, starting from Mu approximately 5.3118761000*10^29 and upwards. You can turn the nonlinear inequalities into a series of 12 nonlinear equalities in 12 auxillary variables that represent how far below zero the nonlinear equalities fall -- f(mu)<=0 implies that f(mu)+e1==0 for some e1>=0, and you can find all of those +e1 and so on in terms of the last of them, e12, and solve, and for consistency you get that Mu must be at least as large as indicated above. The inequality most difficult to meet is the second of them.
I mentioned that the solutions for Mu for consistency with the nonlinear inequality constraints are in terms of the last term, e12. If you plug the formula for Mu in terms of e12 in to the formula for your function, then the result becomes sensitive to the value of e12 (that is, how thoroughly the final nonlinear inequality constraint is satisfied) with Mu increasing nonlinear as e12 increases. The question then becomes where the minima is. It turns out that the minima is when that constraint is infinitely satisfied, leading to an Mu that approaches infinity -- but because of the nonlinearities involved, the value of your function converges rather than diverges. That limiting value for fun, the optimal value, turns out to be
1/6*ln(3)+59/4*ln(2)-1/12*ln(14951361409684971)-1/12*ln(29467178056621089)-1/12*ln(24745298028860029)-1/12*ln(6234758412181391)-1/12*ln(265041706657033951)-1/12*ln(1128198769269787)-1/12*ln(4435842765245791)-1/12*ln(2070669736288154101)-1/12*ln(2070858867286043903)+1/6*ln(167825241552489)-1/12*ln(4128697361830650491)+1/4*ln(55941747184163)-1/12*ln(7482750699096129)+7/12*ln(503475724657467)-1/12*ln(319115652281190400168446314927418388116883567)
which is about -0.3334464096013027 as Mu approaches infinity
This all presumes you discard the nonlinear equality constraint. With the nonlinear equality constraint in place, you can solve for the one variable and then test to see if the nonlinear inequalities are satisfied (which they will not be.)