MATLAB Answers

fmincon performance varies when reformulating interval constraint

8 views (last 30 days)
Sherwin Lee
Sherwin Lee on 22 Apr 2019
Commented: Sherwin Lee on 24 Apr 2019
I am using fmincon for a nonlinear program where one of the constraints restricts the decision variable x to periodic intervals as defined:
where , T is the periodicity, and is the length of the interval.
I thought an elegant way to write this constraint was to use modulo in the inequality constraint:
c = mod(x,T)-D*T;
But the solver either exceeds the max iterations or converges to an infeasible point - unless I choose the right starting point within a very narrow window only possible by inspection.
However, if I explicitly write out an interval as two inequality constraints:
c(1) = -x+T;
c(2) = x-(T+D*T);
Then it converges to a feasible local min. Obviously, this is a specific interval where I specify a particular k so I'd like to generalize the constraint for all
For a real basic example, if I choose , I have these constraints resulting in differing fmincon behavior:
c = mod(x,40)-20;
% versus
c(1) = -x+40;
c(2) = x-60;
My main question is why the solver behaves differently when the above constraints are mathematically equivalent? My only guess is that the interior point algo is sensitive to initial points. But for some reason, even if I start with , the former constraint results in infeasibility whereas the latter solves the problem.
Is there a way around this or perhaps reformulate the constraints as to not require an expensive loop?


Sign in to comment.

Accepted Answer

Alan Weiss
Alan Weiss on 22 Apr 2019
fmincon is a gradient-based solver, and as such does not work well with discontinuous functions. Locally, it attempts to minimize the objective function, while keeping the constraint function negative. If the constraint function jumps, well, fmincon gets confused and hunts around.
I would implement your constraint function as an appropriately shifted and scaled sinusoid, negative for the feasible points, positive for infeasible points. However, even such a smooth formulation will not necessarily give a good solution unless you give a starting point in the correct feasible interval. fmincon is a local solver, and does not look in other locations when it fails to converge to a solution starting from one point. For that, you might want to use MultiStart.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

  1 Comment

Sherwin Lee
Sherwin Lee on 24 Apr 2019
Thanks! Using the sinusoid was an excellent suggestion and it appears the solver now behaves much better given a proper start point.

Sign in to comment.

More Answers (0)

Sign in to answer this question.