Effacer les filtres
Effacer les filtres

FMINCON performing Differently in Mac vs Windows

3 vues (au cours des 30 derniers jours)
Nikita Agrawal
Nikita Agrawal le 29 Mai 2024
Déplacé(e) : Matt J le 29 Mai 2024
I am running an optimization code using fmincon, and using parallel computing. It happens to give me different outputs when run on Mac vs Windows, any idea what can be fixed?
  4 commentaires
John D'Errico
John D'Errico le 29 Mai 2024
Lol. "This is an unacceptable solution." I can rant and rave, stomp my feet all I want, and there are things in the world I cannot change, despite my most strident demands.
If you insist on exactly the same results always, down to the least significant bit, then never change release. Never use a different computer. That MIGHT be sufficient. Even things like the number of processors or the amount of RAM you have may cause issues, since that may influence how a computation gets parallelized.
Instead, you should learn about floating point computations, why they are impacted by the exact sequence of operations performed, and why computations done in parallel can change the results you see. You should learn about the need for tolerances on any result. Never compare two floating point results for exact equality, as even the simplest result need not yield what you know to be mathematically true.
0.1 + 0.2 - 0.3 == 0.2 - 0.3 + 0.1
ans = logical
0
Of course, you don't say if the difference in results is down in the least significant bits, or if it is larger. But even then, the magnitude of the difference may simply be explained by an ill-conditioned system amplifying tiny errors in the least significant bits.
Matt J
Matt J le 29 Mai 2024
Déplacé(e) : Matt J le 29 Mai 2024
It happens to give me different outputs when run on Mac vs Windows, any idea what can be fixed?
Do both solutions give similar objective function values, fval? If so, it is a sign that you may have a non-unique space of solutions. You will need to regularize the problem in some way, to remove the ambiguity in the solution. We might be able to give advice on that, but not without seeing a mathematical description of the problem.

Connectez-vous pour commenter.

Réponses (1)

Ganesh
Ganesh le 29 Mai 2024
As @Torsten has pointed out, it is not unusual for such behaviour. The function "fmincon()" can behave differently on different machines due to slight difference in the underlying mathematical functions. Moreover, as you have parallelized the process, the overall result would get compounded and be different too.
However, you can be assured that the underlying algorithm used for both the processes remain the same.
To answer your question, if you intend to achieve the same result on both your machines, you will have to understand the underlying math and give varying "Initial Guesses" accordingly.
Kindly refer to the following MATLAB Answer, and follow through the entire answer for better understanding.
Hope this helps!

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by