Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

unable to minimize a function through fmincon.

18 views
Skip to first unread message

sagar yellapu

unread,
Sep 5, 2012, 5:52:07 AM9/5/12
to
Hello everyone,
I'm facing a problem with fmincon in making it minimize a function.
Please have a look at the problem I have.

minimization:
[d_sigmae,fval(k+1),exitflag]=fmincon('ipca_loglikelihood',d_sigmae0,[],[],[],[],LB,UB,@mycon,opts);

where function 'ipca_loglikelihood' is as follows:

function obj_fun=ipca_loglikelihood(t_diag_elements)
global cA resid
[n1,n2]=size(resid);
N=n2;
t_sigma_e=diag(t_diag_elements);
temp=cA*t_sigma_e*cA';
rsum=0;
for j=1:N
rsum=rsum+resid(:,j)'*((temp)^-1)*resid(:,j);
end
obj_fun=N*log(det(temp)) + rsum;

the 'obj_fun' is getting minimized over 'd_sigmae' of size 5*1. 'cA' is 3*5 matrix,'t_sigma_e' is 5*5 matrix, and an Inverse is computed for the 'temp' which is a composite matrix of the above two. size of 'resid' is 3*1000 and "N*log(det(temp))" is also there in the objective function.

The non-linear constraints are given by the function 'mycon' as follows:

function [c, ceq] = mycon(d_sigma_e)
global cA
sigma_e=diag(d_sigma_e);
ceq=cA*sigma_e*cA'-eye;
c=[];

If the problem is properly minimized, 'd_sigma_e' should turn out to be [0.1;0.08;0.15;0.2;0.18]

for getting this result even though i put bounds as LB=zeros(5,1) or any set of numbers less than the corresponding converged values, UB=1*ones(n,1) or any set of numbers which are just more than the corresponding converged values, the elements of 'd_sigma_e' are not turning out to be close to the solution and most of the elements are just close to either upper or lower bounds.

I am not knowing, what is wrong with the problem. I doubt the ability of fmincon for dealing with this kind of minimization problem, where there is an involvement of many matrices and inverses and logarithmic functions.
Can you suggest any other way of doing this.

I'm much grateful to the people that look into the problem.

awaiting for reply..
Thanks to all in advance.

Matt J

unread,
Sep 5, 2012, 6:58:07 AM9/5/12
to
"sagar yellapu" <speak...@yahoo.in> wrote in message <k277c7$b$1...@newscl01ah.mathworks.com>...
=================

Just a thought. If ipca_loglikelihood is the loglikelihood for your model, shouldn't you be maximizing it instead of minimizing it? Or equivalently, shouldn't you be multiplying its output by -1 before feeding it to FMINCON? If you were accidentally maximizing the thing you're trying to minimize, it would explain why the solution was pushed close to the boundaries.

Matt J

unread,
Sep 5, 2012, 10:07:08 AM9/5/12
to
"sagar yellapu" <speak...@yahoo.in> wrote in message <k277c7$b$1...@newscl01ah.mathworks.com>...
>
> The non-linear constraints are given by the function 'mycon' as follows:
>
> function [c, ceq] = mycon(d_sigma_e)
> global cA
> sigma_e=diag(d_sigma_e);
> ceq=cA*sigma_e*cA'-eye;
> c=[];
============

Another possible problem. I think ceq above should really be

ceq=cA*sigma_e*cA'-eye(3); %NOTE the eye(3)



> rsum=0;
> for j=1:N
> rsum=rsum+resid(:,j)'*((temp)^-1)*resid(:,j);
> end
=============

Incidentally also, a much better/faster way to compute rsum would be

A=resid*resid'; %precompute this
rsum=trace(A/temp);

Note that A can be precomputed (since your resid variable is constant) and is also a much smaller (3x3) matrix than resid.
0 new messages