Skip to content

feat: add parameterGroup options to share variables between peaks#126

Open
jobo322 wants to merge 4 commits into
mainfrom
125-be-able-to-share-the-same-parameter-between-peaks
Open

feat: add parameterGroup options to share variables between peaks#126
jobo322 wants to merge 4 commits into
mainfrom
125-be-able-to-share-the-same-parameter-between-peaks

Conversation

@jobo322

@jobo322 jobo322 commented Jun 16, 2026

Copy link
Copy Markdown
Member

Refactor: introduce OptimizationLayout and parameterGroups

Summary:
This PR extracts optimizer-to-peak parameter mapping into a dedicated layout builder and adds linked parameters through parameterGroups. Multiple peak parameters can now share one optimization variable with optional factor and offset, without changing the optimizer itself.

Key changes:

  • Added buildOptimizationLayout to centralize optimizer variable mapping.
  • Added reconstructPeaks to centralize peak reconstruction.
  • Wired optimize() and the fixed-parameter path to use the new layout/reconstruction helpers.
  • Added OptimizeOptions.parameterGroups plus ParameterGroup and ParameterGroupMember.
  • Added validation for invalid groups: unknown peak ids, duplicate members, incompatible flags/bounds, invalid factors, and non-finite offsets.
  • For grouped variables, gradientDifference is computed conservatively as min(member.gradientDifference / |factor|).

Compatibility:

  • Default behavior is unchanged when parameterGroups is not provided.
  • Existing LM/direct optimization flows, the no-free-parameters path, and peak id preservation are preserved.

@jobo322 jobo322 linked an issue Jun 16, 2026 that may be closed by this pull request
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.76%. Comparing base (2b13c16) to head (353a899).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #126      +/-   ##
==========================================
+ Coverage   96.52%   97.76%   +1.24%     
==========================================
  Files           9       11       +2     
  Lines         230      358     +128     
  Branches       39       70      +31     
==========================================
+ Hits          222      350     +128     
  Misses          8        8              

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jobo322 jobo322 requested a review from lpatiny June 16, 2026 21:18
Comment thread src/__tests__/parameterGroups.test.ts Outdated
@jobo322 jobo322 force-pushed the 125-be-able-to-share-the-same-parameter-between-peaks branch from b3535b4 to 116dd5f Compare June 19, 2026 16:25
@@ -0,0 +1,220 @@
import type { DataXY } from 'cheminfo-types';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to try to optimiize a doublet superimposing a triplet like in

Image

Comment thread src/util/buildOptimizationLayout.ts
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.

be able to share the same parameter between peaks.

2 participants