numra-ocp 0.1.1

ODE-constrained optimization for Numra: single and multiple shooting, collocation, adjoint sensitivity, parameter estimation for ODE models.
Documentation

numra-ocp

ODE-constrained optimization for the Numra workspace — single and multiple shooting, direct collocation, adjoint gradients, and parameter estimation for ODE models against measured data.

Crates.io docs.rs

Bridges numra-ode and numra-optim: the ODE solver runs in the inner loop, the optimizer minimizes over parameters / initial conditions / controls. Gradients can come from forward sensitivity (via ParametricOdeSystem), adjoint methods, or autodiff bridges.

Example

use numra_ocp::{OdeSolverChoice, ParamEstProblem};

// Recover k from data generated by y' = -k·y with k = 2
let t_data: Vec<f64> = (0..11).map(|i| i as f64 * 0.1).collect();
let y_data: Vec<f64> = t_data.iter().map(|&t| (-2.0 * t).exp()).collect();

let r = ParamEstProblem::new(1, 1)
    .model(|_t, y: &[f64], dy: &mut [f64], p: &[f64]| dy[0] = -p[0] * y[0])
    .data(t_data, y_data)
    .params(vec![1.0])
    .initial_state(vec![1.0])
    .ode_solver(OdeSolverChoice::DoPri5)
    .solve()
    .unwrap();

assert!((r.params[0] - 2.0).abs() < 0.1);

What's in this crate

  • ParamEstProblem — declarative parameter-estimation builder for ODE models against time-series data
  • ShootingProblem — single-shooting optimal control
  • MultipleShootingProblem — multiple-shooting variant for unstable systems
  • CollocationProblem — direct collocation with configurable CollocationScheme
  • adjoint_gradient / AdjointResult — adjoint-method gradients for the cost functional
  • forward_sensitivity / SensitivityResult — forward sensitivity matrices (re-exposed for OCP callers)

Composes with

  • numra-ode — inner ODE solver in shooting / collocation
  • numra-optim — outer optimizer for the parameter / control problem
  • numra-autodiff — analytical Jacobians for ODE sensitivity
  • numra-fit — alternative residual-based fitting for simple models

See interop workflows for the verified parameter-estimation → sensitivity → uncertainty workflow.

Install

[dependencies]
numra-ocp = "0.1"

Or via the umbrella crate:

[dependencies]
numra = "0.1"

Documentation

License

Numra Academic & Research License (Non-Commercial). Academic and research use is free; commercial use requires a separate license — contact contact@spectralautomata.com. See LICENSE.