Constrained minimization problem : fmincon function

19 views (last 30 days)
Hi all,
I want to find a solution to this equation with adding some assumptions:
MATA * Xsol = MATd
where MATA is 1400x12 matrix , MATd is a vector with size 1400
and Xsol =(Xsol(1),Xsol(2),Xsol(3),Xsol(4),Xsol(5),Xsol(6),Xsol(7),Xsol(8),Xsol(9),Xsol(10),Xsol(11),Xsol(12))
I resolved this equation with pinv:
Xsol = pinv(MATAA)*MATd;
But I need some assumptions to add them to my solution. Which are :
dot([ Xsol(1) Xsol(4) Xsol(7)],[ Xsol(2) Xsol(5) Xsol(8)]) =0 ;
dot([ Xsol(1) Xsol(4) Xsol(7)],[ Xsol(3) Xsol(6) Xsol(9)]) =0 ;
dot([ Xsol(3) Xsol(6) Xsol(9)],[ Xsol(2) Xsol(5) Xsol(8)]) =0 ;
So I will use now the fmincon function to solve the constrained minimization problem. First step I get the starting guess with :
Xsol0 = pinv(MATAA)*MATd;
options = optimoptions(@fmincon,'Algorithm','sqp','MaxFunEvals', 3000 );
[Xsol,fval] = fmincon(@objfun,Xsol0,[],[],[],[],[],[],@confun,options);
I define confun.m for the nonlinear constraints.
function [c,ceq] = confun(Xsol)
c=[];
ceq(1)=dot([ Xsol(1) Xsol(4) Xsol(7)],[ Xsol(2) Xsol(5) Xsol(8)]) ;
ceq(2)=dot([ Xsol(1) Xsol(4) Xsol(7)],[ Xsol(3) Xsol(6) Xsol(9)]) ;
ceq(3)=dot([ Xsol(3) Xsol(6) Xsol(9)],[ Xsol(2) Xsol(5) Xsol(8)]);
end
But How can I define my objective function ?? to obtain Xsol with the assumptions ?
function f = objfun(Xsol)
????
?????
end
Any help please?

Answers (1)

Matt J
Matt J on 9 Jun 2016
Edited: Matt J on 9 Jun 2016
Why not a least squares objective as I suggested to you in your previous post on the subject
function fval=objfun(Xsol)
fval=norm( MATA * Xsol - MATd ).^2
end
In the original version of your problem, you are calculating a least squares solution, so why not use a least squares objective function here as well?

Categories

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!