Janus 2.0.0
High-performance C++20 dual-mode numerical framework
Loading...
Searching...
No Matches
janus::DirectCollocation Class Reference

Direct collocation transcription. More...

#include <Collocation.hpp>

Inheritance diagram for janus::DirectCollocation:
Collaboration diagram for janus::DirectCollocation:

Public Member Functions

 DirectCollocation (Opti &opti)
 Construct with a reference to the optimization environment.
std::tuple< SymbolicMatrix, SymbolicMatrix, NumericVectorsetup (int n_states, int n_controls, double t0, double tf, const CollocationOptions &opts={})
 Set up the collocation problem with fixed final time.
std::tuple< SymbolicMatrix, SymbolicMatrix, NumericVectorsetup (int n_states, int n_controls, double t0, const SymbolicScalar &tf, const CollocationOptions &opts={})
 Set up the collocation problem with variable final time.
SymbolicScalar quadrature (const SymbolicVector &integrand) const
 Composite quadrature for an integrand sampled at collocation nodes.
int n_intervals () const
 Get the number of collocation intervals.
Public Member Functions inherited from janus::TranscriptionBase< DirectCollocation >
 TranscriptionBase (Opti &opti)
 Construct with a reference to the optimization environment.
void set_initial_state (const NumericVector &x0)
 Pin all initial states to specified values.
void set_final_state (const NumericVector &xf)
 Pin all final states to specified values.
void set_dynamics (Func &&dynamics)
 Register the dynamics function xdot = f(x, u, t).
const SymbolicMatrixstates () const
 Get the state decision variable matrix.
const SymbolicMatrixcontrols () const
 Get the control decision variable matrix.
const NumericVectortime_grid () const
 Get the normalized time grid.
int n_nodes () const
 Get the number of discretization nodes.
int n_states () const
 Get the number of state variables per node.
int n_controls () const
 Get the number of control variables per node.
void add_dynamics_constraints ()
 Add dynamics constraints to the optimization problem.
void add_defect_constraints ()
 Alias for add_dynamics_constraints().
void add_continuity_constraints ()
 Alias for add_dynamics_constraints().

Friends

class TranscriptionBase< DirectCollocation >

Additional Inherited Members

Protected Member Functions inherited from janus::TranscriptionBase< DirectCollocation >
SymbolicScalar get_duration () const
SymbolicScalar get_time_at_node (int k) const
SymbolicVector get_state_at_node (int k) const
SymbolicVector get_control_at_node (int k) const
Protected Attributes inherited from janus::TranscriptionBase< DirectCollocation >
Optiopti_
int n_states_
int n_controls_
int n_nodes_
double t0_
double tf_fixed_
SymbolicScalar tf_symbolic_
bool tf_is_variable_
bool setup_complete_
bool dynamics_set_
bool dynamics_constraints_added_
NumericVector tau_
SymbolicMatrix states_
SymbolicMatrix controls_
std::function< SymbolicVector(const SymbolicVector &, const SymbolicVector &, const SymbolicScalar &)> dynamics_

Detailed Description

Direct collocation transcription.

See also
TranscriptionBase for shared interface
CollocationOptions for configuration

Constructor & Destructor Documentation

◆ DirectCollocation()

janus::DirectCollocation::DirectCollocation ( Opti & opti)
inlineexplicit

Construct with a reference to the optimization environment.

Parameters
optiOpti instance

Member Function Documentation

◆ n_intervals()

int janus::DirectCollocation::n_intervals ( ) const
inline

Get the number of collocation intervals.

Returns
n_nodes - 1

◆ quadrature()

SymbolicScalar janus::DirectCollocation::quadrature ( const SymbolicVector & integrand) const
inline

Composite quadrature for an integrand sampled at collocation nodes.

Trapezoidal scheme uses composite trapezoidal weights. Hermite-Simpson uses composite Simpson when possible (even number of intervals), otherwise falls back to trapezoidal.

Parameters
integrandsymbolic vector of integrand values at each node
Returns
symbolic scalar approximation of the definite integral

◆ setup() [1/2]

std::tuple< SymbolicMatrix, SymbolicMatrix, NumericVector > janus::DirectCollocation::setup ( int n_states,
int n_controls,
double t0,
const SymbolicScalar & tf,
const CollocationOptions & opts = {} )
inline

Set up the collocation problem with variable final time.

Parameters
n_statesnumber of state variables
n_controlsnumber of control variables
t0initial time
tfsymbolic final time (decision variable)
optscollocation options
Returns
tuple of (states, controls, time_grid)

◆ setup() [2/2]

std::tuple< SymbolicMatrix, SymbolicMatrix, NumericVector > janus::DirectCollocation::setup ( int n_states,
int n_controls,
double t0,
double tf,
const CollocationOptions & opts = {} )
inline

Set up the collocation problem with fixed final time.

Parameters
n_statesnumber of state variables
n_controlsnumber of control variables
t0initial time
tffinal time
optscollocation options
Returns
tuple of (states, controls, time_grid)

◆ TranscriptionBase< DirectCollocation >

friend class TranscriptionBase< DirectCollocation >
friend

The documentation for this class was generated from the following file: