CppADCodeGen
HEAD
A C++ Algorithmic Differentiation Package with Source Code Generation
|
Public Member Functions | |
DummyDerivatives (DaeStructuralIndexReduction< Base > &idxIdentify, const std::vector< Base > &x, const std::vector< Base > &normVar, const std::vector< Base > &normEq) | |
bool | isAvoidConvertAlg2DifVars () const |
void | setAvoidConvertAlg2DifVars (bool avoid) |
bool | isGenerateSemiExplicitDae () const |
void | setGenerateSemiExplicitDae (bool generateSemiExplicitDae) |
bool | isReduceEquations () const |
void | setReduceEquations (bool reduceEquations) |
bool | isReorder () const |
void | setReorder (bool reorder) |
void | setAvoidVarsAsDummies (const std::set< std::string > &avoidAsDummy) |
const std::set< std::string > & | getAvoidVarsAsDummies () const |
std::unique_ptr< ADFun< CG< Base > > > | reduceIndex (std::vector< DaeVarInfo > &newVarInfo, std::vector< DaeEquationInfo > &newEqInfo) override |
ADFun< CG< Base > > & | getOriginalModel () const |
std::ostream & | log () const |
void | setLog (std::ostream &out) |
void | setVerbosity (Verbosity verbosity) |
Verbosity | getVerbosity () const |
Protected Member Functions | |
virtual void | addDummyDerivatives (const std::vector< DaeVarInfo > &varInfo, const std::vector< DaeEquationInfo > &eqInfo, std::vector< DaeVarInfo > &newVarInfo) |
std::unique_ptr< ADFun< CGBase > > | reduceEquations (const std::vector< DaeVarInfo > &reducedVarInfo, std::vector< DaeVarInfo > &newVarInfo, const std::vector< DaeEquationInfo > &reducedEqInfo, std::vector< DaeEquationInfo > &newEqInfo) |
std::unique_ptr< ADFun< CGBase > > | generateSemiExplicitDAE (ADFun< CG< Base > > &fun, const std::vector< DaeVarInfo > &varInfo, std::vector< DaeVarInfo > &newVarInfo, const std::vector< DaeEquationInfo > &eqInfo, std::vector< DaeEquationInfo > &newEqInfo) |
void | matchVars2Eqs4Elimination (std::vector< DaeVarInfo > &varInfo, std::vector< DaeEquationInfo > &eqInfo) |
bool | assignVar2Equation (Enode< Base > &i, std::vector< CGBase > &res0, Vnode< Base > &j, std::vector< CGBase > &indep0, CodeHandler< Base > &handler, std::vector< bool > &jacSparsity, const std::map< size_t, Vnode< Base > *> &tape2FreeVariables, std::vector< Enode< Base > *> &equations, std::vector< DaeVarInfo > &varInfo) |
std::unique_ptr< ADFun< CGBase > > | reorderModelEqNVars (ADFun< CG< Base > > &fun, const std::vector< DaeVarInfo > &varInfo, std::vector< DaeVarInfo > &newVarInfo, const std::vector< DaeEquationInfo > &eqInfo, std::vector< DaeEquationInfo > &newEqInfo) |
ADFun< CGBase > * | generateReorderedModel (CodeHandler< Base > &handler, const std::vector< CGBase > &res0, const std::vector< DaeVarInfo > &varInfo, const std::vector< DaeVarInfo > &newVarInfo, const std::vector< DaeEquationInfo > &eqInfo, const std::vector< DaeEquationInfo > &newEqInfo) const |
void | determineJacobian () |
void | selectDummyDerivatives (const std::vector< Enode< Base > * > &eqs, const std::vector< Vnode< Base > * > &vars, MatrixB &work) |
Static Protected Member Functions | |
static void | printModel (std::ostream &out, CodeHandler< Base > &handler, const std::vector< CGBase > &res, const std::vector< DaeVarInfo > &varInfo, const std::set< size_t > &erasedVariables, const std::set< size_t > &erasedEquations) |
static void | printGraphSparsity (std::ostream &out, const std::vector< bool > &jacSparsity, const std::map< size_t, Vnode< Base > *> &tape2FreeVariables, const std::vector< Enode< Base > *> &equations, const size_t n) |
template<class T > | |
static void | deleteVectorValues (std::vector< T *> &v) |
Protected Attributes | |
DaeStructuralIndexReduction< Base > *const | idxIdentify_ |
std::vector< Base > | x_ |
std::vector< Base > | normVar_ |
std::vector< Base > | normEq_ |
std::unique_ptr< ADFun< CGBase > > | reducedFun_ |
std::vector< bool > | jacSparsity_ |
size_t | diffVarStart_ |
size_t | diffEqStart_ |
Eigen::SparseMatrix< Base, Eigen::RowMajor > | jacobian_ |
std::vector< Vnode< Base > * > | dummyD_ |
bool | reduceEquations_ |
bool | generateSemiExplicitDae_ |
bool | reorder_ |
bool | avoidConvertAlg2DifVars_ |
std::set< std::string > | avoidAsDummy_ |
ADFun< CG< Base > > *const | fun_ |
Verbosity | verbosity_ |
std::ostream * | log_ |
Dummy derivatives DAE index reduction algorithm
Definition at line 34 of file dummy_deriv.hpp.
|
inline |
Creates the DAE index reduction algorithm that implements the dummy derivatives method.
idxIdentify | A structural index reduction method that identifies which variables and equations need to be differentiated |
x | typical variable values (used to determine Jacobian values) |
normVar | variable normalization values |
normEq | equation normalization values |
Definition at line 114 of file dummy_deriv.hpp.
|
inlineprotectedvirtual |
Consider all of the current equations that are differentiated versions of the original ones. Collect their predecessors and let them be the current equations.
Consider all current unknowns that are at least of order one. Collect their predecessors of one order less and let them be the current candidates for elimination.
Prepare the output information
Definition at line 299 of file dummy_deriv.hpp.
|
inlineprotected |
Implement the assignment in the model
Update the connections to the other equations affected by the substitution
Redetermine solvability for the affected equations
Implement changes in graph
Finalize model
Implement the assignment in the graph
Definition at line 961 of file dummy_deriv.hpp.
Referenced by CppAD::cg::DummyDerivatives< Base >::matchVars2Eqs4Elimination().
|
inlineprotected |
Determines the Jacobian relative to the differential variables (e.g. dxdt)
Definition at line 1312 of file dummy_deriv.hpp.
Referenced by CppAD::cg::DummyDerivatives< Base >::addDummyDerivatives().
|
inlineprotected |
the model must be called with the handler order
removed variables using substitution are taken out from the list of independent variables in the handler
Definition at line 1242 of file dummy_deriv.hpp.
Referenced by CppAD::cg::DummyDerivatives< Base >::reorderModelEqNVars().
|
inlineprotected |
Attempts to generate a semi-explicit DAE.
reorder | place all the differential equations and variables together |
differentialEqs |
CGException | on failure |
Generate an operation graph
Eliminate time derivatives from equations
Determine which equation to keep as differential
determine the variable indexes after the elimination of the time derivatives
Prepare the output information
Implement the reordering and derivative variable elimination in the model
Definition at line 610 of file dummy_deriv.hpp.
|
inline |
Which variables should not be selected as dummy derivatives (algebraic variables). These variables can still be selected as dummy derivatives when there is no other option.
Definition at line 235 of file dummy_deriv.hpp.
|
inlineinherited |
Provides the original model with a representation of an implicit DAE (potentially high index).
Definition at line 55 of file dae_index_reduction.hpp.
|
inline |
Whether or not to avoid converting algebraic variables to differential variables. When algebraic variables should not be converted to differential variables, derivatives for variables which where initially algebraic are selected first as dummy derivatives.
Definition at line 148 of file dummy_deriv.hpp.
|
inline |
Whether or not to attempt to generate a semi-explicit DAE by performing algebraic manipulations.
Definition at line 167 of file dummy_deriv.hpp.
|
inline |
Whether or not the total number of equations is to be reduced by performing variable substitutions.
Definition at line 186 of file dummy_deriv.hpp.
|
inline |
Whether or not variables and equations are to be reordered.
Definition at line 201 of file dummy_deriv.hpp.
|
inlineprotected |
Create a new bipartite graph
Match equations to variables (derivatives and dummy derivatives only)
assign variables that can only be solved by a single equation
assign dummy derivatives that can only be solved by a single equation
assign equations that can only be used to solve for a single variable
All variables have at least two equations that can be used and all equations have at least two variables choose a tearing variable/equation
Assign algebraic variables (except dummy derivatives) This is only for information purposes!
save results
Definition at line 725 of file dummy_deriv.hpp.
|
inlineprotected |
Attempts to reduce the number of equations by variable substitution.
newVarInfo | Variable information of the resulting model |
Generate an operation graph
maps the equations indexes of the reduced model to the new equation indexes in the model with less equations and variables (removed equations have negative indexes)
maps the variables indexes in the tape of the reduced model to the new tape indexes in the model with less equations and variables (removed variables have negative indexes)
attempt to eliminate dummy derivatives and the equation they are assigned to
Determine which equation to use to eliminate the dummy derivative
Prepare the output information
Implement the model after after the reduction of equations and variables by substitution
Definition at line 425 of file dummy_deriv.hpp.
Referenced by CppAD::cg::DummyDerivatives< Base >::setReduceEquations().
|
inlineoverridevirtual |
Performs the DAE index reduction and creates a new reduced index model.
newVarInfo | Variable related information of the reduced index model |
equationInfo | Equation related information of the reduced index model |
Variable information for the reduced
Equation information for the reduced model
Implements CppAD::cg::DaeIndexReduction< Base >.
Definition at line 239 of file dummy_deriv.hpp.
|
inlineprotected |
Determine the variables that have derivatives in the model
sort variables
reorder variables
reorder equations
Generate an operation graph
Implement the reordering in the model
Definition at line 1116 of file dummy_deriv.hpp.
|
inlineprotected |
Determine the columns/variables that must be removed
Definition at line 1382 of file dummy_deriv.hpp.
|
inline |
Defines whether or not to avoid converting algebraic variables to differential variables. When algebraic variables should not be converted to differential variables, derivatives for variables which where initially algebraic are selected first as dummy derivatives
Definition at line 159 of file dummy_deriv.hpp.
|
inline |
Define a set of variables which should not be selected as dummy derivatives (algebraic variables). These variables can still be selected as dummy derivatives when there is no other option.
avoidAsDummy | a set of variable names which should not be selected as dummy derivatives |
Definition at line 225 of file dummy_deriv.hpp.
|
inline |
Whether or not to attempt to generate a semi-explicit DAE by performing algebraic manipulations.
Definition at line 178 of file dummy_deriv.hpp.
|
inline |
Whether or not to attempt to reduce the total number of equations by performing variable substitutions.
Definition at line 194 of file dummy_deriv.hpp.
|
inline |
Whether or not to reorder variables and equations. If reordering is enabled, variables will sorted as: {differential vars, algebraic vars, derivative var, integrated var}. Equations are sorted as: {differential equations, algebraic equations}.
Definition at line 212 of file dummy_deriv.hpp.
|
protected |
Avoid using these variables as dummy derivatives
Definition at line 100 of file dummy_deriv.hpp.
Referenced by CppAD::cg::DummyDerivatives< Base >::getAvoidVarsAsDummies().
|
protected |
Dummy derivatives
Definition at line 79 of file dummy_deriv.hpp.
|
protectedinherited |
The original model representing an implicit DAE system
Definition at line 36 of file dae_index_reduction.hpp.
Referenced by CppAD::cg::DaeIndexReduction< Base >::getOriginalModel().
|
protected |
Attempt to generate a semi-explicit DAE by algebraic manipulations
Definition at line 88 of file dummy_deriv.hpp.
Referenced by CppAD::cg::DummyDerivatives< Base >::isGenerateSemiExplicitDae().
|
protected |
Method used to identify the structural index
Definition at line 44 of file dummy_deriv.hpp.
|
protected |
Normalized Jacobian of the index one system's differentiated equations relative to the time derivatives (in the new variable order).
Definition at line 75 of file dummy_deriv.hpp.
|
protected |
Jacobian sparsity pattern of the reduced system (in the original variable order)
Definition at line 65 of file dummy_deriv.hpp.
|
protected |
normalization constants for the equations
Definition at line 56 of file dummy_deriv.hpp.
|
protected |
normalization constants for the variables (in the original order)
Definition at line 52 of file dummy_deriv.hpp.
|
protected |
new index reduced model
Definition at line 60 of file dummy_deriv.hpp.
|
protected |
Attempt to reduce the total number of equations by performing variable substitutions
Definition at line 84 of file dummy_deriv.hpp.
Referenced by CppAD::cg::DummyDerivatives< Base >::isReduceEquations().
|
protected |
Reduce the total number of equations through variable substitutions
Definition at line 92 of file dummy_deriv.hpp.
Referenced by CppAD::cg::DummyDerivatives< Base >::isReorder().
|
protected |
typical values used to determine the Jacobian
Definition at line 48 of file dummy_deriv.hpp.