On 7/19/2011 5:47 AM, Simon Preston wrote:
> Hi,
>
> I am having some difficulties with fmincon and wondered if somebody
> might be able to advise. I want to minimise an objective function
> objFunc w.r.t. variable theta, subject to the condition that some matrix
> function of theta, C(theta), is positive definite. I know that the
> feasible region contains a unique solution, and also that it includes
> the point theta0 = [0 0]. Sketched code for my objective function and
> constraint is as follows.
>
> % 
>
> function [out1, out2] = objFunc(theta,otherpars)
>
> C = calc_C(theta,otherpars);
> Cinv = inv(C);
> out1 = calc_K(Cinv,otherpars)  sum(theta);
>
> if nargout > 1
> out2 = calc_K1(Cinv,otherpars)  1;
> end
>
> % 
>
> function [c,ceq] = nonlcon(theta,otherpars)
> C = calc_C(theta,otherpars);
> c = min(eig(C)); % Nonlinear inequality at theta.
> ceq = []; % No nonlinear equalities at theta.
>
> % 
>
> For particular choices of “otherpars” I can use fminunc and the
> constraint doesn’t come into play, e.g. “thetaHat = fminunc(@(theta)
> objFunc(theta,otherpars), theta0);” returns
>
> Norm of Firstorder
> Iteration f(x) step optimality CGiterations
> 0 0 286 1 8.29312 0.0364222 128 1
> 2 14.0235 0.0560131 57.5 1
> ….
> 12 25.077 1.55671e06 1.62e12 1
> 13 25.077 1.90914e12 0 1
>
> Optimization completed: The firstorder optimality measure, 0.000000e+00,
> is less than the selected value of options.TolFun = 1.000000e14, and no
> negative/zero curvature is detected in the trustregion model.
>
> But when I try using fmincon instead, with the *same value of
> “otherpars”*, i.e. with the call “fmincon(@(theta)
> objFunc(theta,otherpars), theta0, [],[],[],[],[],[], @(theta)
> nonlcon(theta,otherpars));”, things blow up and the search seems to be
> exploring values of theta that don’t respect the contraint:
>
>
> Max Line search Directional Firstorder
> Iter Fcount f(x) constraint steplength derivative optimality Procedure
> 0 3 0 0.1 1 11 3.70977 23.39 0.0625 341 0.941 2 15 3.87583 22.88 1
> 0.63 0.941 3 19 442.068 0.001148 1 0.642 7.64e+05 Hessian modified 4
> 38 1123.75 0.0004496 3.05e05 7.36e+05 4.99e+06 …..........
> 13 345 280205 1.801e06 7.45e09 1.61e+11 3.11e+11 Hessian modified 14
> 372 424098 1.19e06 1.19e07 3.11e+11 7.13e+11 Hessian modified twice
> 15 401 925468 5.452e07 2.98e08 7.12e+11 3.4e+12 Hessian modified
> twice 16 432 2.93929e+07 1.716e08 7.45e09 3.39e+12 3.42e+15 Hessian
> modified
> …......
>
> To repeat: I am trying to use fmincon for a problem in which I know
> there is a unique solution in the feasible region, and in which I know
> the starting point lies inside the feasible region. fmincon seems to
> fail in circumstances where using fminunc (ignoring the constraint)
> finds the correct solution.
>
> Can anybody tell me what might be going wrong?
>
> S
There could be a few different things going on.
1. Your nonlinear constraint is not smooth. That can sometimes cause
fmincon to behave badly.
2. Your starting point might be touchy. Try one nearby, such as x0 +
.1*randn(size(x0))
3. Try using the fmincon interiorpoint algorithm, which is much more
robust than the activeset algorithm (the one you were using).
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
