"sagar yellapu" <speak2sa
...@yahoo.in> wrote in message <k277c7$
...@newscl01ah.mathworks.com>...
> 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.
=================
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.