# optimization of matrices with random initialization

6 views (last 30 days)

Show older comments

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!

##### 0 Comments

### Accepted Answer

Matt J
on 20 Oct 2021

### More Answers (1)

Alan Weiss
on 19 Oct 2021

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

### See Also

### Community Treasure Hunt

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

Start Hunting!