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.

Problem Definition

sindae.problem

The ProblemDefinition abstract base class is the single entry point for declaring an ODE/DAE system to SiNDAE. Subclass it, implement the three abstract methods, and pass an instance to any training or inference function.

The three required methods are:

Everything else has a sensible default: discretize applies Lagrange–Radau collocation, get_obs_vars defaults to the NN inputs, and get_aux_vars defaults to none. Implement the optional add_true_output_constraints only if you want to synthesize data with generate_data.

Usage

A minimal one-state ODE, dx/dt = z, where z is the unknown rate the network will learn:

import numpy as np
import pyomo.environ as pyo
import pyomo.dae as dae
from sindae.problem import ProblemDefinition


class ExponentialDecay(ProblemDefinition):
    def build_trajectory(self, block, traj_idx):
        t0 = self.t_span[0]
        block.t    = dae.ContinuousSet(bounds=self.t_span)
        block.x    = pyo.Var(block.t, range(self.input_dim), initialize=1.0)
        block.z    = pyo.Var(block.t, range(self.z_dim), initialize=0.0)
        block.dxdt = dae.DerivativeVar(block.x, wrt=block.t)

        @block.Constraint(block.t, range(self.input_dim))
        def ode(b, t, i):
            return b.dxdt[t, i] == b.z[t, 0]      # z is supplied by the network

        block.x[t0, 0].fix(float(self.ics[traj_idx, 0]))

    def get_input_vars(self, block, t):
        return [block.x[t, 0]]                    # NN input  = state x

    def get_output_vars(self, block, t):
        return [block.z[t, 0]]                    # NN output = learned rate z


problem = ExponentialDecay(
    ics=np.array([[1.0]]),     # one trajectory, x(0) = 1
    input_dim=1, z_dim=1,
    t_span=(0.0, 5.0), nfe=20, ncp=3,
)

See the examples gallery for complete ODE and DAE problems, and Defining a Network Architecture for the network side.

API reference

ProblemDefinition

class ProblemDefinition(
    ics: np.ndarray,
    input_dim: int,
    z_dim: int,
    t_span: tuple,
    nfe: int,
    ncp: int,
    obs_times: Optional[List[np.ndarray]] = None,
    obs_values: Optional[List[np.ndarray]] = None,
    obs_dim: Optional[int] = None,
    aux_vars_dim: Optional[int] = None,
)

Base class for a Neural DAE problem.

The user subclasses this and implements: build_trajectory(block, traj_idx) — base DAE (no NN, no discretization) get_input_vars(block, t) — raw Pyomo vars fed into the NN get_output_vars(block, t) — raw Pyomo vars produced by the NN get_obs_vars(block, t) — observed vars (default: same as get_input_vars) get_aux_vars(block, t) — extra vars to track (default: none)

Discretization uses Lagrange-Radau collocation by default; override discretize for custom schemes.

Parameters

Properties

Methods

build_trajectory

build_trajectory(block: pyo.Block, traj_idx: int) -> None

Add base DAE variables and constraints to block (no NN, no discretization).

Parameters

get_input_vars

get_input_vars(block: pyo.Block, t) -> list

Return the list of raw Pyomo Var objects fed into the NN at time t.

Parameters

Returns

get_output_vars

get_output_vars(block: pyo.Block, t) -> list

Return the list of raw Pyomo Var objects produced by the NN at time t.

Parameters

Returns

discretize

discretize(model: pyo.ConcreteModel) -> None

Discretize all trajectories with Lagrange-Radau collocation.

Override for non-standard schemes (e.g. different collocation type, per-trajectory nfe/ncp, or non-DAE problems).

Parameters

get_obs_vars

get_obs_vars(block: pyo.Block, t) -> list

Return observed Pyomo vars used in the data-fit objective at time t. Default: same as get_input_vars. Override when obs != NN inputs.

Parameters

Returns

get_aux_vars

get_aux_vars(block: pyo.Block, t) -> list

Return additional Pyomo vars to track in InstanceData (e.g. algebraic vars). Default: none. Override to populate TrajectoryData.aux_vars.

Parameters

Returns

add_true_output_constraints

add_true_output_constraints(block: pyo.Block) -> None

Add constraints pinning the output vars to the true formula.

Called pre-discretisation (block.t is still a ContinuousSet). Used only by generate_data — not part of normal training.

Parameters