Mathematics    

Troubleshooting

Below is a list of typical problems and recommendations for dealing with them.

Problem
Recommendation
The solution found by fminbnd or fminsearch does not appear to be a global minimum.

There is no guarantee that you have a global minimum unless your problem is continuous and has only one minimum. Starting the optimization from a number of different starting points (or intervals in the case of fminbnd) may help to locate the global minimum or verify that there is only one minimum. Use different methods, where possible, to verify results.

Sometimes an optimization problem has values of x for which it is impossible to evaluate f.

Modify your function to include a penalty function to give a large positive value to f when infeasibility is encountered.

The minimization routine appears to enter an infinite loop or returns a solution that is not a minimum (or not a zero in the case of fzero).

Your objective function (fun) may be returning Inf, NaN, or complex values. The optimization routines expect only real numbers to be returned. Any other values may cause unexpected results. Insert code into your objective function M-file to verify that only real numbers are returned (use the functions isreal and isfinite).


  Tips Converting Your Optimization Code to MATLAB Version 5 Syntax