Fmincon DOES produce different results on different Windows machines. Why does this happen?

5 views (last 30 days)
Hi,
I'm solving optimal control problems with a collocation method and depending on the machine I run Matlab on I get different results. One machine is my laptop (Intel I7, win 10), the other is a desktop (Intel I7, win 7), Matlab 2016b in both cases, and using sqp algorithm.
On my laptop it converges to local optimality (1e-7), while on the desktop it stops because the stepsize gets too small.
I cannot copy paste all the code because it's very long, but: 1) I can guarantee the code is the same, because I pull from the same repository on Git 2) The code has been tested quite thoroughly, with many problems known in the literature, and gives the expected results 3) The solution should be differentiable. On my laptop it converges to optimality, and the final stepsize is 1, so it seems to be very smooth there too. 4) There is no randomness in my code (obviously, but I've seen this point stated many times in similar questions, for example https://nl.mathworks.com/matlabcentral/answers/329955-fmincon-produces-different-results-on-different-pcs)
My question is: is there any documentation explaining when and if fmincon and Matlab in general are portable? What could be the causes? Are different BLAS used on different OS?
Thanks

Answers (2)

Matt J
Matt J on 28 Nov 2017
Edited: Matt J on 28 Nov 2017
Generally speaking, optimization results may be non-portable from machine to machine if the solution is unstable, i.e., you have a continuum of non-unique solutions. What is the final objective function value reached in each case? What is the initial objective function value? If they are similar, it is an indication that you have a continuum of solutions.
Another possibility is that your iterations start or land at some point where the step direction computation is unstable (for example, the Hessian is singular). Machine-to-machine differences in floating point error can then send the iterations in very different directions.
Do you see the same problem regardless of the initial point? Do you see the same problem regardless of the objective function?

Walter Roberson
Walter Roberson on 28 Nov 2017
Edited: Walter Roberson on 28 Nov 2017
"Are different BLAS used on different OS"
Different LAPACK, yes. Though more relevant might be that different MKL (Intel Math Kernel Library) are used for different OS and different processors; if I recall correctly these are supplied with the OS for MS Windows.
  2 Comments
Lorenzo Ricciardi
Lorenzo Ricciardi on 28 Nov 2017
Edited: Walter Roberson on 28 Nov 2017
I discovered that my laptop and the desktop do indeed use different versions of both the LAPACK and of MKL (my laptop uses CVR branch AVX2 while the desktop uses CVR branch AVX).
Is it possible to set the same version in Matlab? I found this exact question here https://nl.mathworks.com/matlabcentral/answers/301338-how-to-change-the-cnr-setting-using-intel-mkl-blas-to-get-reproducible-results but without any answers.
Is anyone able to help me? We might clarify some long standing portability issue
Walter Roberson
Walter Roberson on 28 Nov 2017
Which level are you setting that environment variable at? If you are starting MATLAB from icon then you would probably need to have set the environment variables at a different level. https://superuser.com/questions/949560/how-do-i-set-system-environment-variables-in-windows-10

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!