sindae.algorithms.smoother
The smoother NLP fits a smooth trajectory to noisy observations and produces the
warm-start values and normalization statistics used by subsequent training. It penalises
the time derivative of the NN-output variable , weighted by smooth_coef
(larger ⇒ smoother fit).
SmootherConfigholds the stage’s hyperparameters; it is whatHybridDAE(smoother=...)takes.build_smoother_modelconstructs the Pyomo model.solve_smootherbuilds and solves it, returning the solved model.
Running the smoother is the first step of the standard workflow: the solved model both warm-starts the main solve (it is already built and discretized) and supplies the normalization constants for the network.
Usage¶
from sindae import extract_instance_data
from sindae.algorithms.smoother import solve_smoother
# problem.obs_times / problem.obs_values must be set (from data or generate_data)
smoother_m = solve_smoother(problem, mlp, smooth_coef=1.0)
smoother_data = extract_instance_data(problem, smoother_m)
# smoother_data feeds pre-training and supplies normalization stats;
# smoother_m can be reused as the base model for the training solve.API reference¶
SmootherConfig¶
class SmootherConfig(smooth_coef: float = 1.0)Hyperparameters for the smoother stage (used by HybridDAE).
smooth_coef weights the smoothness penalty
smooth_coef * mean((dz_smooth/dt)^2) against the data fit; larger
values give smoother warm-start trajectories.
Fields
smooth_coef(float, default1.0)
build_smoother_model¶
build_smoother_model(
problem: ProblemDefinition,
mlp: SimpleMLP,
traj_indices: List[int],
smooth_coef: float = 1.0,
unfix_io: bool = True,
) -> pyo.ConcreteModelBuild a multi-trajectory smoother NLP.
A raw auxiliary variable z_smooth[t, k] is linked to get_output_vars
and its time derivative is penalised for smoothness. No norm_input or
norm_output vars are created here; those are added post-discretisation when
the decomp or simultaneous model is built from the solved smoother.
Obs stats are computed from problem.obs_values so this can be called
before problem.norm_stats is set.
Parameters
problem(ProblemDefinition)mlp(SimpleMLP)traj_indices(List[int])smooth_coef(float, default1.0) — Weight on smoothness penalty:smooth_coef * mean((dz_smooth/dt)^2).unfix_io(bool, defaultTrue) — Unfix the NN input/output variables; set False for partially observed problems (seesolve_smoother).
Returns
m(pyo.ConcreteModel) — Extra attributes:m._traj_t_sorted: List[List[float]]m._traj_norm_target: List[np.ndarray] normalised obs targets
solve_smoother¶
solve_smoother(
problem: ProblemDefinition,
mlp: SimpleMLP,
traj_indices: Optional[List[int]] = None,
smooth_coef: float = 1.0,
solver_options: Optional[dict] = None,
nlp_solver: str = 'pounce',
timer: Optional[HierarchicalTimer] = None,
unfix_io: bool = True,
) -> pyo.ConcreteModelBuild and solve the smoother NLP, returning the solved model.
Parameters
problem(ProblemDefinition)mlp(SimpleMLP)traj_indices(Optional[List[int]], defaultNone)smooth_coef(float, default1.0)solver_options(Optional[dict], defaultNone) — Options for the NLP solver, e.g.{'tol': 1e-6, 'max_iter': 500}.nlp_solver(str, default'pounce') — NLP solver backend.timer(Optional[HierarchicalTimer], defaultNone)unfix_io(bool, defaultTrue) — Unfix the NN input/output variables so the smoother can move them off the data. Set False for partially observed problems: unmeasured states have no data anchor, and leaving their variables free makes the solve diverge.
Returns
m(pyo.ConcreteModel(solved))