Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Inference

sindae.algorithms.inference

Embed a trained MLP back into a new (or the same) DAE problem and solve for the trajectory consistent with the learned dynamics. The network is enforced as a hard GBM output constraint by default (slack_coef=0, a square system solved by POUNCE), or relaxed via an 1\ell_1 slack (slack_coef > 0) when the trained network does not fit the inference problem’s dynamics exactly.

Because the mechanistic equations remain hard constraints, predictions stay physically consistent even at initial conditions never seen during training.

Usage

import numpy as np
from sindae import extract_instance_data
from sindae.algorithms.inference import solve_inference

# New initial conditions — the discretization may also differ from training.
val_problem = MyProblem(
    ics=np.array([[5.0, 0.3]]),
    input_dim=2, z_dim=1, t_span=(0, 80), nfe=20, ncp=2,
)

inference_m = solve_inference(
    val_problem, mlp,
    data=trained_data,        # normalization stats from training
    slack_coef=1e-5,          # small l1 relaxation; use 0.0 for a hard constraint
)
prediction = extract_instance_data(val_problem, inference_m)

API reference

make_inference_model

make_inference_model(
    problem: ProblemDefinition,
    mlp: SimpleMLP,
    traj_indices: List[int],
    data: InstanceData,
    slack_coef: float = 0.0,
) -> pyo.ConcreteModel

Build an inference NLP: DAE + trained NN embedded as a GBM constraint.

Parameters

Returns

solve_inference

solve_inference(
    problem: ProblemDefinition,
    mlp: SimpleMLP,
    data: InstanceData,
    traj_indices: Optional[List[int]] = None,
    slack_coef: float = 0.0,
    solver_options: Optional[dict] = None,
    nlp_solver: str = 'pounce',
    tee: bool = False,
    timer: Optional[HierarchicalTimer] = None,
) -> pyo.ConcreteModel

Build and solve the inference NLP, returning the solved model.

Parameters

Returns