How can I minimize a function over certain elements of two matrices?

Hi everyone, I am trying to minimize the following function: x=sumabs(A*Omega*A'-Sigma) where all of the inputs are 6x6 matrices. I need, however, to minimize only over the choice of certain elements in A and Sigma. I defined a starting value vector sv=[3 4 5 6 7 8 1 1 1 1 1 1]' and pre-allocated Matrix A and Sigma as follows: A =
1 3 4 0 0 0
5 1 6 0 0 0
7 8 1 0 0 0
0 0 0 1 3 4
0 0 0 5 1 6
0 0 0 7 8 1
and Sigma =
1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1
Omega has the following form: Omega =
31.7281 42.2014 22.9941 0 0 0
42.2014 57.2294 31.2287 0 0 0
22.9941 31.2287 17.7333 0 0 0
0 0 0 267.9891 321.6098 158.4370
0 0 0 321.6098 392.2539 193.2416
0 0 0 158.4370 193.2416 96.1085
Hence x should be minimized only(!) over the choice of the off-diagonal values in the diagonal block sub-matrices of A (i.e. 3 4 5 6 7 8) and over the choice of the diagonal elements in Sigma. Does anyone maybe have an idea how one could set this up in Matlab? Any help would be much appreciated! Thank you!

 Accepted Answer

Take sv as unknown vector x, build the matrices A and Sigma from this vector, use
sumabs(A*Omega*A'-Sigma)
as objective function to be minimized and call MATLAB's "fminsearch" to solve.
Best wishes
Torsten.

2 Comments

Thank you very much for your quick reply!
How do you allocate unknowns to a vector so that it can be used in the optimization? I already tried what you suggested and fed sv into fminsearch as the vector of variables over which it should optimize - fminsearch needs a starting value, right?
fun=@(sv)sumabs(A*Omega*A'-Sigma);
x=fminsearch(fun,sv);
This, however, gives the same A matrix I put into the optimization as the result of the optimization. Somehow the algorithm does not realize that it should change the values of the starting vector sv in A and Sigma - it treats them as numbers not as variables. It only seems to work if I build the matrices A and Sigma in the objective function like
fun = @(sv)sumabs([1 sv(1,1) sv(2,1) 0 0 0; sv(3,1) 1 sv(4,1) 0 0 0; sv(5,1) sv(6,1) 1 0 0 0; 0 0 0 1 sv(1,1) sv(2,1); 0 0 0 sv(3,1) 1 sv(4,1); 0 0 0 sv(5,1) sv(6,1) 1]*Omega*...).
not if I build it before. But that seems rather cumbersome...
If you had any idea, I'd much appreciate your help. Thanks!
You have to build the matrices from the sv-vector explicitly in the objective function - that's the only way to go.
Best wishes
Torsten.

Sign in to comment.

More Answers (0)

Categories

Asked:

on 2 Feb 2017

Commented:

on 3 Feb 2017

Community Treasure Hunt

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

Start Hunting!