Is fmincon deterministic? If so, why am I getting different results?

4 views (last 30 days)
I've been writing a program for 2D Laplace inversion that involves minimizing an N-dimensional function where N is around 20-50 or so. The code operates fairly quickly, but for some reason the results are drastically different from run-to-run. I've set it up so that the input is just ones(size(F0)), and when I run the exact same problem more than once, with the same inputs, I'll sometimes get drastically different answers.
I'm also iterating a Tikhonov normalization parameter (it's early stages so I just want to see how that changes things), and I've noticed that the outputs don't seem uncorrelated, so when I run code like this:
F0 = ones(n, 1);
for i = 1:nAlphas
alpha = alphas(i);
F = fmincon(@(f)laplace(f, alpha), F0, [], [], [], [], ...
zeros(size(F0)), [], [], o);
out.F{i} = F;
end
I'll find that it goes through cycles, where say nAlphas = 16, I'll get 16 similar-looking spectra, then I'll run it again and get 16 spectra that look similar to one another, but completely different from the previous one. Does anyone know why this would be? Is it the nature of fmincon?
If it makes a difference, I've been using interior-point algorithm, but I've also noticed it with the default algorithm and sqp.
  1 Comment
Sargondjani
Sargondjani on 27 Jun 2012
i have never experienced different results with deterministic problems. i would be surprised if that happens.... is there any stochastic process inside the functions?

Sign in to comment.

Accepted Answer

Alan Weiss
Alan Weiss on 28 Jun 2012
fmincon is deterministic. I suspect that your objective or constraint functions are not, or that somewhere in your code you have something depending on history (such as an initial condition that changes, or an option value or something).
Alan Weiss
MATLAB mathematical toolbox documentation

More Answers (1)

Mark Schelbergen
Mark Schelbergen on 6 May 2013
I have encountered a similar problem. When running my optimization on a desktop fmincon returns different results each run. When I run exactly the same optimization on the cluster I get identical results each run. I use nonlinear constraints which are determined by finite element method software. The input and output of the software is written (rounded values, however DiffMinChange is set accordingly) and read from large text files. However as I see it this is not the cause of the difference. For a certain run on the desktop the objective value of the first iteration (the one after the initial point) is identical to the first iteration on the cluster, afterwards the objective values of the iterations start to differ. I've been storing the values for x send to the objective and constraint function by fmincon. The first differences are spotted in x when fmincon finishes the finite-difference steps at the initial point; these are however in the order of magnitude of 1e-12. After the finite-difference steps of the first iteration however the values for x differ significantly:
x_cluster(eval18)=[1.62441992820243 1.66666666666667 1.07899984754487 0.637268977410626 0.904495259590448 0.573612611695331 1.14722522339066;]
x_desktop(eval18)=[0.0833333333333335 0.615017036475342 0.746894388065924 0.818089325909087 0.390321710440730 0.513574930529536 1.02714986105907;]
The values for the nonlinear constraints of the desktop and cluster have been identical until the 18th function evaluation.
Thanks for reading my question and hopefully somebody can help me out. Mark

Products

Community Treasure Hunt

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

Start Hunting!