FMINCON performing Differently in Mac vs Windows
조회 수: 4 (최근 30일)
이전 댓글 표시
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
John D'Errico
2024년 5월 29일
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
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
2024년 5월 29일
이동: Matt J
2024년 5월 29일
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.
답변 (1개)
Ganesh
2024년 5월 29일
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!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!