The old Google Groups will be going away soon, but your browser is incompatible with the new version.
unable to minimize a function through fmincon.
 There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic. There was an error processing your request. Please try again. Standard view   View as tree
 3 messages

From:
To:
Cc:
Followup To:
Subject:
 Validation: For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon.

More options Sep 5 2012, 5:52 am
Newsgroups: comp.soft-sys.matlab
From: "sagar yellapu" <speak2sa...@yahoo.in>
Date: Wed, 5 Sep 2012 09:52:07 +0000 (UTC)
Local: Wed, Sep 5 2012 5:52 am
Subject: unable to minimize a function through fmincon.
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.

To post a message you must first join this group.
You do not have the permission required to post.
More options Sep 5 2012, 6:58 am
Newsgroups: comp.soft-sys.matlab
From: "Matt J " <mattjacREM...@THISieee.spam>
Date: Wed, 5 Sep 2012 10:58:07 +0000 (UTC)
Local: Wed, Sep 5 2012 6:58 am
Subject: Re: unable to minimize a function through fmincon.

=================

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.

To post a message you must first join this group.
You do not have the permission required to post.
More options Sep 5 2012, 10:07 am
Newsgroups: comp.soft-sys.matlab
From: "Matt J " <mattjacREM...@THISieee.spam>
Date: Wed, 5 Sep 2012 14:07:08 +0000 (UTC)
Local: Wed, Sep 5 2012 10:07 am
Subject: Re: unable to minimize a function through fmincon.
"sagar yellapu" <speak2sa...@yahoo.in> wrote in message <k277c7\$...@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.