pub fn fit(
graph: &FitGraphSpec,
datasets: Vec<MeasurementSpec>,
options: &FitOptionsSpec,
) -> Result<FitResultSpec, CoreError>Expand description
Run a fit of graph against datasets using the solver named by
options.solver (see Solver::parse for the accepted strings: lm,
lm-legacy, trf, geodesic, dogleg, newton-cg, irls[:weight],
global, varpro, auto).
The LM family (lm, lm-legacy, trf, geodesic) plus the
trust-region methods (dogleg, newton-cg) and auto’s non-VarPro
fallback share one pre-solve/solve/post-fit path through this function.
irls, global, and varpro are routed to their own modules/crates in
dispatch_solver and return before that shared path runs.
Returns a fully populated FitResultSpec including parameter values,
standard errors, covariance matrix, and goodness-of-fit statistics.
§Errors
Returns CoreError when:
options.solverdoes not parse (unrecognised solver name, or an unrecognisedirls:<weight>weight-function name) —Solver::parse.- The routed non-LM-family solver fails:
irls(crate::irls::solve_irls),global(differential evolution), orvarpro(not separable, tied parameters present, or per-dataset scoping unsupported). - Graph compilation or the initial model evaluation fails (malformed
graph, a free-key/parameter lookup miss, or a model evaluation error) —
prepare_lm_pre_solve. - The LM-family solve itself fails or produces a numerically unusable
result (e.g. ill-conditioned Jacobian) that maps to
CoreError::Solver. options.etais set alongsidesolver="dogleg"/"newton-cg"but is not finite and in[0.0, 0.25)—SolverError::InvalidEta.- Post-fit assembly fails while re-evaluating the model or its Jacobian
at the solution —
postfit::assemble_result.