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

A symbolic representation of a differential-algebraic equations model. More...

#include <dae_builder.hpp>

Detailed Description

Variables:

t:      independent variable (usually time)
c:      constants
p:      parameters
d:      dependent parameters (time independent)
u:      controls
w:      dependent variables  (time dependent)
x:      differential states
z:      algebraic variables
q:      quadrature states
y:      outputs

Equations:

differential equations: \dot{x} ==  ode(...)
algebraic equations:          0 ==  alg(...)
quadrature equations:   \dot{q} == quad(...)
dependent parameters:         d == ddef(d_prev,p)
dependent variables:          w == wdef(w_prev,x,z,u,p,t)
output equations:             y == ydef(...)
initial equations:     init_lhs == init_rhs(...)
events:      when when_cond < 0: when_lhs := when_rhs
Date
2012-2021
Author
Joel Andersson

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

Definition at line 68 of file dae_builder.hpp.

Inheritance diagram for casadi::DaeBuilder:
Inheritance graph
[legend]
Collaboration diagram for casadi::DaeBuilder:
Collaboration graph
[legend]

Public Types

using internal_base_type = SharedObjectInternal
 
using base_type = SharedObject
 

Public Member Functions

std::string type_name () const
 Readable name of the class. More...
 
 DaeBuilder ()
 Default constructor. More...
 
 DaeBuilder (const std::string &name, const std::string &path="", const Dict &opts=Dict())
 Construct a DaeBuilder instance. More...
 
const std::string & name () const
 Name of instance. More...
 
void reorder (const std::string &cat, const std::vector< std::string > &v)
 Reorder variables in a category. More...
 
void clear_all (const std::string &v)
 [DEPRECATED] Use set_variability, set_causality or set_category to change variable category More...
 
void set_all (const std::string &v, const std::vector< std::string > &name)
 [DEPRECATED] Use set_variability, set_causality, set_category and/or reorder More...
 
void eliminate_d ()
 [DEPRECATED] Use eliminate("d") More...
 
void eliminate_w ()
 [DEPRECATED] Use eliminate("w") More...
 
void eliminate_quad ()
 [DEPRECATED] Use eliminate("q") More...
 
void sort_d ()
 [DEPRECATED] Use sort("d") More...
 
void sort_w ()
 [DEPRECATED] Use sort("w") More...
 
void sort_z (const std::vector< std::string > &z_order)
 [DEPRECATED] Use reorder("z", new_order) More...
 
Function create (const std::string &fname, const Dict &opts=Dict()) const
 Create a function with standard integrator DAE signature. More...
 
Function create () const
 Create a function with standard integrator DAE signature, default naming. More...
 
Function dependent_fun (const std::string &fname, const std::vector< std::string > &s_in, const std::vector< std::string > &s_out) const
 Construct a function for evaluating dependent parameters. More...
 
Function transition (const std::string &fname, casadi_int index) const
 Construct a function describing transition at a specific events. More...
 
Function transition (const std::string &fname) const
 Construct a function describing transition at any events. More...
 
Function transition () const
 Construct an event transition function, default naming. More...
 
std::vector< std::string > der (const std::vector< std::string > &name) const
 Get the time derivative of model variables. More...
 
std::vector< std::string > pre (const std::vector< std::string > &name) const
 Get the pre-variables of model variables. More...
 
MX pre (const MX &v) const
 Get the pre-expression given variable expression. More...
 
bool has_beq (const std::string &name) const
 Does a variable have a binding equation? More...
 
MX beq (const std::string &name) const
 Get the binding equation for a variable. More...
 
std::string causality (const std::string &name) const
 Get the causality. More...
 
void set_causality (const std::string &name, const std::string &val)
 Set the causality, if permitted. More...
 
std::string variability (const std::string &name) const
 Get the variability. More...
 
void set_variability (const std::string &name, const std::string &val)
 Set the variability, if permitted. More...
 
std::string category (const std::string &name) const
 Get the variable category. More...
 
void set_category (const std::string &name, const std::string &val)
 Set the variable category, if permitted. More...
 
casadi_int numel (const std::string &name) const
 Get the number of elements of a variable. More...
 
std::vector< casadi_int > dimension (const std::string &name) const
 Get the dimensions of a variable. More...
 
double start_time () const
 Get the start time. More...
 
void set_start_time (double val)
 Set the start time. More...
 
double stop_time () const
 Get the stop time. More...
 
void set_stop_time (double val)
 Set the stop time. More...
 
double tolerance () const
 Get the tolerance. More...
 
void set_tolerance (double val)
 Set the tolerance. More...
 
double step_size () const
 Get the step size. More...
 
void set_step_size (double val)
 Set the step size. More...
 
std::string der (const std::string &name) const
 Get the time derivative of model variables, single variable. More...
 
std::string pre (const std::string &name) const
 Get the pre-variables of model variables. More...
 
double attribute (const std::string &a, const std::string &name) const
 Get an attribute, single variable. More...
 
void set_attribute (const std::string &a, const std::string &name, double val)
 Set an attribute, single variable. More...
 
double min (const std::string &name) const
 Get the lower bound, single variable. More...
 
void set_min (const std::string &name, double val)
 Set the lower bound, single variable. More...
 
double max (const std::string &name) const
 Get the upper bound, single variable. More...
 
void set_max (const std::string &name, double val)
 Set the upper bound, single variable. More...
 
double nominal (const std::string &name) const
 Get the nominal value, single variable. More...
 
void set_nominal (const std::string &name, double val)
 Set the nominal value, single variable. More...
 
std::vector< double > start (const std::string &name) const
 Get the start attribute, single variable. More...
 
void set_start (const std::string &name, double val)
 Set the start attribute, single variable. More...
 
void set_start (const std::string &name, const std::vector< double > &val)
 Set the start attribute, vector argument. More...
 
void reset ()
 
void set (const std::string &name, double val)
 
void set (const std::string &name, const std::string &val)
 
GenericType get (const std::string &name) const
 Evaluate the values for a set of variables at the initial time, single value. More...
 
std::vector< double > attribute (const std::string &a, const std::vector< std::string > &name) const
 Get an attribute. More...
 
void set_attribute (const std::string &a, const std::vector< std::string > &name, const std::vector< double > &val)
 Set an attribute. More...
 
std::vector< double > min (const std::vector< std::string > &name) const
 Get the lower bound. More...
 
void set_min (const std::vector< std::string > &name, const std::vector< double > &val)
 Set the lower bound. More...
 
std::vector< double > max (const std::vector< std::string > &name) const
 Get the upper bound. More...
 
void set_max (const std::vector< std::string > &name, const std::vector< double > &val)
 Set the upper bound. More...
 
std::vector< double > nominal (const std::vector< std::string > &name) const
 Get the nominal value. More...
 
void set_nominal (const std::vector< std::string > &name, const std::vector< double > &val)
 Set the nominal value. More...
 
std::vector< double > start (const std::vector< std::string > &name) const
 Get the start attribute. More...
 
void set_start (const std::vector< std::string > &name, const std::vector< double > &val)
 Set the start attribute. More...
 
void set (const std::vector< std::string > &name, const std::vector< double > &val)
 Set the current value. More...
 
void set (const std::vector< std::string > &name, const std::vector< std::string > &val)
 Set the current value (string) More...
 
std::vector< GenericTypeget (const std::vector< std::string > &name) const
 Evaluate the values for a set of variables at the initial time. More...
 
bool has (const std::string &name) const
 Check if a particular variable exists. More...
 
std::vector< std::string > all () const
 Get a list of all variables. More...
 
std::vector< std::string > all (const std::string &cat) const
 Get a list of all variables of a particular category. More...
 
MX add_variable (const std::string &name, casadi_int n=1)
 [DEPRECATED] Use add More...
 
MX add_variable (const std::string &name, const Sparsity &sp)
 [DEPRECATED] Use add More...
 
void add_variable (const MX &new_v)
 Add a new variable from symbolic expressions. More...
 
size_t add_variable_new (const std::string &name, casadi_int n=1)
 [DEPRECATED] Use add More...
 
size_t add_variable_new (const std::string &name, const Sparsity &sp)
 [DEPRECATED] Use add More...
 
size_t add_variable_new (const MX &new_v)
 [DEPRECATED] Use add More...
 
bool has_variable (const std::string &name) const
 [DEPRECATED] Ranamed "has" More...
 
std::vector< std::string > all_variables () const
 Get a list of all variables. More...
 
Function oracle (bool sx=false, bool elim_w=false, bool lifted_calls=false) const
 Get the (cached) oracle, SX or MX. More...
 
Sparsity jac_sparsity (const std::vector< std::string > &onames, const std::vector< std::string > &inames) const
 Get Jacobian sparsity. More...
 
Variablenew_variable (const std::string &name, casadi_int numel=1)
 [DEPRECATED] Use add More...
 
const DaeBuilderInternaloperator-> () const
 Access a member function or object. More...
 
DaeBuilderInternaloperator-> ()
 Access a member function or object. More...
 
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...
 
void print_ptr (std::ostream &stream=casadi::uout()) const
 
void own (SharedObjectInternal *node)
 
void assign (SharedObjectInternal *node)
 Assign the node to a node class pointer without reference counting. More...
 
SharedObjectInternalget () const
 Get a const pointer to the node. More...
 
casadi_int getCount () const
 Get the reference count. More...
 
void swap (GenericShared &other)
 Swap content with another instance. More...
 
std::string debug_repr () const
 
bool is_null () const
 Is a null pointer? More...
 
casadi_int __hash__ () const
 Returns a number that is unique for a given Node. More...
 
GenericWeakRef< SharedObject, SharedObjectInternal > * weak ()
 Get a weak reference to the object. More...
 
Variables and equations
const MXtime () const
 Expression for independent variable (usually time) More...
 
std::vector< std::string > t_new () const
 Independent variable (usually time) More...
 
std::vector< std::string > x () const
 Differential states. More...
 
std::vector< std::string > y () const
 Outputs *‍/. More...
 
std::vector< MXode () const
 Ordinary differential equations (ODE) More...
 
std::vector< std::string > z () const
 Algebraic variables. More...
 
std::vector< MXalg () const
 Algebraic equations. More...
 
std::vector< std::string > q () const
 Quadrature states. More...
 
std::vector< MXquad () const
 Quadrature equations. More...
 
std::vector< MXzero () const
 Zero-crossing functions. More...
 
std::vector< MXydef () const
 Definitions of output variables. More...
 
void set_y (const std::vector< std::string > &name)
 Set all output variables. More...
 
std::vector< std::string > rate () const
 Get all rate variables. More...
 
void set_rate (const std::vector< std::string > &name)
 Set rate variables. More...
 
std::vector< std::string > u () const
 Free controls. More...
 
std::vector< std::string > p () const
 Parameters. More...
 
std::vector< std::string > c () const
 Named constants. More...
 
std::vector< MXcdef () const
 Definitions of named constants. More...
 
std::vector< std::string > d () const
 Dependent parameters. More...
 
std::vector< MXddef () const
 Definitions of dependent parameters. More...
 
std::vector< std::string > w () const
 Dependent variables. More...
 
std::vector< MXwdef () const
 Dependent variables and corresponding definitions. More...
 
std::vector< MXinit_lhs () const
 Initial conditions, left-hand-side. More...
 
std::vector< MXinit_rhs () const
 Initial conditions, right-hand-side. More...
 
std::vector< std::string > outputs () const
 Model structure: outputs. More...
 
std::vector< std::string > derivatives () const
 Model structure: derivatives. More...
 
std::vector< std::string > initial_unknowns () const
 Model structure: initial unknowns. More...
 
bool has_t () const
 Is there a time variable? More...
 
bool has_rate () const
 Is there a rate output? More...
 
casadi_int nx () const
 Differential states. More...
 
casadi_int nz () const
 Algebraic variables. More...
 
casadi_int nq () const
 Quadrature states. More...
 
casadi_int nzero () const
 Zero-crossing functions. More...
 
casadi_int ny () const
 Output variables. More...
 
casadi_int nu () const
 Free controls. More...
 
casadi_int np () const
 Parameters. More...
 
casadi_int nc () const
 Named constants. More...
 
casadi_int nd () const
 Dependent parameters. More...
 
casadi_int nw () const
 Dependent variables. More...
 
Symbolic modeling

Formulate a dynamic system model

MX add (const std::string &name, const std::string &causality, const std::string &variability, const Dict &opts=Dict())
 Add a new model variable. More...
 
MX add (const std::string &name, const std::string &causality, const Dict &opts=Dict())
 Add a new model variable, default variability. More...
 
MX add (const std::string &name, const Dict &opts=Dict())
 Add a new model variable, default variability and causality. More...
 
void add (const std::string &name, const std::string &causality, const std::string &variability, const MX &expr, const Dict &opts=Dict())
 Add a new model variable, symbolic expression already available. More...
 
const MXt () const
 [DEPRECATED] Renamed "time" More...
 
MX add_t (const std::string &name="t")
 [DEPRECATED] Replaced by add More...
 
MX add_p (const std::string &name=std::string())
 [DEPRECATED] Replaced by add More...
 
MX add_u (const std::string &name=std::string())
 [DEPRECATED] Replaced by add More...
 
MX add_x (const std::string &name=std::string())
 [DEPRECATED] Replaced by add More...
 
MX add_z (const std::string &name=std::string())
 [DEPRECATED] Replaced by add More...
 
MX add_q (const std::string &name=std::string())
 [DEPRECATED] Replaced by add More...
 
MX add_c (const std::string &name, const MX &new_cdef)
 [DEPRECATED] Replaced by add and eq More...
 
MX add_d (const std::string &name, const MX &new_ddef)
 [DEPRECATED] Replaced by add and eq More...
 
MX add_w (const std::string &name, const MX &new_wdef)
 [DEPRECATED] Replaced by add and eq More...
 
MX add_y (const std::string &name, const MX &new_ydef)
 [DEPRECATED] Replaced by add and eq More...
 
void set_beq (const std::string &name, const MX &val)
 [DEPRECATED] Replaced by eq More...
 
void eq (const MX &lhs, const MX &rhs, const Dict &opts=Dict())
 Add a simple equation. More...
 
void when (const MX &cond, const std::vector< std::string > &eqs, const Dict &opts=Dict())
 Add when equations. More...
 
std::string assign (const std::string &name, const MX &val)
 Assignment inside a when-equation or if-else equation. More...
 
std::string reinit (const std::string &name, const MX &val)
 Reinitialize a state inside when-equations. More...
 
void set_init (const std::string &name, const MX &init_rhs)
 Specify the initial equation for a variable. More...
 
void set_ode (const std::string &name, const MX &ode_rhs)
 [DEPRECATED] Replaced by eq More...
 
void set_alg (const std::string &name, const MX &alg_rhs)
 [DEPRECATED] Replaced by eq More...
 
void add_init (const MX &lhs, const MX &rhs)
 [DEPRECATED] Replaced by set_init More...
 
casadi_int ne () const
 [DEPRECATED] Replaced by nzero() More...
 
std::vector< std::string > e () const
 [DEPRECATED] Use all("zero") *‍/ More...
 
void sanity_check () const
 Check if dimensions match. More...
 
[DEPRECATED] Register an existing variable
void register_t (const std::string &name)
 
void register_p (const std::string &name)
 
void register_u (const std::string &name)
 
void register_x (const std::string &name)
 
void register_z (const std::string &name)
 
void register_q (const std::string &name)
 
void register_c (const std::string &name)
 
void register_d (const std::string &name)
 
void register_w (const std::string &name)
 
void register_y (const std::string &name)
 
void register_e (const std::string &name)
 
Manipulation

Reformulate the dynamic optimization problem.

void eliminate (const std::string &cat)
 Eliminate all dependent parameters. More...
 
void sort (const std::string &cat)
 Sort dependent parameters. More...
 
void lift (bool lift_shared=true, bool lift_calls=true)
 Lift problem formulation by extracting shared subexpressions. More...
 
void prune (bool prune_p=true, bool prune_u=true)
 Prune unused controls. More...
 
void tear ()
 Identify iteration variables and residual equations using naming convention. More...
 
Functions

Add or load auxiliary functions

Function add_fun (const std::string &name, const std::vector< std::string > &arg, const std::vector< std::string > &res, const Dict &opts=Dict())
 Add a function from loaded expressions. More...
 
Function add_fun (const Function &f)
 Add an already existing function. More...
 
Function add_fun (const std::string &name, const Importer &compiler, const Dict &opts=Dict())
 Add an external function. More...
 
bool has_fun (const std::string &name) const
 Does a particular function already exist? More...
 
Function fun (const std::string &name) const
 Get function by name. More...
 
std::vector< Functionfun () const
 Get all functions. More...
 
void gather_fun (casadi_int max_depth=-1)
 Collect embedded functions from the expression graph. More...
 
Import and export
void parse_fmi (const std::string &filename)
 
bool provides_directional_derivatives () const
 Does the FMU provide support for analytic derivatives. More...
 
bool provides_directional_derivative () const
 Does the FMU provide support for analytic derivatives (FMI 2 naming) More...
 
void load_fmi_description (const std::string &filename)
 Import problem description from FMI or XML. More...
 
std::vector< std::string > export_fmu (const Dict &opts=Dict())
 Export instance into an FMU. More...
 
void add_lc (const std::string &name, const std::vector< std::string > &f_out)
 Add a named linear combination of output expressions. More...
 
Function create (const std::string &fname, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, bool sx, bool lifted_calls=false) const
 Construct a function object, legacy syntax. More...
 
Function create (const std::string &name, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict()) const
 Construct a function object, names provided. More...
 
MX var (const std::string &name) const
 
MX operator() (const std::string &name) const
 
MX der (const MX &v) const
 
MX der (const MX &v)
 
casadi_int value_reference (const std::string &name) const
 
void set_value_reference (const std::string &name, casadi_int val)
 
std::string description (const std::string &name) const
 
void set_description (const std::string &name, const std::string &val)
 
std::string type (const std::string &name, casadi_int fmi_version=3) const
 
void set_type (const std::string &name, const std::string &val)
 
std::string initial (const std::string &name) const
 
void set_initial (const std::string &name, const std::string &val)
 
std::string unit (const std::string &name) const
 
void set_unit (const std::string &name, const std::string &val)
 
std::string display_unit (const std::string &name) const
 
void set_display_unit (const std::string &name, const std::string &val)
 
Variablevariable (const std::string &name)
 
const Variablevariable (const std::string &name) const
 
Variablevariable (size_t ind)
 
const Variablevariable (size_t ind) const
 
size_t find (const std::string &name) const
 
std::vector< size_t > find (const std::vector< std::string > &name) const
 
const std::string & name (size_t ind) const
 
std::vector< std::string > name (const std::vector< size_t > &ind) const
 
const MXvar (size_t ind) const
 
std::vector< MXvar (const std::vector< size_t > &ind) const
 

Static Public Member Functions

static bool test_cast (const SharedObjectInternal *ptr)
 Check if a particular cast is allowed. More...
 

Protected Member Functions

void count_up ()
 
void count_down ()
 

Member Typedef Documentation

◆ base_type

Definition at line 103 of file shared_object.hpp.

◆ internal_base_type

Definition at line 102 of file shared_object.hpp.

Constructor & Destructor Documentation

◆ DaeBuilder() [1/2]

casadi::DaeBuilder::DaeBuilder ( )

Definition at line 51 of file dae_builder.cpp.

51  {
52 }

◆ DaeBuilder() [2/2]

casadi::DaeBuilder::DaeBuilder ( const std::string &  name,
const std::string &  path = "",
const Dict opts = Dict() 
)
explicit

Definition at line 54 of file dae_builder.cpp.

54  {
55  own(new DaeBuilderInternal(name, path, opts));
56  if (!path.empty()) load_fmi_description((*this)->resource_.path() + "/modelDescription.xml");
57 }
const std::string & name() const
Name of instance.
Definition: dae_builder.cpp:59
void load_fmi_description(const std::string &filename)
Import problem description from FMI or XML.
std::vector< casadi_int > path(const std::vector< casadi_int > &map, casadi_int i_start)

References load_fmi_description(), name(), casadi::GenericShared< SharedObject, SharedObjectInternal >::own(), and casadi::path().

Member Function Documentation

◆ __hash__()

casadi_int casadi::GenericShared< SharedObject , SharedObjectInternal >::__hash__
inherited

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

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

Definition at line 123 of file generic_shared_impl.hpp.

141  {
142  return reinterpret_cast<casadi_int>(get());
143  }

◆ add() [1/4]

MX casadi::DaeBuilder::add ( const std::string &  name,
const Dict opts = Dict() 
)

Definition at line 650 of file dae_builder.cpp.

650  {
651  try {
652  return (*this)->add(name, opts).v;
653  } catch (std::exception& e) {
654  THROW_ERROR("add", e.what());
655  return MX();
656  }
657 }
std::vector< std::string > e() const
[DEPRECATED] Use all("zero") *‍/

References e(), and name().

◆ add() [2/4]

MX casadi::DaeBuilder::add ( const std::string &  name,
const std::string &  causality,
const Dict opts = Dict() 
)

Definition at line 641 of file dae_builder.cpp.

641  {
642  try {
643  return (*this)->add(name, to_enum<Causality>(causality), opts).v;
644  } catch (std::exception& e) {
645  THROW_ERROR("add", e.what());
646  return MX();
647  }
648 }
std::string causality(const std::string &name) const
Get the causality.

References causality(), e(), and name().

◆ add() [3/4]

MX casadi::DaeBuilder::add ( const std::string &  name,
const std::string &  causality,
const std::string &  variability,
const Dict opts = Dict() 
)

Definition at line 630 of file dae_builder.cpp.

631  {
632  try {
633  return (*this)->add(name, to_enum<Causality>(causality),
634  to_enum<Variability>(variability), opts).v;
635  } catch (std::exception& e) {
636  THROW_ERROR("add", e.what());
637  return MX();
638  }
639 }
std::string variability(const std::string &name) const
Get the variability.

References causality(), e(), name(), and variability().

Referenced by add_c(), add_d(), add_p(), add_q(), add_t(), add_u(), add_w(), add_x(), add_y(), and add_z().

◆ add() [4/4]

void casadi::DaeBuilder::add ( const std::string &  name,
const std::string &  causality,
const std::string &  variability,
const MX expr,
const Dict opts = Dict() 
)

Definition at line 659 of file dae_builder.cpp.

660  {
661  try {
662  // Ensure pure symbolic expression
663  casadi_assert(expr.is_symbolic(), "Expression must be symbolic");
664  // Make sure name matches expression
665  casadi_assert(name == expr.name(), "Name must match expression");
666  // Add variable
667  (*this)->add(name, to_enum<Causality>(causality), to_enum<Variability>(variability),
668  expr, opts);
669  } catch (std::exception& e) {
670  THROW_ERROR("add", e.what());
671  }
672 }

References causality(), e(), casadi::MX::is_symbolic(), name(), casadi::MX::name(), and variability().

◆ add_c()

MX casadi::DaeBuilder::add_c ( const std::string &  name,
const MX new_cdef 
)

Definition at line 704 of file dae_builder.cpp.

704  {
705  MX v = add(name, "local", "constant");
706  set_beq(name, new_cdef);
707  return v;
708 }
void set_beq(const std::string &name, const MX &val)
[DEPRECATED] Replaced by eq
MX add(const std::string &name, const std::string &causality, const std::string &variability, const Dict &opts=Dict())
Add a new model variable.

References add(), name(), and set_beq().

◆ add_d()

MX casadi::DaeBuilder::add_d ( const std::string &  name,
const MX new_ddef 
)

Definition at line 710 of file dae_builder.cpp.

710  {
711  MX v = add(name, "calculatedParameter", "fixed");
712  set_beq(name, new_ddef);
713  return v;
714 }

References add(), name(), and set_beq().

◆ add_fun() [1/3]

Function casadi::DaeBuilder::add_fun ( const Function f)

Definition at line 1134 of file dae_builder.cpp.

1134  {
1135  try {
1136  return (*this)->add_fun(f);
1137  } catch (std::exception& e) {
1138  THROW_ERROR("add_fun", e.what());
1139  return Function(); // never reached
1140  }
1141 }

References e().

◆ add_fun() [2/3]

Function casadi::DaeBuilder::add_fun ( const std::string &  name,
const Importer compiler,
const Dict opts = Dict() 
)

Definition at line 1153 of file dae_builder.cpp.

1153  {
1154  casadi_assert(!has_fun(name), "Function '" + name + "' already exists");
1155  return add_fun(external(name, compiler, opts));
1156 }
bool has_fun(const std::string &name) const
Does a particular function already exist?
Function add_fun(const std::string &name, const std::vector< std::string > &arg, const std::vector< std::string > &res, const Dict &opts=Dict())
Add a function from loaded expressions.
Function external(const std::string &name, const Importer &li, const Dict &opts)
Load a just-in-time compiled external function.
Definition: external.cpp:42

References add_fun(), casadi::external(), has_fun(), and name().

◆ add_fun() [3/3]

Function casadi::DaeBuilder::add_fun ( const std::string &  name,
const std::vector< std::string > &  arg,
const std::vector< std::string > &  res,
const Dict opts = Dict() 
)

Definition at line 1143 of file dae_builder.cpp.

1144  {
1145  try {
1146  return (*this)->add_fun(name, arg, res, opts);
1147  } catch (std::exception& e) {
1148  THROW_ERROR("add_fun", e.what());
1149  return Function(); // never reached
1150  }
1151 }

References e(), and name().

Referenced by add_fun(), and gather_fun().

◆ add_init()

void casadi::DaeBuilder::add_init ( const MX lhs,
const MX rhs 
)
inline

Definition at line 385 of file dae_builder.hpp.

385  {
386  set_init(lhs.name(), rhs);
387  }
void set_init(const std::string &name, const MX &init_rhs)
Specify the initial equation for a variable.

References casadi::MX::name().

◆ add_lc()

void casadi::DaeBuilder::add_lc ( const std::string &  name,
const std::vector< std::string > &  f_out 
)

Definition at line 1094 of file dae_builder.cpp.

1095  {
1096  try {
1097  (*this)->add_lc(name, f_out);
1098  } catch (std::exception& e) {
1099  THROW_ERROR("add_lc", e.what());
1100  }
1101 }

References e(), and name().

◆ add_p()

MX casadi::DaeBuilder::add_p ( const std::string &  name = std::string())

Definition at line 679 of file dae_builder.cpp.

679  {
680  casadi_assert(!name.empty(), "Variable name is required");
681  return add(name, "parameter", "tunable");
682 }

References add(), and name().

◆ add_q()

MX casadi::DaeBuilder::add_q ( const std::string &  name = std::string())

Definition at line 699 of file dae_builder.cpp.

699  {
700  casadi_assert(!name.empty(), "Variable name is required");
701  return add(name);
702 }

References add(), and name().

◆ add_t()

MX casadi::DaeBuilder::add_t ( const std::string &  name = "t")

Definition at line 675 of file dae_builder.cpp.

675  {
676  return add(name, "independent");
677 }

References add(), and name().

◆ add_u()

MX casadi::DaeBuilder::add_u ( const std::string &  name = std::string())

Definition at line 684 of file dae_builder.cpp.

684  {
685  casadi_assert(!name.empty(), "Variable name is required");
686  return add(name, "input");
687 }

References add(), and name().

◆ add_variable() [1/3]

void casadi::DaeBuilder::add_variable ( const MX new_v)

Definition at line 475 of file dae_builder.cpp.

475  {
476  Variable& v = new_variable(new_v.name());
477  v.v = new_v;
478 }
Variable & new_variable(const std::string &name, casadi_int numel=1)
[DEPRECATED] Use add
struct VariableStruct Variable

References casadi::MX::name(), new_variable(), and casadi::Variable::v.

◆ add_variable() [2/3]

MX casadi::DaeBuilder::add_variable ( const std::string &  name,
casadi_int  n = 1 
)

Definition at line 465 of file dae_builder.cpp.

465  {
466  return add_variable(name, Sparsity::dense(n));
467 }
MX add_variable(const std::string &name, casadi_int n=1)
[DEPRECATED] Use add
static Sparsity dense(casadi_int nrow, casadi_int ncol=1)
Create a dense rectangular sparsity pattern *.
Definition: sparsity.cpp:1012

References casadi::Sparsity::dense(), and name().

◆ add_variable() [3/3]

MX casadi::DaeBuilder::add_variable ( const std::string &  name,
const Sparsity sp 
)

Definition at line 469 of file dae_builder.cpp.

469  {
470  Variable& v = new_variable(name);
471  v.v = MX::sym(name, sp);
472  return v.v;
473 }
static MX sym(const std::string &name, casadi_int nrow=1, casadi_int ncol=1)
Create an nrow-by-ncol symbolic primitive.

References name(), new_variable(), casadi::GenericMatrix< MX >::sym(), and casadi::Variable::v.

◆ add_variable_new() [1/3]

size_t casadi::DaeBuilder::add_variable_new ( const MX new_v)

Definition at line 490 of file dae_builder.cpp.

490  {
491  Variable& v = new_variable(new_v.name());
492  v.v = new_v;
493  return v.index;
494 }

References casadi::Variable::index, casadi::MX::name(), new_variable(), and casadi::Variable::v.

◆ add_variable_new() [2/3]

size_t casadi::DaeBuilder::add_variable_new ( const std::string &  name,
casadi_int  n = 1 
)

Definition at line 480 of file dae_builder.cpp.

480  {
482 }
size_t add_variable_new(const std::string &name, casadi_int n=1)
[DEPRECATED] Use add

References casadi::Sparsity::dense(), and name().

◆ add_variable_new() [3/3]

size_t casadi::DaeBuilder::add_variable_new ( const std::string &  name,
const Sparsity sp 
)

Definition at line 484 of file dae_builder.cpp.

484  {
485  Variable& v = new_variable(name);
486  v.v = MX::sym(name, sp);
487  return v.index;
488 }

References casadi::Variable::index, name(), new_variable(), casadi::GenericMatrix< MX >::sym(), and casadi::Variable::v.

◆ add_w()

MX casadi::DaeBuilder::add_w ( const std::string &  name,
const MX new_wdef 
)

Definition at line 716 of file dae_builder.cpp.

716  {
717  MX v = add(name);
718  eq(v, new_wdef);
719  return v;
720 }
void eq(const MX &lhs, const MX &rhs, const Dict &opts=Dict())
Add a simple equation.

References add(), eq(), and name().

◆ add_x()

MX casadi::DaeBuilder::add_x ( const std::string &  name = std::string())

Definition at line 689 of file dae_builder.cpp.

689  {
690  casadi_assert(!name.empty(), "Variable name is required");
691  return add(name);
692 }

References add(), and name().

◆ add_y()

MX casadi::DaeBuilder::add_y ( const std::string &  name,
const MX new_ydef 
)

Definition at line 722 of file dae_builder.cpp.

722  {
723  MX v = add(name, "output");
724  eq(v, new_ydef);
725  return v;
726 }

References add(), eq(), and name().

◆ add_z()

MX casadi::DaeBuilder::add_z ( const std::string &  name = std::string())

Definition at line 694 of file dae_builder.cpp.

694  {
695  casadi_assert(!name.empty(), "Variable name is required");
696  return add(name);
697 }

References add(), and name().

◆ alg()

std::vector< MX > casadi::DaeBuilder::alg ( ) const

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

Definition at line 91 of file dae_builder.cpp.

91  {
92  try {
93  return (*this)->output(OutputCategory::ALG);
94  } catch (std::exception& e) {
95  THROW_ERROR("alg", e.what());
96  return {}; // never reached
97  }
98 }

References casadi::ALG, and e().

◆ all() [1/2]

std::vector< std::string > casadi::DaeBuilder::all ( ) const

Definition at line 351 of file dae_builder.cpp.

351  {
352  try {
353  return (*this)->all();
354  } catch (std::exception& e) {
355  THROW_ERROR("all", e.what());
356  return {}; // never reached
357  }
358 }

References e().

◆ all() [2/2]

std::vector< std::string > casadi::DaeBuilder::all ( const std::string &  cat) const

Definition at line 360 of file dae_builder.cpp.

360  {
361  try {
362  return (*this)->all(to_enum<Category>(cat));
363  } catch (std::exception& e) {
364  THROW_ERROR("all", e.what());
365  return {}; // never reached
366  }
367 }

References e().

◆ all_variables()

std::vector<std::string> casadi::DaeBuilder::all_variables ( ) const
inline

Definition at line 834 of file dae_builder.hpp.

834 {return all();}
std::vector< std::string > all() const
Get a list of all variables.

References casadi::all().

◆ assign() [1/2]

std::string casadi::DaeBuilder::assign ( const std::string &  name,
const MX val 
)

Definition at line 754 of file dae_builder.cpp.

754  {
755  try {
756  return (*this)->assign(name, val).name;
757  } catch (std::exception& e) {
758  THROW_ERROR("assign", e.what());
759  return std::string(); // never reached
760  }
761 }

References e(), and name().

◆ assign() [2/2]

void casadi::GenericShared< SharedObject , SharedObjectInternal >::assign ( Internal *  node)
inherited

improper use will cause memory leaks!

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

Definition at line 96 of file generic_shared_impl.hpp.

79  {
80  node = node_;
81  }

◆ attribute() [1/2]

double casadi::DaeBuilder::attribute ( const std::string &  a,
const std::string &  name 
) const

Definition at line 1269 of file dae_builder.cpp.

1269  {
1270  try {
1271  return (*this)->attribute(to_enum<Attribute>(a), name);
1272  } catch (std::exception& e) {
1273  THROW_ERROR("attribute", e.what());
1274  return 0; // never reached
1275  }
1276 }

References e(), and name().

◆ attribute() [2/2]

std::vector< double > casadi::DaeBuilder::attribute ( const std::string &  a,
const std::vector< std::string > &  name 
) const

Definition at line 1278 of file dae_builder.cpp.

1279  {
1280  try {
1281  return (*this)->attribute(to_enum<Attribute>(a), name);
1282  } catch (std::exception& e) {
1283  THROW_ERROR("attribute", e.what());
1284  return {}; // never reached
1285  }
1286 }

References e(), and name().

◆ beq()

MX casadi::DaeBuilder::beq ( const std::string &  name) const

Definition at line 873 of file dae_builder.cpp.

873  {
874  try {
875  const Variable& v = (*this)->variable(name);
876  return (*this)->variable(v.bind).v;
877  } catch (std::exception& e) {
878  THROW_ERROR("beq", e.what());
879  return MX(); // never reached
880  }
881 }

References casadi::Variable::bind, e(), name(), and casadi::Variable::v.

◆ c()

std::vector<std::string> casadi::DaeBuilder::c ( ) const
inline

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

Definition at line 171 of file dae_builder.hpp.

171 {return all("c");}

References casadi::all().

◆ category()

std::string casadi::DaeBuilder::category ( const std::string &  name) const

Definition at line 977 of file dae_builder.cpp.

977  {
978  try {
979  return to_string((*this)->category((*this)->find(name)));
980  } catch (std::exception& e) {
981  THROW_ERROR("category", e.what());
982  return std::string(); // never reached
983  }
984 }
std::string to_string(TypeFmi2 v)

References e(), name(), and casadi::to_string().

◆ causality()

std::string casadi::DaeBuilder::causality ( const std::string &  name) const

Definition at line 943 of file dae_builder.cpp.

943  {
944  try {
945  return to_string((*this)->causality((*this)->find(name)));
946  } catch (std::exception& e) {
947  THROW_ERROR("causality", e.what());
948  return std::string(); // never reached
949  }
950 }

References e(), name(), and casadi::to_string().

Referenced by add().

◆ cdef()

std::vector< MX > casadi::DaeBuilder::cdef ( ) const

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

Definition at line 180 of file dae_builder.cpp.

180  {
181  try {
182  return (*this)->cdef();
183  } catch (std::exception& e) {
184  THROW_ERROR("cdef", e.what());
185  return {}; // never reached
186  }
187 }

References e().

◆ class_name()

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

◆ clear_all()

void casadi::DaeBuilder::clear_all ( const std::string &  v)

Definition at line 590 of file dae_builder.cpp.

590  {
591  try {
592  (*this)->clear_cache_ = true; // Clear cache after this
593  (*this)->indices(to_enum<Category>(v)).clear();
594  } catch (std::exception& e) {
595  THROW_ERROR("clear_all", e.what());
596  }
597 }

References e().

◆ count_down()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::count_down
protectedinherited

Definition at line 133 of file generic_shared_impl.hpp.

46  {
47 #ifdef WITH_EXTRA_CHECKS
48  casadi_assert_dev(Function::call_depth_==0);
49 #endif // WITH_EXTRA_CHECKS
50  if (!node) return;
51  if (node->weak_ref_) {
52 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
53  auto mutex = node->weak_ref_->get_mutex();
54  // Avoid triggering a delete while a weak_ref.shared_if_alive is being called
55  std::lock_guard<std::mutex> lock(*mutex);
56  // Could it be that this mutex is destroyed when the lock goes out of scope?
57 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
58 
59  if (--static_cast<Internal*>(node)->count == 0) {
60  delete node;
61  node = nullptr;
62  }
63  } else {
64  if (--static_cast<Internal*>(node)->count == 0) {
65  delete node;
66  node = nullptr;
67  }
68  }
69  }

◆ count_up()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::count_up
protectedinherited

Definition at line 132 of file generic_shared_impl.hpp.

36  {
37 #ifdef WITH_EXTRA_CHECKS
38  casadi_assert_dev(Function::call_depth_==0);
39 #endif // WITH_EXTRA_CHECKS
40 
41  if (node) static_cast<Internal*>(node)->count++;
42 
43  }

◆ create() [1/4]

Function casadi::DaeBuilder::create ( ) const
inline

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

Definition at line 549 of file dae_builder.hpp.

549 {return create(name() + "_dae");}
Function create() const
Create a function with standard integrator DAE signature, default naming.

References create().

Referenced by create(), and get().

◆ create() [2/4]

Function casadi::DaeBuilder::create ( const std::string &  fname,
const Dict opts = Dict() 
) const
Parameters
nameName assigned to the resulting function object
optsOptional settings

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

Definition at line 1125 of file dae_builder.cpp.

1125  {
1126  try {
1127  return (*this)->create(name, dyn_in(), dyn_out(), opts, false, false);
1128  } catch (std::exception& e) {
1129  THROW_ERROR("create", e.what());
1130  return Function(); // never reached
1131  }
1132 }
std::vector< std::string > dyn_out()
Get output scheme of a DAE function.
Definition: integrator.cpp:236
std::vector< std::string > dyn_in()
Get input scheme of a DAE function.
Definition: integrator.cpp:232

References casadi::dyn_in(), casadi::dyn_out(), e(), and name().

◆ create() [3/4]

Function casadi::DaeBuilder::create ( const std::string &  fname,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
bool  sx,
bool  lifted_calls = false 
) const

Definition at line 1103 of file dae_builder.cpp.

1105  {
1106  try {
1107  return (*this)->create(fname, name_in, name_out, Dict(), sx, lifted_calls);
1108  } catch (std::exception& e) {
1109  THROW_ERROR("create", e.what());
1110  return Function(); // never reached
1111  }
1112 }
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.

References e().

◆ create() [4/4]

Function casadi::DaeBuilder::create ( const std::string &  name,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts = Dict() 
) const
Parameters
nameName assigned to the resulting function object
name_inNames of all the inputs
name_outNames of all the outputs
optsOptional settings

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

Definition at line 1114 of file dae_builder.cpp.

1116  {
1117  try {
1118  return (*this)->create(fname, name_in, name_out, opts, false, false);
1119  } catch (std::exception& e) {
1120  THROW_ERROR("create", e.what());
1121  return Function(); // never reached
1122  }
1123 }

References e().

◆ d()

std::vector<std::string> casadi::DaeBuilder::d ( ) const
inline

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

Definition at line 181 of file dae_builder.hpp.

181 {return all("d");}

References casadi::all().

◆ ddef()

std::vector< MX > casadi::DaeBuilder::ddef ( ) const

Interdependencies are allowed but must be non-cyclic.

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

Definition at line 189 of file dae_builder.cpp.

189  {
190  try {
191  return (*this)->output(OutputCategory::DDEF);
192  } catch (std::exception& e) {
193  THROW_ERROR("ddef", e.what());
194  return {}; // never reached
195  }
196 }

References casadi::DDEF, and e().

◆ debug_repr()

std::string casadi::GenericShared< SharedObject , SharedObjectInternal >::debug_repr
inherited

Definition at line 112 of file generic_shared_impl.hpp.

84  {
85  if (node) {
86  return node->debug_repr(node);
87  } else {
88  return "NULL";
89  }
90  }
std::string debug_repr(const Internal *) const

◆ dependent_fun()

Function casadi::DaeBuilder::dependent_fun ( const std::string &  fname,
const std::vector< std::string > &  s_in,
const std::vector< std::string > &  s_out 
) const

Definition at line 1210 of file dae_builder.cpp.

1212  {
1213  try {
1214  return (*this)->dependent_fun(fname, s_in, s_out);
1215  } catch (std::exception& e) {
1216  THROW_ERROR("dependent_fun", e.what());
1217  return Function(); // never reached
1218  }
1219 }

References e().

◆ der() [1/4]

MX casadi::DaeBuilder::der ( const MX v)

Differentiate an expression with respect to time

Definition at line 1260 of file dae_builder.cpp.

1260  {
1261  try {
1262  return (*this)->der(v);
1263  } catch (std::exception& e) {
1264  THROW_ERROR("der", e.what());
1265  return MX(); // never reached
1266  }
1267 }

References e().

◆ der() [2/4]

MX casadi::DaeBuilder::der ( const MX v) const

Differentiate an expression with respect to time

Definition at line 1251 of file dae_builder.cpp.

1251  {
1252  try {
1253  return (*this)->der(v);
1254  } catch (std::exception& e) {
1255  THROW_ERROR("der", e.what());
1256  return MX(); // never reached
1257  }
1258 }

References e().

◆ der() [3/4]

std::string casadi::DaeBuilder::der ( const std::string &  name) const

Definition at line 797 of file dae_builder.cpp.

797  {
798  try {
799  // Get variable index
800  size_t ind = (*this)->find(name);
801  // Differentiate
802  ind = (*this)->variable(ind).der;
803  casadi_assert(ind != size_t(-1), "No derivative expression for " + name);
804  // Return name
805  return (*this)->variable(ind).name;
806  } catch (std::exception& e) {
807  THROW_ERROR("der", e.what());
808  return std::string(); // never reached
809  }
810 }

References e(), and name().

◆ der() [4/4]

std::vector< std::string > casadi::DaeBuilder::der ( const std::vector< std::string > &  name) const

Definition at line 842 of file dae_builder.cpp.

842  {
843  try {
844  std::vector<std::string> r(name.size());
845  for (size_t i = 0; i < r.size(); ++i) r[i] = der(name[i]);
846  return r;
847  } catch (std::exception& e) {
848  THROW_ERROR("der", e.what());
849  return {}; // never reached
850  }
851 }
std::vector< std::string > der(const std::vector< std::string > &name) const
Get the time derivative of model variables.

References e(), and name().

◆ derivatives()

std::vector< std::string > casadi::DaeBuilder::derivatives ( ) const

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

Definition at line 224 of file dae_builder.cpp.

224  {
225  try {
226  return (*this)->name((*this)->derivatives_);
227  } catch (std::exception& e) {
228  THROW_ERROR("derivatives", e.what());
229  return {}; // never reached
230  }
231 }

References e().

◆ description()

std::string casadi::DaeBuilder::description ( const std::string &  name) const

Get/set description

Definition at line 915 of file dae_builder.cpp.

915  {
916  return (*this)->variable(name).description;
917 }

References name().

◆ dimension()

std::vector< casadi_int > casadi::DaeBuilder::dimension ( const std::string &  name) const

Definition at line 1022 of file dae_builder.cpp.

1022  {
1023  return (*this)->variable(name).dimension;
1024 }

References name().

◆ disp()

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

Definition at line 35 of file shared_object.cpp.

35  {
36  if (is_null()) {
37  stream << "NULL";
38  } else {
39  (*this)->disp(stream, more);
40  }
41  }

References casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null().

Referenced by casadi::Nlpsol::disp_more(), and casadi::CsparseInterface::nfact().

◆ display_unit()

std::string casadi::DaeBuilder::display_unit ( const std::string &  name) const

Get/set the display unit

Definition at line 1010 of file dae_builder.cpp.

1010  {
1011  return (*this)->variable(name).display_unit;
1012 }

References name().

◆ e()

std::vector<std::string> casadi::DaeBuilder::e ( ) const
inline

◆ eliminate()

void casadi::DaeBuilder::eliminate ( const std::string &  cat)

Definition at line 883 of file dae_builder.cpp.

883  {
884  try {
885  return (*this)->eliminate(to_enum<Category>(cat));
886  } catch (std::exception& e) {
887  THROW_ERROR("eliminate", e.what());
888  }
889 }

References e().

Referenced by eliminate_d(), eliminate_quad(), and eliminate_w().

◆ eliminate_d()

void casadi::DaeBuilder::eliminate_d ( )

Definition at line 542 of file dae_builder.cpp.

542  {
543  try {
544  return eliminate("d");
545  } catch (std::exception& e) {
546  THROW_ERROR("eliminate_d", e.what());
547  }
548 }
void eliminate(const std::string &cat)
Eliminate all dependent parameters.

References e(), and eliminate().

◆ eliminate_quad()

void casadi::DaeBuilder::eliminate_quad ( )

Definition at line 558 of file dae_builder.cpp.

558  {
559  try {
560  return eliminate("q");
561  } catch (std::exception& e) {
562  THROW_ERROR("eliminate_quad", e.what());
563  }
564 }

References e(), and eliminate().

◆ eliminate_w()

void casadi::DaeBuilder::eliminate_w ( )

Definition at line 550 of file dae_builder.cpp.

550  {
551  try {
552  return eliminate("w");
553  } catch (std::exception& e) {
554  THROW_ERROR("eliminate_w", e.what());
555  }
556 }

References e(), and eliminate().

◆ eq()

void casadi::DaeBuilder::eq ( const MX lhs,
const MX rhs,
const Dict opts = Dict() 
)

Definition at line 738 of file dae_builder.cpp.

738  {
739  try {
740  (*this)->eq(lhs, rhs, opts);
741  } catch (std::exception& e) {
742  THROW_ERROR("eq", e.what());
743  }
744 }

References e().

Referenced by add_w(), add_y(), and set_beq().

◆ export_fmu()

std::vector< std::string > casadi::DaeBuilder::export_fmu ( const Dict opts = Dict())

Definition at line 318 of file dae_builder.cpp.

318  {
319  try {
320  return (*this)->export_fmu(opts);
321  } catch (std::exception& e) {
322  THROW_ERROR("export_fmu", e.what());
323  }
324 }

References e().

◆ find() [1/2]

size_t casadi::DaeBuilder::find ( const std::string &  name) const

[DEPRECATED] Access to internal class and corresponding indexing removed

Definition at line 410 of file dae_builder.cpp.

410  {
411  try {
412  return (*this)->find(name);
413  } catch (std::exception& e) {
414  THROW_ERROR("find", e.what());
415  return -1; // never reached
416  }
417 }

References e(), and name().

Referenced by register_c(), register_d(), register_e(), register_p(), register_q(), register_t(), register_u(), register_w(), register_x(), register_y(), and register_z().

◆ find() [2/2]

std::vector< size_t > casadi::DaeBuilder::find ( const std::vector< std::string > &  name) const

[DEPRECATED] Access to internal class and corresponding indexing removed

Definition at line 419 of file dae_builder.cpp.

419  {
420  try {
421  return (*this)->find(name);
422  } catch (std::exception& e) {
423  THROW_ERROR("find", e.what());
424  return {}; // never reached
425  }
426 }

References e(), and name().

◆ fun() [1/2]

std::vector< Function > casadi::DaeBuilder::fun ( ) const

Definition at line 1197 of file dae_builder.cpp.

1197  {
1198  return (*this)->fun_;
1199 }

◆ fun() [2/2]

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

Definition at line 1167 of file dae_builder.cpp.

1167  {
1168  try {
1169  return (*this)->fun(name);
1170  } catch (std::exception& e) {
1171  THROW_ERROR("fun", e.what());
1172  return Function(); // never reached
1173  }
1174 }

References e(), and name().

◆ gather_fun()

void casadi::DaeBuilder::gather_fun ( casadi_int  max_depth = -1)

Definition at line 1176 of file dae_builder.cpp.

1176  {
1177  try {
1178  // Get a function corresponding to all equations (no inputs)
1179  Function all_eq = (*this)->gather_eq();
1180  // Gather all functions
1181  std::vector<Function> allfun = all_eq.find_functions(max_depth);
1182  // Add to list of functions
1183  for (const Function& f : allfun) {
1184  if (has_fun(f.name())) {
1185  // Skip functions with duplicate names
1186  casadi_warning("Duplicate function: '" + f.name() + "', ignored");
1187  } else {
1188  // Add to list of functions
1189  add_fun(f);
1190  }
1191  }
1192  } catch (std::exception& e) {
1193  THROW_ERROR("gather_fun", e.what());
1194  }
1195 }

References add_fun(), e(), casadi::Function::find_functions(), and has_fun().

◆ get() [1/3]

Definition at line 99 of file generic_shared_impl.hpp.

108  {
109  return node;
110  }

◆ get() [2/3]

GenericType casadi::DaeBuilder::get ( const std::string &  name) const

Definition at line 1490 of file dae_builder.cpp.

1490  {
1491  return get(std::vector<std::string>{name}).front();
1492 }
SharedObjectInternal * get() const
Get a const pointer to the node.

References casadi::GenericShared< SharedObject, SharedObjectInternal >::get(), and name().

◆ get() [3/3]

std::vector< GenericType > casadi::DaeBuilder::get ( const std::vector< std::string > &  name) const

Definition at line 1494 of file dae_builder.cpp.

1494  {
1495  try {
1496  casadi_assert(!(*this)->symbolic_,
1497  "Functionality not implemented for symbolic representation");
1498  // Create a temporary FmuFunction instance
1499  Function f = create(this->name() + "_get", {}, {}, Dict{{"aux", name}});
1500  // Get the stats
1501  Dict stats = f.stats().at("aux");
1502  // Return in the same order as inputs
1503  std::vector<GenericType> ret;
1504  ret.reserve(name.size());
1505  for (const std::string& n : name) ret.push_back(stats.at(n));
1506  return ret;
1507  } catch (std::exception& e) {
1508  THROW_ERROR("get", e.what());
1509  return {};
1510  }
1511 }

References create(), e(), name(), and casadi::Function::stats().

◆ get_str()

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

Definition at line 91 of file shared_object.hpp.

91  {
92  std::stringstream ss;
93  disp(ss, more);
94  return ss.str();
95  }
void disp(std::ostream &stream, bool more=false) const
Print a description of the object.

◆ getCount()

casadi_int casadi::GenericShared< SharedObject , SharedObjectInternal >::getCount
inherited

Definition at line 102 of file generic_shared_impl.hpp.

131  {
132  return (*this)->getCount();
133  }

◆ has()

bool casadi::DaeBuilder::has ( const std::string &  name) const

Definition at line 342 of file dae_builder.cpp.

342  {
343  try {
344  return (*this)->has(name);
345  } catch (std::exception& e) {
346  THROW_ERROR("has", e.what());
347  return false; // never reached
348  }
349 }

References e(), and name().

◆ has_beq()

bool casadi::DaeBuilder::has_beq ( const std::string &  name) const

Definition at line 864 of file dae_builder.cpp.

864  {
865  try {
866  return !(*this)->variable(name).has_beq();
867  } catch (std::exception& e) {
868  THROW_ERROR("has_beq", e.what());
869  return false; // never reached
870  }
871 }

References e(), and name().

◆ has_fun()

bool casadi::DaeBuilder::has_fun ( const std::string &  name) const

Definition at line 1158 of file dae_builder.cpp.

1158  {
1159  try {
1160  return (*this)->has_fun(name);
1161  } catch (std::exception& e) {
1162  THROW_ERROR("has_fun", e.what());
1163  return false; // never reached
1164  }
1165 }

References e(), and name().

Referenced by add_fun(), and gather_fun().

◆ has_rate()

bool casadi::DaeBuilder::has_rate ( ) const

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

Definition at line 251 of file dae_builder.cpp.

251  {
252  try {
253  return !(*this)->rate_.empty();
254  } catch (std::exception& e) {
255  THROW_ERROR("has_rate", e.what());
256  return false; // never reached
257  }
258 }

References e().

◆ has_t()

bool casadi::DaeBuilder::has_t ( ) const

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

Definition at line 242 of file dae_builder.cpp.

242  {
243  try {
244  return (*this)->has_t();
245  } catch (std::exception& e) {
246  THROW_ERROR("has_t", e.what());
247  return false; // never reached
248  }
249 }

References e().

Referenced by register_t().

◆ has_variable()

bool casadi::DaeBuilder::has_variable ( const std::string &  name) const
inline

Definition at line 831 of file dae_builder.hpp.

831 {return has(name);}
bool has(const std::string &name) const
Check if a particular variable exists.

◆ init_lhs()

std::vector< MX > casadi::DaeBuilder::init_lhs ( ) const

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

Definition at line 207 of file dae_builder.cpp.

207  {
208  return (*this)->init_lhs();
209 }

◆ init_rhs()

std::vector< MX > casadi::DaeBuilder::init_rhs ( ) const

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

Definition at line 211 of file dae_builder.cpp.

211  {
212  return (*this)->init_rhs();
213 }

Referenced by set_init().

◆ initial()

std::string casadi::DaeBuilder::initial ( const std::string &  name) const

Get/set the initial property

Definition at line 994 of file dae_builder.cpp.

994  {
995  return to_string((*this)->variable(name).initial);
996 }

References name(), and casadi::to_string().

◆ initial_unknowns()

std::vector< std::string > casadi::DaeBuilder::initial_unknowns ( ) const

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

Definition at line 233 of file dae_builder.cpp.

233  {
234  try {
235  return (*this)->name((*this)->initial_unknowns_);
236  } catch (std::exception& e) {
237  THROW_ERROR("initial_unknowns", e.what());
238  return {}; // never reached
239  }
240 }

References e().

◆ is_null()

Definition at line 116 of file generic_shared_impl.hpp.

113  {
114  return node==nullptr;
115  }

◆ jac_sparsity()

Sparsity casadi::DaeBuilder::jac_sparsity ( const std::vector< std::string > &  onames,
const std::vector< std::string > &  inames 
) const

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

Definition at line 1513 of file dae_builder.cpp.

1514  {
1515  try {
1516  return (*this)->jac_sparsity((*this)->find(onames), (*this)->find(inames));
1517  } catch (std::exception& e) {
1518  THROW_ERROR("jac_sparsity", e.what());
1519  return Sparsity(); // never reached
1520  }
1521 }

References e().

◆ lift()

void casadi::DaeBuilder::lift ( bool  lift_shared = true,
bool  lift_calls = true 
)

Definition at line 899 of file dae_builder.cpp.

899  {
900  try {
901  (*this)->lift(lift_shared, lift_calls);
902  } catch (std::exception& e) {
903  THROW_ERROR("lift", e.what());
904  }
905 }

References e().

◆ load_fmi_description()

void casadi::DaeBuilder::load_fmi_description ( const std::string &  filename)

Definition at line 300 of file dae_builder.cpp.

300  {
301  try {
302  (*this)->load_fmi_description(filename);
303  } catch (std::exception& e) {
304  THROW_ERROR("load_fmi_description", e.what());
305  }
306 }
std::string filename(const std::string &path)
Definition: ghc.cpp:55

References e(), and casadi::filename().

Referenced by DaeBuilder().

◆ max() [1/2]

double casadi::DaeBuilder::max ( const std::string &  name) const

Definition at line 1339 of file dae_builder.cpp.

1339  {
1340  try {
1341  return (*this)->variable(name).max;
1342  } catch (std::exception& e) {
1343  THROW_ERROR("max", e.what());
1344  return 0; // never reached
1345  }
1346 }

References e(), and name().

◆ max() [2/2]

std::vector< double > casadi::DaeBuilder::max ( const std::vector< std::string > &  name) const

Definition at line 1348 of file dae_builder.cpp.

1348  {
1349  try {
1350  return (*this)->attribute(Attribute::MAX, name);
1351  } catch (std::exception& e) {
1352  THROW_ERROR("max", e.what());
1353  return {}; // never reached
1354  }
1355 }

References e(), casadi::MAX, and name().

◆ min() [1/2]

double casadi::DaeBuilder::min ( const std::string &  name) const

Definition at line 1305 of file dae_builder.cpp.

1305  {
1306  try {
1307  return (*this)->variable(name).min;
1308  } catch (std::exception& e) {
1309  THROW_ERROR("min", e.what());
1310  return 0; // never reached
1311  }
1312 }

References e(), and name().

◆ min() [2/2]

std::vector< double > casadi::DaeBuilder::min ( const std::vector< std::string > &  name) const

Definition at line 1314 of file dae_builder.cpp.

1314  {
1315  try {
1316  return (*this)->attribute(Attribute::MIN, name);
1317  } catch (std::exception& e) {
1318  THROW_ERROR("min", e.what());
1319  return {}; // never reached
1320  }
1321 }

References e(), casadi::MIN, and name().

◆ name() [1/3]

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

◆ name() [2/3]

std::vector< std::string > casadi::DaeBuilder::name ( const std::vector< size_t > &  ind) const

[DEPRECATED] Access to internal class and corresponding indexing removed

Definition at line 438 of file dae_builder.cpp.

438  {
439  try {
440  return (*this)->name(ind);
441  } catch (std::exception& e) {
442  THROW_ERROR("name", e.what());
443  return {}; // never reached
444  }
445 }

References e().

◆ name() [3/3]

const std::string & casadi::DaeBuilder::name ( size_t  ind) const

[DEPRECATED] Access to internal class and corresponding indexing removed

Definition at line 428 of file dae_builder.cpp.

428  {
429  try {
430  return (*this)->name(ind);
431  } catch (std::exception& e) {
432  THROW_ERROR("name", e.what());
433  static std::string dummy;
434  return dummy; // never reached
435  }
436 }

References e().

◆ nc()

casadi_int casadi::DaeBuilder::nc ( ) const

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

Definition at line 288 of file dae_builder.cpp.

288  {
289  return (*this)->size(Category::C);
290 }

References casadi::C.

◆ nd()

casadi_int casadi::DaeBuilder::nd ( ) const

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

Definition at line 292 of file dae_builder.cpp.

292  {
293  return (*this)->size(Category::D);
294 }

References casadi::D.

◆ ne()

casadi_int casadi::DaeBuilder::ne ( ) const
inline

Definition at line 390 of file dae_builder.hpp.

390 {return nzero();}
casadi_int nzero() const
Zero-crossing functions.

◆ new_variable()

Variable & casadi::DaeBuilder::new_variable ( const std::string &  name,
casadi_int  numel = 1 
)

Definition at line 370 of file dae_builder.cpp.

370  {
371  try {
372  return (*this)->new_variable(name, {numel});
373  } catch (std::exception& e) {
374  THROW_ERROR("new_variable", e.what());
375  }
376 }

References e(), and name().

Referenced by add_variable(), and add_variable_new().

◆ nominal() [1/2]

double casadi::DaeBuilder::nominal ( const std::string &  name) const

Definition at line 1373 of file dae_builder.cpp.

1373  {
1374  try {
1375  return (*this)->variable(name).nominal;
1376  } catch (std::exception& e) {
1377  THROW_ERROR("nominal", e.what());
1378  return 0; // never reached
1379  }
1380 }

References e(), and name().

◆ nominal() [2/2]

std::vector< double > casadi::DaeBuilder::nominal ( const std::vector< std::string > &  name) const

Definition at line 1382 of file dae_builder.cpp.

1382  {
1383  try {
1384  return (*this)->attribute(Attribute::NOMINAL, name);
1385  } catch (std::exception& e) {
1386  THROW_ERROR("nominal", e.what());
1387  return {}; // never reached
1388  }
1389 }

References e(), name(), and casadi::NOMINAL.

◆ np()

casadi_int casadi::DaeBuilder::np ( ) const

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

Definition at line 284 of file dae_builder.cpp.

284  {
285  return (*this)->size(Category::P);
286 }

References casadi::P.

◆ nq()

casadi_int casadi::DaeBuilder::nq ( ) const

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

Definition at line 268 of file dae_builder.cpp.

268  {
269  return (*this)->size(Category::Q);
270 }

References casadi::Q.

◆ nu()

casadi_int casadi::DaeBuilder::nu ( ) const

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

Definition at line 280 of file dae_builder.cpp.

280  {
281  return (*this)->size(Category::U);
282 }

References casadi::U.

◆ numel()

casadi_int casadi::DaeBuilder::numel ( const std::string &  name) const

Definition at line 1018 of file dae_builder.cpp.

1018  {
1019  return (*this)->variable(name).numel;
1020 }

References name().

◆ nw()

casadi_int casadi::DaeBuilder::nw ( ) const

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

Definition at line 296 of file dae_builder.cpp.

296  {
297  return (*this)->size(Category::W);
298 }

References casadi::W.

◆ nx()

casadi_int casadi::DaeBuilder::nx ( ) const

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

Definition at line 260 of file dae_builder.cpp.

260  {
261  return (*this)->size(Category::X);
262 }

References casadi::X.

◆ ny()

casadi_int casadi::DaeBuilder::ny ( ) const

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

Definition at line 276 of file dae_builder.cpp.

276  {
277  return (*this)->outputs_.size();
278 }

◆ nz()

casadi_int casadi::DaeBuilder::nz ( ) const

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

Definition at line 264 of file dae_builder.cpp.

264  {
265  return (*this)->size(Category::Z);
266 }

References casadi::Z.

◆ nzero()

casadi_int casadi::DaeBuilder::nzero ( ) const

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

Definition at line 272 of file dae_builder.cpp.

272  {
273  return (*this)->event_indicators_.size();
274 }

◆ ode()

std::vector< MX > casadi::DaeBuilder::ode ( ) const

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

Definition at line 82 of file dae_builder.cpp.

82  {
83  try {
84  return (*this)->output(OutputCategory::ODE);
85  } catch (std::exception& e) {
86  THROW_ERROR("ode", e.what());
87  return {}; // never reached
88  }
89 }

References e(), and casadi::ODE.

◆ operator()()

MX casadi::DaeBuilder::operator() ( const std::string &  name) const
inline

Get variable expression by name

Definition at line 568 of file dae_builder.hpp.

568 {return var(name);}
MX var(const std::string &name) const

◆ operator->() [1/2]

DaeBuilderInternal * casadi::DaeBuilder::operator-> ( )

Definition at line 1243 of file dae_builder.cpp.

1243  {
1244  return static_cast<DaeBuilderInternal*>(SharedObject::operator->());
1245 }
SharedObjectInternal * operator->() const
Access a member function or object.

References casadi::GenericShared< SharedObject, SharedObjectInternal >::operator->().

◆ operator->() [2/2]

const DaeBuilderInternal * casadi::DaeBuilder::operator-> ( ) const

Definition at line 1247 of file dae_builder.cpp.

1247  {
1248  return static_cast<const DaeBuilderInternal*>(SharedObject::operator->());
1249 }

References casadi::GenericShared< SharedObject, SharedObjectInternal >::operator->().

◆ oracle()

Function casadi::DaeBuilder::oracle ( bool  sx = false,
bool  elim_w = false,
bool  lifted_calls = false 
) const

Definition at line 1201 of file dae_builder.cpp.

1201  {
1202  try {
1203  return (*this)->oracle(sx, elim_w, lifted_calls);
1204  } catch (std::exception& e) {
1205  THROW_ERROR("oracle", e.what());
1206  return Function(); // never reached
1207  }
1208 }

References e(), and casadi::FunctionInternal::oracle().

◆ outputs()

std::vector< std::string > casadi::DaeBuilder::outputs ( ) const

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

Definition at line 215 of file dae_builder.cpp.

215  {
216  try {
217  return (*this)->name((*this)->outputs_);
218  } catch (std::exception& e) {
219  THROW_ERROR("outputs", e.what());
220  return {}; // never reached
221  }
222 }

References e().

◆ own()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::own ( Internal *  node)
inherited

Assign the node to a node class pointer (or null)

Definition at line 89 of file generic_shared_impl.hpp.

◆ p()

std::vector<std::string> casadi::DaeBuilder::p ( ) const
inline

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

Definition at line 166 of file dae_builder.hpp.

166 {return all("p");}

References casadi::all().

◆ parse_fmi()

void casadi::DaeBuilder::parse_fmi ( const std::string &  filename)
inline

Import existing problem from FMI/XML

Definition at line 502 of file dae_builder.hpp.

References casadi::filename().

◆ pre() [1/3]

MX casadi::DaeBuilder::pre ( const MX v) const

Definition at line 827 of file dae_builder.cpp.

827  {
828  try {
829  // Not implemented
830  static bool warned = false;
831  if (!warned) {
832  casadi_warning("DaeBuilder::pre has not been implemented: Returning identity mapping");
833  warned = true;
834  }
835  return v;
836  } catch (std::exception& e) {
837  THROW_ERROR("pre", e.what());
838  return MX(); // never reached
839  }
840 }

References e().

◆ pre() [2/3]

std::string casadi::DaeBuilder::pre ( const std::string &  name) const

Definition at line 812 of file dae_builder.cpp.

812  {
813  try {
814  // Not implemented
815  static bool warned = false;
816  if (!warned) {
817  casadi_warning("DaeBuilder::pre has not been implemented: Returning identity mapping");
818  warned = true;
819  }
820  return name;
821  } catch (std::exception& e) {
822  THROW_ERROR("pre", e.what());
823  return std::string(); // never reached
824  }
825 }

References e(), and name().

◆ pre() [3/3]

std::vector< std::string > casadi::DaeBuilder::pre ( const std::vector< std::string > &  name) const

Definition at line 853 of file dae_builder.cpp.

853  {
854  try {
855  std::vector<std::string> r(name.size());
856  for (size_t i = 0; i < r.size(); ++i) r[i] = pre(name[i]);
857  return r;
858  } catch (std::exception& e) {
859  THROW_ERROR("pre", e.what());
860  return {}; // never reached
861  }
862 }
std::vector< std::string > pre(const std::vector< std::string > &name) const
Get the pre-variables of model variables.

References e(), and name().

◆ print_ptr()

void casadi::SharedObject::print_ptr ( std::ostream &  stream = casadi::uout()) const
inherited

Print the pointer to the internal class

Definition at line 43 of file shared_object.cpp.

43  {
44  stream << get();
45  }

References casadi::GenericShared< SharedObject, SharedObjectInternal >::get().

◆ provides_directional_derivative()

bool casadi::DaeBuilder::provides_directional_derivative ( ) const
inline

Definition at line 508 of file dae_builder.hpp.

bool provides_directional_derivatives() const
Does the FMU provide support for analytic derivatives.

◆ provides_directional_derivatives()

bool casadi::DaeBuilder::provides_directional_derivatives ( ) const

Definition at line 308 of file dae_builder.cpp.

308  {
309  try {
310  casadi_assert(!(*this)->symbolic_, "Functionality only applies to imported standard FMUs");
311  return (*this)->provides_directional_derivatives_;
312  } catch (std::exception& e) {
313  THROW_ERROR("provides_directional_derivatives", e.what());
314  return false;
315  }
316 }

References e().

◆ prune()

void casadi::DaeBuilder::prune ( bool  prune_p = true,
bool  prune_u = true 
)

Definition at line 326 of file dae_builder.cpp.

326  {
327  try {
328  (*this)->prune(prune_p, prune_u);
329  } catch (std::exception& e) {
330  THROW_ERROR("prune", e.what());
331  }
332 }

References e().

◆ q()

std::vector<std::string> casadi::DaeBuilder::q ( ) const
inline

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

Definition at line 126 of file dae_builder.hpp.

126 {return all("q");}

References casadi::all().

◆ quad()

std::vector< MX > casadi::DaeBuilder::quad ( ) const

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

Definition at line 100 of file dae_builder.cpp.

100  {
101  try {
102  return (*this)->output(OutputCategory::QUAD);
103  } catch (std::exception& e) {
104  THROW_ERROR("quad", e.what());
105  return {}; // never reached
106  }
107 }

References e(), and casadi::QUAD.

◆ rate()

std::vector< std::string > casadi::DaeBuilder::rate ( ) const

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

Definition at line 162 of file dae_builder.cpp.

162  {
163  try {
164  return (*this)->name((*this)->rate_);
165  } catch (std::exception& e) {
166  THROW_ERROR("rate", e.what());
167  return {}; // never reached
168  }
169 }

References e().

◆ register_c()

void casadi::DaeBuilder::register_c ( const std::string &  name)

Definition at line 522 of file dae_builder.cpp.

522  {
523  (*this)->indices(Category::C).push_back(find(name));
524 }
size_t find(const std::string &name) const

References casadi::C, find(), and name().

◆ register_d()

void casadi::DaeBuilder::register_d ( const std::string &  name)

Definition at line 526 of file dae_builder.cpp.

526  {
527  (*this)->indices(Category::D).push_back(find(name));
528 }

References casadi::D, find(), and name().

◆ register_e()

void casadi::DaeBuilder::register_e ( const std::string &  name)

Definition at line 538 of file dae_builder.cpp.

538  {
539  (*this)->event_indicators_.push_back(find(name));
540 }

References find(), and name().

◆ register_p()

void casadi::DaeBuilder::register_p ( const std::string &  name)

Definition at line 502 of file dae_builder.cpp.

502  {
503  (*this)->indices(Category::P).push_back(find(name));
504 }

References find(), name(), and casadi::P.

◆ register_q()

void casadi::DaeBuilder::register_q ( const std::string &  name)

Definition at line 518 of file dae_builder.cpp.

518  {
519  (*this)->indices(Category::Q).push_back(find(name));
520 }

References find(), name(), and casadi::Q.

◆ register_t()

void casadi::DaeBuilder::register_t ( const std::string &  name)

Definition at line 496 of file dae_builder.cpp.

496  {
497  // Save to class
498  casadi_assert(!has_t(), "'t' already defined");
499  (*this)->indices(Category::T).push_back(find(name));
500 }
bool has_t() const
Is there a time variable?

References find(), has_t(), name(), and casadi::T.

◆ register_u()

void casadi::DaeBuilder::register_u ( const std::string &  name)

Definition at line 506 of file dae_builder.cpp.

506  {
507  (*this)->indices(Category::U).push_back(find(name));
508 }

References find(), name(), and casadi::U.

◆ register_w()

void casadi::DaeBuilder::register_w ( const std::string &  name)

Definition at line 530 of file dae_builder.cpp.

530  {
531  (*this)->indices(Category::W).push_back(find(name));
532 }

References find(), name(), and casadi::W.

◆ register_x()

void casadi::DaeBuilder::register_x ( const std::string &  name)

Definition at line 510 of file dae_builder.cpp.

510  {
511  (*this)->indices(Category::X).push_back(find(name));
512 }

References find(), name(), and casadi::X.

◆ register_y()

void casadi::DaeBuilder::register_y ( const std::string &  name)

Definition at line 534 of file dae_builder.cpp.

534  {
535  (*this)->outputs_.push_back(find(name));
536 }

References find(), and name().

◆ register_z()

void casadi::DaeBuilder::register_z ( const std::string &  name)

Definition at line 514 of file dae_builder.cpp.

514  {
515  (*this)->indices(Category::Z).push_back(find(name));
516 }

References find(), name(), and casadi::Z.

◆ reinit()

std::string casadi::DaeBuilder::reinit ( const std::string &  name,
const MX val 
)

Definition at line 763 of file dae_builder.cpp.

763  {
764  try {
765  return (*this)->reinit(name, val).name;
766  } catch (std::exception& e) {
767  THROW_ERROR("reinit", e.what());
768  return std::string(); // never reached
769  }
770 }

References e(), and name().

◆ reorder()

void casadi::DaeBuilder::reorder ( const std::string &  cat,
const std::vector< std::string > &  v 
)

Definition at line 615 of file dae_builder.cpp.

615  {
616  try {
617  auto vind = (*this)->find(v);
618  if (cat == "y") {
619  // Reorder outputs
620  (*this)->reorder("y", (*this)->outputs_, vind);
621  } else {
622  // Reorder inputs
623  (*this)->reorder(to_enum<Category>(cat), vind);
624  }
625  } catch (std::exception& e) {
626  THROW_ERROR("reorder", e.what());
627  }
628 }

References e().

Referenced by sort_z().

◆ reset()

void casadi::DaeBuilder::reset ( )

Definition at line 1449 of file dae_builder.cpp.

1449  {
1450  try {
1451  (*this)->reset();
1452  } catch (std::exception& e) {
1453  THROW_ERROR("reset", e.what());
1454  }
1455 }

References e().

◆ sanity_check()

void casadi::DaeBuilder::sanity_check ( ) const

Definition at line 780 of file dae_builder.cpp.

780  {
781  try {
782  (*this)->sanity_check();
783  } catch (std::exception& e) {
784  THROW_ERROR("sanity_check", e.what());
785  }
786 }

References e().

◆ set() [1/4]

void casadi::DaeBuilder::set ( const std::string &  name,
const std::string &  val 
)

Definition at line 1465 of file dae_builder.cpp.

1465  {
1466  try {
1467  (*this)->set_string_attribute(Attribute::STRINGVALUE, name, val);
1468  } catch (std::exception& e) {
1469  THROW_ERROR("set", e.what());
1470  }
1471 }

References e(), name(), and casadi::STRINGVALUE.

◆ set() [2/4]

void casadi::DaeBuilder::set ( const std::string &  name,
double  val 
)

Definition at line 1457 of file dae_builder.cpp.

1457  {
1458  try {
1459  (*this)->set_attribute(Attribute::VALUE, name, val);
1460  } catch (std::exception& e) {
1461  THROW_ERROR("set", e.what());
1462  }
1463 }

References e(), name(), and casadi::VALUE.

◆ set() [3/4]

void casadi::DaeBuilder::set ( const std::vector< std::string > &  name,
const std::vector< double > &  val 
)

Definition at line 1473 of file dae_builder.cpp.

1473  {
1474  try {
1475  (*this)->set_attribute(Attribute::VALUE, name, val);
1476  } catch (std::exception& e) {
1477  THROW_ERROR("set", e.what());
1478  }
1479 }

References e(), name(), and casadi::VALUE.

◆ set() [4/4]

void casadi::DaeBuilder::set ( const std::vector< std::string > &  name,
const std::vector< std::string > &  val 
)

Definition at line 1481 of file dae_builder.cpp.

1482  {
1483  try {
1484  (*this)->set_string_attribute(Attribute::STRINGVALUE, name, val);
1485  } catch (std::exception& e) {
1486  THROW_ERROR("set", e.what());
1487  }
1488 }

References e(), name(), and casadi::STRINGVALUE.

◆ set_alg()

void casadi::DaeBuilder::set_alg ( const std::string &  name,
const MX alg_rhs 
)
inline

Definition at line 379 of file dae_builder.hpp.

379  {
380  (void)name;
381  eq(0, alg_rhs);
382  }

◆ set_all()

void casadi::DaeBuilder::set_all ( const std::string &  v,
const std::vector< std::string > &  name 
)

Definition at line 599 of file dae_builder.cpp.

599  {
600  try {
601  (*this)->clear_cache_ = true; // Clear cache after this
602  const std::vector<size_t>& new_ind = (*this)->find(name);
603  if (v == "y") {
604  (*this)->outputs_ = new_ind;
605  } else {
606  (*this)->indices(to_enum<Category>(v)) = new_ind;
607  }
608  } catch (std::exception& e) {
609  THROW_ERROR("set_all", e.what());
610  }
611 }

References e(), and name().

◆ set_attribute() [1/2]

void casadi::DaeBuilder::set_attribute ( const std::string &  a,
const std::string &  name,
double  val 
)

Definition at line 1288 of file dae_builder.cpp.

1288  {
1289  try {
1290  (*this)->set_attribute(to_enum<Attribute>(a), name, val);
1291  } catch (std::exception& e) {
1292  THROW_ERROR("set_attribute", e.what());
1293  }
1294 }

References e(), and name().

◆ set_attribute() [2/2]

void casadi::DaeBuilder::set_attribute ( const std::string &  a,
const std::vector< std::string > &  name,
const std::vector< double > &  val 
)

Definition at line 1296 of file dae_builder.cpp.

1297  {
1298  try {
1299  (*this)->set_attribute(to_enum<Attribute>(a), name, val);
1300  } catch (std::exception& e) {
1301  THROW_ERROR("set_attribute", e.what());
1302  }
1303 }

References e(), and name().

◆ set_beq()

void casadi::DaeBuilder::set_beq ( const std::string &  name,
const MX val 
)

Definition at line 728 of file dae_builder.cpp.

728  {
729  try {
730  eq(var(name), val);
731  } catch (std::exception& e) {
732  THROW_ERROR("set_beq", e.what());
733  }
734 }

References e(), eq(), name(), and var().

Referenced by add_c(), and add_d().

◆ set_category()

void casadi::DaeBuilder::set_category ( const std::string &  name,
const std::string &  val 
)

The following changes are permitted: Controls 'u' can be changed to/from tunable parameters 'p' or fixed parameters 'c' Differential states that do not appear in the right-hand-sides can be changed between regular states 'x' and quadrature states 'q'

Other changes are not permitted. Causality and variability is updated accordingly.

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

Definition at line 986 of file dae_builder.cpp.

986  {
987  try {
988  (*this)->set_category((*this)->find(name), to_enum<Category>(val));
989  } catch (std::exception& e) {
990  THROW_ERROR("set_category", e.what());
991  }
992 }

References e(), and name().

◆ set_causality()

void casadi::DaeBuilder::set_causality ( const std::string &  name,
const std::string &  val 
)

The following changes are permitted: For controls 'u' (variability 'continuous', causality 'input'), free parameters 'p' (variability 'tunable', causality 'parameter') and fixed parameters 'c' (variability 'fixed', causality 'parameter'), causality can only be changed indirectly, by updating the variability Add or remove an output 'y' by setting the causality to 'output' or 'local', respectively

No other changes are permitted.

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

Definition at line 952 of file dae_builder.cpp.

952  {
953  try {
954  (*this)->set_causality((*this)->find(name), to_enum<Causality>(val));
955  } catch (std::exception& e) {
956  THROW_ERROR("set_causality", e.what());
957  }
958 }

References e(), and name().

Referenced by set_y().

◆ set_description()

void casadi::DaeBuilder::set_description ( const std::string &  name,
const std::string &  val 
)

Get/set description

Definition at line 919 of file dae_builder.cpp.

919  {
920  (*this)->variable(name).description = val;
921 }

References name().

◆ set_display_unit()

void casadi::DaeBuilder::set_display_unit ( const std::string &  name,
const std::string &  val 
)

Get/set the display unit

Definition at line 1014 of file dae_builder.cpp.

1014  {
1015  (*this)->variable(name).display_unit = val;
1016 }

References name().

◆ set_init()

void casadi::DaeBuilder::set_init ( const std::string &  name,
const MX init_rhs 
)

Definition at line 772 of file dae_builder.cpp.

772  {
773  try {
774  (*this)->set_init(name, init_rhs);
775  } catch (std::exception& e) {
776  THROW_ERROR("set_init", e.what());
777  }
778 }
std::vector< MX > init_rhs() const
Initial conditions, right-hand-side.

References e(), init_rhs(), and name().

◆ set_initial()

void casadi::DaeBuilder::set_initial ( const std::string &  name,
const std::string &  val 
)

Get/set the initial property

Definition at line 998 of file dae_builder.cpp.

998  {
999  (*this)->variable(name).initial = to_enum<Initial>(val);
1000 }

References name().

◆ set_max() [1/2]

void casadi::DaeBuilder::set_max ( const std::string &  name,
double  val 
)

Definition at line 1357 of file dae_builder.cpp.

1357  {
1358  try {
1359  (*this)->variable(name).max = val;
1360  } catch (std::exception& e) {
1361  THROW_ERROR("set_max", e.what());
1362  }
1363 }

References e(), and name().

◆ set_max() [2/2]

void casadi::DaeBuilder::set_max ( const std::vector< std::string > &  name,
const std::vector< double > &  val 
)

Definition at line 1365 of file dae_builder.cpp.

1365  {
1366  try {
1367  (*this)->set_attribute(Attribute::MAX, name, val);
1368  } catch (std::exception& e) {
1369  THROW_ERROR("set_max", e.what());
1370  }
1371 }

References e(), casadi::MAX, and name().

◆ set_min() [1/2]

void casadi::DaeBuilder::set_min ( const std::string &  name,
double  val 
)

Definition at line 1323 of file dae_builder.cpp.

1323  {
1324  try {
1325  (*this)->variable(name).min = val;
1326  } catch (std::exception& e) {
1327  THROW_ERROR("set_min", e.what());
1328  }
1329 }

References e(), and name().

◆ set_min() [2/2]

void casadi::DaeBuilder::set_min ( const std::vector< std::string > &  name,
const std::vector< double > &  val 
)

Definition at line 1331 of file dae_builder.cpp.

1331  {
1332  try {
1333  (*this)->set_attribute(Attribute::MIN, name, val);
1334  } catch (std::exception& e) {
1335  THROW_ERROR("set_min", e.what());
1336  }
1337 }

References e(), casadi::MIN, and name().

◆ set_nominal() [1/2]

void casadi::DaeBuilder::set_nominal ( const std::string &  name,
double  val 
)

Definition at line 1391 of file dae_builder.cpp.

1391  {
1392  try {
1393  (*this)->variable(name).nominal = val;
1394  } catch (std::exception& e) {
1395  THROW_ERROR("set_nominal", e.what());
1396  }
1397 }

References e(), and name().

◆ set_nominal() [2/2]

void casadi::DaeBuilder::set_nominal ( const std::vector< std::string > &  name,
const std::vector< double > &  val 
)

Definition at line 1399 of file dae_builder.cpp.

1399  {
1400  try {
1401  (*this)->set_attribute(Attribute::NOMINAL, name, val);
1402  } catch (std::exception& e) {
1403  THROW_ERROR("set_mininal", e.what());
1404  }
1405 }

References e(), name(), and casadi::NOMINAL.

◆ set_ode()

void casadi::DaeBuilder::set_ode ( const std::string &  name,
const MX ode_rhs 
)
inline

Definition at line 374 of file dae_builder.hpp.

374  {
375  eq(var(name), ode_rhs);
376  }

◆ set_rate()

void casadi::DaeBuilder::set_rate ( const std::vector< std::string > &  name)

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

Definition at line 171 of file dae_builder.cpp.

171  {
172  try {
173  casadi_assert(name.size() <= 1, "At most one rate variable");
174  (*this)->rate_ = (*this)->find(name);
175  } catch (std::exception& e) {
176  THROW_ERROR("set_rate", e.what());
177  }
178 }

References e(), and name().

◆ set_start() [1/3]

void casadi::DaeBuilder::set_start ( const std::string &  name,
const std::vector< double > &  val 
)

Definition at line 1433 of file dae_builder.cpp.

1433  {
1434  try {
1435  (*this)->set_attribute(Attribute::START, std::vector<std::string>{name}, val);
1436  } catch (std::exception& e) {
1437  THROW_ERROR("set_start", e.what());
1438  }
1439 }

References e(), name(), and casadi::START.

◆ set_start() [2/3]

void casadi::DaeBuilder::set_start ( const std::string &  name,
double  val 
)

Definition at line 1425 of file dae_builder.cpp.

1425  {
1426  try {
1427  (*this)->set_attribute(Attribute::START, name, val);
1428  } catch (std::exception& e) {
1429  THROW_ERROR("set_start", e.what());
1430  }
1431 }

References e(), name(), and casadi::START.

◆ set_start() [3/3]

void casadi::DaeBuilder::set_start ( const std::vector< std::string > &  name,
const std::vector< double > &  val 
)

Definition at line 1441 of file dae_builder.cpp.

1441  {
1442  try {
1443  (*this)->set_attribute(Attribute::START, name, val);
1444  } catch (std::exception& e) {
1445  THROW_ERROR("set_start", e.what());
1446  }
1447 }

References e(), name(), and casadi::START.

◆ set_start_time()

void casadi::DaeBuilder::set_start_time ( double  val)

Definition at line 1035 of file dae_builder.cpp.

1035  {
1036  try {
1037  (*this)->start_time_ = val;
1038  } catch (std::exception& e) {
1039  THROW_ERROR("set_start_time", e.what());
1040  }
1041 }

References e().

◆ set_step_size()

void casadi::DaeBuilder::set_step_size ( double  val)

Definition at line 1086 of file dae_builder.cpp.

1086  {
1087  try {
1088  (*this)->step_size_ = val;
1089  } catch (std::exception& e) {
1090  THROW_ERROR("set_step_size", e.what());
1091  }
1092 }

References e().

◆ set_stop_time()

void casadi::DaeBuilder::set_stop_time ( double  val)

Definition at line 1052 of file dae_builder.cpp.

1052  {
1053  try {
1054  (*this)->stop_time_ = val;
1055  } catch (std::exception& e) {
1056  THROW_ERROR("set_stop_time", e.what());
1057  }
1058 }

References e().

◆ set_tolerance()

void casadi::DaeBuilder::set_tolerance ( double  val)

Definition at line 1069 of file dae_builder.cpp.

1069  {
1070  try {
1071  (*this)->tolerance_ = val;
1072  } catch (std::exception& e) {
1073  THROW_ERROR("set_tolerance", e.what());
1074  }
1075 }

References e().

◆ set_type()

void casadi::DaeBuilder::set_type ( const std::string &  name,
const std::string &  val 
)

Get/set the type

Definition at line 934 of file dae_builder.cpp.

934  {
935  // Fallback to FMI 2, if necessary
936  if (has_enum<TypeFmi2>(val) && !has_enum<Type>(val)) {
937  (*this)->variable(name).type = from_fmi2(to_enum<TypeFmi2>(val));
938  }
939  // Assume FMI 3
940  (*this)->variable(name).type = to_enum<Type>(val);
941 }
Type from_fmi2(TypeFmi2 v)

References casadi::from_fmi2(), and name().

◆ set_unit()

void casadi::DaeBuilder::set_unit ( const std::string &  name,
const std::string &  val 
)

Get/set the unit

Definition at line 1006 of file dae_builder.cpp.

1006  {
1007  (*this)->variable(name).unit = val;
1008 }

References name().

◆ set_value_reference()

void casadi::DaeBuilder::set_value_reference ( const std::string &  name,
casadi_int  val 
)

Get/set value reference

Definition at line 911 of file dae_builder.cpp.

911  {
912  (*this)->variable(name).value_reference = val;
913 }

References name().

◆ set_variability()

void casadi::DaeBuilder::set_variability ( const std::string &  name,
const std::string &  val 
)

For controls 'u' (variability 'continuous', causality 'input'), free parameters 'p' (variability 'tunable', causality 'parameter') and fixed parameters 'c' (variability 'fixed', causality 'parameter'), update variability in order to change the category. Causality is updated accordingly.

Other changes are not permitted

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

Definition at line 969 of file dae_builder.cpp.

969  {
970  try {
971  (*this)->set_variability((*this)->find(name), to_enum<Variability>(val));
972  } catch (std::exception& e) {
973  THROW_ERROR("set_variability", e.what());
974  }
975 }

References e(), and name().

◆ set_y()

void casadi::DaeBuilder::set_y ( const std::vector< std::string > &  name)

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

Definition at line 126 of file dae_builder.cpp.

126  {
127  try {
128  // Update causality of any existing outputs not in name
129  std::set<std::string> name_set(name.begin(), name.end());
130  casadi_assert(name_set.size() == name.size(), "Duplicate names");
131  for (auto&& n : y()) {
132  auto it = name_set.find(n);
133  if (it == name_set.end()) {
134  // Not an output anymore, make local
135  set_causality(n, "local");
136  } else {
137  // Mark as added
138  name_set.erase(it);
139  }
140  }
141  // Update causality of new outputs
142  for (auto&& n : name) {
143  // Check if not already added
144  auto it = name_set.find(n);
145  if (it != name_set.end()) {
146  // Make output causality
147  set_causality(n, "output");
148  // Mark as added
149  name_set.erase(it);
150  }
151  }
152  // Consistency checks
153  casadi_assert_dev(name_set.empty());
154  casadi_assert_dev((*this)->outputs_.size() == name.size());
155  // Update output ordering
156  (*this)->outputs_ = (*this)->find(name);
157  } catch (std::exception& e) {
158  THROW_ERROR("set_rate", e.what());
159  }
160 }
void set_causality(const std::string &name, const std::string &val)
Set the causality, if permitted.
std::vector< std::string > y() const
Outputs *‍/.
Definition: dae_builder.cpp:73

References e(), name(), set_causality(), and y().

◆ sort()

void casadi::DaeBuilder::sort ( const std::string &  cat)

Definition at line 891 of file dae_builder.cpp.

891  {
892  try {
893  return (*this)->sort(to_enum<Category>(cat));
894  } catch (std::exception& e) {
895  THROW_ERROR("sort", e.what());
896  }
897 }

References e().

Referenced by sort_d(), and sort_w().

◆ sort_d()

void casadi::DaeBuilder::sort_d ( )

Definition at line 566 of file dae_builder.cpp.

566  {
567  try {
568  return sort("d");
569  } catch (std::exception& e) {
570  THROW_ERROR("sort_d", e.what());
571  }
572 }
void sort(const std::string &cat)
Sort dependent parameters.

References e(), and sort().

◆ sort_w()

void casadi::DaeBuilder::sort_w ( )

Definition at line 574 of file dae_builder.cpp.

574  {
575  try {
576  return sort("w");
577  } catch (std::exception& e) {
578  THROW_ERROR("sort_w", e.what());
579  }
580 }

References e(), and sort().

◆ sort_z()

void casadi::DaeBuilder::sort_z ( const std::vector< std::string > &  z_order)

Definition at line 582 of file dae_builder.cpp.

582  {
583  try {
584  return reorder("z", z_order);
585  } catch (std::exception& e) {
586  THROW_ERROR("sort_z", e.what());
587  }
588 }
void reorder(const std::string &cat, const std::vector< std::string > &v)
Reorder variables in a category.

References e(), and reorder().

◆ start() [1/2]

std::vector< double > casadi::DaeBuilder::start ( const std::string &  name) const

Definition at line 1407 of file dae_builder.cpp.

1407  {
1408  try {
1409  return (*this)->attribute(Attribute::START, std::vector<std::string>{name});
1410  } catch (std::exception& e) {
1411  THROW_ERROR("start", e.what());
1412  return {}; // never reached
1413  }
1414 }

References e(), and casadi::START.

◆ start() [2/2]

std::vector< double > casadi::DaeBuilder::start ( const std::vector< std::string > &  name) const

Definition at line 1416 of file dae_builder.cpp.

1416  {
1417  try {
1418  return (*this)->attribute(Attribute::START, name);
1419  } catch (std::exception& e) {
1420  THROW_ERROR("start", e.what());
1421  return {}; // never reached
1422  }
1423 }

References e(), name(), and casadi::START.

◆ start_time()

double casadi::DaeBuilder::start_time ( ) const

Definition at line 1026 of file dae_builder.cpp.

1026  {
1027  try {
1028  return (*this)->start_time_;
1029  } catch (std::exception& e) {
1030  THROW_ERROR("start_time", e.what());
1031  return nan;
1032  }
1033 }
const double nan
Not a number.
Definition: calculus.hpp:53

References e(), and casadi::nan.

◆ step_size()

double casadi::DaeBuilder::step_size ( ) const

Definition at line 1077 of file dae_builder.cpp.

1077  {
1078  try {
1079  return (*this)->step_size_;
1080  } catch (std::exception& e) {
1081  THROW_ERROR("step_size", e.what());
1082  return nan;
1083  }
1084 }

References e(), and casadi::nan.

◆ stop_time()

double casadi::DaeBuilder::stop_time ( ) const

Definition at line 1043 of file dae_builder.cpp.

1043  {
1044  try {
1045  return (*this)->stop_time_;
1046  } catch (std::exception& e) {
1047  THROW_ERROR("stop_time", e.what());
1048  return nan;
1049  }
1050 }

References e(), and casadi::nan.

◆ swap()

Definition at line 105 of file generic_shared_impl.hpp.

124  {
125  GenericShared<Shared, Internal> temp = *this;
126  *this = other;
127  other = temp;
128  }

◆ t()

const MX& casadi::DaeBuilder::t ( ) const
inline

Definition at line 320 of file dae_builder.hpp.

320 { return time();}
const MX & time() const
Expression for independent variable (usually time)
Definition: dae_builder.cpp:63

Referenced by time().

◆ t_new()

std::vector<std::string> casadi::DaeBuilder::t_new ( ) const
inline

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

Definition at line 98 of file dae_builder.hpp.

98 {return all("t");}

References casadi::all().

◆ tear()

void casadi::DaeBuilder::tear ( )

Definition at line 334 of file dae_builder.cpp.

334  {
335  try {
336  (*this)->tear();
337  } catch (std::exception& e) {
338  THROW_ERROR("tear", e.what());
339  }
340 }

References e().

◆ test_cast()

bool casadi::DaeBuilder::test_cast ( const SharedObjectInternal ptr)
static

Definition at line 1239 of file dae_builder.cpp.

1239  {
1240  return dynamic_cast<const DaeBuilderInternal*>(ptr) != nullptr;
1241 }

◆ time()

const MX & casadi::DaeBuilder::time ( ) const

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

Definition at line 63 of file dae_builder.cpp.

63  {
64  try {
65  return (*this)->time();
66  } catch (std::exception& e) {
67  THROW_ERROR("time", e.what());
68  static const MX t;
69  return t; // never reached
70  }
71 }
const MX & t() const
[DEPRECATED] Renamed "time"

References e(), and t().

◆ tolerance()

double casadi::DaeBuilder::tolerance ( ) const

Definition at line 1060 of file dae_builder.cpp.

1060  {
1061  try {
1062  return (*this)->tolerance_;
1063  } catch (std::exception& e) {
1064  THROW_ERROR("tolerance", e.what());
1065  return nan;
1066  }
1067 }

References e(), and casadi::nan.

◆ transition() [1/3]

Function casadi::DaeBuilder::transition ( ) const
inline

Definition at line 563 of file dae_builder.hpp.

563 {return transition(name() + "_transition");}
Function transition() const
Construct an event transition function, default naming.

References transition().

Referenced by transition().

◆ transition() [2/3]

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

Definition at line 1230 of file dae_builder.cpp.

1230  {
1231  try {
1232  return (*this)->transition(fname);
1233  } catch (std::exception& e) {
1234  THROW_ERROR("transition", e.what());
1235  return Function(); // never reached
1236  }
1237 }

References e().

◆ transition() [3/3]

Function casadi::DaeBuilder::transition ( const std::string &  fname,
casadi_int  index 
) const

Definition at line 1221 of file dae_builder.cpp.

1221  {
1222  try {
1223  return (*this)->transition(fname, index);
1224  } catch (std::exception& e) {
1225  THROW_ERROR("transition", e.what());
1226  return Function(); // never reached
1227  }
1228 }

References e().

◆ type()

std::string casadi::DaeBuilder::type ( const std::string &  name,
casadi_int  fmi_version = 3 
) const

Get/set the type

Definition at line 923 of file dae_builder.cpp.

923  {
924  // Check version
925  casadi_assert(fmi_version == 2 || fmi_version == 3, "Only FMI version 2 or 3 supported");
926  // Handle FMI 2
927  if (fmi_version == 2) {
928  return to_string(to_fmi2((*this)->variable(name).type));
929  }
930  // Assume FMI 3
931  return to_string((*this)->variable(name).type);
932 }
TypeFmi2 to_fmi2(Type v)

References name(), casadi::to_fmi2(), and casadi::to_string().

◆ type_name()

std::string casadi::DaeBuilder::type_name ( ) const
inline

Definition at line 74 of file dae_builder.hpp.

74 {return "DaeBuilder";}

◆ u()

std::vector<std::string> casadi::DaeBuilder::u ( ) const
inline

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

Definition at line 161 of file dae_builder.hpp.

161 {return all("u");}

References casadi::all().

◆ unit()

std::string casadi::DaeBuilder::unit ( const std::string &  name) const

Get/set the unit

Definition at line 1002 of file dae_builder.cpp.

1002  {
1003  return (*this)->variable(name).unit;
1004 }

References name().

◆ value_reference()

casadi_int casadi::DaeBuilder::value_reference ( const std::string &  name) const

Get/set value reference

Definition at line 907 of file dae_builder.cpp.

907  {
908  return (*this)->variable(name).value_reference;
909 }

References name().

◆ var() [1/3]

MX casadi::DaeBuilder::var ( const std::string &  name) const

Get variable expression by name

Definition at line 788 of file dae_builder.cpp.

788  {
789  try {
790  return (*this)->variable(name).v;
791  } catch (std::exception& e) {
792  THROW_ERROR("var", e.what());
793  return MX(); // never reached
794  }
795 }

References e(), and name().

Referenced by set_beq().

◆ var() [2/3]

std::vector< MX > casadi::DaeBuilder::var ( const std::vector< size_t > &  ind) const

[DEPRECATED] Use string name, not internal index to access variables

Definition at line 456 of file dae_builder.cpp.

456  {
457  try {
458  return (*this)->var(ind);
459  } catch (std::exception& e) {
460  THROW_ERROR("var", e.what());
461  return {}; // never reached
462  }
463 }

References e().

◆ var() [3/3]

const MX & casadi::DaeBuilder::var ( size_t  ind) const

[DEPRECATED] Use string name, not internal index to access variables

Definition at line 446 of file dae_builder.cpp.

446  {
447  try {
448  return (*this)->var(ind);
449  } catch (std::exception& e) {
450  THROW_ERROR("var", e.what());
451  static MX dummy;
452  return dummy; // never reached
453  }
454 }

References e().

◆ variability()

std::string casadi::DaeBuilder::variability ( const std::string &  name) const

Definition at line 960 of file dae_builder.cpp.

960  {
961  try {
962  return to_string((*this)->variability((*this)->find(name)));
963  } catch (std::exception& e) {
964  THROW_ERROR("variability", e.what());
965  return std::string(); // never reached
966  }
967 }

References e(), name(), and casadi::to_string().

Referenced by add().

◆ variable() [1/4]

Variable & casadi::DaeBuilder::variable ( const std::string &  name)

[DEPRECATED] Access to internal class and corresponding indexing removed

Definition at line 378 of file dae_builder.cpp.

378  {
379  try {
380  return (*this)->variable(name);
381  } catch (std::exception& e) {
382  THROW_ERROR("variable", e.what());
383  }
384 }

References e(), and name().

◆ variable() [2/4]

const Variable & casadi::DaeBuilder::variable ( const std::string &  name) const

[DEPRECATED] Access to internal class and corresponding indexing removed

Definition at line 386 of file dae_builder.cpp.

386  {
387  try {
388  return (*this)->variable(name);
389  } catch (std::exception& e) {
390  THROW_ERROR("variable", e.what());
391  }
392 }

References e(), and name().

◆ variable() [3/4]

Variable & casadi::DaeBuilder::variable ( size_t  ind)

[DEPRECATED] Access to internal class and corresponding indexing removed

Definition at line 394 of file dae_builder.cpp.

394  {
395  try {
396  return (*this)->variable(ind);
397  } catch (std::exception& e) {
398  THROW_ERROR("variable", e.what());
399  }
400 }

References e().

◆ variable() [4/4]

const Variable & casadi::DaeBuilder::variable ( size_t  ind) const

[DEPRECATED] Access to internal class and corresponding indexing removed

Definition at line 402 of file dae_builder.cpp.

402  {
403  try {
404  return (*this)->variable(ind);
405  } catch (std::exception& e) {
406  THROW_ERROR("variable", e.what());
407  }
408 }

References e().

◆ w()

std::vector<std::string> casadi::DaeBuilder::w ( ) const
inline

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

Definition at line 193 of file dae_builder.hpp.

193 {return all("w");}

References casadi::all().

◆ wdef()

std::vector< MX > casadi::DaeBuilder::wdef ( ) const

Interdependencies are allowed but must be non-cyclic.

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

Definition at line 198 of file dae_builder.cpp.

198  {
199  try {
200  return (*this)->output(OutputCategory::WDEF);
201  } catch (std::exception& e) {
202  THROW_ERROR("wdef", e.what());
203  return {}; // never reached
204  }
205 }

References e(), and casadi::WDEF.

◆ weak()

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

Definition at line 130 of file generic_shared_impl.hpp.

136  {
137  return (*this)->weak();
138  }

◆ when()

void casadi::DaeBuilder::when ( const MX cond,
const std::vector< std::string > &  eqs,
const Dict opts = Dict() 
)

Definition at line 746 of file dae_builder.cpp.

746  {
747  try {
748  (*this)->when(cond, eqs, opts);
749  } catch (std::exception& e) {
750  THROW_ERROR("when", e.what());
751  }
752 }

References e().

◆ x()

std::vector<std::string> casadi::DaeBuilder::x ( ) const
inline

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

Definition at line 103 of file dae_builder.hpp.

103 {return all("x");}

References casadi::all().

◆ y()

std::vector< std::string > casadi::DaeBuilder::y ( ) const

Definition at line 73 of file dae_builder.cpp.

73  {
74  try {
75  return (*this)->name((*this)->outputs_);
76  } catch (std::exception& e) {
77  THROW_ERROR("y", e.what());
78  return {}; // never reached
79  }
80 }

References e().

Referenced by set_y().

◆ ydef()

std::vector< MX > casadi::DaeBuilder::ydef ( ) const

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

Definition at line 117 of file dae_builder.cpp.

117  {
118  try {
119  return (*this)->output(OutputCategory::Y);
120  } catch (std::exception& e) {
121  THROW_ERROR("ydef", e.what());
122  return {}; // never reached
123  }
124 }

References e(), and casadi::Y.

◆ z()

std::vector<std::string> casadi::DaeBuilder::z ( ) const
inline

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

Definition at line 116 of file dae_builder.hpp.

116 {return all("z");}

References casadi::all().

◆ zero()

std::vector< MX > casadi::DaeBuilder::zero ( ) const

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

Definition at line 109 of file dae_builder.cpp.

109  {
110  try {
111  return (*this)->output(OutputCategory::ZERO);
112  } catch (std::exception& e) {
113  THROW_ERROR("zero", e.what());
114  }
115 }

References e(), and casadi::ZERO.


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