OCS2 Manual  v1.0.0
OCS2 Documentation
ocs2_ocs2

Detailed Description

Classes

class  ocs2::FrankWolfeGDDP< STATE_DIM, INPUT_DIM >
 
class  ocs2::GDDP< STATE_DIM, INPUT_DIM >
 
class  ocs2::GDDP_Settings
 
class  ocs2::GSLQSolver< STATE_DIM, INPUT_DIM, OUTPUT_DIM, NUM_Subsystems >
 
class  ocs2::NumGDDP< STATE_DIM, INPUT_DIM >
 
class  ocs2::OCS2< STATE_DIM, INPUT_DIM >
 
class  ocs2::BvpSensitivityEquations< STATE_DIM, INPUT_DIM >
 
class  ocs2::BvpSensitivityErrorEquations< STATE_DIM, INPUT_DIM >
 
class  ocs2::RolloutSensitivityEquations< STATE_DIM, INPUT_DIM >
 
class  ocs2::SensitivitySequentialRiccatiEquations< STATE_DIM, INPUT_DIM >
 
class  ocs2::UpperLevelConstraints
 
class  ocs2::UpperLevelCost< STATE_DIM, INPUT_DIM >
 

Functions

void ocs2::GDDP_Settings::loadSettings (const std::string &filename, const std::string &fieldName="gddp", bool verbose=true)
 
 ocs2::FrankWolfeGDDP< STATE_DIM, INPUT_DIM >::FrankWolfeGDDP (const GDDP_Settings &gddpSettings)
 
void ocs2::FrankWolfeGDDP< STATE_DIM, INPUT_DIM >::run (const slq_data_collector_t *dcPtr, const dynamic_vector_t &maxGradientInverse, NLP_Constraints *eventTimeConstraintPtr)
 
 ocs2::GDDP< STATE_DIM, INPUT_DIM >::GDDP (GDDP_Settings gddpSettings)
 
virtual void ocs2::GDDP< STATE_DIM, INPUT_DIM >::setupOptimizer (const size_t &numPartitions)
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::calculateRolloutCostate (const scalar_array2_t &timeTrajectoriesStock, const state_vector_array2_t &stateTrajectoriesStock, state_vector_array2_t &costateTrajectoriesStock, scalar_t learningRate=0.0)
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::calculateRolloutCostate (const std::vector< scalar_array_t > &timeTrajectoriesStock, state_vector_array2_t &costateTrajectoriesStock)
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::calculateNominalRolloutLagrangeMultiplier (const scalar_array2_t &timeTrajectoriesStock, constraint1_vector_array2_t &lagrangeTrajectoriesStock)
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::computeEquivalentSystemMultiplier (const size_t &eventTimeIndex, const size_t &activeSubsystem, scalar_t &multiplier) const
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::getRolloutSensitivity2EventTime (const size_t &eventTimeIndex, std::vector< scalar_array_t > &sensitivityTimeTrajectoriesStock, state_matrix_array2_t &sensitivityStateTrajectoriesStock, input_matrix_array2_t &sensitivityInputTrajectoriesStock)
 
GDDP_Settingsocs2::GDDP< STATE_DIM, INPUT_DIM >::settings ()
 
template<typename Derived >
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::getCostFuntionDerivative (Eigen::MatrixBase< Derived > const &costFunctionDerivative) const
 
const scalar_array_tocs2::GDDP< STATE_DIM, INPUT_DIM >::eventTimes () const
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::propagateRolloutSensitivity (size_t workerIndex, const size_t &eventTimeIndex, const linear_controller_array_t &controllersStock, const input_vector_array2_t &LvTrajectoriesStock, const scalar_array2_t &sensitivityTimeTrajectoriesStock, const size_array2_t &postEventIndicesStock, state_vector_array2_t &sensitivityStateTrajectoriesStock, input_vector_array2_t &sensitivityInputTrajectoriesStock)
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::approximateNominalLQPSensitivity2EventTime (const state_vector_array2_t &sensitivityStateTrajectoriesStock, const input_vector_array2_t &sensitivityInputTrajectoriesStock, eigen_scalar_array2_t &nablaqTrajectoriesStock, state_vector_array2_t &nablaQvTrajectoriesStock, input_vector_array2_t &nablaRvTrajectoriesStock, eigen_scalar_array2_t &nablaqFinalStock, state_vector_array2_t &nablaQvFinalStock) const
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::approximateNominalHeuristicsSensitivity2EventTime (const state_vector_t &sensitivityFinalState, eigen_scalar_t &nablasHeuristics, state_vector_t &nablaSvHeuristics) const
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::solveSensitivityRiccatiEquations (size_t workerIndex, const size_t &eventTimeIndex, const scalar_t &learningRate, const eigen_scalar_t &nablasHeuristics, const state_vector_t &nablaSvHeuristics, const state_matrix_t &nablaSmHeuristics, eigen_scalar_array2_t &nablasTrajectoriesStock, state_vector_array2_t &nablaSvTrajectoriesStock, state_matrix_array2_t &nablaSmTrajectoriesStock)
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::solveSensitivityBVP (size_t workerIndex, const size_t &eventTimeIndex, const state_vector_t &MvFinal, const state_vector_t &MveFinal, state_vector_array2_t &MvTrajectoriesStock, state_vector_array2_t &MveTrajectoriesStock)
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::calculateLQSensitivityControllerForward (size_t workerIndex, const size_t &eventTimeIndex, const scalar_array2_t &timeTrajectoriesStock, const state_vector_array2_t &nablaSvTrajectoriesStock, input_vector_array2_t &nablaLvTrajectoriesStock)
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::calculateBVPSensitivityControllerForward (size_t workerIndex, const size_t &eventTimeIndex, const scalar_array2_t &timeTrajectoriesStock, const state_vector_array2_t &MvTrajectoriesStock, const state_vector_array2_t &MveTrajectoriesStock, input_vector_array2_t &LvTrajectoriesStock)
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::getValueFuntionSensitivity (const size_t &eventTimeIndex, const scalar_t &time, const state_vector_t &state, scalar_t &valueFunctionDerivative)
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::calculateCostDerivative (size_t workerIndex, const size_t &eventTimeIndex, const state_vector_array2_t &sensitivityStateTrajectoriesStock, const input_vector_array2_t &sensitivityInputTrajectoriesStock, scalar_t &costDerivative) const
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::runLQBasedMethod ()
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::runSweepingBVPMethod ()
 
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::run (const slq_data_collector_t *dcPtr)
 
size_t ocs2::GSLQSolver< STATE_DIM, INPUT_DIM, OUTPUT_DIM, NUM_Subsystems >::findNearestController (const Eigen::Matrix< double, NUM_Subsystems - 1, 1 > &parameters) const
 
void ocs2::GSLQSolver< STATE_DIM, INPUT_DIM, OUTPUT_DIM, NUM_Subsystems >::run (const double &initTime, const state_vector_t &initState, const std::vector< scalar_t > &switchingTimes)
 
 ocs2::NumGDDP< STATE_DIM, INPUT_DIM >::NumGDDP (const controlled_system_base_t *systemDynamicsPtr, const derivatives_base_t *systemDerivativesPtr, const constraint_base_t *systemConstraintsPtr, const cost_function_base_t *costFunctionPtr, const operating_trajectories_base_t *operatingTrajectoriesPtr, const SLQ_Settings &settings=SLQ_Settings(), const LOGIC_RULES_T *logicRulesPtr=nullptr, const cost_function_base_t *heuristicsFunctionPtr=nullptr)
 
template<typename Derived >
void ocs2::NumGDDP< STATE_DIM, INPUT_DIM >::getCostFuntionDerivative (Eigen::MatrixBase< Derived > const &costFunctionDerivative) const
 
void ocs2::NumGDDP< STATE_DIM, INPUT_DIM >::setSolverEventTime (const scalar_array_t &eventTimes)
 
void ocs2::NumGDDP< STATE_DIM, INPUT_DIM >::run (const scalar_t &initTime, const state_vector_t &initState, const scalar_t &finalTime, const scalar_array_t &partitioningTimes, const scalar_array_t &eventTimes)
 
 ocs2::OCS2< STATE_DIM, INPUT_DIM >::OCS2 (const rollout_base_t *rolloutPtr, const derivatives_base_t *systemDerivativesPtr, const constraint_base_t *systemConstraintsPtr, const cost_function_base_t *costFunctionPtr, const operating_trajectories_base_t *operatingTrajectoriesPtr, const SLQ_Settings &settings, std::shared_ptr< ModeScheduleManager< STATE_DIM, INPUT_DIM >> modeScheduleManagerPtr, const cost_function_base_t *heuristicsFunctionPtr=nullptr, const GDDP_Settings &gddpSettings=GDDP_Settings(), const NLP_Settings &nlpSettings=NLP_Settings())
 
GDDP_Settingsocs2::OCS2< STATE_DIM, INPUT_DIM >::gddpSettings ()
 
SLQ_Settings & ocs2::OCS2< STATE_DIM, INPUT_DIM >::slqSettings ()
 
NLP_Settingsocs2::OCS2< STATE_DIM, INPUT_DIM >::nlpSettings ()
 
void ocs2::OCS2< STATE_DIM, INPUT_DIM >::getIterationsLog (scalar_array_t &iterationCost) const
 
void ocs2::OCS2< STATE_DIM, INPUT_DIM >::getParameters (dynamic_vector_t &parameters) const
 
void ocs2::OCS2< STATE_DIM, INPUT_DIM >::getCost (scalar_t &cost) const
 
void ocs2::OCS2< STATE_DIM, INPUT_DIM >::run (const scalar_t &initTime, const state_vector_t &initState, const scalar_t &finalTime, const scalar_array_t &partitioningTimes, const scalar_array_t &initEventTimes)
 

Function Documentation

◆ approximateNominalHeuristicsSensitivity2EventTime()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::approximateNominalHeuristicsSensitivity2EventTime ( const state_vector_t sensitivityFinalState,
eigen_scalar_t nablasHeuristics,
state_vector_t nablaSvHeuristics 
) const
protected

Approximates nominal LQ problem sensitivity to event times.

Parameters
[in]sensitivityFinalStateFinal state sensitivity.
[out]nablasHeuristicsSensitivity of the Heuristics zero order variation.
[out]nablaSvHeuristicsSensitivity of the Heuristics first order state variation.

◆ approximateNominalLQPSensitivity2EventTime()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::approximateNominalLQPSensitivity2EventTime ( const state_vector_array2_t sensitivityStateTrajectoriesStock,
const input_vector_array2_t sensitivityInputTrajectoriesStock,
eigen_scalar_array2_t nablaqTrajectoriesStock,
state_vector_array2_t nablaQvTrajectoriesStock,
input_vector_array2_t nablaRvTrajectoriesStock,
eigen_scalar_array2_t nablaqFinalStock,
state_vector_array2_t nablaQvFinalStock 
) const
protected

Approximates nominal LQ problem sensitivity to event times.

Parameters
[in]sensitivityStateTrajectoriesStockArray of state sensitivity trajectory.
[in]sensitivityInputTrajectoriesStockArray of input sensitivity trajectory.
[out]nablaqTrajectoriesStockSensitivity of the cost's zero order variation.
[out]nablaQvTrajectoriesStockSensitivity of the cost's first order state variation.
[out]nablaRvTrajectoriesStockSensitivity of the cost's first order input variation.
[out]nablaqFinalStockSensitivity of the final cost's zero order variation.
[out]nablaQvFinalStockSensitivity of the final cost's first order state variation.

◆ calculateBVPSensitivityControllerForward()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::calculateBVPSensitivityControllerForward ( size_t  workerIndex,
const size_t &  eventTimeIndex,
const scalar_array2_t timeTrajectoriesStock,
const state_vector_array2_t MvTrajectoriesStock,
const state_vector_array2_t MveTrajectoriesStock,
input_vector_array2_t LvTrajectoriesStock 
)
protected

calculate the sensitivity of the control input increment to event times based on the BVP method.

Parameters
[in]workerIndexWorking agent index.
[in]eventTimeIndexEvent time index.
[in]timeTrajectoriesStockTime stamp of the BVP solution
[in]MvTrajectoriesStockBVP solution for Mv.
[in]MveTrajectoriesStockBVP solution for Mve.
[out]LvTrajectoriesStockSensitivity of the control input increment to event times.

◆ calculateCostDerivative()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::calculateCostDerivative ( size_t  workerIndex,
const size_t &  eventTimeIndex,
const state_vector_array2_t sensitivityStateTrajectoriesStock,
const input_vector_array2_t sensitivityInputTrajectoriesStock,
scalar_t costDerivative 
) const
protected

calculates cost function derivative based on BVP solution

Parameters
[in]workerIndexWorking agent index.
[in]eventTimeIndexEvent time index.
[in]sensitivityStateTrajectoriesStockArray of state sensitivity trajectory.
[in]sensitivityInputTrajectoriesStockArray of input sensitivity trajectory.
[out]costDerivativeThe cost function's derivative w.r.t. an event time.

◆ calculateLQSensitivityControllerForward()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::calculateLQSensitivityControllerForward ( size_t  workerIndex,
const size_t &  eventTimeIndex,
const scalar_array2_t timeTrajectoriesStock,
const state_vector_array2_t nablaSvTrajectoriesStock,
input_vector_array2_t nablaLvTrajectoriesStock 
)
protected

Calculates controller's feedforward part sensitivity for the LQ method.

Parameters
[in]workerIndexWorking agent index.
[in]eventTimeIndexEvent time index.
[in]timeTrajectoriesStockTime stamp of the Riccati solution
[in]nablaSvTrajectoriesStockSensitivity of the Riccati equations's first order variation.
[out]nablaLvTrajectoriesStockSensitivity of the control input increment to event times.

◆ calculateNominalRolloutLagrangeMultiplier()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::calculateNominalRolloutLagrangeMultiplier ( const scalar_array2_t timeTrajectoriesStock,
constraint1_vector_array2_t lagrangeTrajectoriesStock 
)
protected

Computes the Lagrange multiplier of the state-input constraint over the given time trajectory.

Parameters
[in]timeTrajectoriesStockthe inquiry rollout time
[out]lagrangeTrajectoriesStocklagrangeMultiplier value over the given trajectory

◆ calculateRolloutCostate() [1/2]

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::calculateRolloutCostate ( const scalar_array2_t timeTrajectoriesStock,
const state_vector_array2_t stateTrajectoriesStock,
state_vector_array2_t costateTrajectoriesStock,
scalar_t  learningRate = 0.0 
)
protected

Computes the costate over the given rollout.

Parameters
[in]timeTrajectoriesStockthe inquiry rollout time
[in]stateTrajectoriesStockthe inquiry rollout state
[out]costateTrajectoriesStockcostate vector for the given trajectory
[in]learningRatethe learning rate.

◆ calculateRolloutCostate() [2/2]

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::calculateRolloutCostate ( const std::vector< scalar_array_t > &  timeTrajectoriesStock,
state_vector_array2_t costateTrajectoriesStock 
)
protected

Computes the nominal costate over the given time.

Parameters
[in]timeTrajectoriesStockthe inquiry rollout time
[out]costateTrajectoriesStockcostate vector for the given trajectory
[in]learningRatethe learning rate.

◆ computeEquivalentSystemMultiplier()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::computeEquivalentSystemMultiplier ( const size_t &  eventTimeIndex,
const size_t &  activeSubsystem,
scalar_t multiplier 
) const
protected

Computes the equivalent system formulation multiplier. which is $ \frac{\delta_{i,j}-\delta_{i-1,j}}{t_{i}-t_{i-1}} $ where i is activeSubsystem and j is eventTimeIndex.

Parameters
[in]eventTimeIndexEvent time index.
[in]activeSubsystemCurrent active subsystem index.
[out]multiplierEquivalent system formulation multiplier.

◆ eventTimes()

template<size_t STATE_DIM, size_t INPUT_DIM>
const GDDP< STATE_DIM, INPUT_DIM >::scalar_array_t & ocs2::GDDP< STATE_DIM, INPUT_DIM >::eventTimes ( ) const

Gets a constant reference to the event time vector.

Returns
A constant reference to the event time vector.

◆ findNearestController()

template<size_t STATE_DIM, size_t INPUT_DIM, size_t OUTPUT_DIM, size_t NUM_Subsystems>
size_t ocs2::GSLQSolver< STATE_DIM, INPUT_DIM, OUTPUT_DIM, NUM_Subsystems >::findNearestController ( const Eigen::Matrix< double, NUM_Subsystems - 1, 1 > &  parameters) const
protected

◆ FrankWolfeGDDP()

template<size_t STATE_DIM, size_t INPUT_DIM>
ocs2::FrankWolfeGDDP< STATE_DIM, INPUT_DIM >::FrankWolfeGDDP ( const GDDP_Settings gddpSettings)
explicit

Constructor.

Parameters
[in]settingsStructure containing the settings for the SLQ algorithm.

◆ GDDP()

template<size_t STATE_DIM, size_t INPUT_DIM>
ocs2::GDDP< STATE_DIM, INPUT_DIM >::GDDP ( GDDP_Settings  gddpSettings)
explicit

Constructor.

Parameters
[in]settingsStructure containing the settings for the GDDP algorithm.

◆ gddpSettings()

template<size_t STATE_DIM, size_t INPUT_DIM>
GDDP_Settings & ocs2::OCS2< STATE_DIM, INPUT_DIM >::gddpSettings ( )

Gets a reference to the GDDP settings structure.

Returns
a reference to the GDDP settings.

◆ getCost()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::OCS2< STATE_DIM, INPUT_DIM >::getCost ( scalar_t cost) const

Gets the cost.

Parameters
[out]costvalue

◆ getCostFuntionDerivative() [1/2]

template<size_t STATE_DIM, size_t INPUT_DIM>
template<typename Derived >
void ocs2::NumGDDP< STATE_DIM, INPUT_DIM >::getCostFuntionDerivative ( Eigen::MatrixBase< Derived > const &  costFunctionDerivative) const

Calculates the cost function's derivatives w.r.t. event times.

Parameters
[out]costFunctionDerivativecost function's derivatives w.r.t. event times.

◆ getCostFuntionDerivative() [2/2]

template<size_t STATE_DIM, size_t INPUT_DIM>
template<typename Derived >
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::getCostFuntionDerivative ( Eigen::MatrixBase< Derived > const &  costFunctionDerivative) const

Calculates the cost function's derivatives w.r.t. event times.

Parameters
[out]costFunctionDerivativecost function's derivatives w.r.t. event times.

◆ getIterationsLog()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::OCS2< STATE_DIM, INPUT_DIM >::getIterationsLog ( scalar_array_t iterationCost) const

Gets the iteration cost log.

Parameters
[out]iterationCostThe cost value in each iteration.

◆ getParameters()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::OCS2< STATE_DIM, INPUT_DIM >::getParameters ( dynamic_vector_t parameters) const

Gets the parameter vector.

Parameters
[out]parametersthe parameter vector

◆ getRolloutSensitivity2EventTime()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::getRolloutSensitivity2EventTime ( const size_t &  eventTimeIndex,
std::vector< scalar_array_t > &  sensitivityTimeTrajectoriesStock,
state_matrix_array2_t sensitivityStateTrajectoriesStock,
input_matrix_array2_t sensitivityInputTrajectoriesStock 
)

Gets the calculated rollout's sensitivity to an event time.

Parameters
[in]eventTimeIndexEvent time index.
[out]sensitivityTimeTrajectoriesStocktime stamps of the sensitivity values.
[out]sensitivityStateTrajectoriesStockstate trajectory sensitivity to the switching times.
[out]sensitivityInputTrajectoriesStockcontrol input trajectory sensitivity to the switching times.

◆ getValueFuntionSensitivity()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::getValueFuntionSensitivity ( const size_t &  eventTimeIndex,
const scalar_t time,
const state_vector_t state,
scalar_t valueFunctionDerivative 
)
protected

Calculates the value function's derivative w.r.t. an event time for a given time and state.

Parameters
[in]eventTimeIndexEvent time index.
[in]timeThe inquired time.
[in]stateThe inquired state.
[out]valueFunctionDerivativeThe value function's derivative w.r.t. an event time.

◆ loadSettings()

void ocs2::GDDP_Settings::loadSettings ( const std::string &  filename,
const std::string &  fieldName = "gddp",
bool  verbose = true 
)
inline

This function loads the "GDDP_Settings" variables from a config file. This file contains the settings for the SQL and OCS2 algorithms. Here, we use the INFO format which was created specifically for the property tree library (refer to www.goo.gl/fV3yWA).

It has the following format:
slq
{
maxIterationGDDP value
minLearningRateGDDP value
maxLearningRateGDDP value
minRelCostGDDP value
(and so on for the other fields)
}

If a value for a specific field is not defined it will set to the default value defined in "GDDP_Settings".

Parameters
[in]filenameFile name which contains the configuration data.
[in]fieldNameField name which contains the configuration data (the default is slq).
[in]verboseFlag to determine whether to print out the loaded settings or not (the default is true).

◆ nlpSettings()

template<size_t STATE_DIM, size_t INPUT_DIM>
NLP_Settings & ocs2::OCS2< STATE_DIM, INPUT_DIM >::nlpSettings ( )

Gets a constant reference to the NLP of settings.

Returns
A constant reference to the NLP of settings.

◆ NumGDDP()

template<size_t STATE_DIM, size_t INPUT_DIM>
ocs2::NumGDDP< STATE_DIM, INPUT_DIM >::NumGDDP ( const controlled_system_base_t *  systemDynamicsPtr,
const derivatives_base_t *  systemDerivativesPtr,
const constraint_base_t *  systemConstraintsPtr,
const cost_function_base_t *  costFunctionPtr,
const operating_trajectories_base_t *  operatingTrajectoriesPtr,
const SLQ_Settings &  settings = SLQ_Settings(),
const LOGIC_RULES_T *  logicRulesPtr = nullptr,
const cost_function_base_t *  heuristicsFunctionPtr = nullptr 
)

Constructor.

Parameters
[in]systemDynamicsPtrThe system dynamics which possibly includes some subsystems.
[in]systemDerivativesPtrThe system dynamics derivatives for subsystems of the system.
[in]systemConstraintsPtrThe system constraint function and its derivatives for subsystems.
[in]costFunctionPtrThe cost function (intermediate and terminal costs) and its derivatives for subsystems.
[in]operatingTrajectoriesPtrThe operating trajectories of system which will be used for initialization of SLQ.
[in]settingsStructure containing the settings for the SLQ algorithm.
[in]logicRulesPtrThe logic rules used for implementing mixed logical dynamical systems.
[in]heuristicsFunctionPtrHeuristic function used in the infinite time optimal control formulation. If it is not defined, we will use the terminal cost function defined in costFunctionPtr.

◆ OCS2()

template<size_t STATE_DIM, size_t INPUT_DIM>
ocs2::OCS2< STATE_DIM, INPUT_DIM >::OCS2 ( const rollout_base_t rolloutPtr,
const derivatives_base_t systemDerivativesPtr,
const constraint_base_t systemConstraintsPtr,
const cost_function_base_t costFunctionPtr,
const operating_trajectories_base_t operatingTrajectoriesPtr,
const SLQ_Settings &  settings,
std::shared_ptr< ModeScheduleManager< STATE_DIM, INPUT_DIM >>  modeScheduleManagerPtr,
const cost_function_base_t heuristicsFunctionPtr = nullptr,
const GDDP_Settings gddpSettings = GDDP_Settings(),
const NLP_Settings nlpSettings = NLP_Settings() 
)

Constructor

Parameters
[in]rolloutPtrThe rollout class used for simulating the system dynamics.
[in]systemDerivativesPtrThe system dynamics derivatives for subsystems of the system.
[in]systemConstraintsPtrThe system constraint function and its derivatives for subsystems.
[in]costFunctionPtrThe cost function (intermediate and terminal costs) and its derivatives for subsystems.
[in]operatingTrajectoriesPtrThe operating trajectories of system which will be used for initialization of SLQ.
[in]settingsStructure containing the settings for the SLQ algorithm.
[in]logicRulesPtrThe logic rules used for implementing mixed-logic dynamical systems.
[in]heuristicsFunctionPtrHeuristic function used in the infinite time optimal control formulation. If it is not defined, we will use the terminal cost function defined in costFunctionPtr.
[in]gddpSettingsStructure containing the settings for the GDDP algorithm.
[in]nlpSettingsStructure containing the settings for the NLP algorithm.

◆ propagateRolloutSensitivity()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::propagateRolloutSensitivity ( size_t  workerIndex,
const size_t &  eventTimeIndex,
const linear_controller_array_t controllersStock,
const input_vector_array2_t LvTrajectoriesStock,
const scalar_array2_t sensitivityTimeTrajectoriesStock,
const size_array2_t postEventIndicesStock,
state_vector_array2_t sensitivityStateTrajectoriesStock,
input_vector_array2_t sensitivityInputTrajectoriesStock 
)
protected

Integrates the sensitivity equation of the rollout w.r.t. event times.

Parameters
[in]workerIndexWorking agent index.
[in]eventTimeIndexEvent time index.
[in]controllersStockNominal controller.
[in]LvTrajectoriesStockController's feedforward sensitivity
[in]sensitivityTimeTrajectoriesStockIntegration time trajectory.
[in]postEventIndicesStockPost event indices array.
[out]sensitivityStateTrajectoriesStockArray of state sensitivity trajectory.
[out]sensitivityInputTrajectoriesStockArray of input sensitivity trajectory.

◆ run() [1/5]

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::FrankWolfeGDDP< STATE_DIM, INPUT_DIM >::run ( const slq_data_collector_t dcPtr,
const dynamic_vector_t maxGradientInverse,
NLP_Constraints eventTimeConstraintPtr 
)

Runs the GDDP to compute the gradient of the cost function w.r.t. the event times while respecting the provided constraints.

Parameters
[in]dcPtrA constant pointer to SLQ data collector which already collected the SLQ variables.
[in]maxGradientInversedescent directions element-wise maximum inverse. Note that if there is no limit for a direction set associated element to zero.
[in]eventTimeConstraintPtrA pointer to the NLP constraints for event times.

◆ run() [2/5]

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::NumGDDP< STATE_DIM, INPUT_DIM >::run ( const scalar_t initTime,
const state_vector_t &  initState,
const scalar_t finalTime,
const scalar_array_t partitioningTimes,
const scalar_array_t eventTimes 
)

Runs the NumGDDP to compute the gradient of the cost function w.r.t. the event times.

Parameters
[in]initTimeThe initial time.
[in]initStateThe initial state.
[in]finalTimeThe final time.
[in]partitioningTimesThe partitioning times between subsystems.
[in]eventTimesThe event times vector.

◆ run() [3/5]

template<size_t STATE_DIM, size_t INPUT_DIM, size_t OUTPUT_DIM, size_t NUM_Subsystems>
void ocs2::GSLQSolver< STATE_DIM, INPUT_DIM, OUTPUT_DIM, NUM_Subsystems >::run ( const double &  initTime,
const state_vector_t initState,
const std::vector< scalar_t > &  switchingTimes 
)

Run function

Parameters
[in]initTime
[in]initState
[in]switchingTimes

◆ run() [4/5]

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::OCS2< STATE_DIM, INPUT_DIM >::run ( const scalar_t initTime,
const state_vector_t initState,
const scalar_t finalTime,
const scalar_array_t partitioningTimes,
const scalar_array_t initEventTimes 
)

The main routine of OCS2 which uses a first order method to optimize the event time in the top-level of the bi-level optimization scheme.

Parameters
[in]initTimeThe initial time.
[in]initStateThe initial state.
[in]finalTimeThe final time.
[in]partitioningTimesThe partitioning times between subsystems.
[in]initEventTimesThe initial guess for the optimum event times.

◆ run() [5/5]

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::run ( const slq_data_collector_t dcPtr)

Runs the GSLQ to compute the gradient of the cost function w.r.t. the event times.

Parameters
[in]dcPtrA constant pointer to SLQ data collector which already collected the SLQ variables.

◆ runLQBasedMethod()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::runLQBasedMethod ( )
protected

Runs the LQ-based algorithm to compute the value function derivatives wr.t. event times.

◆ runSweepingBVPMethod()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::runSweepingBVPMethod ( )
protected

Runs the Sweeping-BVP algorithm to compute the cost function derivatives wr.t. event times.

◆ setSolverEventTime()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::NumGDDP< STATE_DIM, INPUT_DIM >::setSolverEventTime ( const scalar_array_t eventTimes)
protected

Sets the event times to the solver.

Parameters
[in]eventTimesThe event times vector.

◆ settings()

template<size_t STATE_DIM, size_t INPUT_DIM>
GDDP_Settings & ocs2::GDDP< STATE_DIM, INPUT_DIM >::settings ( )

Gets a reference to the Options structure.

Returns
a reference to the Options structure.

◆ setupOptimizer()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::setupOptimizer ( const size_t &  numPartitions)
protectedvirtual

Sets up optimizer for different number of partitions.

Parameters
[in]numPartitionsnumber of partitions.

◆ slqSettings()

template<size_t STATE_DIM, size_t INPUT_DIM>
SLQ_Settings & ocs2::OCS2< STATE_DIM, INPUT_DIM >::slqSettings ( )

Gets a reference to the SLQ settings structure.

Returns
a reference to the SLQ settings.

◆ solveSensitivityBVP()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::solveSensitivityBVP ( size_t  workerIndex,
const size_t &  eventTimeIndex,
const state_vector_t MvFinal,
const state_vector_t MveFinal,
state_vector_array2_t MvTrajectoriesStock,
state_vector_array2_t MveTrajectoriesStock 
)
protected

Solves a boundary value problem using a Riccati approach which later be used to compute controller's feedforward sensitivity w.r.t. event times.

Parameters
[in]workerIndexWorking agent index.
[in]eventTimeIndexEvent time index.
[in]MvFinalThe final Heuristic value for Mv.
[in]MveFinalThe final Heuristic value for Mve.
[out]MvTrajectoriesStockBoundary value problem solution for Mv.
[out]MvTrajectoriesStockBoundary value problem solution for Mve.

◆ solveSensitivityRiccatiEquations()

template<size_t STATE_DIM, size_t INPUT_DIM>
void ocs2::GDDP< STATE_DIM, INPUT_DIM >::solveSensitivityRiccatiEquations ( size_t  workerIndex,
const size_t &  eventTimeIndex,
const scalar_t learningRate,
const eigen_scalar_t nablasHeuristics,
const state_vector_t nablaSvHeuristics,
const state_matrix_t nablaSmHeuristics,
eigen_scalar_array2_t nablasTrajectoriesStock,
state_vector_array2_t nablaSvTrajectoriesStock,
state_matrix_array2_t nablaSmTrajectoriesStock 
)
protected

Solves the SLQ Riccati equations sensitivity differential equations.

Parameters
[in]workerIndexWorking agent index.
[in]eventTimeIndexEvent time index.
[in]learningRatelearning rate typically should be zero.
[in]nablasHeuristicsSensitivity of the Heuristics zero order variation.
[in]nablaSvHeuristicsSensitivity of the Heuristics first order state variation.
[in]nablaSmHeuristicsSensitivity of the Heuristics second order state variation.
[out]nablasTrajectoriesStockSensitivity of the Riccati equations's zero order variation.
[out]nablaSvTrajectoriesStockSensitivity of the Riccati equations's first order variation.
[out]nablaSmTrajectoriesStockSensitivity of the Riccati equations's second order variation.