Optimization of a sum with unknown coefficients

10 views (last 30 days)
Matt
Matt on 12 Mar 2014
Edited: Matt J on 13 Mar 2014
I'm working on some coding and I'm having an issue with mimimizing an equation. Essientally, I have a sum that has a different coeffiecent for every term and I'm trying find the coefficent. Mathematically it looks like:
A*B = sum(C*D)
I know A,B, and D. A and B are both scalar. C and D I have reshaped (using reshape) from a square matrix to a vector. So the right hand sid eof the equation is essentially C(1)*D(1) + C(2)*D(2) + ... + C(N)*D(N).
I've been trying to use fminsearch to find the values but I keep running into issues. The code I created looks like:
fn = @(C) (A*B - sum(C*D))^2
opt = fminsearch(fn, 1)
Any thoughts or suggestions would be appreciated.

Answers (2)

Roger Stafford
Roger Stafford on 12 Mar 2014
If the values of the D elements are non-zero, you have a very undetermined system for which there are infinitely many values of the C coefficients that will yield a minimum value of zero to 'fn'. It's no wonder you "keep running into issues". The 'fminsearch' function doesn't understand which of this infinitude you wish to choose.
For example, suppose N = 3 and the C coefficients are x, y, and z cartesian coordinates of points in 3D space. The A*B and three D quantities represent a 2D plane somewhere in that space. The 'fn' quantity would be the square of the orthogonal distance from a point (x,y,z) in space to that plane. You would be asking 'fminsearch' which is the point that is closest to the plane. Unfortunately there are infinitely many points that are right on the plane with zero distance and 'fminsearch' is left not knowing which one to choose.
I have the feeling you have some other conditions you wish also to place on your coefficients that you are not telling us about.
  2 Comments
Matt
Matt on 13 Mar 2014
Edited: Matt on 13 Mar 2014
Yeah there are a couple of other constraints on C. I know that it should be between 0.5 and 1.5 ideally. Additionally, I know that the diagonal should be 1's. Is there someway to bound the solution with these constraints?
Also, I see what you are seeing about a defined plane. I should have thought about that when I was working on it.
Other than that I really don't have any other constraints that I can think of. Thanks,
Matt J
Matt J on 13 Mar 2014
Edited: Matt J on 13 Mar 2014
A plane intersects a box at infinite locations (generally), so even with the box constraints, you will have an ill-defined solution.

Sign in to comment.


Matt J
Matt J on 12 Mar 2014
Edited: Matt J on 12 Mar 2014
A*B = sum(C*D)
This is the equation for a (hyper)plane. Any one of infinite C lying on the hyperplane is a solution of the equation, so no wonder you cannot solve it uniquely.
However, the minimum norm solution is given by
C = pinv(D(:).')*(A*B)

Categories

Find more on Get Started with Optimization Toolbox 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!