How to minimize a function with 112 variables?

1 view (last 30 days)
Jhon
Jhon on 12 Apr 2014
Edited: John D'Errico on 13 Apr 2014
I have a non-negative function(in the attachment) named `aim` with 112 variables to minimize, but even
fminsearch('aim',random('Normal',0,3,1,112),optimset('MaxFunEvals',100^141))
output that
Exiting: Maximum number of iterations has been exceeded
- increase MaxIter option.
Current function value: 1.977209
As I know, the minimum of `aim` should be 0. But I just do not know what to do then.
Then I increase the MaxIter option, and it is still running...
fminsearch('aim',random('Normal',0,3,1,112),optimset('MaxFunEvals',10^9,'MaxIter',10^9))

Answers (2)

John D'Errico
John D'Errico on 12 Apr 2014
NEVER use a tool like fminsearch to minimize a function with more than about 10 variables. Really, about 6 unknowns is a good practical limit for that tool. 112 variables is just folly, as you have found.
Beyond that, you need to use a toolbox function like fminunc or fmincon from the optimization toolbox. If you don't have that toolbox and you do optimization with any frequency, BUY IT.
You can also use tools like simulated annealing, particle swarms, genetic algorithms, etc. These stochastic optimizers have some good properties for nasty problems with multiple local solutions or with problems like internal singularities.
Typically I'd suggest that for smooth functions, you use a tool like fminunc/fmincon. It will be efficient and will converge to an accurate solution more rapidly than will the stochastic tools I suggested. For problems with a problem like those I mentioned above, go with a stochastic tool.
You can find toolboxes for all of these things from the MathWorks, and at least a few of them on the file exchange. For example, there are many particle swarm toolboxes to be found on the FEX.
  3 Comments
Jhon
Jhon on 13 Apr 2014
Each `fminunc` or `fmincon` may take more than half a minute, the whole program may run 10000 years
John D'Errico
John D'Errico on 13 Apr 2014
Edited: John D'Errico on 13 Apr 2014
So you have many millions of problems to solve, each of which has 112 variables, if each fminunc solution would run for on the order of 30 seconds?
Then guess how many millions of years do you think it would take fminsearch to converge for that many problems?
Just because your computer is fast does not make it a super computer. Solve smaller problems, or find some time on a seriously massive computer. Just wanting to solve a massive problem is not sufficient.
And a good idea is to choose your starting value more intelligently. Random starts will simply not suffice for a problem like this.

Sign in to comment.


Walter Roberson
Walter Roberson on 12 Apr 2014
For something like that you would usually use a technique such as simulated annealing, and you would not expect to definitely find the global minimum.

Community Treasure Hunt

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

Start Hunting!