Borrar filtros
Borrar filtros

Cannot replicate results of nonlinear optimization w/ nonlinear constraints from replication files

3 visualizaciones (últimos 30 días)
I cannot seem to replicate simulation results generated by my MATLAB code despite using same code, functions, starting values, random number generator, etc. Since I am literally using the same code/conditions used to generate the code the first time, I have omitted the code itself.
General description of code used: I simulate N nonlinear optimization problems with nonlinear constraints using fmincon, parallelized over my machine’s cores. I iterate over these simulations until a fixed point is reached. I am using fmincon’s SQP solver with centralized finite differences and have provided the analytical gradients for both my objective and constraint functions. Generally, CheckGradients does not fail – will get one failed for a large number of passed CheckGradients, presumably due to some scaling issue for a particular simulation.
Description of problem: I ran five experiments in the latter months of 2021: 3 in September on MATLAB 2018A, and 2 in December on MATLAB 2021B. All five experiments generated results that were generally consistent with one another.
In January 2022, I attempted to replicate all three of the September experiments using code archived in October for the express purpose of replicating the September results (there were no changes to the code between September and October); in particular, when I attempt to simply re-run the last iteration of the fixed-point algorithm – i.e., the iteration in which the code should terminate – the code does not terminate. In fact, in examining the “replicate” simulations, I see results that are very, very different than my original results.
Final context: I believe I installed the following updates in between the last time my code was generating consistent results and the point at which things started going haywire:
  • Feature update to Windows 10, version 21H2
  • Cumulative Update for .NET Framework 3.5 and 4.8 for Windows 10 Version 20H2 for x64 (KB5008876)
  • Update for Windows 10 Version 21H2 for x64-based systems (KB5008212)
Again – I am using the same code files, same environments, same starting environments, etc. Can someone shed some light as to why I am encountering this phenomenon?

Respuestas (1)

Matt J
Matt J el 4 de Feb. de 2022
Editada: Matt J el 4 de Feb. de 2022
when I attempt to simply re-run the last iteration of the fixed-point algorithm
You wouldn't be able to re-run the last iteration unless you had the second to last iteration as a start point. If you mean you used the October 2021 output of fmincon as the initial guess, then,
(1) Whether the iterations would continue depends on which stopping criteria caused the October 2021 runs to stop. If you simply reached the MaxIteration limit, then convergence never happenened and there is no reason the iterations should not continue when resumed.
(2) Some stopping criteria are defined relative to the norm of the gradient at the initial point, see
Since you are now launching fmincon at a different point, those stopping rules would be affected.
(3) The SQP algorithm uses quasi-newton methods to estimate the Hessian of the Lagrangian, which means the Hessian is iteratively updated from some starting guess. I don't think you have any way of resuming the Hessian updates from where they left off in October.
(4) You may have multiple solutions. What is the first order optimality measure at the new and old solutions? How different are the objective values at the two solutions?
(5) You say the new solutions are very different, but we don't know how you are evaluating that. Even if the differences are on the order of 10^15, we can't know whether to consider that a large number. If the gradients in the neighborhood of the October solution are also O(10^15), it makes sense to view that as a small change.
  7 comentarios
Nick Rowe
Nick Rowe el 5 de Feb. de 2022
"Therefore, the operations inside your objective function may not be multithreaded the same way, leading to differences in floating point errors. However, if the solutions ot the optimization problems are unique and well-conditioned, as you say they are, the difference shouldn't be very big....
Unless, perhaps, the October solutions were saddle points of the objective function. Saddle points are unstable, so small floating point differences could tip the iterations in the direction of a substantially different minimum..."
Just wanted to provide an update, as this was really helpful. While my program should not have saddle points, it does have another source of instability: scaling. Previously, I had thought that my extant fixes had vanquished the scaling issue, as I continued to get what appeared to be stable optimization results even as I varied the program's structural parameters significantly.
However, given your point regarding solution stability and multithreading changes, it appears that what was really happening was that the solver was returning solutions of poor quality that were consistent with one another. My guess is that an OS update in early January changed the nature of the non-MATLAB processes running in the background in a manner that allowed the solver to perform better, generating a structural break in the solutions generated by the solver.
The final clue that scaling is the culprit: since encounter the structural break in January, re-calibrating the model has been a nightmare, as my solutions - while better (in an fval sense) than those obtained before - have been extremely unstable with respect to changes in underlying structural parameters. After getting inspired by your comment, I tweaked my function definitions to ensure the control variables are closer in magnitude. While it's too early to tell whether this willl definitively end the issue, initial results have been encouraging. Thank you!

Iniciar sesión para comentar.

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by