List of all members | Public Types | Public Member Functions | Static Public Member Functions
casadi::Function Class Reference

Function object A Function instance is a general multiple-input, multiple-output function where each input and output can be a sparse matrix.
. More...

#include <function.hpp>

Detailed Description

For an introduction to this class, see the CasADi user guide.
Function is a reference counted and immutable class; copying a class instance is very cheap and its behavior (with some exceptions) is not affected by calling its member functions.

Author
Joel Andersson
Date
2010-2017

List of available options
IdTypeDescriptionUsed in
ad_weightOT_DOUBLEWeighting factor for derivative calculation.When there is an option of either using forward or reverse mode directional derivatives, the condition ad_weight*nf<=(1-ad_weight)*na is used where nf and na are estimates of the number of forward/reverse mode directional derivatives needed. By default, ad_weight is calculated automatically, but this can be overridden by setting this option. In particular, 0 means forcing forward mode and 1 forcing reverse mode. Leave unset for (class specific) heuristics.casadi::FunctionInternal
ad_weight_spOT_DOUBLEWeighting factor for sparsity pattern calculation calculation.Overrides default behavior. Set to 0 and 1 to force forward and reverse mode respectively. Cf. option "ad_weight".casadi::FunctionInternal
compilerOT_STRINGJust-in-time compiler plugin to be used.casadi::FunctionInternal
derivative_ofOT_FUNCTIONThe function is a derivative of another function. The type of derivative (directional derivative, Jacobian) is inferred from the function name.casadi::FunctionInternal
enable_fdOT_BOOLEnable derivative calculation by finite differencing. [default: false]]casadi::FunctionInternal
enable_forwardOT_BOOLEnable derivative calculation using generated functions for Jacobian-times-vector products - typically using forward mode AD - if available. [default: true]casadi::FunctionInternal
enable_jacobianOT_BOOLEnable derivative calculation using generated functions for Jacobians of all differentiable outputs with respect to all differentiable inputs - if available. [default: true]casadi::FunctionInternal
enable_reverseOT_BOOLEnable derivative calculation using generated functions for transposed Jacobian-times-vector products - typically using reverse mode AD - if available. [default: true]casadi::FunctionInternal
fd_methodOT_STRINGMethod for finite differencing [default 'central']casadi::FunctionInternal
fd_optionsOT_DICTOptions to be passed to the finite difference instancecasadi::FunctionInternal
fd_stepOT_DOUBLEFinite difference perturbation size [default: 1e-8]casadi::FunctionInternal
gather_statsOT_BOOLDeprecated option (ignored): Statistics are now always collected.casadi::FunctionInternal
input_schemeOT_STRINGVECTORDeprecated option (ignored)casadi::FunctionInternal
inputs_checkOT_BOOLThrow exceptions when the numerical values of the inputs don't make sensecasadi::FunctionInternal
jac_penaltyOT_DOUBLEWhen requested for a number of forward/reverse directions, it may be cheaper to compute first the full jacobian and then multiply with seeds, rather than obtain the requested directions in a straightforward manner. Casadi uses a heuristic to decide which is cheaper. A high value of 'jac_penalty' makes it less likely for the heurstic to chose the full Jacobian strategy. The special value -1 indicates never to use the full Jacobian strategycasadi::FunctionInternal
jitOT_BOOLUse just-in-time compiler to speed up the evaluationcasadi::FunctionInternal
jit_optionsOT_DICTOptions to be passed to the jit compiler.casadi::FunctionInternal
max_num_dirOT_INTSpecify the maximum number of directions for derivative functions. Overrules the builtin optimized_num_dir.casadi::FunctionInternal
output_schemeOT_STRINGVECTORDeprecated option (ignored)casadi::FunctionInternal
print_timeOT_BOOLprint information about execution timecasadi::FunctionInternal
regularity_checkOT_BOOLThrow exceptions when NaN or Inf appears during evaluationcasadi::FunctionInternal
user_dataOT_VOIDPTRA user-defined field that can be used to identify the function or pass additional informationcasadi::FunctionInternal
verboseOT_BOOLVerbose evaluation – for debuggingcasadi::FunctionInternal
Examples:
integrators/simulator.py, solvers/callback.py, solvers/exacthessian.py, solvers/ipopt.py, SX/SXFunction_constr_oct.m, and SX/SXFunction_constr_py.py.

Definition at line 54 of file function.hpp.

Inheritance diagram for casadi::Function:
Inheritance graph
[legend]

Public Types

typedef std::map< std::string,
std::vector< std::string > > 
AuxOut
 

Public Member Functions

 Function ()
 Default constructor, null pointer. More...
 
 Function (const std::string &fname)
 Construct from a file. More...
 
 ~Function ()
 To resolve ambiguity on some compilers. More...
 
int n_in () const
 Get the number of function inputs. More...
 
int n_out () const
 Get the number of function outputs. More...
 
std::vector< std::string > name_in () const
 Get input scheme. More...
 
std::vector< std::string > name_out () const
 Get output scheme. More...
 
std::string name_in (int ind) const
 Get input scheme name by index. More...
 
std::string name_out (int ind) const
 Get output scheme name by index. More...
 
int index_in (const std::string &name) const
 Find the index for a string describing a particular entry of an input scheme. More...
 
int index_out (const std::string &name) const
 Find the index for a string describing a particular entry of an output scheme. More...
 
double default_in (int ind) const
 Get default input value. More...
 
double max_in (int ind) const
 Get largest input value. More...
 
double min_in (int ind) const
 Get smallest input value. More...
 
Function factory (const std::string &name, const std::vector< std::string > &s_in, const std::vector< std::string > &s_out, const AuxOut &aux=AuxOut(), const Dict &opts=Dict()) const
 
Function oracle () const
 Get oracle. More...
 
Function wrap () const
 Wrap in an Function instance consisting of only one MX call. More...
 
std::vector< bool > which_depends (const std::string &s_in, const std::vector< std::string > &s_out, int order=1, bool tr=false) const
 Which variables enter with some order. More...
 
void print_dimensions (std::ostream &stream=casadi::userOut()) const
 Print dimensions of inputs and outputs. More...
 
void print_options (std::ostream &stream=casadi::userOut()) const
 Print options to a stream. More...
 
void print_option (const std::string &name, std::ostream &stream=casadi::userOut()) const
 Print all information there is to know about a certain option. More...
 
bool uses_output () const
 Do the derivative functions need nondifferentiated outputs? More...
 
std::vector< MXmapsum (const std::vector< MX > &arg, const std::string &parallelization="serial") const
 Evaluate symbolically in parallel and sum (matrix graph) More...
 
Function map (int n, const std::string &parallelization="serial") const
 Create a mapped version of this function. More...
 
Function slice (const std::string &name, const std::vector< int > &order_in, const std::vector< int > &order_out, const Dict &opts=Dict()) const
 returns a new function with a selection of inputs/outputs of the original More...
 
Function forward (int nfwd) const
 Get a function that calculates nfwd forward derivatives. More...
 
Function reverse (int nadj) const
 Get a function that calculates nadj adjoint derivatives. More...
 
std::string generate (const std::string &fname, const Dict &opts=Dict()) const
 Export / Generate C code for the function. More...
 
std::string generate (const Dict &opts=Dict()) const
 Export / Generate C code for the function. More...
 
std::string generate_dependencies (const std::string &fname, const Dict &opts=Dict()) const
 Export / Generate C code for the dependency function. More...
 
Dict stats (int mem=0) const
 Get all statistics obtained at the end of the last evaluate call. More...
 
bool has_free () const
 Does the function have free variables. More...
 
std::vector< std::string > get_free () const
 Get free variables as a string. More...
 
void print_free (std::ostream &stream=casadi::userOut()) const
 [DEPRECATED] Use get_free instead More...
 
std::vector< SXfree_sx () const
 Get all the free variables of the function. More...
 
std::vector< MXfree_mx () const
 Get all the free variables of the function. More...
 
void generate_lifted (Function &output_vdef_fcn, Function &output_vinit_fcn) const
 Extract the functions needed for the Lifted Newton method. More...
 
int n_nodes () const
 Number of nodes in the algorithm. More...
 
int n_instructions () const
 Number of instruction in the algorithm (SXFunction) More...
 
int instruction_id (int k) const
 Identifier index of the instruction (SXFunction) More...
 
std::pair< int, int > instruction_input (int k) const
 Locations in the work vector for the inputs of the instruction (SXFunction) More...
 
double instruction_constant (int k) const
 Get the floating point output argument of an instruction (SXFunction) More...
 
int instruction_output (int k) const
 Location in the work vector for the output of the instruction (SXFunction) More...
 
int getAlgorithmSize () const
 [DEPRECATED] Renamed n_instructions More...
 
int getWorkSize () const
 [DEPRECATED] Use sz_w instead More...
 
int getAtomicOperation (int k) const
 [DEPRECATED] Renamed instruction_id More...
 
std::pair< int, int > getAtomicInput (int k) const
 [DEPRECATED] Renamed instruction_index More...
 
double getAtomicInputReal (int k) const
 [DEPRECATED] Renamed instruction_constant More...
 
int getAtomicOutput (int k) const
 [DEPRECATED] Renamed instruction_output More...
 
std::string name () const
 Name of the function. More...
 
bool is_a (const std::string &type, bool recursive=true) const
 Check if the function is of a particular type Optionally check if name matches one of the base classes (default true) More...
 
void assert_size_in (int i, int nrow, int ncol) const
 Assert that an input dimension is equal so some given value. More...
 
void assert_size_out (int i, int nrow, int ncol) const
 Assert that an output dimension is equal so some given value. More...
 
int checkout () const
 Checkout a memory object. More...
 
void release (int mem) const
 Release a memory object. More...
 
std::vector< std::string > get_function () const
 
Function get_function (const std::string &name) const
 
bool has_function (const std::string &fname) const
 
void conic_debug (const std::string &filename) const
 
void conic_debug (std::ostream &file) const
 
std::string class_name () const
 Get class name. More...
 
void disp (std::ostream &stream, bool more=false) const
 Print a description of the object. More...
 
std::string get_str (bool more=false) const
 Get string representation. More...
 
bool is_null () const
 Is a null pointer? More...
 
size_t __hash__ () const
 Returns a number that is unique for a given Node. If the Object does not point to any node, "0" is returned. More...
 
 Function (const std::string &name, const std::vector< SX > &ex_in, const std::vector< SX > &ex_out, const Dict &opts=Dict())
 Construct an SX function. More...
 
 Function (const std::string &name, const std::vector< SX > &ex_in, const std::vector< SX > &ex_out, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict())
 Construct an SX function. More...
 
 Function (const std::string &name, const std::map< std::string, SX > &dict, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict())
 Construct an SX function. More...
 
 Function (const std::string &name, const std::vector< MX > &ex_in, const std::vector< MX > &ex_out, const Dict &opts=Dict())
 Construct an MX function. More...
 
 Function (const std::string &name, const std::vector< MX > &ex_in, const std::vector< MX > &ex_out, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict())
 Construct an MX function. More...
 
 Function (const std::string &name, const std::map< std::string, MX > &dict, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict())
 Construct an MX function. More...
 
Function expand () const
 Expand a function to SX. More...
 
Function expand (const std::string &name, const Dict &opts=Dict()) const
 Expand a function to SX. More...
 
int size1_in (int ind) const
 Get input dimension. More...
 
int size1_in (const std::string &iname) const
 Get input dimension. More...
 
int size2_in (int ind) const
 Get input dimension. More...
 
int size2_in (const std::string &iname) const
 Get input dimension. More...
 
std::pair< int, int > size_in (int ind) const
 Get input dimension. More...
 
std::pair< int, int > size_in (const std::string &iname) const
 Get input dimension. More...
 
int size1_out (int ind) const
 Get output dimension. More...
 
int size1_out (const std::string &oname) const
 Get output dimension. More...
 
int size2_out (int ind) const
 Get output dimension. More...
 
int size2_out (const std::string &oname) const
 Get output dimension. More...
 
std::pair< int, int > size_out (int ind) const
 Get output dimension. More...
 
std::pair< int, int > size_out (const std::string &oname) const
 Get output dimension. More...
 
int nnz_in () const
 Get number of input nonzeros. More...
 
int nnz_in (int ind) const
 Get number of input nonzeros. More...
 
int nnz_in (const std::string &iname) const
 Get number of input nonzeros. More...
 
int nnz_out () const
 Get number of output nonzeros. More...
 
int nnz_out (int ind) const
 Get number of output nonzeros. More...
 
int nnz_out (const std::string &oname) const
 Get number of output nonzeros. More...
 
int numel_in () const
 Get number of input elements. More...
 
int numel_in (int ind) const
 Get number of input elements. More...
 
int numel_in (const std::string &iname) const
 Get number of input elements. More...
 
int numel_out () const
 Get number of output elements. More...
 
int numel_out (int ind) const
 Get number of output elements. More...
 
int numel_out (const std::string &oname) const
 Get number of output elements. More...
 
const Sparsitysparsity_in (int ind) const
 Get sparsity of a given input. More...
 
const Sparsitysparsity_in (const std::string &iname) const
 Get sparsity of a given input. More...
 
const Sparsitysparsity_out (int ind) const
 Get sparsity of a given output. More...
 
const Sparsitysparsity_out (const std::string &iname) const
 Get sparsity of a given output. More...
 
Function jacobian_old (int iind, int oind) const
 Generate a Jacobian function of output oind with respect to input iind. More...
 
Function hessian_old (int iind, int oind) const
 Generate a Hessian function of output oind with respect to input iind. More...
 
Function jacobian () const
 Generate a Jacobian function of all the inputs elements with respect to all the output elements). More...
 
Function fullJacobian () const
 [DEPRECATED] Alias of Function::jacobian More...
 
void call (const std::vector< DM > &arg, std::vector< DM > &output_res, bool always_inline=false, bool never_inline=false) const
 Evaluate the function symbolically or numerically. More...
 
void call (const std::vector< SX > &arg, std::vector< SX > &output_res, bool always_inline=false, bool never_inline=false) const
 Generate a Jacobian function of output oind with respect to input iind. More...
 
void call (const std::vector< MX > &arg, std::vector< MX > &output_res, bool always_inline=false, bool never_inline=false) const
 Generate a Jacobian function of output oind with respect to input iind. More...
 
void call (const DMDict &arg, DMDict &output_res, bool always_inline=false, bool never_inline=false) const
 Generate a Jacobian function of output oind with respect to input iind. More...
 
void call (const SXDict &arg, SXDict &output_res, bool always_inline=false, bool never_inline=false) const
 Generate a Jacobian function of output oind with respect to input iind. More...
 
void call (const MXDict &arg, MXDict &output_res, bool always_inline=false, bool never_inline=false) const
 Generate a Jacobian function of output oind with respect to input iind. More...
 
Function mapaccum (const std::string &name, int n, int n_accum=1, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function mapaccum (const std::string &name, int n, const std::vector< int > &accum_in, const std::vector< int > &accum_out, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function mapaccum (const std::string &name, int n, const std::vector< std::string > &accum_in, const std::vector< std::string > &accum_out, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function map (const std::string &name, const std::string &parallelization, int n, const std::vector< int > &reduce_in, const std::vector< int > &reduce_out, const Dict &opts=Dict()) const
 Map with reduction A subset of the inputs are non-repeated and a subset of the outputs summed up. More...
 
Function map (const std::string &name, const std::string &parallelization, int n, const std::vector< std::string > &reduce_in, const std::vector< std::string > &reduce_out, const Dict &opts=Dict()) const
 Map with reduction A subset of the inputs are non-repeated and a subset of the outputs summed up. More...
 
const Sparsity sparsity_jac (int iind, int oind, bool compact=false, bool symmetric=false) const
 
const Sparsity sparsity_jac (const std::string &iind, int oind=0, bool compact=false, bool symmetric=false) const
 
const Sparsity sparsity_jac (int iind, const std::string &oind, bool compact=false, bool symmetric=false) const
 
const Sparsity sparsity_jac (const std::string &iind, const std::string &oind, bool compact=false, bool symmetric=false) const
 
const SX sx_in (int iind) const
 Get symbolic primitives equivalent to the input expressions There is no guarantee that subsequent calls return unique answers. More...
 
const SX sx_in (const std::string &iname) const
 Get symbolic primitives equivalent to the input expressions There is no guarantee that subsequent calls return unique answers. More...
 
const std::vector< SXsx_in () const
 Get symbolic primitives equivalent to the input expressions There is no guarantee that subsequent calls return unique answers. More...
 
const MX mx_in (int ind) const
 Get symbolic primitives equivalent to the input expressions There is no guarantee that subsequent calls return unique answers. More...
 
const MX mx_in (const std::string &iname) const
 Get symbolic primitives equivalent to the input expressions There is no guarantee that subsequent calls return unique answers. More...
 
const std::vector< MXmx_in () const
 Get symbolic primitives equivalent to the input expressions There is no guarantee that subsequent calls return unique answers. More...
 
const SX sx_out (int oind) const
 Get symbolic primitives equivalent to the output expressions There is no guarantee that subsequent calls return unique answers. More...
 
const SX sx_out (const std::string &oname) const
 Get symbolic primitives equivalent to the output expressions There is no guarantee that subsequent calls return unique answers. More...
 
const std::vector< SXsx_out () const
 Get symbolic primitives equivalent to the output expressions There is no guarantee that subsequent calls return unique answers. More...
 
const MX mx_out (int ind) const
 Get symbolic primitives equivalent to the output expressions There is no guarantee that subsequent calls return unique answers. More...
 
const MX mx_out (const std::string &oname) const
 Get symbolic primitives equivalent to the output expressions There is no guarantee that subsequent calls return unique answers. More...
 
const std::vector< MXmx_out () const
 Get symbolic primitives equivalent to the output expressions There is no guarantee that subsequent calls return unique answers. More...
 
bool has_spfwd () const
 Is the class able to propagate seeds through the algorithm? More...
 
bool has_sprev () const
 Is the class able to propagate seeds through the algorithm? More...
 

Static Public Member Functions

static std::string type_name ()
 Get type name. More...
 
static Function conditional (const std::string &name, const std::vector< Function > &f, const Function &f_def, const Dict &opts=Dict())
 Constuct a switch function. More...
 
static Function bspline (const std::string &name, const std::vector< std::vector< double > > &knots, const std::vector< double > &coeffs, const std::vector< int > &degree, int m=1, const Dict &opts=Dict())
 BSpline evaluator function. More...
 
static Function bspline_dual (const std::string &name, const std::vector< std::vector< double > > &knots, const std::vector< double > &x, const std::vector< int > &degree, int m=1, bool reverse=false, const Dict &opts=Dict())
 Dual BSpline evaluator function. More...
 
static Function if_else (const std::string &name, const Function &f_true, const Function &f_false, const Dict &opts=Dict())
 Constructor (if-else) More...
 
static bool check_name (const std::string &name)
 Check if a string is a valid function name Valid function names consist of. More...
 
static std::string fix_name (const std::string &name)
 Turn a string into a valid function name as defined by "check_name" Non-alphanumeric characters are converted into underscores and multiple consecutive undercores are dropped. More...
 

Member Typedef Documentation

typedef std::map<std::string, std::vector<std::string> > casadi::Function::AuxOut

Definition at line 275 of file function.hpp.

Constructor & Destructor Documentation

casadi::Function::Function ( )
casadi::Function::Function ( const std::string &  fname)
casadi::Function::Function ( const std::string &  name,
const std::vector< SX > &  ex_in,
const std::vector< SX > &  ex_out,
const Dict opts = Dict() 
)
casadi::Function::Function ( const std::string &  name,
const std::vector< SX > &  ex_in,
const std::vector< SX > &  ex_out,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts = Dict() 
)
casadi::Function::Function ( const std::string &  name,
const std::map< std::string, SX > &  dict,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts = Dict() 
)
casadi::Function::Function ( const std::string &  name,
const std::vector< MX > &  ex_in,
const std::vector< MX > &  ex_out,
const Dict opts = Dict() 
)
casadi::Function::Function ( const std::string &  name,
const std::vector< MX > &  ex_in,
const std::vector< MX > &  ex_out,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts = Dict() 
)
casadi::Function::Function ( const std::string &  name,
const std::map< std::string, MX > &  dict,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts = Dict() 
)
casadi::Function::~Function ( )

Destructor

Member Function Documentation

size_t casadi::SharedObject::__hash__ ( ) const
inherited
void casadi::Function::assert_size_in ( int  i,
int  nrow,
int  ncol 
) const
void casadi::Function::assert_size_out ( int  i,
int  nrow,
int  ncol 
) const
static Function casadi::Function::bspline ( const std::string &  name,
const std::vector< std::vector< double > > &  knots,
const std::vector< double > &  coeffs,
const std::vector< int > &  degree,
int  m = 1,
const Dict opts = Dict() 
)
static

Requires a known coefficient tensor

static Function casadi::Function::bspline_dual ( const std::string &  name,
const std::vector< std::vector< double > > &  knots,
const std::vector< double > &  x,
const std::vector< int > &  degree,
int  m = 1,
bool  reverse = false,
const Dict opts = Dict() 
)
static

Requires known evaluation positions WARNING: This function may drastically change or be removed

void casadi::Function::call ( const std::vector< DM > &  arg,
std::vector< DM > &  output_res,
bool  always_inline = false,
bool  never_inline = false 
) const
void casadi::Function::call ( const std::vector< SX > &  arg,
std::vector< SX > &  output_res,
bool  always_inline = false,
bool  never_inline = false 
) const
Parameters
iindThe index of the input
oindThe index of the output Legacy function: To be deprecated in a future version of CasADi. Exists only for compatibility with Function::jacobian pre-CasADi 3.2
void casadi::Function::call ( const std::vector< MX > &  arg,
std::vector< MX > &  output_res,
bool  always_inline = false,
bool  never_inline = false 
) const
Parameters
iindThe index of the input
oindThe index of the output Legacy function: To be deprecated in a future version of CasADi. Exists only for compatibility with Function::jacobian pre-CasADi 3.2
void casadi::Function::call ( const DMDict arg,
DMDict output_res,
bool  always_inline = false,
bool  never_inline = false 
) const
Parameters
iindThe index of the input
oindThe index of the output Legacy function: To be deprecated in a future version of CasADi. Exists only for compatibility with Function::jacobian pre-CasADi 3.2
void casadi::Function::call ( const SXDict arg,
SXDict output_res,
bool  always_inline = false,
bool  never_inline = false 
) const
Parameters
iindThe index of the input
oindThe index of the output Legacy function: To be deprecated in a future version of CasADi. Exists only for compatibility with Function::jacobian pre-CasADi 3.2
void casadi::Function::call ( const MXDict arg,
MXDict output_res,
bool  always_inline = false,
bool  never_inline = false 
) const
Parameters
iindThe index of the input
oindThe index of the output Legacy function: To be deprecated in a future version of CasADi. Exists only for compatibility with Function::jacobian pre-CasADi 3.2
static bool casadi::Function::check_name ( const std::string &  name)
static
  • At least one character
  • Upper and lower case letters: a-zA-Z
  • Numbers 0-9, but never as first character
  • Underscore, but never as first character and never next to another underscore

May not be one of the following keywords: "null", "jac", "hess"

int casadi::Function::checkout ( ) const
std::string casadi::SharedObject::class_name ( ) const
inherited
static Function casadi::Function::conditional ( const std::string &  name,
const std::vector< Function > &  f,
const Function f_def,
const Dict opts = Dict() 
)
static
void casadi::Function::conic_debug ( const std::string &  filename) const

Generate native code in the interfaced language for debugging

void casadi::Function::conic_debug ( std::ostream &  file) const

Generate native code in the interfaced language for debugging

double casadi::Function::default_in ( int  ind) const
void casadi::SharedObject::disp ( std::ostream &  stream,
bool  more = false 
) const
inherited
Function casadi::Function::expand ( ) const
Function casadi::Function::expand ( const std::string &  name,
const Dict opts = Dict() 
) const
Function casadi::Function::factory ( const std::string &  name,
const std::vector< std::string > &  s_in,
const std::vector< std::string > &  s_out,
const AuxOut aux = AuxOut(),
const Dict opts = Dict() 
) const
static std::string casadi::Function::fix_name ( const std::string &  name)
static
Function casadi::Function::forward ( int  nfwd) const

Returns a function with n_in + n_out + n_in inputs and nfwd outputs. The first n_in inputs correspond to nondifferentiated inputs. The next n_out inputs correspond to nondifferentiated outputs. and the last n_in inputs correspond to forward seeds, stacked horizontally The n_out outputs correspond to forward sensitivities, stacked horizontally. * (n_in = n_in(), n_out = n_out())

The functions returned are cached, meaning that if called multiple timed with the same value, then multiple references to the same function will be returned.

std::vector<MX> casadi::Function::free_mx ( ) const
std::vector<SX> casadi::Function::free_sx ( ) const
Function casadi::Function::fullJacobian ( ) const
inline

Definition at line 335 of file function.hpp.

std::string casadi::Function::generate ( const std::string &  fname,
const Dict opts = Dict() 
) const
Examples:
SX/generateCode.py.
std::string casadi::Function::generate ( const Dict opts = Dict()) const
std::string casadi::Function::generate_dependencies ( const std::string &  fname,
const Dict opts = Dict() 
) const
void casadi::Function::generate_lifted ( Function output_vdef_fcn,
Function output_vinit_fcn 
) const
std::vector<std::string> casadi::Function::get_free ( ) const
std::vector<std::string> casadi::Function::get_function ( ) const
Function casadi::Function::get_function ( const std::string &  name) const
std::string casadi::SharedObject::get_str ( bool  more = false) const
inlineinherited

Definition at line 133 of file shared_object.hpp.

int casadi::Function::getAlgorithmSize ( ) const
inline

Definition at line 711 of file function.hpp.

std::pair<int, int> casadi::Function::getAtomicInput ( int  k) const
inline

Definition at line 720 of file function.hpp.

double casadi::Function::getAtomicInputReal ( int  k) const
inline

Definition at line 723 of file function.hpp.

int casadi::Function::getAtomicOperation ( int  k) const
inline

Definition at line 717 of file function.hpp.

int casadi::Function::getAtomicOutput ( int  k) const
inline

Definition at line 726 of file function.hpp.

int casadi::Function::getWorkSize ( ) const
inline

Definition at line 714 of file function.hpp.

bool casadi::Function::has_free ( ) const
bool casadi::Function::has_function ( const std::string &  fname) const
bool casadi::Function::has_spfwd ( ) const
bool casadi::Function::has_sprev ( ) const
Function casadi::Function::hessian_old ( int  iind,
int  oind 
) const
Parameters
iindThe index of the input
oindThe index of the output Legacy function: To be deprecated in a future version of CasADi. Exists only for compatibility with Function::hessian pre-CasADi 3.2
static Function casadi::Function::if_else ( const std::string &  name,
const Function f_true,
const Function f_false,
const Dict opts = Dict() 
)
static
int casadi::Function::index_in ( const std::string &  name) const

example: schemeEntry("x_opt") -> returns NLPSOL_X if FunctionInternal adheres to SCHEME_NLPINput

int casadi::Function::index_out ( const std::string &  name) const

example: schemeEntry("x_opt") -> returns NLPSOL_X if FunctionInternal adheres to SCHEME_NLPINput

double casadi::Function::instruction_constant ( int  k) const
int casadi::Function::instruction_id ( int  k) const
std::pair<int, int> casadi::Function::instruction_input ( int  k) const
int casadi::Function::instruction_output ( int  k) const
bool casadi::Function::is_a ( const std::string &  type,
bool  recursive = true 
) const
bool casadi::SharedObject::is_null ( ) const
inherited
Function casadi::Function::jacobian ( ) const
Function casadi::Function::jacobian_old ( int  iind,
int  oind 
) const
Parameters
iindThe index of the input
oindThe index of the output Legacy function: To be deprecated in a future version of CasADi. Exists only for compatibility with Function::jacobian pre-CasADi 3.2
Function casadi::Function::map ( int  n,
const std::string &  parallelization = "serial" 
) const

Suppose the function has a signature of:

   f: (a, p) -> ( s )

The the mapped version has the signature:

   F: (A, P) -> (S )

    with
        A: horzcat([a0, a1, ..., a_(N-1)])
        P: horzcat([p0, p1, ..., p_(N-1)])
        S: horzcat([s0, s1, ..., s_(N-1)])
    and
        s0 <- f(a0, p0)
        s1 <- f(a1, p1)
        ...
        s_(N-1) <- f(a_(N-1), p_(N-1))
Parameters
parallelizationType of parallelization used: unroll|serial|openmp
Function casadi::Function::map ( const std::string &  name,
const std::string &  parallelization,
int  n,
const std::vector< int > &  reduce_in,
const std::vector< int > &  reduce_out,
const Dict opts = Dict() 
) const
Function casadi::Function::map ( const std::string &  name,
const std::string &  parallelization,
int  n,
const std::vector< std::string > &  reduce_in,
const std::vector< std::string > &  reduce_out,
const Dict opts = Dict() 
) const
Function casadi::Function::mapaccum ( const std::string &  name,
int  n,
int  n_accum = 1,
const Dict opts = Dict() 
) const

Suppose the function has a signature of:

   f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

   F: (x0, U) -> (X , Y )

    with
        U: horzcat([u0, u1, ..., u_(N-1)])
        X: horzcat([x1, x2, ..., x_N])
        Y: horzcat([y0, y1, ..., y_(N-1)])

    and
        x1, y0 <- f(x0, u0)
        x2, y1 <- f(x1, u1)
        ...
        x_N, y_(N-1) <- f(x_(N-1), u_(N-1))
Function casadi::Function::mapaccum ( const std::string &  name,
int  n,
const std::vector< int > &  accum_in,
const std::vector< int > &  accum_out,
const Dict opts = Dict() 
) const

Suppose the function has a signature of:

   f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

   F: (x0, U) -> (X , Y )

    with
        U: horzcat([u0, u1, ..., u_(N-1)])
        X: horzcat([x1, x2, ..., x_N])
        Y: horzcat([y0, y1, ..., y_(N-1)])

    and
        x1, y0 <- f(x0, u0)
        x2, y1 <- f(x1, u1)
        ...
        x_N, y_(N-1) <- f(x_(N-1), u_(N-1))
Function casadi::Function::mapaccum ( const std::string &  name,
int  n,
const std::vector< std::string > &  accum_in,
const std::vector< std::string > &  accum_out,
const Dict opts = Dict() 
) const

Suppose the function has a signature of:

   f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

   F: (x0, U) -> (X , Y )

    with
        U: horzcat([u0, u1, ..., u_(N-1)])
        X: horzcat([x1, x2, ..., x_N])
        Y: horzcat([y0, y1, ..., y_(N-1)])

    and
        x1, y0 <- f(x0, u0)
        x2, y1 <- f(x1, u1)
        ...
        x_N, y_(N-1) <- f(x_(N-1), u_(N-1))
std::vector<MX> casadi::Function::mapsum ( const std::vector< MX > &  arg,
const std::string &  parallelization = "serial" 
) const
Parameters
parallelizationType of parallelization used: unroll|serial|openmp
double casadi::Function::max_in ( int  ind) const
double casadi::Function::min_in ( int  ind) const
const MX casadi::Function::mx_in ( int  ind) const
const MX casadi::Function::mx_in ( const std::string &  iname) const
inline

Definition at line 646 of file function.hpp.

const std::vector<MX> casadi::Function::mx_in ( ) const
const MX casadi::Function::mx_out ( int  ind) const
const MX casadi::Function::mx_out ( const std::string &  oname) const
inline

Definition at line 662 of file function.hpp.

const std::vector<MX> casadi::Function::mx_out ( ) const
int casadi::Function::n_in ( ) const
int casadi::Function::n_instructions ( ) const
int casadi::Function::n_nodes ( ) const
int casadi::Function::n_out ( ) const
std::string casadi::Function::name ( ) const
std::vector<std::string> casadi::Function::name_in ( ) const
std::string casadi::Function::name_in ( int  ind) const
std::vector<std::string> casadi::Function::name_out ( ) const
std::string casadi::Function::name_out ( int  ind) const
int casadi::Function::nnz_in ( ) const

For a particular input or for all of the inputs

int casadi::Function::nnz_in ( int  ind) const

For a particular input or for all of the inputs

int casadi::Function::nnz_in ( const std::string &  iname) const
inline

For a particular input or for all of the inputs

Definition at line 194 of file function.hpp.

int casadi::Function::nnz_out ( ) const

For a particular output or for all of the outputs

int casadi::Function::nnz_out ( int  ind) const

For a particular output or for all of the outputs

int casadi::Function::nnz_out ( const std::string &  oname) const
inline

For a particular output or for all of the outputs

Definition at line 204 of file function.hpp.

int casadi::Function::numel_in ( ) const

For a particular input or for all of the inputs

int casadi::Function::numel_in ( int  ind) const

For a particular input or for all of the inputs

int casadi::Function::numel_in ( const std::string &  iname) const
inline

For a particular input or for all of the inputs

Definition at line 214 of file function.hpp.

int casadi::Function::numel_out ( ) const

For a particular output or for all of the outputs

int casadi::Function::numel_out ( int  ind) const

For a particular output or for all of the outputs

int casadi::Function::numel_out ( const std::string &  oname) const
inline

For a particular output or for all of the outputs

Definition at line 224 of file function.hpp.

Function casadi::Function::oracle ( ) const
void casadi::Function::print_dimensions ( std::ostream &  stream = casadi::userOut()) const
void casadi::Function::print_free ( std::ostream &  stream = casadi::userOut()) const
inline

Definition at line 676 of file function.hpp.

void casadi::Function::print_option ( const std::string &  name,
std::ostream &  stream = casadi::userOut() 
) const
void casadi::Function::print_options ( std::ostream &  stream = casadi::userOut()) const
void casadi::Function::release ( int  mem) const
Function casadi::Function::reverse ( int  nadj) const

Returns a function with n_in + n_out + n_out inputs and n_in outputs. The first n_in inputs correspond to nondifferentiated inputs. The next n_out inputs correspond to nondifferentiated outputs. and the last n_out inputs correspond to adjoint seeds, stacked horizontally The n_in outputs correspond to adjoint sensitivities, stacked horizontally. * (n_in = n_in(), n_out = n_out())

(n_in = n_in(), n_out = n_out())

The functions returned are cached, meaning that if called multiple timed with the same value, then multiple references to the same function will be returned.

int casadi::Function::size1_in ( int  ind) const
int casadi::Function::size1_in ( const std::string &  iname) const
inline

Definition at line 168 of file function.hpp.

int casadi::Function::size1_out ( int  ind) const
int casadi::Function::size1_out ( const std::string &  oname) const
inline

Definition at line 178 of file function.hpp.

int casadi::Function::size2_in ( int  ind) const
int casadi::Function::size2_in ( const std::string &  iname) const
inline

Definition at line 170 of file function.hpp.

int casadi::Function::size2_out ( int  ind) const
int casadi::Function::size2_out ( const std::string &  oname) const
inline

Definition at line 180 of file function.hpp.

std::pair<int, int> casadi::Function::size_in ( int  ind) const
std::pair<int, int> casadi::Function::size_in ( const std::string &  iname) const
inline

Definition at line 172 of file function.hpp.

std::pair<int, int> casadi::Function::size_out ( int  ind) const
std::pair<int, int> casadi::Function::size_out ( const std::string &  oname) const
inline

Definition at line 182 of file function.hpp.

Function casadi::Function::slice ( const std::string &  name,
const std::vector< int > &  order_in,
const std::vector< int > &  order_out,
const Dict opts = Dict() 
) const
const Sparsity& casadi::Function::sparsity_in ( int  ind) const
const Sparsity& casadi::Function::sparsity_in ( const std::string &  iname) const
const Sparsity casadi::Function::sparsity_jac ( int  iind,
int  oind,
bool  compact = false,
bool  symmetric = false 
) const

Get, if necessary generate, the sparsity of a Jacobian block

const Sparsity casadi::Function::sparsity_jac ( const std::string &  iind,
int  oind = 0,
bool  compact = false,
bool  symmetric = false 
) const
inline

Get, if necessary generate, the sparsity of a Jacobian block

Definition at line 589 of file function.hpp.

const Sparsity casadi::Function::sparsity_jac ( int  iind,
const std::string &  oind,
bool  compact = false,
bool  symmetric = false 
) const
inline

Get, if necessary generate, the sparsity of a Jacobian block

Definition at line 593 of file function.hpp.

const Sparsity casadi::Function::sparsity_jac ( const std::string &  iind,
const std::string &  oind,
bool  compact = false,
bool  symmetric = false 
) const
inline

Get, if necessary generate, the sparsity of a Jacobian block

Definition at line 597 of file function.hpp.

const Sparsity& casadi::Function::sparsity_out ( int  ind) const
const Sparsity& casadi::Function::sparsity_out ( const std::string &  iname) const
Dict casadi::Function::stats ( int  mem = 0) const
const SX casadi::Function::sx_in ( int  iind) const
const SX casadi::Function::sx_in ( const std::string &  iname) const
inline

Definition at line 641 of file function.hpp.

const std::vector<SX> casadi::Function::sx_in ( ) const
const SX casadi::Function::sx_out ( int  oind) const
const SX casadi::Function::sx_out ( const std::string &  oname) const
inline

Definition at line 657 of file function.hpp.

const std::vector<SX> casadi::Function::sx_out ( ) const
static std::string casadi::Function::type_name ( )
inlinestatic

Definition at line 59 of file function.hpp.

bool casadi::Function::uses_output ( ) const
std::vector<bool> casadi::Function::which_depends ( const std::string &  s_in,
const std::vector< std::string > &  s_out,
int  order = 1,
bool  tr = false 
) const
Parameters
[in]orderOnly 1 (linear) and 2 (nonlinear) allowed
[in]trFlip the relationship. Return which expressions contain the variables
Function casadi::Function::wrap ( ) const

The documentation for this class was generated from the following file:
Release pointers: extensive python examples, Users Guide (pdf | html )
Official releases: 3.2.0 3.1.1 3.0.0 2.4.2 2.3.0 2.2.0 2.1.1 2.0.0 1.9.0 1.8.0 1.7.1 1.7.0 1.6.1 1.6.0 1.5.0 1.4.0 1.3.0 bleeding edge