How can I minimize a function with constraints on matrix ?
Show older comments
Hi everyone,
I am trying to run a simulation where I want to minimize a parameter (lambda) such that a function equals to 0 (I don't want to minimize this function, I just want to find the lowest lambda which makes my function equal 0).
I am not sure what tools to use, I tried with fmincon but my constraints are on matrix and fmincon seems to support only scalar...(at a moment I need a matrix to be equal to a matrix of zero)
Some help would be awesome :)
Thanks
10 Comments
Torsten
on 22 Feb 2017
You can formulate your constraints elementwise.
If your matrix is mxn, you will arrive at m*n equality constraints.
Best wishes
Torsten.
Vincent DUFOUR
on 22 Feb 2017
Torsten
on 22 Feb 2017
If you reshape ceq, it will not be a matrix of size (mxn), but a vector of length m*n.
Best wishes
Torsten.
Vincent DUFOUR
on 22 Feb 2017
Edited: Walter Roberson
on 22 Feb 2017
Torsten
on 22 Feb 2017
optim must return a scalar ; in your case, it returns a (3x1) vector.
From your first description of the problem I thought that optim just returns lambda ...:
optim=@(lambda) lambda
?
Best wishes
Torsten.
Vincent DUFOUR
on 22 Feb 2017
Torsten
on 23 Feb 2017
I think the objective function is @(lambda) lambda.
Further, you will have to constrain lambda to be between 0 and 2*pi (A*x<=b facility).
The constraint function should force the vector components to be zero.
Best wishes
Torsten.
Vincent DUFOUR
on 23 Feb 2017
Torsten
on 23 Feb 2017
No difference. I guess your solution with lower and upper bound is better. You'll get all possible rotations in your matrix if 0<=lambda<=2*pi - so you should choose 2*pi as upper bound.
Best wishes
Torsten.
Vincent DUFOUR
on 23 Feb 2017
Answers (1)
Walter Roberson
on 22 Feb 2017
0 votes
If your condition is not that a function equals 0 but rather that a matrix of functions each equal 0, then you have a challenge.
Might I suggest that you instead minimize the sum of squares of the matrix elements?
You said that you wanted the smallest p for which that function becomes 0. Is it the case that there are multiple p values that achieve that, but you need the smallest of those different values? (Sort of in the spirit of looking for the smallest eigenvalue?) If that is the case, is there something known about the range of p that might be suitable, or something known about the maximum number of different p that might work?
5 Comments
Vincent DUFOUR
on 22 Feb 2017
Walter Roberson
on 22 Feb 2017
Is there something known about the range of lambda that might be suitable, or something known about the maximum number of different lambda that might work?
Suppose I find a lambda that gives 0 for the cross-product. Is there any way for me to know, looking at it in isolation, that it is the lowest such lambda that needs to be considered? Is there a way for me to know, looking at it and the history of the other lambda I have found, that it is the lowest such lambda that needs to be considered?
Imagine I gave you "black box" function which I assured you was a polynomial with a finite number of real roots, but I did not tell you how many roots, and for any given argument the black box function tells you Yes or No, the argument was a root. And imagine I asked you to find the smallest root. You've found 602 roots so far: can you stop, or do you have to search all the way to -infinity?
Vincent DUFOUR
on 23 Feb 2017
Walter Roberson
on 23 Feb 2017
Edited: Walter Roberson
on 23 Feb 2017
The minimizes make projections about where to try next, and might overshoot and end up in a different local minima. The first found will not necessarily be the one with the smallest lambda . However, it does help to know that the lower bound is 0: then if you find a different value, you can restrict your search to be between 0 and that value; if it comes up with a different value then you make that the new lowest and repeat using that as the upper bound; if no value is found and the search is fine-enough grained then you can end.
If you did not have a lower bound then the search would have to continue indefinitely.
Vincent DUFOUR
on 23 Feb 2017
Categories
Find more on Linear Least Squares 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!