## Minimising a matrix function subject to an equality constraint

Harris Mirza

### Harris Mirza (view profile)

さんによって質問されました 2019 年 2 月 5 日

### John D'Errico (view profile)

さんによって 回答されました 2019 年 2 月 8 日
Hi,
I have a problem which I am trying to optimise for, where I have two matricies, d and x, of which the values are knows, and I want to find a matrix y, such that f(y) is minimised and d*y = x.
I have d, x and f defined, and y is defined as a sym matrix. I can't find a function that can optimise on the matrix.
Update: The matrix y is not a square matrix as assumed in the answers given. Is there still a way to make this work?

Matt J

### Matt J (view profile)

2019 年 2 月 8 日
Update: The matrix y is not a square matrix as assumed in the answers given. Is there still a way to make this work?
But you said previously that y is a symmetric matrix. Therefore, it must be square.
John D'Errico

### John D'Errico (view profile)

2019 年 2 月 8 日
I wonder if y is defined as a symbolic matrix, not a symmetric one? Thus the statement about a sym matrix?

サインイン to comment.

R2017b

## 3 件の回答

### Alan Weiss (view profile)

2019 年 2 月 5 日

This looks like a job for fmincon.
Your unknown values are the upper (say) triangular elements in y.
Create f to handle the upper-triangular y, say by using the tril function along with transpose. I mean, if y is upper triangular, then
ysym = tril(y',-1) + y;
is a symmetric matrix with the same upper triangular part as y. Then you can define your objective and constraint for fmincon easily.
Or to make it even easier on you (but harder on fmincon), let y be a general matrix, and add a nonlinear equality constraint y' = y.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

#### 0 件のコメント

サインイン to comment.

2019 年 2 月 5 日

### Matt J (view profile)

2019 年 2 月 5 日

[N,N]=size(y0); %get matrix dimensions from initial guess, y0
J=(1:N^2).';
I=reshape(J,N,N).';
T=sparse(I,J,1,N^2,N^2); %transposition operator
Aeq=[speye(N^2)-T;... %symmetry constraint
kron(speye(N),d)] ; %other constraint
beq=[zeros(N^2,1);
x(:)];
y=fmincon(@f,y0, [],[],Aeq,beq)

Matt J

### Matt J (view profile)

2019 年 2 月 8 日
If you have no symmetry/squareness assumptions on y, then the above simplifies to,
[M,N]=size(y0);
Aeq=kron(speye(N),d);
beq=x(:);
y=fmincon(@f,y0, [],[],Aeq,beq,[],[],[],options);

サインイン to comment. ### John D'Errico (view profile)

2019 年 2 月 8 日

It appears that y is merely a SYMBOLIC matrix, not a symmetric matrix, as others have assumed. But that just means that y is unknown in your eyes.
The constraint that d*y == x is merely a set of linear equality constraints. You can still set them up like this:
[N,N] = size(y0); %get matrix dimensions from initial guess, y0
Aeq = kron(eye(N),d);
beq = x(:);

#### 0 件のコメント

サインイン to comment.