Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: fmincon troubles
Date: Tue, 19 Jul 2011 09:47:28 +0000 (UTC)
Organization: Univ of Nottingham
Lines: 62
Message-ID: <j03jrg$of6$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-06-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1311068848 25062 172.30.248.38 (19 Jul 2011 09:47:28 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 19 Jul 2011 09:47:28 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1072079
Xref: news.mathworks.com comp.soft-sys.matlab:736706

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      First-order
Iteration        f(x)          step          optimality   CG-iterations
    0                  0                           286                
    1           -8.29312      0.0364222            128           1
    2           -14.0235      0.0560131           57.5           1
                        ….
    12            -25.077    1.55671e-06       1.62e-12           1
    13            -25.077    1.90914e-12              0           1

Optimization completed: The first-order optimality measure, 0.000000e+00,
is less than the selected value of options.TolFun = 1.000000e-14, and no
negative/zero curvature is detected in the trust-region 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  First-order
Iter F-count        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.05e-05    -7.36e+05     4.99e+06   
                              …..........
  13    345      -280205    1.801e-06     7.45e-09    -1.61e+11     3.11e+11  Hessian modified  
  14    372      -424098     1.19e-06     1.19e-07    -3.11e+11     7.13e+11  Hessian modified twice  
  15    401      -925468    5.452e-07     2.98e-08    -7.12e+11      3.4e+12  Hessian modified twice  
  16    432 -2.93929e+07    1.716e-08     7.45e-09    -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