pub struct CompiledGraph {
pub nodes: Vec<NodeEntry>,
pub free_keys: Vec<String>,
pub node_free_cols: Vec<Vec<(usize, usize)>>,
pub tied_plan: TiedPlan,
pub dataset_offsets: Vec<usize>,
}Expand description
The compiled representation of a FitGraphSpec, ready for evaluation.
Fields§
§nodes: Vec<NodeEntry>Nodes in their original declaration order (used for evaluation).
free_keys: Vec<String>Keys "node_id.param_name" for all free parameters,
sorted by node_id alphabetically, then by model param order within a node.
node_free_cols: Vec<Vec<(usize, usize)>>Per-node Jacobian column layout, pre-computed during [compile].
node_free_cols[i] lists (local_param_idx, jac_col) for every free
parameter on nodes[i]. Used by the solver to avoid string-parsing
free_keys on every iteration.
tied_plan: TiedPlanDependency-ordered plan for tied (expr_edge) parameters.
Empty when the graph declares no expr_edges. When non-empty, the
solver calls TiedPlan::apply on the flat parameter map after
updating the free parameters on every iteration, so that each tied
target is recomputed from its expression before the model is evaluated.
Applied per-iteration by spectrafit-solver::lm_problem::set_free_and_tied
— the single set_params entry shared by both the nalgebra-LM and faer
trust-region front-ends. The FD Jacobian re-applies ties per
perturbation, and the analytic Jacobian is swapped for FD when ties are
present so chain-rule terms are captured. End-to-end coverage:
dispatch::tests::test_tied_amplitude_fit_recovers_ratio and
test_tied_fit_reduces_free_param_count in the solver crate.
dataset_offsets: Vec<usize>Per-dataset point boundaries for simultaneous multi-dataset (“global
analysis”) fits: cumulative offsets of length n_datasets + 1, so
dataset i owns the concatenated point-range [offsets[i], offsets[i+1]).
Empty by default (single-dataset / fully-global fits). The solver
dispatch fills it from the dataset sizes after compile(). The executor
only consults it when it is non-empty AND at least one node carries a
[NodeEntry::dataset_index]; otherwise every node contributes to all
points exactly as before (the all-global path is byte-identical).
Implementations§
Source§impl CompiledGraph
impl CompiledGraph
Sourcepub fn compile(graph: &FitGraphSpec) -> Result<Self, CoreError>
pub fn compile(graph: &FitGraphSpec) -> Result<Self, CoreError>
Compile a FitGraphSpec into a CompiledGraph.
§Errors
Returns CoreError::Eval if:
- an unknown model type is encountered
- a required parameter is missing from the spec
- two nodes share the same
id(would silently corrupt the free-column layout and overwrite components) expr_edgescontain duplicate targets (cycle / conflict)
Sourcepub fn node_params(
&self,
node_idx: usize,
flat: &HashMap<String, f64>,
) -> Result<Vec<f64>, CoreError>
pub fn node_params( &self, node_idx: usize, flat: &HashMap<String, f64>, ) -> Result<Vec<f64>, CoreError>
Extract the parameter value vector for node at node_idx from the flat dict.
Values are ordered to match model.param_names().
§Errors
Returns CoreError::Eval (via GraphError::MissingParamKey) if
flat has no entry for one of the node’s "node_id.param_name" keys.
Sourcepub fn n_dims(&self) -> Result<usize, CoreError>
pub fn n_dims(&self) -> Result<usize, CoreError>
The common coordinate dimensionality shared by every node in the graph.
The executor lays the flat x buffer out point-major (stride =
n_dims), so all nodes must agree on how many coordinate components a
single point carries. A graph that mixes a 1-D and a 2-D model over the
same coordinate grid is rejected.
Returns 1 for an empty graph (degenerate but harmless; evaluation
produces zeros).
§Errors
Returns CoreError::Eval if nodes declare differing n_dims.
Auto Trait Implementations§
impl !RefUnwindSafe for CompiledGraph
impl !UnwindSafe for CompiledGraph
impl Freeze for CompiledGraph
impl Send for CompiledGraph
impl Sync for CompiledGraph
impl Unpin for CompiledGraph
impl UnsafeUnpin for CompiledGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.