Skip to content

Reuse solver residual in calibrator#231

Open
mrp089 wants to merge 4 commits into
SimVascular:masterfrom
mrp089:claude/objective-mendeleev-a7e408
Open

Reuse solver residual in calibrator#231
mrp089 wants to merge 4 commits into
SimVascular:masterfrom
mrp089:claude/objective-mendeleev-a7e408

Conversation

@mrp089

@mrp089 mrp089 commented Jun 5, 2026

Copy link
Copy Markdown
Member

Current situation

Closes #153.

Release Notes

The calibrator reuses the code from the solver to calculate the residual, which previously needed to be reimplemented for each block. This makes the code more straightforward and makes calibrating new blocks easier.

Documentation

No change in functionality

Testing

Should work as before

Code of Conduct & Contributing Guidelines

mrp089 and others added 2 commits June 4, 2026 08:59
The block update_gradient methods previously hand-coded the residual
r = E*ydot + F*y + c, duplicating the residual the solver already
assembles in SparseSystem::update_residual (r = -C - E*ydot - F*y).

Reuse the solver residual during calibration and have update_gradient
assemble only the Jacobian of the residual with respect to the
parameters. The Jacobian signs are flipped to match the solver's sign
convention; the overall sign cancels in the LM normal equations, so the
optimization is unchanged.

- LevenbergMarquardtOptimizer now sets the model parameters to the
  current alpha, assembles E/F once, and computes the residual per
  observation via update_solution + update_residual.
- calibrate registers the parameters with the model so the solver's
  assembly can read their values.
- Blocks without calibration parameters (e.g. a normal junction) are
  skipped in the Jacobian loop, so Junction::update_gradient is removed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ndeleev-a7e408

# Conflicts:
#	src/model/Junction.h
#	src/optimize/LevenbergMarquardtOptimizer.cpp
#	src/optimize/calibrate.cpp
@mrp089 mrp089 changed the title Claude/objective mendeleev a7e408 Reuse solver residual in calibrator Jun 5, 2026
@mrp089 mrp089 requested a review from federicaninno June 5, 2026 15:23
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.

Calibrator: Reuse residual from solver

1 participant