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

Function object. More...

#include <function.hpp>

Detailed Description

A Function instance is a general multiple-input, multiple-output function where each input and output can be a sparse matrix.
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

Extra doc: https://github.com/casadi/casadi/wiki/L_1uw

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". When set to -1, sparsity is completely ignored and dense matrices are used.casadi::FunctionInternal
always_inlineOT_BOOLForce inlining.casadi::FunctionInternal
cacheOT_DICTPrepopulate the function cache. Default: emptycasadi::FunctionInternal
compilerOT_STRINGJust-in-time compiler plugin to be used.casadi::FunctionInternal
custom_jacobianOT_FUNCTIONOverride CasADi's AD. Use together with 'jac_penalty': 0. Note: Highly experimental. Syntax may break often.casadi::FunctionInternal
der_optionsOT_DICTDefault options to be used to populate forward_options, reverse_options, and jacobian_options before those options are merged in.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
dumpOT_BOOLDump function to file upon first evaluation. [false]casadi::FunctionInternal
dump_dirOT_STRINGDirectory to dump inputs/outputs to. Make sure the directory exists [.]casadi::FunctionInternal
dump_formatOT_STRINGChoose file format to dump matrices. See DM.from_file [mtx]casadi::FunctionInternal
dump_inOT_BOOLDump numerical values of inputs to file (readable with DM.from_file) [default: false]casadi::FunctionInternal
dump_outOT_BOOLDump numerical values of outputs to file (readable with DM.from_file) [default: false]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
error_on_failOT_BOOLThrow exceptions when function evaluation fails (default true).casadi::ProtoFunction
fd_methodOT_STRINGMethod for finite differencing [default 'central']casadi::FunctionInternal
fd_optionsOT_DICTOptions to be passed to the finite difference instancecasadi::FunctionInternal
forward_optionsOT_DICTOptions to be passed to a forward mode constructorcasadi::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
is_diff_inOT_BOOLVECTORIndicate for each input if it should be differentiable.casadi::FunctionInternal
is_diff_outOT_BOOLVECTORIndicate for each output if it should be differentiable.casadi::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
jacobian_optionsOT_DICTOptions to be passed to a Jacobian constructorcasadi::FunctionInternal
jitOT_BOOLUse just-in-time compiler to speed up the evaluationcasadi::FunctionInternal
jit_cleanupOT_BOOLCleanup up the temporary source file that jit creates. Default: truecasadi::FunctionInternal
jit_nameOT_STRINGThe file name used to write out code. The actual file names used depend on 'jit_temp_suffix' and include extensions. Default: 'jit_tmp'casadi::FunctionInternal
jit_optionsOT_DICTOptions to be passed to the jit compiler.casadi::FunctionInternal
jit_serializeOT_STRINGSpecify behaviour when serializing a jitted function: SOURCE|link|embed.casadi::FunctionInternal
jit_temp_suffixOT_BOOLUse a temporary (seemingly random) filename suffix for generated code and libraries. This is desired for thread-safety. This behaviour may defeat caching compiler wrappers. Default: truecasadi::FunctionInternal
max_ioOT_INTAcceptable number of inputs and outputs. Warn if exceeded.casadi::FunctionInternal
max_num_dirOT_INTSpecify the maximum number of directions for derivative functions. Overrules the builtin optimized_num_dir.casadi::FunctionInternal
never_inlineOT_BOOLForbid inlining.casadi::FunctionInternal
output_schemeOT_STRINGVECTORDeprecated option (ignored)casadi::FunctionInternal
post_expandOT_BOOLAfter construction, expand this Function. Default: Falsecasadi::FunctionInternal
post_expand_optionsOT_DICTOptions to be passed to post-construction expansion. Default: emptycasadi::FunctionInternal
print_inOT_BOOLPrint numerical values of inputs [default: false]casadi::FunctionInternal
print_outOT_BOOLPrint numerical values of outputs [default: false]casadi::FunctionInternal
print_timeOT_BOOLprint information about execution time. Implies record_time.casadi::ProtoFunction
record_timeOT_BOOLrecord information about execution time, for retrieval with stats().casadi::ProtoFunction
regularity_checkOT_BOOLThrow exceptions when NaN or Inf appears during evaluationcasadi::ProtoFunction
reverse_optionsOT_DICTOptions to be passed to a reverse mode constructorcasadi::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::ProtoFunction
Examples
SX/SXFunction_constr_oct.m, SX/SXFunction_constr_py.py, integrators/simulator.py, solvers/callback.py, solvers/exacthessian.py, and solvers/ipopt.py.

Definition at line 58 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 ()
 Destructor. More...
 
casadi_int n_in () const
 Get the number of function inputs. More...
 
casadi_int n_out () const
 Get the number of function outputs. More...
 
const std::vector< std::string > & name_in () const
 Get input scheme. More...
 
const std::vector< std::string > & name_out () const
 Get output scheme. More...
 
const std::string & name_in (casadi_int ind) const
 Get input scheme name by index. More...
 
const std::string & name_out (casadi_int ind) const
 Get output scheme name by index. More...
 
casadi_int index_in (const std::string &name) const
 Find the index for a string describing a particular entry of an input scheme. More...
 
casadi_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 (casadi_int ind) const
 Get default input value. More...
 
double max_in (casadi_int ind) const
 Get largest input value. More...
 
double min_in (casadi_int ind) const
 Get smallest input value. More...
 
std::vector< double > nominal_in (casadi_int ind) const
 Get nominal input value. More...
 
std::vector< double > nominal_out (casadi_int ind) const
 Get nominal output 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...
 
Function wrap_as_needed (const Dict &opts) const
 Wrap in a Function with options. More...
 
std::vector< bool > which_depends (const std::string &s_in, const std::vector< std::string > &s_out, casadi_int order=1, bool tr=false) const
 Which variables enter with some order. More...
 
void print_dimensions (std::ostream &stream=casadi::uout()) const
 Print dimensions of inputs and outputs. More...
 
void print_options (std::ostream &stream=casadi::uout()) const
 Print options to a stream. More...
 
void print_option (const std::string &name, std::ostream &stream=casadi::uout()) const
 Print all information there is to know about a certain option. More...
 
bool has_option (const std::string &option_name) const
 Does a particular option exist. More...
 
void change_option (const std::string &option_name, const GenericType &option_value)
 Change option after object creation for debugging. More...
 
bool uses_output () const
 Do the derivative functions need nondifferentiated outputs? More...
 
Function jacobian_old (casadi_int iind, casadi_int oind) const
 [DEPRECATED] Replaced by Function::factory. More...
 
Function hessian_old (casadi_int iind, casadi_int oind) const
 [DEPRECATED] Replaced by Function::factory. More...
 
Function jacobian () const
 Calculate all Jacobian blocks. More...
 
std::vector< MXmapsum (const std::vector< MX > &x, const std::string &parallelization="serial") const
 Evaluate symbolically in parallel and sum (matrix graph) More...
 
Function map (casadi_int n, const std::string &parallelization="serial") const
 Create a mapped version of this function. More...
 
Function map (casadi_int n, const std::string &parallelization, casadi_int max_num_threads) const
 
Function slice (const std::string &name, const std::vector< casadi_int > &order_in, const std::vector< casadi_int > &order_out, const Dict &opts=Dict()) const
 returns a new function with a selection of inputs/outputs of the original More...
 
Function forward (casadi_int nfwd) const
 Get a function that calculates nfwd forward derivatives. More...
 
Function reverse (casadi_int nadj) const
 Get a function that calculates nadj adjoint derivatives. More...
 
const std::vector< Sparsity > & jac_sparsity (bool compact=false) const
 Get, if necessary generate, the sparsity of all Jacobian blocks. More...
 
Sparsity jac_sparsity (casadi_int oind, casadi_int iind, bool compact=false) const
 Get, if necessary generate, the sparsity of a single Jacobian block. 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...
 
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 &vdef_fcn, Function &vinit_fcn) const
 Extract the functions needed for the Lifted Newton method. More...
 
casadi_int n_nodes () const
 Number of nodes in the algorithm. More...
 
casadi_int n_instructions () const
 Number of instruction in the algorithm (SXFunction/MXFunction) More...
 
casadi_int instruction_id (casadi_int k) const
 Identifier index of the instruction (SXFunction/MXFunction) More...
 
std::vector< casadi_int > instruction_input (casadi_int k) const
 Locations in the work vector for the inputs of the instruction. More...
 
double instruction_constant (casadi_int k) const
 Get the floating point output argument of an instruction (SXFunction) More...
 
std::vector< casadi_int > instruction_output (casadi_int k) const
 Location in the work vector for the output of the instruction. More...
 
MX instruction_MX (casadi_int k) const
 Get the MX node corresponding to an instruction (MXFunction) More...
 
SX instructions_sx () const
 Get the SX node corresponding to all instructions (SXFunction) More...
 
size_t sz_arg () const
 Get required length of arg field. More...
 
size_t sz_res () const
 Get required length of res field. More...
 
size_t sz_iw () const
 Get required length of iw field. More...
 
size_t sz_w () const
 Get required length of w field. More...
 
const 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. More...
 
void assert_size_in (casadi_int i, casadi_int nrow, casadi_int ncol) const
 Assert that an input dimension is equal so some given value. More...
 
void assert_size_out (casadi_int i, casadi_int nrow, casadi_int ncol) const
 Assert that an output dimension is equal so some given value. More...
 
void assert_sparsity_out (casadi_int i, const Sparsity &sp, casadi_int n=1, bool allow_all_zero_sparse=true) const
 Assert that an output sparsity is a multiple of some given sparsity. More...
 
casadi_int checkout () const
 Checkout a memory object. More...
 
void release (int mem) const
 Release a memory object. More...
 
Dict cache () const
 Get all functions in the cache. More...
 
std::vector< std::string > get_function () const
 Get a list of all functions. More...
 
Function get_function (const std::string &name) const
 Get a dependency function. More...
 
bool has_function (const std::string &fname) const
 Check if a particular dependency exists. More...
 
std::vector< Functionfind_functions (casadi_int max_depth=-1) const
 Get all functions embedded in the expression graphs. More...
 
Function find_function (const std::string &name, casadi_int max_depth=-1) const
 Get a specific function embedded in the expression graphs. More...
 
Dict info () 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...
 
casadi_int __hash__ () const
 Returns a number that is unique for a given Node. 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...
 
casadi_int size1_in (casadi_int ind) const
 Get input dimension. More...
 
casadi_int size1_in (const std::string &iname) const
 Get input dimension. More...
 
casadi_int size2_in (casadi_int ind) const
 Get input dimension. More...
 
casadi_int size2_in (const std::string &iname) const
 Get input dimension. More...
 
std::pair< casadi_int, casadi_int > size_in (casadi_int ind) const
 Get input dimension. More...
 
std::pair< casadi_int, casadi_int > size_in (const std::string &iname) const
 Get input dimension. More...
 
casadi_int size1_out (casadi_int ind) const
 Get output dimension. More...
 
casadi_int size1_out (const std::string &oname) const
 Get output dimension. More...
 
casadi_int size2_out (casadi_int ind) const
 Get output dimension. More...
 
casadi_int size2_out (const std::string &oname) const
 Get output dimension. More...
 
std::pair< casadi_int, casadi_int > size_out (casadi_int ind) const
 Get output dimension. More...
 
std::pair< casadi_int, casadi_int > size_out (const std::string &oname) const
 Get output dimension. More...
 
casadi_int nnz_in () const
 Get number of input nonzeros. More...
 
casadi_int nnz_in (casadi_int ind) const
 Get number of input nonzeros. More...
 
casadi_int nnz_in (const std::string &iname) const
 Get number of input nonzeros. More...
 
casadi_int nnz_out () const
 Get number of output nonzeros. More...
 
casadi_int nnz_out (casadi_int ind) const
 Get number of output nonzeros. More...
 
casadi_int nnz_out (const std::string &oname) const
 Get number of output nonzeros. More...
 
casadi_int numel_in () const
 Get number of input elements. More...
 
casadi_int numel_in (casadi_int ind) const
 Get number of input elements. More...
 
casadi_int numel_in (const std::string &iname) const
 Get number of input elements. More...
 
casadi_int numel_out () const
 Get number of output elements. More...
 
casadi_int numel_out (casadi_int ind) const
 Get number of output elements. More...
 
casadi_int numel_out (const std::string &oname) const
 Get number of output elements. More...
 
const Sparsitysparsity_in (casadi_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 (casadi_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...
 
bool is_diff_in (casadi_int ind) const
 Get differentiability of inputs/output. More...
 
bool is_diff_out (casadi_int ind) const
 Get differentiability of inputs/output. More...
 
std::vector< bool > is_diff_in () const
 Get differentiability of inputs/output. More...
 
std::vector< bool > is_diff_out () const
 Get differentiability of inputs/output. More...
 
const Sparsity sparsity_jac (casadi_int iind, casadi_int oind, bool compact=false, bool symmetric=false) const
 
const Sparsity sparsity_jac (const std::string &iind, casadi_int oind=0, bool compact=false, bool symmetric=false) const
 
const Sparsity sparsity_jac (casadi_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
 
void call (const std::vector< DM > &arg, std::vector< DM > &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 > &res, bool always_inline=false, bool never_inline=false) const
 Evaluate the function symbolically or numerically. More...
 
void call (const std::vector< MX > &arg, std::vector< MX > &res, bool always_inline=false, bool never_inline=false) const
 Evaluate the function symbolically or numerically. More...
 
void call (const DMDict &arg, DMDict &res, bool always_inline=false, bool never_inline=false) const
 Evaluate the function symbolically or numerically. More...
 
void call (const SXDict &arg, SXDict &res, bool always_inline=false, bool never_inline=false) const
 Evaluate the function symbolically or numerically. More...
 
void call (const MXDict &arg, MXDict &res, bool always_inline=false, bool never_inline=false) const
 Evaluate the function symbolically or numerically. More...
 
Function mapaccum (const std::string &name, casadi_int N, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function mapaccum (const std::string &name, casadi_int N, casadi_int n_accum, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function mapaccum (const std::string &name, casadi_int n, const std::vector< casadi_int > &accum_in, const std::vector< casadi_int > &accum_out, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function mapaccum (const std::string &name, casadi_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 mapaccum (casadi_int N, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function fold (casadi_int N, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function map (const std::string &name, const std::string &parallelization, casadi_int n, const std::vector< casadi_int > &reduce_in, const std::vector< casadi_int > &reduce_out, const Dict &opts=Dict()) const
 Map with reduction. More...
 
Function map (const std::string &name, const std::string &parallelization, casadi_int n, const std::vector< std::string > &reduce_in, const std::vector< std::string > &reduce_out, const Dict &opts=Dict()) const
 Map with reduction. More...
 
Function map (casadi_int n, const std::vector< bool > &reduce_in, const std::vector< bool > &reduce_out=std::vector< bool >(), const Dict &opts=Dict()) const
 Map with reduction. More...
 
void generate_in (const std::string &fname, const std::vector< DM > &arg)
 Export an input file that can be passed to generate C code with a main. More...
 
std::vector< DMgenerate_in (const std::string &fname)
 Export an input file that can be passed to generate C code with a main. More...
 
void generate_out (const std::string &fname, const std::vector< DM > &arg)
 Export an output file that can be checked with generated C code output. More...
 
std::vector< DMgenerate_out (const std::string &fname)
 Export an output file that can be checked with generated C code output. More...
 
void export_code (const std::string &lang, const std::string &fname, const Dict &options=Dict()) const
 Export function in specific language. More...
 
std::string serialize (const Dict &opts=Dict()) const
 Serialize. More...
 
void save (const std::string &fname, const Dict &opts=Dict()) const
 Save Function to a file. More...
 
std::string export_code (const std::string &lang, const Dict &options=Dict()) const
 Export function in specific language. More...
 
const SX sx_in (casadi_int iind) const
 Get symbolic primitives equivalent to the input expressions. More...
 
const SX sx_in (const std::string &iname) const
 Get symbolic primitives equivalent to the input expressions. More...
 
const std::vector< SXsx_in () const
 Get symbolic primitives equivalent to the input expressions. More...
 
const MX mx_in (casadi_int ind) const
 Get symbolic primitives equivalent to the input expressions. More...
 
const MX mx_in (const std::string &iname) const
 Get symbolic primitives equivalent to the input expressions. More...
 
const std::vector< MXmx_in () const
 Get symbolic primitives equivalent to the input expressions. More...
 
const SX sx_out (casadi_int oind) const
 Get symbolic primitives equivalent to the output expressions. More...
 
const SX sx_out (const std::string &oname) const
 Get symbolic primitives equivalent to the output expressions. More...
 
const std::vector< SXsx_out () const
 Get symbolic primitives equivalent to the output expressions. More...
 
const MX mx_out (casadi_int ind) const
 Get symbolic primitives equivalent to the output expressions. More...
 
const MX mx_out (const std::string &oname) const
 Get symbolic primitives equivalent to the output expressions. More...
 
const std::vector< MXmx_out () const
 Get symbolic primitives equivalent to the output expressions. More...
 
std::vector< double > nz_from_in (const std::vector< DM > &arg) const
 Convert from/to flat vector of input/output nonzeros. More...
 
std::vector< double > nz_from_out (const std::vector< DM > &arg) const
 Convert from/to flat vector of input/output nonzeros. More...
 
std::vector< DMnz_to_in (const std::vector< double > &arg) const
 Convert from/to flat vector of input/output nonzeros. More...
 
std::vector< DMnz_to_out (const std::vector< double > &arg) const
 Convert from/to flat vector of input/output nonzeros. More...
 
DMDict convert_in (const std::vector< DM > &arg) const
 Convert from/to input/output lists/map. More...
 
std::vector< DMconvert_in (const DMDict &arg) const
 Convert from/to input/output lists/map. More...
 
DMDict convert_out (const std::vector< DM > &arg) const
 Convert from/to input/output lists/map. More...
 
std::vector< DMconvert_out (const DMDict &arg) const
 Convert from/to input/output lists/map. More...
 
SXDict convert_in (const std::vector< SX > &arg) const
 Convert from/to input/output lists/map. More...
 
std::vector< SXconvert_in (const SXDict &arg) const
 Convert from/to input/output lists/map. More...
 
SXDict convert_out (const std::vector< SX > &arg) const
 Convert from/to input/output lists/map. More...
 
std::vector< SXconvert_out (const SXDict &arg) const
 Convert from/to input/output lists/map. More...
 
MXDict convert_in (const std::vector< MX > &arg) const
 Convert from/to input/output lists/map. More...
 
std::vector< MXconvert_in (const MXDict &arg) const
 Convert from/to input/output lists/map. More...
 
MXDict convert_out (const std::vector< MX > &arg) const
 Convert from/to input/output lists/map. More...
 
std::vector< MXconvert_out (const MXDict &arg) const
 Convert from/to input/output lists/map. 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 conditional (const std::string &name, const Function &f, const Dict &opts=Dict())
 Conditional call to a function. More...
 
static Function bspline (const std::string &name, const std::vector< std::vector< double > > &knots, const std::vector< double > &coeffs, const std::vector< casadi_int > &degree, casadi_int m=1, const Dict &opts=Dict())
 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. More...
 
static std::string fix_name (const std::string &name)
 Turn a string into a valid function name as defined by "check_name". More...
 
static Function deserialize (std::istream &stream)
 Build function from serialization. More...
 
static Function deserialize (const std::string &s)
 Build function from serialization. More...
 
static Function load (const std::string &filename)
 Build function from serialization. More...
 
static Function deserialize (DeserializingStream &s)
 Build function from serialization. More...
 
static Function jit (const std::string &name, const std::string &body, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
static Function jit (const std::string &name, const std::string &body, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const std::vector< Sparsity > &sparsity_in, const std::vector< Sparsity > &sparsity_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 

Member Typedef Documentation

◆ AuxOut

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

Definition at line 395 of file function.hpp.

Constructor & Destructor Documentation

◆ Function() [1/8]

casadi::Function::Function ( )

◆ Function() [2/8]

casadi::Function::Function ( const std::string &  fname)

◆ Function() [3/8]

casadi::Function::Function ( const std::string &  name,
const std::vector< SX > &  ex_in,
const std::vector< SX > &  ex_out,
const Dict opts = Dict() 
)

◆ Function() [4/8]

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() 
)

◆ Function() [5/8]

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() 
)

◆ Function() [6/8]

casadi::Function::Function ( const std::string &  name,
const std::vector< MX > &  ex_in,
const std::vector< MX > &  ex_out,
const Dict opts = Dict() 
)

◆ Function() [7/8]

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() 
)

◆ Function() [8/8]

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() 
)

◆ ~Function()

casadi::Function::~Function ( )

Member Function Documentation

◆ __hash__()

casadi_int casadi::SharedObject::__hash__ ( ) const
inherited

If the Object does not point to any node, "0" is returned.

Extra doc: https://github.com/casadi/casadi/wiki/L_av

◆ assert_size_in()

void casadi::Function::assert_size_in ( casadi_int  i,
casadi_int  nrow,
casadi_int  ncol 
) const

◆ assert_size_out()

void casadi::Function::assert_size_out ( casadi_int  i,
casadi_int  nrow,
casadi_int  ncol 
) const

◆ assert_sparsity_out()

void casadi::Function::assert_sparsity_out ( casadi_int  i,
const Sparsity sp,
casadi_int  n = 1,
bool  allow_all_zero_sparse = true 
) const

◆ bspline()

static Function casadi::Function::bspline ( const std::string &  name,
const std::vector< std::vector< double > > &  knots,
const std::vector< double > &  coeffs,
const std::vector< casadi_int > &  degree,
casadi_int  m = 1,
const Dict opts = Dict() 
)
static

Requires a known coefficient tensor

Extra doc: https://github.com/casadi/casadi/wiki/L_1wo

◆ cache()

Dict casadi::Function::cache ( ) const

◆ call() [1/6]

void casadi::Function::call ( const DMDict arg,
DMDict res,
bool  always_inline = false,
bool  never_inline = false 
) const

◆ call() [2/6]

void casadi::Function::call ( const MXDict arg,
MXDict res,
bool  always_inline = false,
bool  never_inline = false 
) const

◆ call() [3/6]

void casadi::Function::call ( const std::vector< DM > &  arg,
std::vector< DM > &  res,
bool  always_inline = false,
bool  never_inline = false 
) const

◆ call() [4/6]

void casadi::Function::call ( const std::vector< MX > &  arg,
std::vector< MX > &  res,
bool  always_inline = false,
bool  never_inline = false 
) const

◆ call() [5/6]

void casadi::Function::call ( const std::vector< SX > &  arg,
std::vector< SX > &  res,
bool  always_inline = false,
bool  never_inline = false 
) const

◆ call() [6/6]

void casadi::Function::call ( const SXDict arg,
SXDict res,
bool  always_inline = false,
bool  never_inline = false 
) const

◆ change_option()

void casadi::Function::change_option ( const std::string &  option_name,
const GenericType option_value 
)

This is only possible for a selected number of options that do not change the numerical results of the computation, e.g. to enable a more verbose output or saving to file.

Extra doc: https://github.com/casadi/casadi/wiki/L_1w2

◆ check_name()

static bool casadi::Function::check_name ( const std::string &  name)
static

Valid function names consist of

  • 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"

Extra doc: https://github.com/casadi/casadi/wiki/L_1xx

◆ checkout()

casadi_int casadi::Function::checkout ( ) const

◆ class_name()

std::string casadi::SharedObject::class_name ( ) const
inherited

◆ conditional() [1/2]

static Function casadi::Function::conditional ( const std::string &  name,
const Function f,
const Dict opts = Dict() 
)
static

◆ conditional() [2/2]

static Function casadi::Function::conditional ( const std::string &  name,
const std::vector< Function > &  f,
const Function f_def,
const Dict opts = Dict() 
)
static

◆ convert_in() [1/6]

std::vector<DM> casadi::Function::convert_in ( const DMDict arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

◆ convert_in() [2/6]

std::vector<MX> casadi::Function::convert_in ( const MXDict arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

◆ convert_in() [3/6]

DMDict casadi::Function::convert_in ( const std::vector< DM > &  arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

◆ convert_in() [4/6]

MXDict casadi::Function::convert_in ( const std::vector< MX > &  arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

◆ convert_in() [5/6]

SXDict casadi::Function::convert_in ( const std::vector< SX > &  arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

◆ convert_in() [6/6]

std::vector<SX> casadi::Function::convert_in ( const SXDict arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

◆ convert_out() [1/6]

std::vector<DM> casadi::Function::convert_out ( const DMDict arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

◆ convert_out() [2/6]

std::vector<MX> casadi::Function::convert_out ( const MXDict arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

◆ convert_out() [3/6]

DMDict casadi::Function::convert_out ( const std::vector< DM > &  arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

◆ convert_out() [4/6]

MXDict casadi::Function::convert_out ( const std::vector< MX > &  arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

◆ convert_out() [5/6]

SXDict casadi::Function::convert_out ( const std::vector< SX > &  arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

◆ convert_out() [6/6]

std::vector<SX> casadi::Function::convert_out ( const SXDict arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

◆ default_in()

double casadi::Function::default_in ( casadi_int  ind) const

◆ deserialize() [1/3]

static Function casadi::Function::deserialize ( const std::string &  s)
static

◆ deserialize() [2/3]

static Function casadi::Function::deserialize ( DeserializingStream s)
static

◆ deserialize() [3/3]

static Function casadi::Function::deserialize ( std::istream &  stream)
static

◆ disp()

void casadi::SharedObject::disp ( std::ostream &  stream,
bool  more = false 
) const
inherited

◆ expand() [1/2]

Function casadi::Function::expand ( ) const

◆ expand() [2/2]

Function casadi::Function::expand ( const std::string &  name,
const Dict opts = Dict() 
) const

◆ export_code() [1/2]

std::string casadi::Function::export_code ( const std::string &  lang,
const Dict options = Dict() 
) const

Only allowed for (a subset of) SX/MX Functions

Extra doc: https://github.com/casadi/casadi/wiki/L_1wz

◆ export_code() [2/2]

void casadi::Function::export_code ( const std::string &  lang,
const std::string &  fname,
const Dict options = Dict() 
) const

Only allowed for (a subset of) SX/MX Functions

Extra doc: https://github.com/casadi/casadi/wiki/L_1wz

◆ factory()

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

◆ find_function()

Function casadi::Function::find_function ( const std::string &  name,
casadi_int  max_depth = -1 
) const
Parameters
[in]nameName of function needed
[in]max_depthMaximum depth - a negative number indicates no maximum

Extra doc: https://github.com/casadi/casadi/wiki/L_1y7

◆ find_functions()

std::vector<Function> casadi::Function::find_functions ( casadi_int  max_depth = -1) const
Parameters
[in]max_depthMaximum depth - a negative number indicates no maximum

Extra doc: https://github.com/casadi/casadi/wiki/L_1y6

◆ fix_name()

static std::string casadi::Function::fix_name ( const std::string &  name)
static

Non-alphanumeric characters are converted into underscores and multiple consecutive undercores are dropped

Extra doc: https://github.com/casadi/casadi/wiki/L_1xy

◆ fold()

Function casadi::Function::fold ( casadi_int  N,
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))

Mapaccum has the following benefits over writing an equivalent for-loop:

  • much faster at construction time
  • potentially much faster compilation times (for codegen)
  • offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for-loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly slower at evaluation, than a plain for-loop. The effect is similar to that of a for-loop with a check-pointing instruction after each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

◆ forward()

Function casadi::Function::forward ( casadi_int  nfwd) const
   Returns a function with <tt>n_in + n_out + n_in</tt> inputs
   and <tt>nfwd</tt> outputs.
   The first <tt>n_in</tt> inputs correspond to nondifferentiated inputs.
   The next <tt>n_out</tt> inputs correspond to nondifferentiated outputs.
   and the last <tt>n_in</tt> inputs correspond to forward seeds,
   stacked horizontally
   The  <tt>n_out</tt> outputs correspond to forward sensitivities,
   stacked horizontally.     *
   <tt>(n_in = n_in(), n_out = n_out())</tt>

  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.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wq

◆ free_mx()

std::vector<MX> casadi::Function::free_mx ( ) const

◆ free_sx()

std::vector<SX> casadi::Function::free_sx ( ) const

◆ generate() [1/2]

std::string casadi::Function::generate ( const Dict opts = Dict()) const

◆ generate() [2/2]

std::string casadi::Function::generate ( const std::string &  fname,
const Dict opts = Dict() 
) const

◆ generate_dependencies()

std::string casadi::Function::generate_dependencies ( const std::string &  fname,
const Dict opts = Dict() 
) const

◆ generate_in() [1/2]

std::vector<DM> casadi::Function::generate_in ( const std::string &  fname)
See also
generate_out
convert_in to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wx

◆ generate_in() [2/2]

void casadi::Function::generate_in ( const std::string &  fname,
const std::vector< DM > &  arg 
)
See also
generate_out
convert_in to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wx

◆ generate_lifted()

void casadi::Function::generate_lifted ( Function vdef_fcn,
Function vinit_fcn 
) const

◆ generate_out() [1/2]

std::vector<DM> casadi::Function::generate_out ( const std::string &  fname)
See also
generate_in
convert_out to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wy

◆ generate_out() [2/2]

void casadi::Function::generate_out ( const std::string &  fname,
const std::vector< DM > &  arg 
)
See also
generate_in
convert_out to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wy

◆ get_free()

std::vector<std::string> casadi::Function::get_free ( ) const

◆ get_function() [1/2]

std::vector<std::string> casadi::Function::get_function ( ) const

◆ get_function() [2/2]

Function casadi::Function::get_function ( const std::string &  name) const

◆ get_str()

std::string casadi::SharedObject::get_str ( bool  more = false) const
inlineinherited

Definition at line 138 of file shared_object.hpp.

◆ has_free()

bool casadi::Function::has_free ( ) const

◆ has_function()

bool casadi::Function::has_function ( const std::string &  fname) const

◆ has_option()

bool casadi::Function::has_option ( const std::string &  option_name) const

◆ has_spfwd()

bool casadi::Function::has_spfwd ( ) const

◆ has_sprev()

bool casadi::Function::has_sprev ( ) const

◆ hessian_old()

Function casadi::Function::hessian_old ( casadi_int  iind,
casadi_int  oind 
) const

◆ if_else()

static Function casadi::Function::if_else ( const std::string &  name,
const Function f_true,
const Function f_false,
const Dict opts = Dict() 
)
static

◆ index_in()

casadi_int casadi::Function::index_in ( const std::string &  name) const

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

Extra doc: https://github.com/casadi/casadi/wiki/L_1vk

◆ index_out()

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

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

Extra doc: https://github.com/casadi/casadi/wiki/L_1vl

◆ info()

Dict casadi::Function::info ( ) const

Obtain information about function

◆ instruction_constant()

double casadi::Function::instruction_constant ( casadi_int  k) const

◆ instruction_id()

casadi_int casadi::Function::instruction_id ( casadi_int  k) const

◆ instruction_input()

std::vector<casadi_int> casadi::Function::instruction_input ( casadi_int  k) const

(SXFunction/MXFunction)

Extra doc: https://github.com/casadi/casadi/wiki/L_1xg

◆ instruction_MX()

MX casadi::Function::instruction_MX ( casadi_int  k) const

◆ instruction_output()

std::vector<casadi_int> casadi::Function::instruction_output ( casadi_int  k) const

(SXFunction/MXFunction)

Extra doc: https://github.com/casadi/casadi/wiki/L_1xi

◆ instructions_sx()

SX casadi::Function::instructions_sx ( ) const

Note: input and output instructions have no SX representation. This method returns nan for those instructions.

Extra doc: https://github.com/casadi/casadi/wiki/L_1xk

◆ is_a()

bool casadi::Function::is_a ( const std::string &  type,
bool  recursive = true 
) const

Optionally check if name matches one of the base classes (default true)

Extra doc: https://github.com/casadi/casadi/wiki/L_1xw

◆ is_diff_in() [1/2]

std::vector<bool> casadi::Function::is_diff_in ( ) const

◆ is_diff_in() [2/2]

bool casadi::Function::is_diff_in ( casadi_int  ind) const

◆ is_diff_out() [1/2]

std::vector<bool> casadi::Function::is_diff_out ( ) const

◆ is_diff_out() [2/2]

bool casadi::Function::is_diff_out ( casadi_int  ind) const

◆ is_null()

bool casadi::SharedObject::is_null ( ) const
inherited

◆ jac_sparsity() [1/2]

const std::vector<Sparsity>& casadi::Function::jac_sparsity ( bool  compact = false) const

◆ jac_sparsity() [2/2]

Sparsity casadi::Function::jac_sparsity ( casadi_int  oind,
casadi_int  iind,
bool  compact = false 
) const

◆ jacobian()

Function casadi::Function::jacobian ( ) const

Generates a function that takes all non-differentiated inputs and outputs and calculates all Jacobian blocks. Inputs that are not needed by the routine are all-zero sparse matrices with the correct dimensions. Output blocks that are not calculated, e.g. if the corresponding input or output is marked non-differentiated are also all-zero sparse. The Jacobian blocks are sorted starting by all the blocks for the first output, then all the blocks for the second output and so on. E.g. f : (x, y) -> (r, s) results in the function jac_f : (x, y, out_r, out_s) -> (jac_r_x, jac_r_y, jac_s_x, jac_s_y)

This function is cached.

Extra doc: https://github.com/casadi/casadi/wiki/L_1w6

◆ jacobian_old()

Function casadi::Function::jacobian_old ( casadi_int  iind,
casadi_int  oind 
) const

◆ jit() [1/2]

static Function casadi::Function::jit ( const std::string &  name,
const std::string &  body,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts = Dict() 
)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Create a just-in-time compiled function from a C language string

The names and sparsity patterns of all the inputs and outputs must be provided. If sparsities are not provided, all inputs and outputs are assumed to be scalar. Only specify the function body, assuming that input and output nonzeros are stored in arrays with the specified naming convension. The data type used is 'casadi_real', which is typically equal to 'double‘ or another data type with the same API as 'double’.

Inputs may be null pointers. This means that the all entries are zero. Outputs may be null points. This means that the corresponding result can be ignored.

If an error occurs in the evaluation, issue "return 1;";

The final generated function will have a structure similar to:

casadi_int fname(const casadi_real** arg, casadi_real** res, casadi_int* iw, casadi_real* w, void* mem) { const casadi_real *x1, *x2; casadi_real *r1, *r2; x1 = *arg++; x2 = *arg++; r1 = *res++; r2 = *res++; <FUNCTION_BODY> return 0; }

Extra doc: https://github.com/casadi/casadi/wiki/L_1v3

◆ jit() [2/2]

static Function casadi::Function::jit ( const std::string &  name,
const std::string &  body,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const std::vector< Sparsity > &  sparsity_in,
const std::vector< Sparsity > &  sparsity_out,
const Dict opts = Dict() 
)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Create a just-in-time compiled function from a C language string

The names and sparsity patterns of all the inputs and outputs must be provided. If sparsities are not provided, all inputs and outputs are assumed to be scalar. Only specify the function body, assuming that input and output nonzeros are stored in arrays with the specified naming convension. The data type used is 'casadi_real', which is typically equal to 'double‘ or another data type with the same API as 'double’.

Inputs may be null pointers. This means that the all entries are zero. Outputs may be null points. This means that the corresponding result can be ignored.

If an error occurs in the evaluation, issue "return 1;";

The final generated function will have a structure similar to:

casadi_int fname(const casadi_real** arg, casadi_real** res, casadi_int* iw, casadi_real* w, void* mem) { const casadi_real *x1, *x2; casadi_real *r1, *r2; x1 = *arg++; x2 = *arg++; r1 = *res++; r2 = *res++; <FUNCTION_BODY> return 0; }

Extra doc: https://github.com/casadi/casadi/wiki/L_1v3

◆ load()

static Function casadi::Function::load ( const std::string &  filename)
static

◆ map() [1/5]

Function casadi::Function::map ( casadi_int  n,
const std::string &  parallelization,
casadi_int  max_num_threads 
) const

◆ map() [2/5]

Function casadi::Function::map ( casadi_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

Extra doc: https://github.com/casadi/casadi/wiki/L_1wj

◆ map() [3/5]

Function casadi::Function::map ( casadi_int  n,
const std::vector< bool > &  reduce_in,
const std::vector< bool > &  reduce_out = std::vector< bool >(),
const Dict opts = Dict() 
) const

A subset of the inputs are non-repeated and a subset of the outputs summed up.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wk

◆ map() [4/5]

Function casadi::Function::map ( const std::string &  name,
const std::string &  parallelization,
casadi_int  n,
const std::vector< casadi_int > &  reduce_in,
const std::vector< casadi_int > &  reduce_out,
const Dict opts = Dict() 
) const

A subset of the inputs are non-repeated and a subset of the outputs summed up.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wk

◆ map() [5/5]

Function casadi::Function::map ( const std::string &  name,
const std::string &  parallelization,
casadi_int  n,
const std::vector< std::string > &  reduce_in,
const std::vector< std::string > &  reduce_out,
const Dict opts = Dict() 
) const

A subset of the inputs are non-repeated and a subset of the outputs summed up.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wk

◆ mapaccum() [1/5]

Function casadi::Function::mapaccum ( casadi_int  N,
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))

Mapaccum has the following benefits over writing an equivalent for-loop:

  • much faster at construction time
  • potentially much faster compilation times (for codegen)
  • offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for-loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly slower at evaluation, than a plain for-loop. The effect is similar to that of a for-loop with a check-pointing instruction after each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

◆ mapaccum() [2/5]

Function casadi::Function::mapaccum ( const std::string &  name,
casadi_int  N,
casadi_int  n_accum,
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))

Mapaccum has the following benefits over writing an equivalent for-loop:

  • much faster at construction time
  • potentially much faster compilation times (for codegen)
  • offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for-loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly slower at evaluation, than a plain for-loop. The effect is similar to that of a for-loop with a check-pointing instruction after each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

◆ mapaccum() [3/5]

Function casadi::Function::mapaccum ( const std::string &  name,
casadi_int  N,
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))

Mapaccum has the following benefits over writing an equivalent for-loop:

  • much faster at construction time
  • potentially much faster compilation times (for codegen)
  • offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for-loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly slower at evaluation, than a plain for-loop. The effect is similar to that of a for-loop with a check-pointing instruction after each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

◆ mapaccum() [4/5]

Function casadi::Function::mapaccum ( const std::string &  name,
casadi_int  n,
const std::vector< casadi_int > &  accum_in,
const std::vector< casadi_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))

Mapaccum has the following benefits over writing an equivalent for-loop:

  • much faster at construction time
  • potentially much faster compilation times (for codegen)
  • offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for-loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly slower at evaluation, than a plain for-loop. The effect is similar to that of a for-loop with a check-pointing instruction after each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

◆ mapaccum() [5/5]

Function casadi::Function::mapaccum ( const std::string &  name,
casadi_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))

Mapaccum has the following benefits over writing an equivalent for-loop:

  • much faster at construction time
  • potentially much faster compilation times (for codegen)
  • offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for-loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly slower at evaluation, than a plain for-loop. The effect is similar to that of a for-loop with a check-pointing instruction after each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

◆ mapsum()

std::vector<MX> casadi::Function::mapsum ( const std::vector< MX > &  x,
const std::string &  parallelization = "serial" 
) const
Parameters
parallelizationType of parallelization used: unroll|serial|openmp

Extra doc: https://github.com/casadi/casadi/wiki/L_1wh

◆ max_in()

double casadi::Function::max_in ( casadi_int  ind) const

◆ min_in()

double casadi::Function::min_in ( casadi_int  ind) const

◆ mx_in() [1/3]

const std::vector<MX> casadi::Function::mx_in ( ) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

◆ mx_in() [2/3]

const MX casadi::Function::mx_in ( casadi_int  ind) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

◆ mx_in() [3/3]

const MX casadi::Function::mx_in ( const std::string &  iname) const
inline

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Definition at line 946 of file function.hpp.

◆ mx_out() [1/3]

const std::vector<MX> casadi::Function::mx_out ( ) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

◆ mx_out() [2/3]

const MX casadi::Function::mx_out ( casadi_int  ind) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

◆ mx_out() [3/3]

const MX casadi::Function::mx_out ( const std::string &  oname) const
inline

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Definition at line 964 of file function.hpp.

◆ n_in()

casadi_int casadi::Function::n_in ( ) const

◆ n_instructions()

casadi_int casadi::Function::n_instructions ( ) const

◆ n_nodes()

casadi_int casadi::Function::n_nodes ( ) const

◆ n_out()

casadi_int casadi::Function::n_out ( ) const

◆ name()

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

◆ name_in() [1/2]

const std::vector<std::string>& casadi::Function::name_in ( ) const

◆ name_in() [2/2]

const std::string& casadi::Function::name_in ( casadi_int  ind) const

◆ name_out() [1/2]

const std::vector<std::string>& casadi::Function::name_out ( ) const

◆ name_out() [2/2]

const std::string& casadi::Function::name_out ( casadi_int  ind) const

◆ nnz_in() [1/3]

casadi_int casadi::Function::nnz_in ( ) const

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vc

◆ nnz_in() [2/3]

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

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vc

◆ nnz_in() [3/3]

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

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vc

Definition at line 271 of file function.hpp.

◆ nnz_out() [1/3]

casadi_int casadi::Function::nnz_out ( ) const

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vd

◆ nnz_out() [2/3]

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

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vd

◆ nnz_out() [3/3]

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

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vd

Definition at line 282 of file function.hpp.

◆ nominal_in()

std::vector<double> casadi::Function::nominal_in ( casadi_int  ind) const

◆ nominal_out()

std::vector<double> casadi::Function::nominal_out ( casadi_int  ind) const

◆ numel_in() [1/3]

casadi_int casadi::Function::numel_in ( ) const

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1ve

◆ numel_in() [2/3]

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

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1ve

◆ numel_in() [3/3]

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

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1ve

Definition at line 293 of file function.hpp.

◆ numel_out() [1/3]

casadi_int casadi::Function::numel_out ( ) const

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vf

◆ numel_out() [2/3]

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

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vf

◆ numel_out() [3/3]

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

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vf

Definition at line 304 of file function.hpp.

◆ nz_from_in()

std::vector<double> casadi::Function::nz_from_in ( const std::vector< DM > &  arg) const

◆ nz_from_out()

std::vector<double> casadi::Function::nz_from_out ( const std::vector< DM > &  arg) const

◆ nz_to_in()

std::vector<DM> casadi::Function::nz_to_in ( const std::vector< double > &  arg) const

◆ nz_to_out()

std::vector<DM> casadi::Function::nz_to_out ( const std::vector< double > &  arg) const

◆ oracle()

Function casadi::Function::oracle ( ) const

◆ print_dimensions()

void casadi::Function::print_dimensions ( std::ostream &  stream = casadi::uout()) const

◆ print_option()

void casadi::Function::print_option ( const std::string &  name,
std::ostream &  stream = casadi::uout() 
) const

◆ print_options()

void casadi::Function::print_options ( std::ostream &  stream = casadi::uout()) const

◆ release()

void casadi::Function::release ( int  mem) const

◆ reverse()

Function casadi::Function::reverse ( casadi_int  nadj) const
   Returns a function with <tt>n_in + n_out + n_out</tt> inputs
   and <tt>n_in</tt> outputs.
   The first <tt>n_in</tt> inputs correspond to nondifferentiated inputs.
   The next <tt>n_out</tt> inputs correspond to nondifferentiated outputs.
   and the last <tt>n_out</tt> inputs correspond to adjoint seeds,
   stacked horizontally
   The  <tt>n_in</tt> outputs correspond to adjoint sensitivities,
   stacked horizontally.     *
   <tt>(n_in = n_in(), n_out = n_out())</tt>

   <tt>(n_in = n_in(), n_out = n_out())</tt>

  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.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wr

◆ save()

void casadi::Function::save ( const std::string &  fname,
const Dict opts = Dict() 
) const

◆ serialize()

std::string casadi::Function::serialize ( const Dict opts = Dict()) const

◆ size1_in() [1/2]

casadi_int casadi::Function::size1_in ( casadi_int  ind) const

◆ size1_in() [2/2]

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

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Definition at line 240 of file function.hpp.

◆ size1_out() [1/2]

casadi_int casadi::Function::size1_out ( casadi_int  ind) const

◆ size1_out() [2/2]

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

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Definition at line 254 of file function.hpp.

◆ size2_in() [1/2]

casadi_int casadi::Function::size2_in ( casadi_int  ind) const

◆ size2_in() [2/2]

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

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Definition at line 242 of file function.hpp.

◆ size2_out() [1/2]

casadi_int casadi::Function::size2_out ( casadi_int  ind) const

◆ size2_out() [2/2]

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

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Definition at line 256 of file function.hpp.

◆ size_in() [1/2]

std::pair<casadi_int, casadi_int> casadi::Function::size_in ( casadi_int  ind) const

◆ size_in() [2/2]

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

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Definition at line 244 of file function.hpp.

◆ size_out() [1/2]

std::pair<casadi_int, casadi_int> casadi::Function::size_out ( casadi_int  ind) const

◆ size_out() [2/2]

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

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Definition at line 258 of file function.hpp.

◆ slice()

Function casadi::Function::slice ( const std::string &  name,
const std::vector< casadi_int > &  order_in,
const std::vector< casadi_int > &  order_out,
const Dict opts = Dict() 
) const

◆ sparsity_in() [1/2]

const Sparsity& casadi::Function::sparsity_in ( casadi_int  ind) const

◆ sparsity_in() [2/2]

const Sparsity& casadi::Function::sparsity_in ( const std::string &  iname) const

◆ sparsity_jac() [1/4]

const Sparsity casadi::Function::sparsity_jac ( casadi_int  iind,
casadi_int  oind,
bool  compact = false,
bool  symmetric = false 
) const

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian block

◆ sparsity_jac() [2/4]

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

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian block

Definition at line 481 of file function.hpp.

◆ sparsity_jac() [3/4]

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

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian block

Definition at line 477 of file function.hpp.

◆ sparsity_jac() [4/4]

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

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian block

Definition at line 485 of file function.hpp.

◆ sparsity_out() [1/2]

const Sparsity& casadi::Function::sparsity_out ( casadi_int  ind) const

◆ sparsity_out() [2/2]

const Sparsity& casadi::Function::sparsity_out ( const std::string &  iname) const

◆ stats()

Dict casadi::Function::stats ( int  mem = 0) const

◆ sx_in() [1/3]

const std::vector<SX> casadi::Function::sx_in ( ) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

◆ sx_in() [2/3]

const SX casadi::Function::sx_in ( casadi_int  iind) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

◆ sx_in() [3/3]

const SX casadi::Function::sx_in ( const std::string &  iname) const
inline

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Definition at line 941 of file function.hpp.

◆ sx_out() [1/3]

const std::vector<SX> casadi::Function::sx_out ( ) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

◆ sx_out() [2/3]

const SX casadi::Function::sx_out ( casadi_int  oind) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

◆ sx_out() [3/3]

const SX casadi::Function::sx_out ( const std::string &  oname) const
inline

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Definition at line 959 of file function.hpp.

◆ sz_arg()

size_t casadi::Function::sz_arg ( ) const

◆ sz_iw()

size_t casadi::Function::sz_iw ( ) const

◆ sz_res()

size_t casadi::Function::sz_res ( ) const

◆ sz_w()

size_t casadi::Function::sz_w ( ) const

◆ type_name()

static std::string casadi::Function::type_name ( )
inlinestatic

Extra doc: https://github.com/casadi/casadi/wiki/L_1ux

Definition at line 65 of file function.hpp.

◆ uses_output()

bool casadi::Function::uses_output ( ) const

◆ which_depends()

std::vector<bool> casadi::Function::which_depends ( const std::string &  s_in,
const std::vector< std::string > &  s_out,
casadi_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

Extra doc: https://github.com/casadi/casadi/wiki/L_1vx

◆ wrap()

Function casadi::Function::wrap ( ) const

◆ wrap_as_needed()

Function casadi::Function::wrap_as_needed ( const Dict opts) const

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