Skip to content

Fix parameter assignment#890

Merged
NicolaCourtier merged 50 commits intodevelopfrom
fix-parameter-assignment
Feb 27, 2026
Merged

Fix parameter assignment#890
NicolaCourtier merged 50 commits intodevelopfrom
fix-parameter-assignment

Conversation

@NicolaCourtier
Copy link
Member

Description

Fix the assignment of parameters to problems, when the problems within a MetaProblem depend on a different set of parameters. Also, allow passing a dictionary of parameter names and values to BaseSimulator and update the corresponding test.

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #).

Important checks:

Please confirm the following before marking the PR as ready for review:

  • No style issues: $ pre-commit run or $ nox -s pre-commit (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All tests pass: nox -s tests
  • The documentation builds: nox -s doctest
  • Code is commented for hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

❌ Patch coverage is 91.07143% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.88%. Comparing base (4628a65) to head (b22bda1).
⚠️ Report is 33 commits behind head on develop.

Files with missing lines Patch % Lines
pybop/problems/meta_problem.py 44.44% 5 Missing ⚠️
pybop/costs/error_measures.py 92.30% 2 Missing ⚠️
pybop/costs/design_cost.py 66.66% 1 Missing ⚠️
pybop/costs/likelihoods.py 93.33% 1 Missing ⚠️
pybop/optimisers/base_pints_optimiser.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #890      +/-   ##
===========================================
+ Coverage    89.41%   92.88%   +3.47%     
===========================================
  Files           63       72       +9     
  Lines         4857     5681     +824     
===========================================
+ Hits          4343     5277     +934     
+ Misses         514      404     -110     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@NicolaCourtier
Copy link
Member Author

NicolaCourtier commented Feb 16, 2026

⚠️ More care is needed regarding the order of the parameters to ensure that each problem returns the correct sensitivities (gradient in the cost with respect to each parameter). We use an OrderedDict in the Parameters class to preserve the parameter order. Then, when we construct a Problem, we first add the parameters from the simulator, followed by any extra ones for the cost. Duplicate parameters (those with the same parameter name) are ignored and a warning is thrown. But when we combine problems into a MetaProblem, we do not know if the problems have the same optimisation parameters and in which order they may be. So, this fix for the MetaProblem does not currently work for gradient-based methods if the optimisation parameters differ between the two problems.

Copy link
Contributor

@SarahRo SarahRo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me.

One thing I noticed is that the parameter assignment in MetaProblem does not seem to be tested as in there is no test that would fail without this bug-fix.

@NicolaCourtier NicolaCourtier marked this pull request as draft February 23, 2026 19:35
@NicolaCourtier NicolaCourtier changed the base branch from develop to update-parameter-funtionality February 23, 2026 19:38
@NicolaCourtier NicolaCourtier marked this pull request as ready for review February 25, 2026 00:08
@NicolaCourtier NicolaCourtier changed the base branch from update-parameter-funtionality to develop February 25, 2026 18:12
@NicolaCourtier NicolaCourtier merged commit b666a5e into develop Feb 27, 2026
31 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.

2 participants