CppADCodeGen  HEAD
A C++ Algorithmic Differentiation Package with Source Code Generation
CppAD::cg::FunctorGenericModel< Base > Class Template Referenceabstract
Inheritance diagram for CppAD::cg::FunctorGenericModel< Base >:
Inheritance graph
Collaboration diagram for CppAD::cg::FunctorGenericModel< Base >:
Collaboration graph

Public Member Functions

 FunctorGenericModel (FunctorGenericModel &&other) noexcept
 
 FunctorGenericModel (const FunctorGenericModel &)=delete
 
FunctorGenericModeloperator= (const FunctorGenericModel &)=delete
 
const std::string & getName () const override
 
const std::vector< std::string > & getAtomicFunctionNames () override
 
bool addAtomicFunction (atomic_base< Base > &atomic) override
 
bool addExternalModel (GenericModel< Base > &atomic) override
 
bool isJacobianSparsityAvailable () override
 
std::vector< bool > JacobianSparsityBool () override
 
std::vector< std::set< size_t > > JacobianSparsitySet () override
 
void JacobianSparsity (std::vector< size_t > &equations, std::vector< size_t > &variables) override
 
bool isHessianSparsityAvailable () override
 
std::vector< bool > HessianSparsityBool () override
 
std::vector< std::set< size_t > > HessianSparsitySet () override
 
void HessianSparsity (std::vector< size_t > &rows, std::vector< size_t > &cols) override
 
bool isEquationHessianSparsityAvailable () override
 
std::vector< bool > HessianSparsityBool (size_t i) override
 
std::vector< std::set< size_t > > HessianSparsitySet (size_t i) override
 
void HessianSparsity (size_t i, std::vector< size_t > &rows, std::vector< size_t > &cols) override
 
size_t Domain () const override
 number of independent variables
 
size_t Range () const override
 number of dependent variables
 
bool isForwardZeroAvailable () override
 
void ForwardZero (ArrayView< const Base > x, ArrayView< Base > dep) override
 calculate the dependent values (zero order)
 
void ForwardZero (const std::vector< const Base *> &x, ArrayView< Base > dep) override
 
void ForwardZero (const CppAD::vector< bool > &vx, CppAD::vector< bool > &vy, ArrayView< const Base > tx, ArrayView< Base > ty) override
 
bool isJacobianAvailable () override
 
void Jacobian (ArrayView< const Base > x, ArrayView< Base > jac) override
 calculate entire Jacobian
 
bool isHessianAvailable () override
 
void Hessian (ArrayView< const Base > x, ArrayView< const Base > w, ArrayView< Base > hess) override
 calculate Hessian for one component of f
 
bool isForwardOneAvailable () override
 
void ForwardOne (ArrayView< const Base > tx, ArrayView< Base > ty) override
 
bool isSparseForwardOneAvailable () override
 
void ForwardOne (ArrayView< const Base > x, size_t tx1Nnz, const size_t idx[], const Base tx1[], ArrayView< Base > ty1) override
 
bool isReverseOneAvailable () override
 
void ReverseOne (ArrayView< const Base > tx, ArrayView< const Base > ty, ArrayView< Base > px, ArrayView< const Base > py) override
 
bool isSparseReverseOneAvailable () override
 
void ReverseOne (ArrayView< const Base > x, ArrayView< Base > px, size_t pyNnz, const size_t idx[], const Base py[]) override
 
bool isReverseTwoAvailable () override
 
void ReverseTwo (ArrayView< const Base > tx, ArrayView< const Base > ty, ArrayView< Base > px, ArrayView< const Base > py) override
 
bool isSparseReverseTwoAvailable () override
 
void ReverseTwo (ArrayView< const Base > x, size_t tx1Nnz, const size_t idx[], const Base tx1[], ArrayView< Base > px2, ArrayView< const Base > py2) override
 
bool isSparseJacobianAvailable () override
 
void SparseJacobian (ArrayView< const Base > x, ArrayView< Base > jac) override
 calculate sparse Jacobians
 
void SparseJacobian (const std::vector< Base > &x, std::vector< Base > &jac, std::vector< size_t > &row, std::vector< size_t > &col) override
 
void SparseJacobian (ArrayView< const Base > x, ArrayView< Base > jac, size_t const **row, size_t const **col) override
 
void SparseJacobian (const std::vector< const Base *> &x, ArrayView< Base > jac, size_t const **row, size_t const **col) override
 
bool isSparseHessianAvailable () override
 
void SparseHessian (ArrayView< const Base > x, ArrayView< const Base > w, ArrayView< Base > hess) override
 calculate sparse Hessians
 
void SparseHessian (const std::vector< Base > &x, const std::vector< Base > &w, std::vector< Base > &hess, std::vector< size_t > &row, std::vector< size_t > &col) override
 
void SparseHessian (ArrayView< const Base > x, ArrayView< const Base > w, ArrayView< Base > hess, size_t const **row, size_t const **col) override
 
void SparseHessian (const std::vector< const Base *> &x, ArrayView< const Base > w, ArrayView< Base > hess, size_t const **row, size_t const **col) override
 
void setAtomicEvalForwardOne4CppAD (bool evalForwardOne4CppAD)
 
bool isAtomicEvalForwardOne4CppAD () const
 
template<typename VectorBase >
VectorBase ForwardZero (const VectorBase &x)
 
template<typename VectorBase >
void ForwardZero (const VectorBase &x, VectorBase &dep)
 
template<typename VectorBase >
VectorBase Jacobian (const VectorBase &x)
 
template<typename VectorBase >
void Jacobian (const VectorBase &x, VectorBase &jac)
 
template<typename VectorBase >
VectorBase Hessian (const VectorBase &x, const VectorBase &w)
 
template<typename VectorBase >
void Hessian (const VectorBase &x, const VectorBase &w, VectorBase &hess)
 
template<typename VectorBase >
VectorBase Hessian (const VectorBase &x, size_t i)
 
template<typename VectorBase >
VectorBase ForwardOne (const VectorBase &tx)
 
template<typename VectorBase >
VectorBase ReverseOne (const VectorBase &tx, const VectorBase &ty, const VectorBase &py)
 
template<typename VectorBase >
void ReverseOne (const VectorBase &tx, const VectorBase &ty, VectorBase &px, const VectorBase &py)
 
template<typename VectorBase >
VectorBase ReverseTwo (const VectorBase &tx, const VectorBase &ty, const VectorBase &py)
 
template<typename VectorBase >
void ReverseTwo (const VectorBase &tx, const VectorBase &ty, VectorBase &px, const VectorBase &py)
 
template<typename VectorBase >
VectorBase SparseJacobian (const VectorBase &x)
 
template<typename VectorBase >
void SparseJacobian (const VectorBase &x, VectorBase &jac)
 
template<typename VectorBase >
VectorBase SparseHessian (const VectorBase &x, const VectorBase &w)
 
template<typename VectorBase >
void SparseHessian (const VectorBase &x, const VectorBase &w, VectorBase &hess)
 
virtual CGAtomicGenericModel< Base > & asAtomic ()
 

Protected Member Functions

 FunctorGenericModel (std::string name)
 
virtual void init ()
 
virtual void * loadFunction (const std::string &functionName, bool required=true)=0
 
virtual void validate ()
 
virtual void loadFunctions ()
 
template<class VectorSet >
void loadSparsity (bool set_type, VectorSet &s, unsigned long nrows, unsigned long ncols, unsigned long const *rows, unsigned long const *cols, unsigned long nnz)
 
template<class VectorSet >
void loadSparsity (const std::set< size_t > &set_type, VectorSet &s, unsigned long nrows, unsigned long ncols, unsigned long const *rows, unsigned long const *cols, unsigned long nnz)
 
void createDenseFromSparse (const CppAD::vector< Base > &compressed, unsigned long nrows, unsigned long ncols, unsigned long const *rows, unsigned long const *cols, unsigned long nnz, ArrayView< Base > mat) const
 
virtual void modelLibraryClosed ()
 

Protected Attributes

bool _isLibraryReady
 
const std::string _name
 the model name
 
size_t _m
 
size_t _n
 
std::vector< const Base * > _in
 
std::vector< const Base * > _inHess
 
std::vector< Base * > _out
 
LangCAtomicFun _atomicFuncArg
 
std::vector< std::string > _atomicNames
 
std::vector< ExternalFunctionWrapper< Base > *> _atomic
 
size_t _missingAtomicFunctions
 
CppAD::vector< Base > _tx
 
CppAD::vector< Base > _ty
 
CppAD::vector< Base > _px
 
CppAD::vector< Base > _py
 
void(* _zero )(Base const *const *, Base *const *, LangCAtomicFun)
 
int(* _forwardOne )(Base const tx[], Base ty[], LangCAtomicFun)
 
int(* _reverseOne )(Base const tx[], Base const ty[], Base px[], Base const py[], LangCAtomicFun)
 
int(* _reverseTwo )(Base const tx[], Base const ty[], Base px[], Base const py[], LangCAtomicFun)
 
void(* _jacobian )(Base const *const *, Base *const *, LangCAtomicFun)
 
void(* _hessian )(Base const *const *, Base *const *, LangCAtomicFun)
 
int(* _sparseForwardOne )(unsigned long, Base const *const *, Base *const *, LangCAtomicFun)
 
int(* _sparseReverseOne )(unsigned long, Base const *const *, Base *const *, LangCAtomicFun)
 
int(* _sparseReverseTwo )(unsigned long, Base const *const *, Base *const *, LangCAtomicFun)
 
void(* _sparseJacobian )(Base const *const *, Base *const *, LangCAtomicFun)
 
void(* _sparseHessian )(Base const *const *, Base *const *, LangCAtomicFun)
 
void(* _forwardOneSparsity )(unsigned long, unsigned long const **, unsigned long *)
 
void(* _reverseOneSparsity )(unsigned long, unsigned long const **, unsigned long *)
 
void(* _reverseTwoSparsity )(unsigned long, unsigned long const **, unsigned long *)
 
void(* _jacobianSparsity )(unsigned long const **row, unsigned long const **col, unsigned long *nnz)
 
void(* _hessianSparsity )(unsigned long const **row, unsigned long const **col, unsigned long *nnz)
 
void(* _hessianSparsity2 )(unsigned long i, unsigned long const **row, unsigned long const **col, unsigned long *nnz)
 
void(* _atomicFunctions )(const char ***names, unsigned long *n)
 
bool _evalAtomicForwardOne4CppAD
 

Static Protected Attributes

static constexpr const char * ERROR_LIBRARY_NOT_READY
 

Friends

class AtomicExternalFunctionWrapper< Base >
 

Detailed Description

template<class Base>
class CppAD::cg::FunctorGenericModel< Base >

A model which can be accessed through function pointers. This class is not thread-safe and it should not be used simultaneously in different threads. Multiple instances of this class for the same model from the same model library object can be used simultaneously in different threads.

Author
Joao Leal

Definition at line 147 of file declare_cg.hpp.

Constructor & Destructor Documentation

◆ FunctorGenericModel()

template<class Base>
CppAD::cg::FunctorGenericModel< Base >::FunctorGenericModel ( std::string  name)
inlineexplicitprotected

Creates a new model

Parameters
nameThe model name

Definition at line 893 of file functor_generic_model.hpp.

Member Function Documentation

◆ addAtomicFunction()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::addAtomicFunction ( atomic_base< Base > &  atomic)
inlineoverridevirtual

Defines a CppAD atomic function to be used as an external function by the compiled code. It should match an external function name previously provided to create the source.

Parameters
atomicThe atomic function. This object must only be deleted after the model.
Returns
true if the atomic function is required by the model, false if it will never be used.

Implements CppAD::cg::GenericModel< Base >.

Definition at line 149 of file functor_generic_model.hpp.

◆ addExternalModel()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::addExternalModel ( GenericModel< Base > &  atomic)
inlineoverridevirtual

Defines a generic model to be used as an external function by the compiled code. It should match an external function name previously provided to create the source. This form should be preferred over ::addAtomicFunction whenever possible.

Parameters
atomicThe generic model. This object must only be deleted after the model.
Returns
true if the external function is required by the model, false if it will never be used.

Implements CppAD::cg::GenericModel< Base >.

Definition at line 154 of file functor_generic_model.hpp.

◆ asAtomic()

template<class Base>
virtual CGAtomicGenericModel<Base>& CppAD::cg::GenericModel< Base >::asAtomic ( )
inlinevirtualinherited

Provides a wrapper for this compiled model allowing it to be used as an atomic function. The model must not be deleted while the atomic function is in use.

Returns
an atomic function wrapper for this model

Definition at line 889 of file generic_model.hpp.

◆ ForwardOne() [1/3]

template<class Base>
template<typename VectorBase >
VectorBase CppAD::cg::GenericModel< Base >::ForwardOne ( const VectorBase &  tx)
inlineinherited

Computes results during a forward mode sweep. Computes the first-order Taylor coefficients for dependent variables relative to a single independent variable. This method can be used during the evaluation of the jacobian when the model is used through a user defined external/atomic AD function.

Warning
do not used it as a generic forward mode function!
Parameters
txThe Taylor coefficients of the independent variables
Returns
The Taylor coefficients of the dependent variables

Definition at line 429 of file generic_model.hpp.

Referenced by CppAD::cg::CGAtomicGenericModel< Base >::CGAtomicGenericModel(), and CppAD::cg::GenericModelExternalFunctionWrapper< Base >::forward().

◆ ForwardOne() [2/3]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::ForwardOne ( ArrayView< const Base >  tx,
ArrayView< Base >  ty 
)
inlineoverridevirtual

Computes results during a forward mode sweep. Computes the first-order Taylor coefficients for dependent variables relative to a single independent variable. This method can be used during the evaluation of the jacobian when the model is used through a user defined external/atomic AD function.

Warning
do not used it as a generic forward mode function!
Parameters
txThe Taylor coefficients of the independent variables
tyThe Taylor coefficients of the dependent variables

Implements CppAD::cg::GenericModel< Base >.

Definition at line 447 of file functor_generic_model.hpp.

◆ ForwardOne() [3/3]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::ForwardOne ( ArrayView< const Base >  x,
size_t  tx1Nnz,
const size_t  idx[],
const Base  tx1[],
ArrayView< Base >  ty1 
)
inlineoverridevirtual

Computes results during a first-order forward mode sweep, the first-order Taylor coefficients for dependent variables relative to a single independent variable. This method can be used during the evaluation of the jacobian when the model is used through a user defined external/atomic AD function. This method version avoids some data copies and can be more efficient.

Warning
do not used it as a generic forward mode function!
Parameters
xindependent variable vector
tx1Nnzthe number of non-zeros of the directional derivatives of the independent variables (seed directions)
idxthe locations of the non-zero values the partial derivatives of the dependent variables (seeds)
tx1the non-zero values of the partial derivatives of the dependent variables (seeds)
ty1

Implements CppAD::cg::GenericModel< Base >.

Definition at line 466 of file functor_generic_model.hpp.

◆ ForwardZero() [1/4]

template<class Base>
template<typename VectorBase >
VectorBase CppAD::cg::GenericModel< Base >::ForwardZero ( const VectorBase &  x)
inlineinherited

Evaluates the dependent model variables (zero-order). This method considers that the generic model was prepared with a single array for the independent variables (the default behavior).

Parameters
xThe independent variable vector
Returns
The dependent variable vector

Definition at line 212 of file generic_model.hpp.

Referenced by CppAD::cg::CGAtomicGenericModel< Base >::CGAtomicGenericModel(), CppAD::cg::GenericModelExternalFunctionWrapper< Base >::forward(), and CppAD::cg::GenericModel< Base >::ForwardZero().

◆ ForwardZero() [2/4]

template<class Base>
template<typename VectorBase >
void CppAD::cg::GenericModel< Base >::ForwardZero ( const VectorBase &  x,
VectorBase &  dep 
)
inlineinherited

Evaluates the dependent model variables (zero-order). This method considers that the generic model was prepared using a single array for the independent variables (the default behavior).

Parameters
xThe independent variable vector
depThe dependent variable vector

Definition at line 245 of file generic_model.hpp.

◆ ForwardZero() [3/4]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::ForwardZero ( const std::vector< const Base *> &  x,
ArrayView< Base >  dep 
)
inlineoverridevirtual

Determines the dependent variable values using a variable number of independent variable arrays. This method can be useful if the generic model was prepared considering that the independent variables are provided by several arrays.

Parameters
xContains the several independent variable vectors
depThe values of the dependent variables

Implements CppAD::cg::GenericModel< Base >.

Definition at line 352 of file functor_generic_model.hpp.

◆ ForwardZero() [4/4]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::ForwardZero ( const CppAD::vector< bool > &  vx,
CppAD::vector< bool > &  vy,
ArrayView< const Base >  tx,
ArrayView< Base >  ty 
)
inlineoverridevirtual

Evaluates the dependent model variables (zero-order). This method considers that the generic model was prepared with a single array for the independent variables (the default behavior).

Parameters
vxIf it is not empty then it provides which independent variables are considered as variables (not parameters)
vyIf vx and vy are not empty, it identifies which elements of ty are variables
txThe independent variable vector
tyThe dependent variable vector

Implements CppAD::cg::GenericModel< Base >.

Definition at line 365 of file functor_generic_model.hpp.

◆ getAtomicFunctionNames()

template<class Base>
const std::vector<std::string>& CppAD::cg::FunctorGenericModel< Base >::getAtomicFunctionNames ( )
inlineoverridevirtual

The names of the atomic functions required by this model. All external/atomic functions must be provided before using this model to compute numerical values.

Returns
the names of the atomic functions used by this model

Implements CppAD::cg::GenericModel< Base >.

Definition at line 145 of file functor_generic_model.hpp.

◆ getName()

template<class Base>
const std::string& CppAD::cg::FunctorGenericModel< Base >::getName ( ) const
inlineoverridevirtual

Provides the name for this model.

Returns
The model name

Implements CppAD::cg::GenericModel< Base >.

Definition at line 141 of file functor_generic_model.hpp.

◆ Hessian() [1/3]

template<class Base>
template<typename VectorBase >
VectorBase CppAD::cg::GenericModel< Base >::Hessian ( const VectorBase &  x,
const VectorBase &  w 
)
inlineinherited

Determines the dense weighted sum of the Hessians using dense methods.

\[ hess = \frac{\rm d^2 }{{\rm d} x^2 } \sum_{i} w_i F_i (x) \]

\[ i = 0 , \ldots , m - 1 \]

Parameters
xThe independent variables
wThe equation multipliers
Returns
The values of the dense hessian

Definition at line 347 of file generic_model.hpp.

Referenced by CppAD::cg::GenericModel< Base >::Hessian().

◆ Hessian() [2/3]

template<class Base>
template<typename VectorBase >
void CppAD::cg::GenericModel< Base >::Hessian ( const VectorBase &  x,
const VectorBase &  w,
VectorBase &  hess 
)
inlineinherited

Determines the dense weighted sum of the Hessians using dense methods.

\[ hess = \frac{\rm d^2 }{{\rm d} x^2 } \sum_{i} w_i F_i (x) \]

\[ i = 0 , \ldots , m - 1 \]

Parameters
xThe independent variables
wThe equation multipliers
hessThe values of the dense hessian

Definition at line 366 of file generic_model.hpp.

◆ Hessian() [3/3]

template<class Base>
template<typename VectorBase >
VectorBase CppAD::cg::GenericModel< Base >::Hessian ( const VectorBase &  x,
size_t  i 
)
inlineinherited

Determines the dense Hessian for a given dependent variable using dense methods.

\[ hess = \frac{{\rm d^2} F_i }{{\rm d} x^2 } (x) \]

Parameters
xThe independent variables
iThe index of the function/dependent variable
Returns
The values of the dense hessian for the function/dependent variable i

Definition at line 384 of file generic_model.hpp.

◆ HessianSparsity()

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::HessianSparsity ( size_t  i,
std::vector< size_t > &  rows,
std::vector< size_t > &  cols 
)
inlineoverridevirtual

Provides the sparsity of the hessian for a dependent variable.

Parameters
iThe index of the dependent variable
rowsThe sparsity pattern row indices.
colsThe sparsity pattern column indices.

Implements CppAD::cg::GenericModel< Base >.

Definition at line 301 of file functor_generic_model.hpp.

◆ HessianSparsityBool()

template<class Base>
std::vector<bool> CppAD::cg::FunctorGenericModel< Base >::HessianSparsityBool ( size_t  i)
inlineoverridevirtual

Provides the sparsity of the hessian for a dependent variable.

Parameters
iThe index of the dependent variable
Returns
The sparsity

Implements CppAD::cg::GenericModel< Base >.

Definition at line 269 of file functor_generic_model.hpp.

◆ HessianSparsitySet() [1/2]

template<class Base>
std::vector<std::set<size_t> > CppAD::cg::FunctorGenericModel< Base >::HessianSparsitySet ( )
inlineoverridevirtual

Provides the sparsity of the sum of the hessian for each dependent variable.

Returns
The sparsity

Implements CppAD::cg::GenericModel< Base >.

Definition at line 233 of file functor_generic_model.hpp.

◆ HessianSparsitySet() [2/2]

template<class Base>
std::vector<std::set<size_t> > CppAD::cg::FunctorGenericModel< Base >::HessianSparsitySet ( size_t  i)
inlineoverridevirtual

Provides the sparsity of the hessian for a dependent variable.

Parameters
iThe index of the dependent variable
Returns
The sparsity

Implements CppAD::cg::GenericModel< Base >.

Definition at line 285 of file functor_generic_model.hpp.

◆ isEquationHessianSparsityAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isEquationHessianSparsityAvailable ( )
inlineoverridevirtual

Determines whether or not the sparsity pattern for the Hessian associated with a dependent variable can be requested.

Returns
true if it is possible to request the parsity pattern for the Hessians

Implements CppAD::cg::GenericModel< Base >.

Definition at line 265 of file functor_generic_model.hpp.

◆ isForwardOneAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isForwardOneAvailable ( )
inlineoverridevirtual

Determines whether or not the first-order forward mode dense methods can be called.

Returns
true if it is possible to evaluate the first-order forward mode using the dense vector format

Implements CppAD::cg::GenericModel< Base >.

Definition at line 443 of file functor_generic_model.hpp.

◆ isForwardZeroAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isForwardZeroAvailable ( )
inlineoverridevirtual

Determines whether or not the model evaluation (zero-order forward mode) can be requested.

Returns
true if it is possible to evaluate the model

Implements CppAD::cg::GenericModel< Base >.

Definition at line 329 of file functor_generic_model.hpp.

◆ isHessianAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isHessianAvailable ( )
inlineoverridevirtual

Determines whether or not the dense evaluation of the weighted sum of the Hessians can be requested.

Returns
true if it is possible to evaluate the dense weighted sum of the Hessians

Implements CppAD::cg::GenericModel< Base >.

Definition at line 419 of file functor_generic_model.hpp.

◆ isHessianSparsityAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isHessianSparsityAvailable ( )
inlineoverridevirtual

Determines whether or not the sparsity pattern for the weighted sum of the Hessians can be requested.

Returns
true if it is possible to request the parsity pattern for the weighted sum of the Hessians

Implements CppAD::cg::GenericModel< Base >.

Definition at line 213 of file functor_generic_model.hpp.

◆ isJacobianAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isJacobianAvailable ( )
inlineoverridevirtual

Determines whether or not the dense Jacobian evaluation can be requested.

Returns
true if it is possible to evaluate the dense Jacobian

Implements CppAD::cg::GenericModel< Base >.

Definition at line 397 of file functor_generic_model.hpp.

◆ isJacobianSparsityAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isJacobianSparsityAvailable ( )
inlineoverridevirtual

Determines whether or not the Jacobian sparsity pattern can be requested.

Returns
true if it is possible to request the Jacobian sparsity pattern

Implements CppAD::cg::GenericModel< Base >.

Definition at line 160 of file functor_generic_model.hpp.

◆ isReverseOneAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isReverseOneAvailable ( )
inlineoverridevirtual

Determines whether or not the first-order reverse mode dense methods can be called.

Returns
true if it is possible to evaluate the first-order reverse mode using the dense vector format

Implements CppAD::cg::GenericModel< Base >.

Definition at line 504 of file functor_generic_model.hpp.

◆ isReverseTwoAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isReverseTwoAvailable ( )
inlineoverridevirtual

Determines whether or not the second-order reverse mode dense methods can be called.

Returns
true if it is possible to evaluate the second-order reverse mode using the dense vector format

Implements CppAD::cg::GenericModel< Base >.

Definition at line 570 of file functor_generic_model.hpp.

◆ isSparseForwardOneAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isSparseForwardOneAvailable ( )
inlineoverridevirtual

Determines whether or not the first-order forward mode sparse method can be called.

Returns
true if it is possible to evaluate the first-order forward mode using the sparse vector format

Implements CppAD::cg::GenericModel< Base >.

Definition at line 462 of file functor_generic_model.hpp.

◆ isSparseHessianAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isSparseHessianAvailable ( )
inlineoverridevirtual

Determines whether or not the sparse evaluation of the weighted sum of the Hessians methods can be called.

Returns
true if it is possible to evaluate the sparse weighted sum of the Hessians

Implements CppAD::cg::GenericModel< Base >.

Definition at line 759 of file functor_generic_model.hpp.

◆ isSparseJacobianAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isSparseJacobianAvailable ( )
inlineoverridevirtual

Determines whether or not the sparse Jacobian evaluation methods can be called.

Returns
true if it is possible to evaluate the sparse Jacobian

Implements CppAD::cg::GenericModel< Base >.

Definition at line 642 of file functor_generic_model.hpp.

◆ isSparseReverseOneAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isSparseReverseOneAvailable ( )
inlineoverridevirtual

Determines whether or not the first-order reverse mode sparse method can be called.

Returns
true if it is possible to evaluate the first-order reverse mode using the sparse vector format

Implements CppAD::cg::GenericModel< Base >.

Definition at line 528 of file functor_generic_model.hpp.

◆ isSparseReverseTwoAvailable()

template<class Base>
bool CppAD::cg::FunctorGenericModel< Base >::isSparseReverseTwoAvailable ( )
inlineoverridevirtual

Determines whether or not the second-order reverse mode sparse methods can be called.

Returns
true if it is possible to evaluate the second-order reverse mode using the sparse vector format

Implements CppAD::cg::GenericModel< Base >.

Definition at line 596 of file functor_generic_model.hpp.

◆ Jacobian() [1/2]

template<class Base>
template<typename VectorBase >
VectorBase CppAD::cg::GenericModel< Base >::Jacobian ( const VectorBase &  x)
inlineinherited

Calculates a Jacobian using dense methods and saves it into a dense format:

\[ jac[ i n + j ] = \frac{\partial F_i( x ) }{\partial x_j } \]

\( i = 0 , \ldots , m - 1 \) and \(j = 0 , \ldots , n - 1 \).

Parameters
xindependent variable vector
Returns
jac a dense Jacobian

Definition at line 293 of file generic_model.hpp.

Referenced by CppAD::cg::GenericModel< Base >::Jacobian().

◆ Jacobian() [2/2]

template<class Base>
template<typename VectorBase >
void CppAD::cg::GenericModel< Base >::Jacobian ( const VectorBase &  x,
VectorBase &  jac 
)
inlineinherited

Calculates a Jacobian using dense methods and saves it into a dense format:

\[ jac[ i n + j ] = \frac{\partial F_i( x ) }{\partial x_j } \]

\( i = 0 , \ldots , m - 1 \) and \(j = 0 , \ldots , n - 1 \).

Parameters
xindependent variable vector
jaca dense Jacobian

Definition at line 310 of file generic_model.hpp.

◆ loadFunctions()

template<class Base>
virtual void CppAD::cg::FunctorGenericModel< Base >::loadFunctions ( )
inlineprotectedvirtual

Prepare the atomic functions argument

Definition at line 964 of file functor_generic_model.hpp.

Referenced by CppAD::cg::FunctorGenericModel< Base >::FunctorGenericModel().

◆ ReverseOne() [1/4]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::ReverseOne ( ArrayView< const Base >  tx,
ArrayView< const Base >  ty,
ArrayView< Base >  px,
ArrayView< const Base >  py 
)
inlineoverridevirtual

Computes results during a reverse mode sweep (adjoints or partial derivatives of independent variables) for the evaluation of the jacobian when the model is used through a user defined external/atomic AD function.

Warning
do not used it as a generic reverse mode function!

Implements CppAD::cg::GenericModel< Base >.

Definition at line 508 of file functor_generic_model.hpp.

◆ ReverseOne() [2/4]

template<class Base>
template<typename VectorBase >
VectorBase CppAD::cg::GenericModel< Base >::ReverseOne ( const VectorBase &  tx,
const VectorBase &  ty,
const VectorBase &  py 
)
inlineinherited

Computes results during a reverse mode sweep (adjoints or partial derivatives of independent variables) for the evaluation of the jacobian when the model is used through a user defined external/atomic AD function.

Warning
do not used it as a generic reverse mode function!

Definition at line 511 of file generic_model.hpp.

Referenced by CppAD::cg::CGAtomicGenericModel< Base >::CGAtomicGenericModel(), CppAD::cg::GenericModelExternalFunctionWrapper< Base >::reverse(), and CppAD::cg::GenericModel< Base >::ReverseOne().

◆ ReverseOne() [3/4]

template<class Base>
template<typename VectorBase >
void CppAD::cg::GenericModel< Base >::ReverseOne ( const VectorBase &  tx,
const VectorBase &  ty,
VectorBase &  px,
const VectorBase &  py 
)
inlineinherited

Computes results during a reverse mode sweep (adjoints or partial derivatives of independent variables) for the evaluation of the jacobian when the model is used through a user defined external/atomic AD function.

Warning
do not used it as a generic reverse mode function!

Definition at line 528 of file generic_model.hpp.

◆ ReverseOne() [4/4]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::ReverseOne ( ArrayView< const Base >  x,
ArrayView< Base >  px,
size_t  pyNnz,
const size_t  idx[],
const Base  py[] 
)
inlineoverridevirtual

Computes results during a reverse mode sweep (adjoints or partial derivatives of independent variables) for the evaluation of the jacobian when the model is used through a user defined external/atomic AD function. This method version avoids some data copies and can be more efficient.

Warning
do not used it as a generic reverse mode function!
Parameters
xindependent variable vector
pxpartial derivatives of the independent variables (same size as x)
pyNnzthe number of non-zeros of the partial derivatives of the dependent variables (weight functionals)
idxthe locations of the non-zero values the partial derivatives of the dependent variables (weight functionals)
pythe non-zero values of the partial derivatives of the dependent variables (weight functionals)

Implements CppAD::cg::GenericModel< Base >.

Definition at line 532 of file functor_generic_model.hpp.

◆ ReverseTwo() [1/4]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::ReverseTwo ( ArrayView< const Base >  tx,
ArrayView< const Base >  ty,
ArrayView< Base >  px,
ArrayView< const Base >  py 
)
inlineoverridevirtual

Computes second-order results during a reverse mode sweep (p = 2). This method can be used during the evaluation of the hessian when the model is used through a user defined external/atomic AD function.

Warning
do not used it as a generic reverse mode function!
only the values for px[j * (k+1)] are defined, since px[j * (k+1) + 1] is not used during the hessian evaluation.

Implements CppAD::cg::GenericModel< Base >.

Definition at line 574 of file functor_generic_model.hpp.

◆ ReverseTwo() [2/4]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::ReverseTwo ( ArrayView< const Base >  x,
size_t  tx1Nnz,
const size_t  idx[],
const Base  tx1[],
ArrayView< Base >  px2,
ArrayView< const Base >  py2 
)
inlineoverridevirtual

Computes second-order results during a reverse mode sweep (p = 2). This method can be used during the evaluation of the hessian when the model is used through a user defined external AD function. This method version avoids some data copies and can be more efficient.

Warning
do not used it as a generic reverse mode function!
Parameters
xindependent variable vector
tx1Nnzthe number of non-zeros of the first-order Taylor coefficients of the independents
idxthe locations of the non-zero values of the first-order Taylor coefficients of the independents
tx1the values of the non-zero first-order Taylor coefficients of the independents
px2second-order partials of the independents (should have the same size of x)
py2second-order partials of the dependents (should have the size of the dependent variables)

Implements CppAD::cg::GenericModel< Base >.

Definition at line 600 of file functor_generic_model.hpp.

◆ ReverseTwo() [3/4]

template<class Base>
template<typename VectorBase >
VectorBase CppAD::cg::GenericModel< Base >::ReverseTwo ( const VectorBase &  tx,
const VectorBase &  ty,
const VectorBase &  py 
)
inlineinherited

Computes second-order results during a reverse mode sweep (p = 2). This method can be used during the evaluation of the hessian when the model is used through a user defined external/atomic AD function.

Warning
do not used it as a generic reverse mode function!
only the values for px[j * (k+1)] are defined, since px[j * (k+1) + 1] is not used during the hessian evaluation.

Definition at line 602 of file generic_model.hpp.

Referenced by CppAD::cg::CGAtomicGenericModel< Base >::CGAtomicGenericModel(), CppAD::cg::GenericModelExternalFunctionWrapper< Base >::reverse(), and CppAD::cg::GenericModel< Base >::ReverseTwo().

◆ ReverseTwo() [4/4]

template<class Base>
template<typename VectorBase >
void CppAD::cg::GenericModel< Base >::ReverseTwo ( const VectorBase &  tx,
const VectorBase &  ty,
VectorBase &  px,
const VectorBase &  py 
)
inlineinherited

Computes second-order results during a reverse mode sweep (p = 2). This method can be used during the evaluation of the hessian when the model is used through a user defined external/atomic AD function.

Warning
do not used it as a generic reverse mode function!
only the values for px[j * (k+1)] are defined, since px[j * (k+1) + 1] is not used during the hessian evaluation.

Definition at line 620 of file generic_model.hpp.

◆ setAtomicEvalForwardOne4CppAD()

template<class Base>
void CppAD::cg::GenericModel< Base >::setAtomicEvalForwardOne4CppAD ( bool  evalForwardOne4CppAD)
inlineinherited

Defines whether or not to evaluate a forward mode of an atomic functions during a reverse sweep so that CppAD checks validate OK. If this model is not used within CppAD then it should be set to false.

Parameters
evalForwardOne4CppADtrue to perform the forward mode, false to ignore it

Definition at line 182 of file generic_model.hpp.

◆ SparseHessian() [1/5]

template<class Base>
template<typename VectorBase >
VectorBase CppAD::cg::GenericModel< Base >::SparseHessian ( const VectorBase &  x,
const VectorBase &  w 
)
inlineinherited

Determines the dense weighted sum of the Hessians using sparse methods.

\[ hess = \frac{\rm d^2 }{{\rm d} x^2 } \sum_{i} w_i F_i (x) \]

\[ i = 0 , \ldots , m - 1 \]

Parameters
xThe independent variables
wThe equation multipliers
Returns
The values of the dense Hessian

Definition at line 795 of file generic_model.hpp.

Referenced by CppAD::cg::GenericModel< Base >::SparseHessian().

◆ SparseHessian() [2/5]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::SparseHessian ( const std::vector< Base > &  x,
const std::vector< Base > &  w,
std::vector< Base > &  hess,
std::vector< size_t > &  row,
std::vector< size_t > &  col 
)
inlineoverridevirtual

Determines the sparse weighted sum of the Hessians using a variable number of independent variable arrays.

\[ hess = \frac{\rm d^2 }{{\rm d} x^2 } \sum_{i} w_i F_i (x) \]

\[ i = 0 , \ldots , m - 1 \]

Parameters
xThe independent variables
wThe equation multipliers
hessThe values of the sparse hessian in the order provided by row and col
rowThe row indices of the hessian values
colThe column indices of the hessian values

Implements CppAD::cg::GenericModel< Base >.

Definition at line 797 of file functor_generic_model.hpp.

◆ SparseHessian() [3/5]

template<class Base>
template<typename VectorBase >
void CppAD::cg::GenericModel< Base >::SparseHessian ( const VectorBase &  x,
const VectorBase &  w,
VectorBase &  hess 
)
inlineinherited

Determines the dense weighted sum of the Hessians using sparse methods.

\[ hess = \frac{\rm d^2 }{{\rm d} x^2 } \sum_{i} w_i F_i (x) \]

\[ i = 0 , \ldots , m - 1 \]

Parameters
xThe independent variables
wThe equation multipliers
hessThe values of the dense Hessian

Definition at line 814 of file generic_model.hpp.

◆ SparseHessian() [4/5]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::SparseHessian ( ArrayView< const Base >  x,
ArrayView< const Base >  w,
ArrayView< Base >  hess,
size_t const **  row,
size_t const **  col 
)
inlineoverridevirtual

Determines the sparse weighted sum of the Hessians using a variable number of independent variable arrays.

\[ hess = \frac{\rm d^2 }{{\rm d} x^2 } \sum_{i} w_i F_i (x) \]

\[ i = 0 , \ldots , m - 1 \]

Parameters
xThe independent variables
wThe equation multipliers
hessThe values of the sparse hessian in the order provided by row and col
rowThe row indices of the hessian values
colThe column indices of the hessian values

Implements CppAD::cg::GenericModel< Base >.

Definition at line 830 of file functor_generic_model.hpp.

◆ SparseHessian() [5/5]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::SparseHessian ( const std::vector< const Base *> &  x,
ArrayView< const Base >  w,
ArrayView< Base >  hess,
size_t const **  row,
size_t const **  col 
)
inlineoverridevirtual

Determines the sparse weighted sum of the Hessians using a variable number of independent variable arrays.

\[ hess = \frac{\rm d^2 }{{\rm d} x^2 } \sum_{i} w_i F_i (x) \]

\[ i = 0 , \ldots , m - 1 \]

This method can be useful if the generic model was prepared considering that the independent variables are provided by several arrays.

Parameters
xContains the several independent variable vectors
wThe equation multipliers
w_sizeThe number of equations
hessThe values of the sparse hessian in the order provided by row and col
rowThe row indices of the hessian values
colThe column indices of the hessian values

Implements CppAD::cg::GenericModel< Base >.

Definition at line 859 of file functor_generic_model.hpp.

◆ SparseJacobian() [1/5]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::SparseJacobian ( const std::vector< Base > &  x,
std::vector< Base > &  jac,
std::vector< size_t > &  row,
std::vector< size_t > &  col 
)
inlineoverridevirtual

Calculates a Jacobian using sparse methods and saves it into a sparse format.

Parameters
xindependent variable array (must have n elements)
jacThe values of the sparse Jacobian in the order provided by row and col (must be allocated with at least the same number of non-zero elements as the Jacobian)
rowThe row indices of the Jacobian values
colThe column indices of the Jacobian values

Implements CppAD::cg::GenericModel< Base >.

Definition at line 679 of file functor_generic_model.hpp.

◆ SparseJacobian() [2/5]

template<class Base>
template<typename VectorBase >
VectorBase CppAD::cg::GenericModel< Base >::SparseJacobian ( const VectorBase &  x)
inlineinherited

Calculates a Jacobian using sparse methods and saves it into a dense format:

\[ jac[ i n + j ] = \frac{\partial F_i( x ) }{\partial x_j } \]

\( i = 0 , \ldots , m - 1 \) and \(j = 0 , \ldots , n - 1 \).

Parameters
xindependent variable vector
Returns
a dense Jacobian

Definition at line 697 of file generic_model.hpp.

Referenced by CppAD::cg::GenericModel< Base >::SparseJacobian().

◆ SparseJacobian() [3/5]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::SparseJacobian ( ArrayView< const Base >  x,
ArrayView< Base >  jac,
size_t const **  row,
size_t const **  col 
)
inlineoverridevirtual

Calculates a Jacobian using sparse methods and saves it into a sparse format.

Parameters
xindependent variable array (must have n elements)
jacThe values of the sparse Jacobian in the order provided by row and col (must be allocated with at least the same number of non-zero elements as the Jacobian)
rowThe row indices of the Jacobian values
colThe column indices of the Jacobian values

Implements CppAD::cg::GenericModel< Base >.

Definition at line 708 of file functor_generic_model.hpp.

◆ SparseJacobian() [4/5]

template<class Base>
template<typename VectorBase >
void CppAD::cg::GenericModel< Base >::SparseJacobian ( const VectorBase &  x,
VectorBase &  jac 
)
inlineinherited

Calculates a Jacobian using sparse methods and saves it into a dense format:

\[ jac[ i n + j ] = \frac{\partial F_i( x ) }{\partial x_j } \]

\( i = 0 , \ldots , m - 1 \) and \(j = 0 , \ldots , n - 1 \).

Parameters
xindependent variable vector
jaca vector where the dense Jacobian will be placed

Definition at line 714 of file generic_model.hpp.

◆ SparseJacobian() [5/5]

template<class Base>
void CppAD::cg::FunctorGenericModel< Base >::SparseJacobian ( const std::vector< const Base *> &  x,
ArrayView< Base >  jac,
size_t const **  row,
size_t const **  col 
)
inlineoverridevirtual

Determines the sparse Jacobian using a variable number of independent variable arrays. This method can be useful if the generic model was prepared considering that the independent variables are provided by several arrays.

Parameters
xContains the several independent variable vectors
jacThe values of the sparse Jacobian in the order provided by row and col
rowThe row indices of the Jacobian values
colThe column indices of the Jacobian values

Implements CppAD::cg::GenericModel< Base >.

Definition at line 735 of file functor_generic_model.hpp.

◆ validate()

template<class Base>
virtual void CppAD::cg::FunctorGenericModel< Base >::validate ( )
inlineprotectedvirtual

Check the data type

Definition at line 932 of file functor_generic_model.hpp.

Referenced by CppAD::cg::FunctorGenericModel< Base >::FunctorGenericModel().

Member Data Documentation

◆ ERROR_LIBRARY_NOT_READY

template<class Base>
constexpr const char* CppAD::cg::FunctorGenericModel< Base >::ERROR_LIBRARY_NOT_READY
staticprotected
Initial value:
= "The model library is not ready. The model library that"
" provided this model might have been closed or deleted."

Definition at line 36 of file functor_generic_model.hpp.


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