-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor simplex to use wrapper class handling bound and fixed parameters #204
Refactor simplex to use wrapper class handling bound and fixed parameters #204
Conversation
Also now return number of parameers optimised in stat.params.Np (was previously just length of p0 - but this includes fixed parameters)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #204 +/- ##
==========================================
+ Coverage 42.65% 42.86% +0.21%
==========================================
Files 241 242 +1
Lines 16253 16240 -13
==========================================
+ Hits 6933 6962 +29
+ Misses 9320 9278 -42 ☔ View full report in Codecov by Sentry. |
Test Results 4 files 124 suites 4m 41s ⏱️ Results for commit f60fc5c. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good... just had a few comments, and one change to the cost_function_wrapper
docstring.
Also, could you change the build_pyspinw.yml
file to change build
to wheelhouse
in lines 164 and 171 (so the path reads wheelhouse/*whl
instead of build/*whl
)? It seems to be causing the python tests to fail... I don't know why it passed when I was doing the PR but is failing now... 🤷
In particular note that pfree is p_internal in lmfit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. The failing test is because it uses the self-hosted runner on my desktop which is off as I was on holiday... I'm not going to be in until tomorrow to turn it on.
Refactor simplex to use wrapper class
ndbase.cost_function_wrapper
handling bound and fixed parameters.Bound parameters are transformed using the formulation in MINUIT, as documented in lmfit
https://lmfit.github.io/lmfit-py/bounds.html
The wrapper class works by storing the fixed parameters (if any) and returning all non-fixed (potentially transformed) parameters that are used to evaluate the cost function so that an unconstrained minimisation can be performed (the fixed parameters are used internally when evaluating the cost function, but are not seen by the minimiser).
Have also added unit tests for wrapper class and simplex minimiser. The latter unit tests can be applied for any
ndbase
minimiser - however none of the other current minimisers succeed in optimizing the problems in the test file.lm',
lm2and
lm3` minimisers to not converge on the minimum (there's only one minimum in the cost function surface)pso
minimiser is not suited to unconstrained minimisation (generates initial particle swarm locations based on bounds - the default bounds if none are provided are huge and don't depend on the scale of the input parameters).Because the
lm
minimisers have been observed to perform poorly it has been decided to re-write them from scratch in a separate PR (after which hopefully they can share the same unit test assimplex
)