how to write a constraint file for an optimization problem for which independent variable is a matrix?

1 view (last 30 days)
function j= costfunction(x,As)
% s1 reads .wav file recorded from first microphone at 16 kHz
[x1, Fs, bits_per_sample]=wavread('E:\speech matlab\X1_linear.wav');
% s2 reads .wav file recorded from second microphone at 16 kHz
[x2, Fs, bits_per_sample]=wavread('E:\speech matlab\X2_linear.wav');
L=length(x1);
m=[x1(1:2:L) x2(1:2:L)]';
for k=1:size(m,2)
Rx=(m(:,k)*m(:,k)');
%d=diag(Rx);
%e=Rx-[d(1,1) 0;0 d(2,1)];
e=Rx-x*As*x;
sum=0;
j=sum+(trace(e*e'))^2;
end
this is my objective function file in which x and As are 2x2 matrices. optimization has to be done with respect to x and i am passing As from command window using anonymous function. now i want to have diagonal elements of x(x11 and x22) equal to 1 as constraints. how can i do that? what if i want to optimize with respect to x and As both?
thanx in advance...

Accepted Answer

Matt J
Matt J on 22 Oct 2013
Edited: Matt J on 22 Oct 2013
now i want to have diagonal elements of x(x11 and x22) equal to 1 as constraints. how can i do that?
It doesn't make sense to "constrain" them to equal 1. If you already know they are equal to one, just don't consider them to be unknowns. Optimize over x13 and x31 only.
what if i want to optimize with respect to x and As both?
You must combine the elements of x and As into a single vector. If it helps to think of As as a matrix, you can extract and reshape it inside the objective function, e.g.,
function j= costfunction(unknowns)
x=ones(2);
x(1,3)=unknowns(1);
x(3,1)=unknowns(2);
As=reshape(unknowns(3:end),2,2);
...

More Answers (1)

Alan Weiss
Alan Weiss on 22 Oct 2013
There is a little bit of documentation on this subject. I don't know if it is enough to help you, but you might want to take a look.
Alan Weiss
MATLAB mathematical toolbox documentation

Community Treasure Hunt

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

Start Hunting!