Skip to content
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

Merged
merged 21 commits into from
Nov 1, 2024

Conversation

RichardWaiteSTFC
Copy link
Collaborator

@RichardWaiteSTFC RichardWaiteSTFC commented Sep 16, 2024

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.

  • The lm', lm2andlm3` minimisers to not converge on the minimum (there's only one minimum in the cost function surface)
  • The 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 as simplex)

@codecov-commenter
Copy link

codecov-commenter commented Sep 16, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 98.36066% with 2 lines in your changes missing coverage. Please review.

Project coverage is 42.86%. Comparing base (d859b68) to head (f60fc5c).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
swfiles/+ndbase/simplex.m 94.59% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Sep 16, 2024

Test Results

    4 files    124 suites   4m 41s ⏱️
  791 tests   773 ✅ 18 💤 0 ❌
2 240 runs  2 204 ✅ 36 💤 0 ❌

Results for commit f60fc5c.

♻️ This comment has been updated with latest results.

Copy link
Member

@mducle mducle left a 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... 🤷

Copy link
Member

@mducle mducle left a 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.

@RichardWaiteSTFC RichardWaiteSTFC merged commit 73f604a into master Nov 1, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants