Enumerations | Enumerator | Functions | Variables
Title

Enumerations

enum  casadi::RfpIn { casadi::RFP_X , casadi::RFP_P , casadi::RFP_NUM_IN }
 Inputs of the symbolic representation of the rootfinding problem. More...
 
enum  casadi::RfpOut { casadi::RFP_G , casadi::RFP_NUM_OUT }
 Inputs of the symbolic representation of the rootfinding problem. More...
 
enum  casadi::RootfinderInput { casadi::ROOTFINDER_X0 , casadi::ROOTFINDER_P , casadi::ROOTFINDER_NUM_IN }
 Input arguments of a rootfinder. More...
 
enum  casadi::RootfinderOutput { casadi::ROOTFINDER_X , casadi::ROOTFINDER_NUM_OUT }
 Output arguments of a rootfinder. More...
 

Functions

Function casadi::rootfinder (const std::string &name, const std::string &solver, const SXDict &rfp, const Dict &opts)
 
Function casadi::rootfinder (const std::string &name, const std::string &solver, const MXDict &rfp, const Dict &opts)
 
Function casadi::rootfinder (const std::string &name, const std::string &solver, const Function &f, const Dict &opts)
 
std::vector< std::string > casadi::rootfinder_in ()
 Get rootfinder input scheme. More...
 
std::vector< std::string > casadi::rootfinder_out ()
 Get rootfinder output scheme. More...
 
std::string casadi::rootfinder_in (casadi_int ind)
 Get rootfinder input scheme name by index. More...
 
std::string casadi::rootfinder_out (casadi_int ind)
 Get rootfinder output scheme name by index. More...
 
casadi_int casadi::rootfinder_n_in ()
 Number of rootfinder inputs. More...
 
casadi_int casadi::rootfinder_n_out ()
 Number of rootfinder outputs. More...
 
std::vector< std::string > casadi::rootfinder_options (const std::string &name)
 Get all options for a plugin. More...
 
std::string casadi::rootfinder_option_type (const std::string &name, const std::string &op)
 Get type info for a particular option. More...
 
std::string casadi::rootfinder_option_info (const std::string &name, const std::string &op)
 Get documentation for a particular option. More...
 
bool casadi::has_rootfinder (const std::string &name)
 Check if a particular plugin is available. More...
 
void casadi::load_rootfinder (const std::string &name)
 Explicitly load a plugin dynamically. More...
 
std::string casadi::doc_rootfinder (const std::string &name)
 Get the documentation string for a plugin. More...
 

Variables

const std::vector< std::string > casadi::RFP_INPUTS = {"x", "p"}
 Shortnames for DAE symbolic representation inputs. More...
 
const std::vector< std::string > casadi::RFP_OUTPUTS = {"g"}
 Shortnames for DAE symbolic representation outputs. More...
 

Detailed Description

Create a solver for rootfinding problems Takes a function where one of the inputs is unknown and one of the outputs is a residual function that is always zero, defines a new function where the the unknown input has been replaced by a guess for the unknown and the residual output has been replaced by the calculated value for the input.

For a function [y0, y1, ...,yi, .., yn] = F(x0, x1, ..., xj, ..., xm), where xj is unknown and yi=0, defines a new function [y0, y1, ...,xj, .., yn] = G(x0, x1, ..., xj_guess, ..., xm),

xj and yi must have the same dimension and d(yi)/d(xj) must be invertable.

By default, the first input is unknown and the first output is the residual.

General information


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
common_optionsOT_DICTOptions for auto-generated functionscasadi::OracleFunction
compilerOT_STRINGJust-in-time compiler plugin to be used.casadi::FunctionInternal
constraintsOT_INTVECTORConstrain the unknowns. 0 (default): no constraint on ui, 1: ui >= 0.0, -1: ui <= 0.0, 2: ui > 0.0, -2: ui < 0.0.casadi::Rootfinder
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
expandOT_BOOLReplace MX with SX expressions in problem formulation [false] This happens before creating derivatives unless indicated by postpone_expandcasadi::OracleFunction
external_transformOT_VECTORVECTORList of external_transform instruction arguments. Default: emptycasadi::FunctionInternal
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
implicit_inputOT_INTIndex of the input that corresponds to the actual root-findingcasadi::Rootfinder
implicit_outputOT_INTIndex of the output that corresponds to the actual root-findingcasadi::Rootfinder
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_functionOT_FUNCTIONFunction object for calculating the Jacobian (autogenerated by default)casadi::Rootfinder
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
linear_solverOT_STRINGUser-defined linear solver class. Needed for sensitivities.casadi::Rootfinder
linear_solver_optionsOT_DICTOptions to be passed to the linear solver.casadi::Rootfinder
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
monitorOT_STRINGVECTORSet of user problem functions to be monitoredcasadi::OracleFunction
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
postpone_expandOT_BOOLWhen expand is active, postpone it until after creation of derivatives. Default: Falsecasadi::OracleFunction
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
show_eval_warningsOT_BOOLShow warnings generated from function evaluations [true]casadi::OracleFunction
specific_optionsOT_DICTOptions for specific auto-generated functions, overwriting the defaults from common_options. Nested dictionary.casadi::OracleFunction
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

Input scheme: casadi::RootfinderInput (ROOTFINDER_NUM_IN = 2)
Full nameShortDescription
ROOTFINDER_X0x0Initial guess for the solution.
ROOTFINDER_PpParameters.

Output scheme: casadi::RootfinderOutput (ROOTFINDER_NUM_OUT = 1)
Full nameShortDescription
ROOTFINDER_XxSolution to the system of equations.

List of plugins

- kinsol

- fast_newton

- nlpsol

- newton

Note: some of the plugins in this list might not be available on your system. Also, there might be extra plugins available to you that are not listed here. You can obtain their documentation with Rootfinder.doc("myextraplugin")


kinsol

KINSOL interface from the Sundials suite

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


List of available options
IdTypeDescription
abstolOT_DOUBLEStopping criterion tolerance
disable_internal_warningsOT_BOOLDisable KINSOL internal warning messages
exact_jacobianOT_BOOLUse exact Jacobian information
f_scaleOT_DOUBLEVECTOREquation scaling factors
iterative_solverOT_STRINGgmres|bcgstab|tfqmr
linear_solver_typeOT_STRINGdense|banded|iterative|user_defined
lower_bandwidthOT_INTLower bandwidth for banded linear solvers
max_iterOT_INTMaximum number of Newton iterations. Putting 0 sets the default value of KinSol.
max_krylovOT_INTMaximum Krylov space dimension
pretypeOT_STRINGType of preconditioner
print_levelOT_INTVerbosity level
strategyOT_STRINGGlobalization strategy
u_scaleOT_DOUBLEVECTORVariable scaling factors
upper_bandwidthOT_INTUpper bandwidth for banded linear solvers
use_preconditionerOT_BOOLPrecondition an iterative solver

fast_newton

Implements simple newton iterations to solve an implicit function.

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


List of available options
IdTypeDescription
abstolOT_DOUBLEStopping criterion tolerance on ||g||__inf)
abstolStepOT_DOUBLEStopping criterion tolerance on step size
max_iterOT_INTMaximum number of Newton iterations to perform before returning.

nlpsol


newton

Implements simple newton iterations to solve an implicit function.

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


List of available options
IdTypeDescription
abstolOT_DOUBLEStopping criterion tolerance on max(|F|)
abstolStepOT_DOUBLEStopping criterion tolerance on step size
line_searchOT_BOOLEnable line-search (default: true)
max_iterOT_INTMaximum number of Newton iterations to perform before returning.
print_iterationOT_BOOLPrint information about each iteration
Author
Joel Andersson
Date
2011-2015

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

Enumeration Type Documentation

◆ RfpIn

Enumerator
RFP_X 
RFP_P 
RFP_NUM_IN 

Definition at line 139 of file rootfinder.hpp.

139  {
140  RFP_X,
141  RFP_P,
142  RFP_NUM_IN};
@ RFP_NUM_IN
Definition: rootfinder.hpp:142

◆ RfpOut

Enumerator
RFP_G 
RFP_NUM_OUT 

Definition at line 148 of file rootfinder.hpp.

148  {
149  RFP_G,
150  RFP_NUM_OUT};
@ RFP_NUM_OUT
Definition: rootfinder.hpp:150

◆ RootfinderInput

Enumerator
ROOTFINDER_X0 

Initial guess for the solution.

ROOTFINDER_P 

Parameters.

ROOTFINDER_NUM_IN 

Number of input arguments of a rootfinder.

Definition at line 156 of file rootfinder.hpp.

156  {
160  ROOTFINDER_P,
163  };
@ ROOTFINDER_NUM_IN
Number of input arguments of a rootfinder.
Definition: rootfinder.hpp:162
@ ROOTFINDER_P
Parameters.
Definition: rootfinder.hpp:160
@ ROOTFINDER_X0
Initial guess for the solution.
Definition: rootfinder.hpp:158

◆ RootfinderOutput

Enumerator
ROOTFINDER_X 

Solution to the system of equations.

ROOTFINDER_NUM_OUT 

Number of output arguments of a rootfinder.

Definition at line 166 of file rootfinder.hpp.

166  {
168  ROOTFINDER_X,
171  };
@ ROOTFINDER_X
Solution to the system of equations.
Definition: rootfinder.hpp:168
@ ROOTFINDER_NUM_OUT
Number of output arguments of a rootfinder.
Definition: rootfinder.hpp:170

Function Documentation

◆ doc_rootfinder()

CASADI_EXPORT std::string casadi::doc_rootfinder ( const std::string &  name)

Definition at line 107 of file rootfinder.cpp.

107  {
108  return Rootfinder::getPlugin(name).doc;
109  }

References casadi::PluginInterface< Rootfinder >::getPlugin().

◆ has_rootfinder()

CASADI_EXPORT bool casadi::has_rootfinder ( const std::string &  name)

Definition at line 99 of file rootfinder.cpp.

99  {
100  return Rootfinder::has_plugin(name);
101  }

References casadi::PluginInterface< Rootfinder >::has_plugin().

◆ load_rootfinder()

CASADI_EXPORT void casadi::load_rootfinder ( const std::string &  name)

Definition at line 103 of file rootfinder.cpp.

103  {
104  Rootfinder::load_plugin(name);
105  }

References casadi::PluginInterface< Rootfinder >::load_plugin().

◆ rootfinder() [1/3]

CASADI_EXPORT Function casadi::rootfinder ( const std::string &  name,
const std::string &  solver,
const Function f,
const Dict opts 
)

Definition at line 152 of file rootfinder.cpp.

153  {
154  // Make sure that residual function is sound
155  if (f.has_free()) {
156  casadi_error("Cannot create '" + name + "' since " + str(f.get_free()) + " are free.");
157  }
158  return Function::create(Rootfinder::instantiate(name, solver, f), opts);
159  }
std::string str(const T &v)
String representation, any type.

References casadi::Function::create(), casadi::Function::get_free(), casadi::Function::has_free(), casadi::PluginInterface< Rootfinder >::instantiate(), and casadi::str().

◆ rootfinder() [2/3]

CASADI_EXPORT Function casadi::rootfinder ( const std::string &  name,
const std::string &  solver,
const MXDict rfp,
const Dict opts 
)

Definition at line 116 of file rootfinder.cpp.

117  {
118  return rootfinder(name, solver, Rootfinder::create_oracle(rfp, opts), opts);
119  }
Function rootfinder(const std::string &name, const std::string &solver, const Function &f, const Dict &opts)
Definition: rootfinder.cpp:152

References casadi::Rootfinder::create_oracle(), and casadi::rootfinder().

◆ rootfinder() [3/3]

CASADI_EXPORT Function casadi::rootfinder ( const std::string &  name,
const std::string &  solver,
const SXDict rfp,
const Dict opts = Dict() 
)
Examples
solvers/KinsolSolver.py, solvers/NLPImplicitSolver.py, and solvers/NewtonImplicitSolver.py.

Definition at line 111 of file rootfinder.cpp.

112  {
113  return rootfinder(name, solver, Rootfinder::create_oracle(rfp, opts), opts);
114  }

References casadi::Rootfinder::create_oracle().

Referenced by casadi::ImplicitFixedStepIntegrator::init(), casadi::rootfinder(), and casadi::simpleIRK().

◆ rootfinder_in() [1/2]

CASADI_EXPORT std::vector< std::string > casadi::rootfinder_in ( )

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

Definition at line 35 of file rootfinder.cpp.

35  {
36  std::vector<std::string> ret(rootfinder_n_in());
37  for (size_t i=0; i<ret.size(); ++i) ret[i]=rootfinder_in(i);
38  return ret;
39  }
casadi_int rootfinder_n_in()
Number of rootfinder inputs.
Definition: rootfinder.cpp:64
std::string rootfinder_in(casadi_int ind)
Get rootfinder input scheme name by index.
Definition: rootfinder.cpp:47

References casadi::rootfinder_n_in().

◆ rootfinder_in() [2/2]

CASADI_EXPORT std::string casadi::rootfinder_in ( casadi_int  ind)

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

Definition at line 47 of file rootfinder.cpp.

47  {
48  switch (static_cast<RootfinderInput>(ind)) {
49  case ROOTFINDER_X0: return "x0";
50  case ROOTFINDER_P: return "p";
51  case ROOTFINDER_NUM_IN: break;
52  }
53  return std::string();
54  }
RootfinderInput
Input arguments of a rootfinder.
Definition: rootfinder.hpp:156

References casadi::ROOTFINDER_NUM_IN, casadi::ROOTFINDER_P, and casadi::ROOTFINDER_X0.

◆ rootfinder_n_in()

CASADI_EXPORT casadi_int casadi::rootfinder_n_in ( )

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

Definition at line 64 of file rootfinder.cpp.

64  {
65  return ROOTFINDER_NUM_IN;
66  }

References casadi::ROOTFINDER_NUM_IN.

Referenced by casadi::rootfinder_in().

◆ rootfinder_n_out()

CASADI_EXPORT casadi_int casadi::rootfinder_n_out ( )

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

Definition at line 68 of file rootfinder.cpp.

68  {
69  return ROOTFINDER_NUM_OUT;
70  }

References casadi::ROOTFINDER_NUM_OUT.

Referenced by casadi::rootfinder_out().

◆ rootfinder_option_info()

CASADI_EXPORT std::string casadi::rootfinder_option_info ( const std::string &  name,
const std::string &  op 
)

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

Definition at line 95 of file rootfinder.cpp.

95  {
96  return Rootfinder::plugin_options(name).info(op);
97  }

References casadi::Options::info(), and casadi::PluginInterface< Rootfinder >::plugin_options().

◆ rootfinder_option_type()

CASADI_EXPORT std::string casadi::rootfinder_option_type ( const std::string &  name,
const std::string &  op 
)

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

Definition at line 91 of file rootfinder.cpp.

91  {
92  return Rootfinder::plugin_options(name).type(op);
93  }

References casadi::PluginInterface< Rootfinder >::plugin_options(), and casadi::Options::type().

◆ rootfinder_options()

CASADI_EXPORT std::vector< std::string > casadi::rootfinder_options ( const std::string &  name)

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

Definition at line 87 of file rootfinder.cpp.

87  {
88  return Rootfinder::plugin_options(name).all();
89  }

References casadi::Options::all(), and casadi::PluginInterface< Rootfinder >::plugin_options().

Referenced by casadi::ImplicitFixedStepIntegrator::init().

◆ rootfinder_out() [1/2]

CASADI_EXPORT std::vector< std::string > casadi::rootfinder_out ( )

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

Definition at line 41 of file rootfinder.cpp.

41  {
42  std::vector<std::string> ret(rootfinder_n_out());
43  for (size_t i=0; i<ret.size(); ++i) ret[i]=rootfinder_out(i);
44  return ret;
45  }
std::string rootfinder_out(casadi_int ind)
Get rootfinder output scheme name by index.
Definition: rootfinder.cpp:56
casadi_int rootfinder_n_out()
Number of rootfinder outputs.
Definition: rootfinder.cpp:68

References casadi::rootfinder_n_out().

◆ rootfinder_out() [2/2]

CASADI_EXPORT std::string casadi::rootfinder_out ( casadi_int  ind)

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

Definition at line 56 of file rootfinder.cpp.

56  {
57  switch (static_cast<RootfinderOutput>(ind)) {
58  case ROOTFINDER_X: return "x";
59  case ROOTFINDER_NUM_OUT: break;
60  }
61  return std::string();
62  }
RootfinderOutput
Output arguments of a rootfinder.
Definition: rootfinder.hpp:166

References casadi::ROOTFINDER_NUM_OUT, and casadi::ROOTFINDER_X.

Variable Documentation

◆ RFP_INPUTS

const std::vector<std::string> casadi::RFP_INPUTS = {"x", "p"}

Definition at line 145 of file rootfinder.hpp.

◆ RFP_OUTPUTS

const std::vector<std::string> casadi::RFP_OUTPUTS = {"g"}

Definition at line 153 of file rootfinder.hpp.