|
Janus 2.0.0
High-performance C++20 dual-mode numerical framework
|
janus::BirkhoffPseudospectral is a Birkhoff-form pseudospectral transcription where state-derivative variables are collocated directly and states are recovered through a linear integration matrix. Unlike classical pseudospectral methods that use a dense differentiation matrix D*X, the Birkhoff form keeps dense coupling mostly in linear constraints (X = x_a * 1 + B * V) while dynamics constraints are pointwise (V_i = (dt/2) * f(X_i, U_i, t_i)). This gives improved numerical conditioning at higher node counts. Works in symbolic mode via the janus::Opti interface. The class lives in <janus/optimization/BirkhoffPseudospectral.hpp>.
| Method | Description |
|---|---|
| BirkhoffPseudospectral(opti) | Construct with a janus::Opti instance |
| setup(n_states, n_controls, t0, tf, opts) | Create decision variables and time grid |
| set_dynamics(ode) | Set the ODE function: (x, u, t) -> dxdt |
| add_dynamics_constraints() | Apply Birkhoff dynamics and state-recovery constraints |
| add_defect_constraints() | Alias for add_dynamics_constraints() |
| set_initial_state(x0) | Set initial boundary condition |
| set_final_state(xf) | Set final boundary condition |
| n_nodes() | Number of collocation nodes |
| time_grid() | Normalized time grid [0, 1] |
| integration_matrix() | Access the Birkhoff integration matrix B |
| quadrature_weights() | Access the quadrature weight vector |
| quadrature(integrand) | Compute weighted integral of an integrand vector |
| virtual_vars() | Access the virtual (state-derivative) decision variables V |
For nodes on [-1, 1]:
B is the Birkhoff integration matrix with entries:
The file examples/optimization/transcription_comparison_demo.cpp compares Direct Collocation, Multiple Shooting, classical Pseudospectral, and Birkhoff Pseudospectral on the same problem with performance and convergence output.
The virtual variables V represent the scaled state derivatives at each node. They are additional decision variables beyond X and U, which is why the Birkhoff formulation has more decision variables than classical pseudospectral but trades that for better conditioning and pointwise nonlinear structure.