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.

Simultaneous Solver

sindae.algorithms.simultaneous

The simultaneous approach embeds the NN weights and biases directly in a single large NLP and optimizes states, NN outputs, and NN parameters jointly in one solver call — no outer training loop. Two backends are available, selected by SimultaneousConfig.use_gbm:

use_gbmBackendSolverHessian
False (default)expression-writingPOUNCEexact
Truegrey-box (GBM)POUNCEL-BFGS (limited-memory)

The expression-writing backend rewrites the SimpleMLP as explicit Pyomo expressions and gets an exact Hessian; the grey-box backend treats the network as a black box (function + Jacobian) and works with any smooth Equinox module. See Defining a Network Architecture for the trade-offs.

Usage

from sindae import extract_instance_data
from sindae.algorithms.simultaneous.train import SimultaneousConfig, solve_simultaneous

cfg = SimultaneousConfig(use_gbm=False, reg_coef=1e-3)   # expression-writing, exact Hessian

trained_m, mlp = solve_simultaneous(
    problem, mlp, cfg,
    data=smoother_data,              # normalization statistics
    smoother_model=smoother_m,       # reuse the discretized smoother as a warm start
    solver_options={'tol': 1e-6, 'max_iter': 1000},
)
trained_data = extract_instance_data(problem, trained_m)

For problems whose exact Hessian is awkward (e.g. ratio terms like P/XP/X), switch to the grey-box variant with a limited-memory Hessian:

cfg = SimultaneousConfig(use_gbm=True, reg_coef=1e-3)
trained_m, mlp = solve_simultaneous(
    problem, mlp, cfg, data=smoother_data, smoother_model=smoother_m,
    solver_options={'tol': 1e-6, 'max_iter': 1000,
                    'hessian_approximation': 'limited-memory'},
)

API reference

SimultaneousConfig

class SimultaneousConfig(use_gbm: bool = False, reg_coef: float = 0.0)

Hyperparameters for the simultaneous (single-NLP) training approach.

Fields

build_simultaneous_model

build_simultaneous_model(
    problem: ProblemDefinition,
    mlp: SimpleMLP,
    traj_indices: List[int],
    data: InstanceData,
    smoother_model: Optional[pyo.ConcreteModel] = None,
    reg_coef: float = 0.0,
    unfix_io: bool = True,
) -> pyo.ConcreteModel

Build a simultaneous NLP using expression-writing.

NN weights and biases are Pyomo decision variables (as an NNBlock). The NN forward pass is written symbolically as Pyomo arithmetic expressions, yielding exact second-order information (Hessian available for IPOPT).

Parameters

Returns

build_simultaneous_model_gbm

build_simultaneous_model_gbm(
    problem: ProblemDefinition,
    mlp: SimpleMLP,
    traj_indices: List[int],
    data: InstanceData,
    smoother_model: Optional[pyo.ConcreteModel] = None,
    reg_coef: float = 0.0,
    unfix_io: bool = True,
) -> pyo.ConcreteModel

Build a simultaneous NLP using the grey-box (GBM) formulation.

The NN parameters theta are flat Pyomo Var objects (m.nn_params). NNSimulGreyBoxModel evaluates NN(norm_input; theta) and provides the Jacobian w.r.t. both norm_input and theta via JAX.

Because no Hessian is provided, IPOPT must use L-BFGS (hessian_approximation='limited-memory').

Parameters

Returns

extract_mlp

extract_mlp(m: pyo.ConcreteModel) -> SimpleMLP

Extract a SimpleMLP with the optimised weights from a solved simultaneous model.

Works for both the expression-writing path (reads Pyomo NNBlock Var values) and the GBM path (reads flat Pyomo Var values).

Parameters

Returns

solve_simultaneous

solve_simultaneous(
    problem: ProblemDefinition,
    mlp: SimpleMLP,
    cfg: SimultaneousConfig,
    data: InstanceData,
    smoother_model: Optional[pyo.ConcreteModel] = None,
    solver_options: Optional[dict] = None,
    nlp_solver: Optional[str] = None,
    traj_indices: Optional[List[int]] = None,
    tee: bool = False,
    timer: Optional[HierarchicalTimer] = None,
    unfix_io: bool = True,
) -> Tuple[pyo.ConcreteModel, SimpleMLP]

Build and solve the simultaneous NLP, returning the solved model and the trained SimpleMLP.

Parameters

Returns