optimization of matrices with random initialization

5 ビュー (過去 30 日間)
Jing Xie
Jing Xie 2021 年 10 月 19 日
コメント済み: Jing Xie 2021 年 10 月 21 日
Ciao, everyone
I want to optimize a function
where pi are optimal variables and matrices of different sizes. (each pi_bar have the same size as corresponding pi)
I reshape all the pi to one single column so I could use the fminunc to solve the problem.
The problem is unconstraint but yi is updated using pi. It also involves some random initialization (using randn) at the beginning for some variables.
pi_bar and yi_bar are already known.
case 1: I run the optimization, it returns different values each time, which is understandable as there is random inialization in the algorithm
case 2: I fixed the random initialization, using rng for example. It returns an error "maximum number of function evaluations has been exceeded " even if I set the value to very high (500000).
It seems that the algorithm only finds a better point when there is better random initialization points. Is there a better way to cope with the random initialization in optimization problem? And what could be the reasons for the case 2?
Thanks a lot for any suggestion in advance!

採用された回答

Matt J
Matt J 2021 年 10 月 20 日
Make sure your objective function code does not contain any randomization steps. Your initial guess can be random, but the objective function itself needs to be deterministic. Aside from that, nothing can be diagnosed without seeing your code.
  8 件のコメント
Matt J
Matt J 2021 年 10 月 20 日
編集済み: Matt J 2021 年 10 月 20 日
That doesn't clarify why you are not optimizing xp. Surely the accuracy of the prediction of depends jointly on xp and the other parameters. If you change x1...x8, your prediction can become worse if you don't change xp as well.
Also, you say that your initial guess of x1...x8 came from a previously trained LSTM. Why not use the xp from that network as well (regardless of whether xp is treated as an unknown or not)?
Jing Xie
Jing Xie 2021 年 10 月 21 日
Thanks for the comment!
I think treating xp as optimal variables is a nice idea to eliminate the randomness in the process. Although it returns the same error "exceeds max number of function evaluations". I think the initial guess of the optimal variables are still too far away from optimal solutions. If I choose less variables to optimize (e.g. only x1 and x2), the algorithm works fine.

サインインしてコメントする。

その他の回答 (1 件)

Alan Weiss
Alan Weiss 2021 年 10 月 19 日
You would probably do well to use the Problem-Based Optimization Workflow. But you can just as easily change your current solution method to use a more efficient algorithm. The point is that lsqnonlin is the solver of choice for sum-of-squares problems. Your objective function should return the and lsqnonlin implicitly sums the squares and minimizes.
That said, I might be misunderstanding your problem. You said that your are functions of , and I do noot see that connection in your problem formulation. So I might have it wrong somehow.
In any case, see whether the problem-based formulation makes sense for you and whether it chooses a more efficient solver.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 件のコメント
Jing Xie
Jing Xie 2021 年 10 月 20 日
Hi Alan
thanks a lot for the answer!
Sorry I did not state it clearly. The optimization variables are only in my algorithm. I am actually using fminunc to solve my optimization. I also have tried problem-based optimization and it automatically chooses fminunc as the solver. And it returns the exact same error.
In my problem formulation, is actually a sequence and is calculated through and some variables (lets say ).
If is randomly initialized, the algorithm only finds a better point if there is a good random initialization.
I initialize the optimal variable with the previous best result (according to my algorithm, it is the best initializaton for ).
For, I used a good guess (at least in my opinion) to initialize it.
But it still throws the error "fminunc stopped because it exceeded the function evaluation limit"
I am new to optimization algorithm. Is it because that there is no available (sub)optimal points near the initial point of ? Or the algorithm is too conservative to take large steps that it is trapped?
I also would like to add, it is a relatively big optimization problem with 8 different optimization variables (all are matrices with different size) and together 724 scalar optimization variable. Is fminunc suitable for problems with large number of optimization variables?
I would appreciate any suggestions!
Jing

サインインしてコメントする。

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by