- 3.0.1 core module.
|
Jacobian using Auto-Diff Codegeneration. More...
#include <DerivativesCppadJIT.h>
Public Types | |
using | CG_SCALAR = ADCGScalar |
CG_SCALAR type. More... | |
using | CG_VALUE_TYPE = ADCGValueType |
autodiff scalar type More... | |
using | IN_TYPE_CG = Eigen::Matrix< CG_SCALAR, IN_DIM, 1 > |
function input vector type More... | |
using | OUT_TYPE_CG = Eigen::Matrix< CG_SCALAR, OUT_DIM, 1 > |
function output vector type More... | |
using | IN_TYPE_D = Eigen::Matrix< double, IN_DIM, 1 > |
function input vector type double More... | |
using | OUT_TYPE_D = Eigen::Matrix< double, OUT_DIM, 1 > |
function output vector type More... | |
using | JAC_TYPE_D = Eigen::Matrix< double, OUT_DIM, IN_DIM > |
Jacobian type. More... | |
using | JAC_TYPE_ROW_MAJOR = Eigen::Matrix< double, OUT_DIM, IN_DIM, Eigen::RowMajor > |
Jac. type in row-major. More... | |
using | HES_TYPE_D = Eigen::Matrix< double, IN_DIM, IN_DIM > |
using | HES_TYPE_ROW_MAJOR = Eigen::Matrix< double, IN_DIM, IN_DIM, Eigen::RowMajor > |
using | FUN_TYPE_CG = std::function< OUT_TYPE_CG(const IN_TYPE_CG &)> |
function type More... | |
using | DerivativesBase = Derivatives< IN_DIM, OUT_DIM > |
Public Types inherited from ct::core::Derivatives< IN_DIM, OUT_DIM, double > | |
typedef Eigen::Matrix< double, IN_DIM, 1 > | IN_TYPE |
function input vector type More... | |
typedef Eigen::Matrix< double, OUT_DIM, 1 > | OUT_TYPE |
function output vector type More... | |
typedef Eigen::Matrix< double, OUT_DIM, IN_DIM > | JAC_TYPE |
typedef Eigen::Matrix< double, IN_DIM, IN_DIM > | HES_TYPE |
Public Member Functions | |
DerivativesCppadJIT (FUN_TYPE_CG &f, int inputDim=IN_DIM, int outputDim=OUT_DIM) | |
Contructs the derivatives for codegeneration using a FUN_TYPE_CG function. More... | |
DerivativesCppadJIT (const DerivativesCppadJIT &arg) | |
copy constructor More... | |
void | update (FUN_TYPE_CG &f, const size_t inputDim=IN_DIM, const size_t outputDim=OUT_DIM) |
update the Jacobian with a new function More... | |
virtual | ~DerivativesCppadJIT ()=default |
destructor More... | |
DerivativesCppadJIT * | clone () const |
deep cloning of Jacobian More... | |
virtual OUT_TYPE_D | forwardZero (const Eigen::VectorXd &x) |
Evaluates the method itself. More... | |
virtual JAC_TYPE_D | jacobian (const Eigen::VectorXd &x) |
Evaluates the jacobian with respect to the input. More... | |
virtual void | sparseJacobian (const Eigen::VectorXd &x, Eigen::VectorXd &jac, Eigen::VectorXi &iRow, Eigen::VectorXi &jCol) |
Returns the evaluated jacobian in sparse format. More... | |
virtual Eigen::VectorXd | sparseJacobianValues (const Eigen::VectorXd &x) |
Returns the non zero values of the jacobian. More... | |
virtual HES_TYPE_D | hessian (const Eigen::VectorXd &x, const Eigen::VectorXd &lambda) |
Evaluates the hessian (2nd order derivatives with respect to input) of the method. In case of a vector valued function, the method returns the weighted sum of the hessians with weights w. More... | |
virtual void | sparseHessian (const Eigen::VectorXd &x, const Eigen::VectorXd &lambda, Eigen::VectorXd &hes, Eigen::VectorXi &iRow, Eigen::VectorXi &jCol) |
Returns the weighted sum of hessian of the problem in sparse format. More... | |
virtual Eigen::VectorXd | sparseHessianValues (const Eigen::VectorXd &x, const Eigen::VectorXd &lambda) |
Returns the non zero elements of the hessian of the problem. More... | |
Eigen::Matrix< bool, Eigen::Dynamic, Eigen::Dynamic > | getSparsityPatternJacobian () |
get Jacobian sparsity pattern More... | |
Eigen::Matrix< bool, Eigen::Dynamic, Eigen::Dynamic > | getSparsityPatternHessian () |
get Hessian sparsity pattern More... | |
void | getSparsityPatternJacobian (Eigen::VectorXi &rows, Eigen::VectorXi &columns) |
get Jacobian sparsity pattern More... | |
size_t | getNumNonZerosJacobian () |
Returns the number of nonzeros in the sparse jacobian. More... | |
size_t | getNumNonZerosHessian () |
Returns the number of nonzeros in the sparse hessian. More... | |
void | getSparsityPatternHessian (Eigen::VectorXi &rows, Eigen::VectorXi &columns) |
get Hessian sparsity pattern More... | |
void | compileJIT (const DerivativesCppadSettings &settings, const std::string &libName="unnamedLib", bool verbose=false) |
Uses just-in-time compilation to compile the Jacobian and other derivatives. More... | |
const std::shared_ptr< CppAD::cg::DynamicLib< double > > | getDynamicLib () |
retrieve the dynamic library, e.g. for testing purposes More... | |
Public Member Functions inherited from ct::core::Derivatives< IN_DIM, OUT_DIM, double > | |
Derivatives () | |
virtual | ~Derivatives () |
default destructor More... | |
Protected Member Functions | |
void | recordCg () |
record the Auto-Diff terms for code generation More... | |
Protected Attributes | |
std::function< OUT_TYPE_CG(const IN_TYPE_CG &)> | cgStdFun_ |
int | inputDim_ |
the function More... | |
int | outputDim_ |
function input dimension More... | |
CppAD::ADFun< CG_VALUE_TYPE > | cgCppadFun_ |
function output dimension More... | |
bool | compiled_ |
auto-diff function More... | |
std::string | libName_ |
flag if Jacobian is compiled More... | |
std::vector< size_t > | sparsityRowsJacobian_ |
a unique name for this library More... | |
std::vector< size_t > | sparsityColsJacobian_ |
std::vector< size_t > | sparsityRowsHessian_ |
std::vector< size_t > | sparsityColsHessian_ |
Eigen::VectorXi | sparsityRowsJacobianEigen_ |
Eigen::VectorXi | sparsityColsJacobianEigen_ |
Eigen::VectorXi | sparsityRowsHessianEigen_ |
Eigen::VectorXi | sparsityColsHessianEigen_ |
CppAD::cg::GccCompiler< double > | compiler_ |
CppAD::cg::ClangCompiler< double > | compilerClang_ |
compile for codegeneration More... | |
std::shared_ptr< CppAD::cg::DynamicLib< double > > | dynamicLib_ |
std::shared_ptr< CppAD::cg::GenericModel< double > > | model_ |
dynamic library to load after compilation More... | |
Jacobian using Auto-Diff Codegeneration.
Uses Auto-Diff code generation to compute the Jacobian of a regular vector-valued mathematical function .
x has IN_DIM dimension and y has OUT_DIM dimension. Thus, they can be scalar functions (IN_DIM = 1, OUT_DIM = 1), fixed or variable size (IN_DIM = -1, OUT_DIM = -1) functions.
IN_DIM | Input dimensionality of the function (use Eigen::Dynamic (-1) for dynamic size) |
OUT_DIM | Output dimensionailty of the function (use Eigen::Dynamic (-1) for dynamic size) |
using ct::core::DerivativesCppadJIT< IN_DIM, OUT_DIM >::CG_SCALAR = ADCGScalar |
CG_SCALAR type.
using ct::core::DerivativesCppadJIT< IN_DIM, OUT_DIM >::CG_VALUE_TYPE = ADCGValueType |
autodiff scalar type
using ct::core::DerivativesCppadJIT< IN_DIM, OUT_DIM >::IN_TYPE_CG = Eigen::Matrix<CG_SCALAR, IN_DIM, 1> |
function input vector type
using ct::core::DerivativesCppadJIT< IN_DIM, OUT_DIM >::OUT_TYPE_CG = Eigen::Matrix<CG_SCALAR, OUT_DIM, 1> |
function output vector type
using ct::core::DerivativesCppadJIT< IN_DIM, OUT_DIM >::IN_TYPE_D = Eigen::Matrix<double, IN_DIM, 1> |
function input vector type double
using ct::core::DerivativesCppadJIT< IN_DIM, OUT_DIM >::OUT_TYPE_D = Eigen::Matrix<double, OUT_DIM, 1> |
function output vector type
using ct::core::DerivativesCppadJIT< IN_DIM, OUT_DIM >::JAC_TYPE_D = Eigen::Matrix<double, OUT_DIM, IN_DIM> |
Jacobian type.
using ct::core::DerivativesCppadJIT< IN_DIM, OUT_DIM >::JAC_TYPE_ROW_MAJOR = Eigen::Matrix<double, OUT_DIM, IN_DIM, Eigen::RowMajor> |
Jac. type in row-major.
using ct::core::DerivativesCppadJIT< IN_DIM, OUT_DIM >::HES_TYPE_D = Eigen::Matrix<double, IN_DIM, IN_DIM> |
using ct::core::DerivativesCppadJIT< IN_DIM, OUT_DIM >::HES_TYPE_ROW_MAJOR = Eigen::Matrix<double, IN_DIM, IN_DIM, Eigen::RowMajor> |
using ct::core::DerivativesCppadJIT< IN_DIM, OUT_DIM >::FUN_TYPE_CG = std::function<OUT_TYPE_CG(const IN_TYPE_CG&)> |
function type
using ct::core::DerivativesCppadJIT< IN_DIM, OUT_DIM >::DerivativesBase = Derivatives<IN_DIM, OUT_DIM> |
|
inline |
Contructs the derivatives for codegeneration using a FUN_TYPE_CG function.
f | The function to be autodiffed | |
[in] | inputDim | inputDim input dimension, must be specified if template parameter IN_DIM is -1 (dynamic) |
[in] | outputDim | outputDim output dimension, must be specified if template parameter IN_DIM is -1 (dynamic) |
|
inline |
copy constructor
arg | instance to copy |
|
virtualdefault |
destructor
Referenced by ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::update().
|
inline |
update the Jacobian with a new function
f | new function to compute Jacobian of |
inputDim | input dimension, must be specified if template parameter IN_DIM is -1 (dynamic) |
outputDim | output dimension, must be specified if template parameter IN_DIM is -1 (dynamic) |
Referenced by ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::DerivativesCppadJIT().
|
inlinevirtual |
deep cloning of Jacobian
Implements ct::core::Derivatives< IN_DIM, OUT_DIM, double >.
|
inlinevirtual |
Evaluates the method itself.
[in] | x | The point of evaluation |
Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.
|
inlinevirtual |
Evaluates the jacobian with respect to the input.
[in] | x | The point of evaluation |
Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.
|
inlinevirtual |
Returns the evaluated jacobian in sparse format.
[in] | x | The point of evaluation |
[out] | jac | The non zero values of the jacobian |
[out] | iRow | The row indices of the non zero values |
[out] | jCol | The column indices of the non zero values |
Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.
|
inlinevirtual |
Returns the non zero values of the jacobian.
[in] | x | The point of evaluation |
Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.
|
inlinevirtual |
Evaluates the hessian (2nd order derivatives with respect to input) of the method. In case of a vector valued function, the method returns the weighted sum of the hessians with weights w.
[in] | x | The point of evaluation |
[in] | lambda | The weights of the sum |
Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.
Referenced by ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::hessian().
|
inlinevirtual |
Returns the weighted sum of hessian of the problem in sparse format.
[in] | x | The point of evaluation |
[in] | lambda | The weights of the sum of the hessian |
hes | The non zero values of the hessian | |
iRow | The row indices of the non zero values | |
jCol | The column indices of the non zero values |
Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.
|
inlinevirtual |
Returns the non zero elements of the hessian of the problem.
[in] | x | The point of evaluation |
[in] | lambda | The weights of the sum of the hessian |
Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.
|
inline |
get Jacobian sparsity pattern
Auto-Diff automatically detects the sparsity pattern of the Jacobian. This method returns the pattern.
|
inline |
get Hessian sparsity pattern
|
inline |
get Jacobian sparsity pattern
Auto-Diff automatically detects the sparsity pattern of the Jacobian. This method returns the pattern in row-column format. Row and columns contain the indeces of all non-zero entries.
rows | row indeces of non-zero entries |
columns | column indeces of non-zero entries |
|
inline |
Returns the number of nonzeros in the sparse jacobian.
|
inline |
Returns the number of nonzeros in the sparse hessian.
|
inline |
get Hessian sparsity pattern
Auto-Diff automatically detects the sparsity pattern of the Jacobian. This method returns the pattern in row-column format. Row and columns contain the indeces of all non-zero entries.
rows | row indeces of non-zero entries |
columns | column indeces of non-zero entries |
|
inline |
Uses just-in-time compilation to compile the Jacobian and other derivatives.
This method generates source code for the Jacobian and zero order derivative. It then compiles the source code to a dynamically loadable library that then gets loaded.
|
inline |
retrieve the dynamic library, e.g. for testing purposes
|
inlineprotected |
record the Auto-Diff terms for code generation
Referenced by ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::update().
|
protected |
|
protected |
the function
Referenced by ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::getSparsityPatternHessian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::getSparsityPatternJacobian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::recordCg(), and ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::update().
|
protected |
function input dimension
Referenced by ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::getSparsityPatternJacobian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::hessian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::jacobian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::recordCg(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseHessian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseHessianValues(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseJacobian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseJacobianValues(), and ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::update().
|
protected |
|
protected |
auto-diff function
Referenced by ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::compileJIT(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::DerivativesCppadJIT(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::forwardZero(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::hessian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::jacobian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseHessian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseHessianValues(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseJacobian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseJacobianValues(), and ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::update().
|
protected |
|
protected |
a unique name for this library
Referenced by ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::compileJIT(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::getNumNonZerosJacobian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseJacobian(), and ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseJacobianValues().
|
protected |
|
protected |
Referenced by ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::compileJIT(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::getNumNonZerosHessian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseHessian(), and ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseHessianValues().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
compile for codegeneration
|
protected |
Referenced by ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::compileJIT(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::DerivativesCppadJIT(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::getDynamicLib(), and ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::update().
|
protected |
dynamic library to load after compilation
Referenced by ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::compileJIT(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::DerivativesCppadJIT(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::forwardZero(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::getNumNonZerosHessian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::getNumNonZerosJacobian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::getSparsityPatternHessian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::getSparsityPatternJacobian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::hessian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::jacobian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseHessian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseHessianValues(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseJacobian(), ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::sparseJacobianValues(), and ct::core::DerivativesCppadJIT< STATE_DIM+CONTROL_DIM+1, 1 >::update().