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 set_all (const std::string &v, const std::vector< std::string > &name)
 Set all variables within a a category. 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
 Model structure: All time derivatives. 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...
 
std::vector< std::string > categories (const std::string &name) const
 Which categories are possible for a variable? 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...
 
bool symbolic () const
 Symbolic DAE instance? 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...
 
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...
 
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< std::string > z () const
 Algebraic variables. More...
 
std::vector< std::string > q () const
 Quadrature states. More...
 
std::vector< MXinputs (const std::string &cat) const
 Input expressions for a specific category. More...
 
std::vector< MXoutputs (const std::string &cat) const
 Output expressions for a specific category. More...
 
std::vector< MXode () const
 [DEPRECATED] Replaced with outputs("ode") More...
 
std::vector< MXalg () const
 [DEPRECATED] Replaced with outputs("alg") More...
 
std::vector< MXquad () const
 [DEPRECATED] Replaced with outputs("quad") More...
 
std::vector< MXzero () const
 [DEPRECATED] Replaced with outputs("zero") More...
 
std::vector< MXydef () const
 [DEPRECATED] Replaced with outputs("y") More...
 
void set_y (const std::vector< std::string > &name)
 [DEPRECATED] Replaced with set_all("y", name) 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
 [DEPRECATED] Renamed "y" More...
 
std::vector< std::string > derivatives () const
 [DEPRECATED] Renamed "der" More...
 
std::vector< std::string > initial_unknowns () const
 Model structure: initial unknowns. More...
 
bool has_t () const
 Is there a time variable? 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...
 
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 sanity_check () const
 Check if dimensions match. More...
 
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...
 
Dict export_fmu (const Dict &opts=Dict())
 Export instance into an FMU. More...
 
Dict compile_fmu (const Dict &files, const Dict &opts=Dict())
 Compile the sources produced by export_fmu. More...
 
std::string pack_fmu (const Dict &files, const Dict &opts=Dict())
 Pack files from export_fmu / compile_fmu into a single .fmu archive. 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)
 

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.

148  {
149  return reinterpret_cast<casadi_int>(get());
150  }

◆ add() [1/4]

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

Definition at line 361 of file dae_builder.cpp.

361  {
362  try {
363  return (*this)->add(name, opts).v;
364  } catch (std::exception& e) {
365  THROW_ERROR("add", e.what());
366  return MX();
367  }
368 }

References name().

◆ add() [2/4]

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

Definition at line 352 of file dae_builder.cpp.

352  {
353  try {
354  return (*this)->add(name, to_enum<Causality>(causality), opts).v;
355  } catch (std::exception& e) {
356  THROW_ERROR("add", e.what());
357  return MX();
358  }
359 }
std::string causality(const std::string &name) const
Get the causality.

References causality(), 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 341 of file dae_builder.cpp.

342  {
343  try {
344  return (*this)->add(name, to_enum<Causality>(causality),
345  to_enum<Variability>(variability), opts).v;
346  } catch (std::exception& e) {
347  THROW_ERROR("add", e.what());
348  return MX();
349  }
350 }
std::string variability(const std::string &name) const
Get the variability.

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

◆ 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 370 of file dae_builder.cpp.

371  {
372  try {
373  // Ensure pure symbolic expression
374  casadi_assert(expr.is_symbolic(), "Expression must be symbolic");
375  // Make sure name matches expression
376  casadi_assert(name == expr.name(), "Name must match expression");
377  // Add variable
378  (*this)->add(name, to_enum<Causality>(causality), to_enum<Variability>(variability),
379  expr, opts);
380  } catch (std::exception& e) {
381  THROW_ERROR("add", e.what());
382  }
383 }

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

◆ add_fun() [1/3]

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

Definition at line 795 of file dae_builder.cpp.

795  {
796  try {
797  return (*this)->add_fun(f);
798  } catch (std::exception& e) {
799  THROW_ERROR("add_fun", e.what());
800  return Function(); // never reached
801  }
802 }

◆ add_fun() [2/3]

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

Definition at line 814 of file dae_builder.cpp.

814  {
815  casadi_assert(!has_fun(name), "Function '" + name + "' already exists");
816  return add_fun(external(name, compiler, opts));
817 }
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 804 of file dae_builder.cpp.

805  {
806  try {
807  return (*this)->add_fun(name, arg, res, opts);
808  } catch (std::exception& e) {
809  THROW_ERROR("add_fun", e.what());
810  return Function(); // never reached
811  }
812 }

References name().

Referenced by add_fun(), and gather_fun().

◆ add_lc()

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

Definition at line 755 of file dae_builder.cpp.

756  {
757  try {
758  (*this)->add_lc(name, f_out);
759  } catch (std::exception& e) {
760  THROW_ERROR("add_lc", e.what());
761  }
762 }

References name().

◆ alg()

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

Definition at line 135 of file dae_builder.hpp.

135 {return outputs("alg");}
std::vector< std::string > outputs() const
[DEPRECATED] Renamed "y"

◆ all() [1/2]

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

Definition at line 263 of file dae_builder.cpp.

263  {
264  try {
265  return (*this)->all();
266  } catch (std::exception& e) {
267  THROW_ERROR("all", e.what());
268  return {}; // never reached
269  }
270 }

Referenced by set_all().

◆ all() [2/2]

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

Definition at line 272 of file dae_builder.cpp.

272  {
273  try {
274  return (*this)->all(to_enum<Category>(cat));
275  } catch (std::exception& e) {
276  THROW_ERROR("all", e.what());
277  return {}; // never reached
278  }
279 }

◆ assign() [1/2]

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

Definition at line 401 of file dae_builder.cpp.

401  {
402  try {
403  return (*this)->assign(name, val).name;
404  } catch (std::exception& e) {
405  THROW_ERROR("assign", e.what());
406  return std::string(); // never reached
407  }
408 }

References 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.

86  {
87  node = node_;
88  }

◆ attribute() [1/2]

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

Definition at line 930 of file dae_builder.cpp.

930  {
931  try {
932  return (*this)->attribute(to_enum<Attribute>(a), name);
933  } catch (std::exception& e) {
934  THROW_ERROR("attribute", e.what());
935  return 0; // never reached
936  }
937 }

References name().

◆ attribute() [2/2]

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

Definition at line 939 of file dae_builder.cpp.

940  {
941  try {
942  return (*this)->attribute(to_enum<Attribute>(a), name);
943  } catch (std::exception& e) {
944  THROW_ERROR("attribute", e.what());
945  return {}; // never reached
946  }
947 }

References name().

◆ beq()

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

Definition at line 520 of file dae_builder.cpp.

520  {
521  try {
522  const Variable& v = (*this)->variable(name);
523  return (*this)->variable(v.bind).v;
524  } catch (std::exception& e) {
525  THROW_ERROR("beq", e.what());
526  return MX(); // never reached
527  }
528 }
struct VariableStruct Variable

References casadi::Variable::bind, 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 163 of file dae_builder.hpp.

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

References casadi::all().

◆ categories()

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

Definition at line 599 of file dae_builder.cpp.

599  {
600  try {
601  std::vector<std::string> ret;
602  for (auto&& cat : (*this)->variable(name).categories()) {
603  ret.push_back(to_string(cat));
604  }
605  return ret;
606  } catch (std::exception& e) {
607  THROW_ERROR("categories", e.what());
608  return {}; // never reached
609  }
610 }
std::string to_string(TypeFmi2 v)

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

◆ category()

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

Definition at line 637 of file dae_builder.cpp.

637  {
638  try {
639  return to_string((*this)->category((*this)->find(name)));
640  } catch (std::exception& e) {
641  THROW_ERROR("category", e.what());
642  return std::string(); // never reached
643  }
644 }

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

◆ causality()

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

Definition at line 590 of file dae_builder.cpp.

590  {
591  try {
592  return to_string((*this)->causality((*this)->find(name)));
593  } catch (std::exception& e) {
594  THROW_ERROR("causality", e.what());
595  return std::string(); // never reached
596  }
597 }

References 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 91 of file dae_builder.cpp.

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

◆ class_name()

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

◆ compile_fmu()

Dict casadi::DaeBuilder::compile_fmu ( const Dict files,
const Dict opts = Dict() 
)
Parameters
filesthe {local_file -> archive path} map returned by export_fmu
optscompile options: compiler, compiler_options, include_dirs
Returns
the file map augmented with the amalgamation source and compiled binary

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

Definition at line 220 of file dae_builder.cpp.

220  {
221  try {
222  return (*this)->compile_fmu(files, opts);
223  } catch (std::exception& e) {
224  THROW_ERROR("compile_fmu", e.what());
225  return Dict(); // never reached
226  }
227 }
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.

◆ 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 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
52  GenericWeakRef<Shared, Internal>* weak_ref =
53  node->weak_ref_.load(std::memory_order_acquire);
54 #else
55  GenericWeakRef<Shared, Internal>* weak_ref = node->weak_ref_;
56 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
57  if (weak_ref) {
58 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
59  // get_mutex() returns a shared_ptr copy, so the mutex outlives this lock
60  // even if delete node (below) destroys the WeakRefInternal holding it
61  auto mutex = weak_ref->get_mutex();
62  // Avoid triggering a delete while a weak_ref.shared_if_alive is being called
63  std::lock_guard<std::mutex> lock(*mutex);
64 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
65 
66  if (--static_cast<Internal*>(node)->count == 0) {
67  delete node;
68  node = nullptr;
69  }
70  } else {
71  if (--static_cast<Internal*>(node)->count == 0) {
72  delete node;
73  node = nullptr;
74  }
75  }
76  }

◆ 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 448 of file dae_builder.hpp.

448 {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 786 of file dae_builder.cpp.

786  {
787  try {
788  return (*this)->create(name, dyn_in(), dyn_out(), opts, false, false);
789  } catch (std::exception& e) {
790  THROW_ERROR("create", e.what());
791  return Function(); // never reached
792  }
793 }
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(), 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 764 of file dae_builder.cpp.

766  {
767  try {
768  return (*this)->create(fname, name_in, name_out, Dict(), sx, lifted_calls);
769  } catch (std::exception& e) {
770  THROW_ERROR("create", e.what());
771  return Function(); // never reached
772  }
773 }

◆ 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 775 of file dae_builder.cpp.

777  {
778  try {
779  return (*this)->create(fname, name_in, name_out, opts, false, false);
780  } catch (std::exception& e) {
781  THROW_ERROR("create", e.what());
782  return Function(); // never reached
783  }
784 }

◆ d()

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

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

Definition at line 173 of file dae_builder.hpp.

173 {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 100 of file dae_builder.cpp.

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

References casadi::DDEF.

◆ debug_repr()

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

Definition at line 112 of file generic_shared_impl.hpp.

91  {
92  if (node) {
93  return node->debug_repr(node);
94  } else {
95  return "NULL";
96  }
97  }
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 871 of file dae_builder.cpp.

873  {
874  try {
875  return (*this)->dependent_fun(fname, s_in, s_out);
876  } catch (std::exception& e) {
877  THROW_ERROR("dependent_fun", e.what());
878  return Function(); // never reached
879  }
880 }

◆ der() [1/5]

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

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

Definition at line 126 of file dae_builder.cpp.

126  {
127  try {
128  return (*this)->name((*this)->der_);
129  } catch (std::exception& e) {
130  THROW_ERROR("der", e.what());
131  return {}; // never reached
132  }
133 }

Referenced by der().

◆ der() [2/5]

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

Differentiate an expression with respect to time

Definition at line 921 of file dae_builder.cpp.

921  {
922  try {
923  return (*this)->der(v);
924  } catch (std::exception& e) {
925  THROW_ERROR("der", e.what());
926  return MX(); // never reached
927  }
928 }

◆ der() [3/5]

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

Differentiate an expression with respect to time

Definition at line 912 of file dae_builder.cpp.

912  {
913  try {
914  return (*this)->der(v);
915  } catch (std::exception& e) {
916  THROW_ERROR("der", e.what());
917  return MX(); // never reached
918  }
919 }

◆ der() [4/5]

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

Definition at line 444 of file dae_builder.cpp.

444  {
445  try {
446  // Get variable index
447  size_t ind = (*this)->find(name);
448  // Differentiate
449  ind = (*this)->variable(ind).der;
450  casadi_assert(ind != size_t(-1), "No derivative expression for " + name);
451  // Return name
452  return (*this)->variable(ind).name;
453  } catch (std::exception& e) {
454  THROW_ERROR("der", e.what());
455  return std::string(); // never reached
456  }
457 }

References name().

◆ der() [5/5]

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

Definition at line 489 of file dae_builder.cpp.

489  {
490  try {
491  std::vector<std::string> r(name.size());
492  for (size_t i = 0; i < r.size(); ++i) r[i] = der(name[i]);
493  return r;
494  } catch (std::exception& e) {
495  THROW_ERROR("der", e.what());
496  return {}; // never reached
497  }
498 }
std::vector< std::string > der() const
Model structure: All time derivatives.

References der(), and name().

◆ derivatives()

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

Definition at line 209 of file dae_builder.hpp.

209 {return der();}

◆ description()

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

Get/set description

Definition at line 562 of file dae_builder.cpp.

562  {
563  return (*this)->variable(name).description;
564 }

References name().

◆ dimension()

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

Definition at line 683 of file dae_builder.cpp.

683  {
684  return (*this)->variable(name).dimension;
685 }

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 671 of file dae_builder.cpp.

671  {
672  return (*this)->variable(name).display_unit;
673 }

References name().

◆ eliminate()

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

Definition at line 530 of file dae_builder.cpp.

530  {
531  try {
532  (*this)->eliminate(to_enum<Category>(cat));
533  } catch (std::exception& e) {
534  THROW_ERROR("eliminate", e.what());
535  }
536 }

◆ eq()

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

Definition at line 385 of file dae_builder.cpp.

385  {
386  try {
387  (*this)->eq(lhs, rhs, opts);
388  } catch (std::exception& e) {
389  THROW_ERROR("eq", e.what());
390  }
391 }

◆ export_fmu()

Dict casadi::DaeBuilder::export_fmu ( const Dict opts = Dict())

Definition at line 211 of file dae_builder.cpp.

211  {
212  try {
213  return (*this)->export_fmu(opts);
214  } catch (std::exception& e) {
215  THROW_ERROR("export_fmu", e.what());
216  return Dict(); // never reached
217  }
218 }

◆ fun() [1/2]

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

Definition at line 858 of file dae_builder.cpp.

858  {
859  return (*this)->fun_;
860 }

◆ fun() [2/2]

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

Definition at line 828 of file dae_builder.cpp.

828  {
829  try {
830  return (*this)->fun(name);
831  } catch (std::exception& e) {
832  THROW_ERROR("fun", e.what());
833  return Function(); // never reached
834  }
835 }

References name().

◆ gather_fun()

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

Definition at line 837 of file dae_builder.cpp.

837  {
838  try {
839  // Get a function corresponding to all equations (no inputs)
840  Function all_eq = (*this)->gather_eq();
841  // Gather all functions
842  std::vector<Function> allfun = all_eq.find_functions(max_depth);
843  // Add to list of functions
844  for (const Function& f : allfun) {
845  if (has_fun(f.name())) {
846  // Skip functions with duplicate names
847  casadi_warning("Duplicate function: '" + f.name() + "', ignored");
848  } else {
849  // Add to list of functions
850  add_fun(f);
851  }
852  }
853  } catch (std::exception& e) {
854  THROW_ERROR("gather_fun", e.what());
855  }
856 }

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

◆ get() [1/3]

Definition at line 99 of file generic_shared_impl.hpp.

115  {
116  return node;
117  }

◆ get() [2/3]

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

Definition at line 1151 of file dae_builder.cpp.

1151  {
1152  return get(std::vector<std::string>{name}).front();
1153 }
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 1155 of file dae_builder.cpp.

1155  {
1156  try {
1157  // Allocate return value
1158  std::vector<GenericType> ret;
1159  ret.reserve(name.size());
1160  // For symbolic FMUs, we can just retrieve the values
1161  if (symbolic()) {
1162  // Retrieve the attributes
1163  for (const auto& n : name) {
1164  // Get the variable
1165  const Variable& v = (*this)->variable(n);
1166  if (v.type == Type::STRING) {
1167  // Attribute is a string
1168  std::string val;
1169  v.get_attribute(Attribute::STRINGVALUE, &val);
1170  ret.push_back(val);
1171  } else if (v.numel == 1) {
1172  // Attribute is numerical scalar
1173  double val;
1174  v.get_attribute(Attribute::VALUE, &val);
1175  ret.push_back(val);
1176  } else {
1177  // Attribute is a vector
1178  std::vector<double> val;
1179  v.get_attribute(Attribute::VALUE, &val);
1180  ret.push_back(val);
1181  }
1182  }
1183  } else {
1184  // Create a temporary FmuFunction instance
1185  Function f = create(this->name() + "_get", {}, {}, Dict{{"aux", name}});
1186  // Get the stats
1187  Dict stats = f.stats().at("aux");
1188  // Return in the same order as inputs
1189  for (const std::string& n : name) ret.push_back(stats.at(n));
1190  }
1191  return ret;
1192  } catch (std::exception& e) {
1193  THROW_ERROR("get", e.what());
1194  return {};
1195  }
1196 }
bool symbolic() const
Symbolic DAE instance?

References create(), casadi::Variable::get_attribute(), name(), casadi::Variable::numel, casadi::Function::stats(), casadi::STRING, casadi::STRINGVALUE, symbolic(), casadi::Variable::type, and casadi::VALUE.

◆ 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.

138  {
139  return (*this)->getCount();
140  }

◆ has()

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

Definition at line 254 of file dae_builder.cpp.

254  {
255  try {
256  return (*this)->has(name);
257  } catch (std::exception& e) {
258  THROW_ERROR("has", e.what());
259  return false; // never reached
260  }
261 }

References name().

◆ has_beq()

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

Definition at line 511 of file dae_builder.cpp.

511  {
512  try {
513  return !(*this)->variable(name).has_beq();
514  } catch (std::exception& e) {
515  THROW_ERROR("has_beq", e.what());
516  return false; // never reached
517  }
518 }

References name().

◆ has_fun()

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

Definition at line 819 of file dae_builder.cpp.

819  {
820  try {
821  return (*this)->has_fun(name);
822  } catch (std::exception& e) {
823  THROW_ERROR("has_fun", e.what());
824  return false; // never reached
825  }
826 }

References name().

Referenced by add_fun(), and gather_fun().

◆ has_t()

bool casadi::DaeBuilder::has_t ( ) const

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

Definition at line 144 of file dae_builder.cpp.

144  {
145  try {
146  return (*this)->has_t();
147  } catch (std::exception& e) {
148  THROW_ERROR("has_t", e.what());
149  return false; // never reached
150  }
151 }

◆ init_lhs()

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

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

Definition at line 118 of file dae_builder.cpp.

118  {
119  return (*this)->init_lhs();
120 }

◆ init_rhs()

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

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

Definition at line 122 of file dae_builder.cpp.

122  {
123  return (*this)->init_rhs();
124 }

Referenced by set_init().

◆ initial()

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

Get/set the initial property

Definition at line 655 of file dae_builder.cpp.

655  {
656  return to_string((*this)->variable(name).initial);
657 }

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 135 of file dae_builder.cpp.

135  {
136  try {
137  return (*this)->name((*this)->initial_unknowns_);
138  } catch (std::exception& e) {
139  THROW_ERROR("initial_unknowns", e.what());
140  return {}; // never reached
141  }
142 }

◆ inputs()

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

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

Definition at line 73 of file dae_builder.cpp.

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

◆ is_null()

Definition at line 116 of file generic_shared_impl.hpp.

120  {
121  return node==nullptr;
122  }

◆ 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 1207 of file dae_builder.cpp.

1208  {
1209  try {
1210  return (*this)->jac_sparsity((*this)->find(onames), (*this)->find(inames));
1211  } catch (std::exception& e) {
1212  THROW_ERROR("jac_sparsity", e.what());
1213  return Sparsity(); // never reached
1214  }
1215 }

◆ lift()

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

Definition at line 546 of file dae_builder.cpp.

546  {
547  try {
548  (*this)->lift(lift_shared, lift_calls);
549  } catch (std::exception& e) {
550  THROW_ERROR("lift", e.what());
551  }
552 }

◆ load_fmi_description()

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

Definition at line 193 of file dae_builder.cpp.

193  {
194  try {
195  (*this)->load_fmi_description(filename);
196  } catch (std::exception& e) {
197  THROW_ERROR("load_fmi_description", e.what());
198  }
199 }
std::string filename(const std::string &path)
Definition: ghc.cpp:55

References casadi::filename().

Referenced by DaeBuilder().

◆ max() [1/2]

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

Definition at line 1000 of file dae_builder.cpp.

1000  {
1001  try {
1002  return (*this)->variable(name).max;
1003  } catch (std::exception& e) {
1004  THROW_ERROR("max", e.what());
1005  return 0; // never reached
1006  }
1007 }

References name().

◆ max() [2/2]

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

Definition at line 1009 of file dae_builder.cpp.

1009  {
1010  try {
1011  return (*this)->attribute(Attribute::MAX, name);
1012  } catch (std::exception& e) {
1013  THROW_ERROR("max", e.what());
1014  return {}; // never reached
1015  }
1016 }

References casadi::MAX, and name().

◆ min() [1/2]

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

Definition at line 966 of file dae_builder.cpp.

966  {
967  try {
968  return (*this)->variable(name).min;
969  } catch (std::exception& e) {
970  THROW_ERROR("min", e.what());
971  return 0; // never reached
972  }
973 }

References name().

◆ min() [2/2]

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

Definition at line 975 of file dae_builder.cpp.

975  {
976  try {
977  return (*this)->attribute(Attribute::MIN, name);
978  } catch (std::exception& e) {
979  THROW_ERROR("min", e.what());
980  return {}; // never reached
981  }
982 }

References casadi::MIN, and name().

◆ name()

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

◆ nc()

casadi_int casadi::DaeBuilder::nc ( ) const

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

Definition at line 181 of file dae_builder.cpp.

181  {
182  return (*this)->size(Category::C);
183 }

References casadi::C.

◆ nd()

casadi_int casadi::DaeBuilder::nd ( ) const

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

Definition at line 185 of file dae_builder.cpp.

185  {
186  return (*this)->size(Category::D);
187 }

References casadi::D.

◆ nominal() [1/2]

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

Definition at line 1034 of file dae_builder.cpp.

1034  {
1035  try {
1036  return (*this)->variable(name).nominal;
1037  } catch (std::exception& e) {
1038  THROW_ERROR("nominal", e.what());
1039  return 0; // never reached
1040  }
1041 }

References name().

◆ nominal() [2/2]

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

Definition at line 1043 of file dae_builder.cpp.

1043  {
1044  try {
1045  return (*this)->attribute(Attribute::NOMINAL, name);
1046  } catch (std::exception& e) {
1047  THROW_ERROR("nominal", e.what());
1048  return {}; // never reached
1049  }
1050 }

References name(), and casadi::NOMINAL.

◆ np()

casadi_int casadi::DaeBuilder::np ( ) const

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

Definition at line 177 of file dae_builder.cpp.

177  {
178  return (*this)->size(Category::P);
179 }

References casadi::P.

◆ nq()

casadi_int casadi::DaeBuilder::nq ( ) const

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

Definition at line 161 of file dae_builder.cpp.

161  {
162  return (*this)->size(Category::Q);
163 }

References casadi::Q.

◆ nu()

casadi_int casadi::DaeBuilder::nu ( ) const

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

Definition at line 173 of file dae_builder.cpp.

173  {
174  return (*this)->size(Category::U);
175 }

References casadi::U.

◆ numel()

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

Definition at line 679 of file dae_builder.cpp.

679  {
680  return (*this)->variable(name).numel;
681 }

References name().

◆ nw()

casadi_int casadi::DaeBuilder::nw ( ) const

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

Definition at line 189 of file dae_builder.cpp.

189  {
190  return (*this)->size(Category::W);
191 }

References casadi::W.

◆ nx()

casadi_int casadi::DaeBuilder::nx ( ) const

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

Definition at line 153 of file dae_builder.cpp.

153  {
154  return (*this)->size(Category::X);
155 }

References casadi::X.

◆ ny()

casadi_int casadi::DaeBuilder::ny ( ) const

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

Definition at line 169 of file dae_builder.cpp.

169  {
170  return (*this)->size(Category::Y);
171 }

References casadi::Y.

Referenced by set_all().

◆ nz()

casadi_int casadi::DaeBuilder::nz ( ) const

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

Definition at line 157 of file dae_builder.cpp.

157  {
158  return (*this)->size(Category::Z);
159 }

References casadi::Z.

◆ nzero()

casadi_int casadi::DaeBuilder::nzero ( ) const

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

Definition at line 165 of file dae_builder.cpp.

165  {
166  return (*this)->size(Category::ZERO);
167 }

References casadi::ZERO.

◆ ode()

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

Definition at line 132 of file dae_builder.hpp.

132 {return outputs("ode");}

◆ operator()()

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

Get variable expression by name

Definition at line 467 of file dae_builder.hpp.

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

◆ operator->() [1/2]

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

Definition at line 904 of file dae_builder.cpp.

904  {
905  return static_cast<DaeBuilderInternal*>(SharedObject::operator->());
906 }
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 908 of file dae_builder.cpp.

908  {
909  return static_cast<const DaeBuilderInternal*>(SharedObject::operator->());
910 }

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 862 of file dae_builder.cpp.

862  {
863  try {
864  return (*this)->oracle(sx, elim_w, lifted_calls);
865  } catch (std::exception& e) {
866  THROW_ERROR("oracle", e.what());
867  return Function(); // never reached
868  }
869 }

References casadi::FunctionInternal::oracle().

◆ outputs() [1/2]

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

Definition at line 206 of file dae_builder.hpp.

206 {return y();}
std::vector< std::string > y() const
Outputs.

◆ outputs() [2/2]

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

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

Definition at line 82 of file dae_builder.cpp.

82  {
83  try {
84  return (*this)->outputs(to_enum<Category>(cat));
85  } catch (std::exception& e) {
86  THROW_ERROR("outputs", e.what());
87  return {}; // never reached
88  }
89 }

◆ 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 158 of file dae_builder.hpp.

158 {return all("p");}

References casadi::all().

◆ pack_fmu()

std::string casadi::DaeBuilder::pack_fmu ( const Dict files,
const Dict opts = Dict() 
)
Parameters
filesthe {local_file -> archive path} map to pack
optspackaging options: path (default '<name>.fmu')

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

Definition at line 229 of file dae_builder.cpp.

229  {
230  try {
231  return (*this)->pack_fmu(files, opts);
232  } catch (std::exception& e) {
233  THROW_ERROR("pack_fmu", e.what());
234  return std::string(); // never reached
235  }
236 }

◆ parse_fmi()

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

Import existing problem from FMI/XML

Definition at line 384 of file dae_builder.hpp.

References casadi::filename().

◆ pre() [1/3]

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

Definition at line 474 of file dae_builder.cpp.

474  {
475  try {
476  // Not implemented
477  static bool warned = false;
478  if (!warned) {
479  casadi_warning("DaeBuilder::pre has not been implemented: Returning identity mapping");
480  warned = true;
481  }
482  return v;
483  } catch (std::exception& e) {
484  THROW_ERROR("pre", e.what());
485  return MX(); // never reached
486  }
487 }

◆ pre() [2/3]

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

Definition at line 459 of file dae_builder.cpp.

459  {
460  try {
461  // Not implemented
462  static bool warned = false;
463  if (!warned) {
464  casadi_warning("DaeBuilder::pre has not been implemented: Returning identity mapping");
465  warned = true;
466  }
467  return name;
468  } catch (std::exception& e) {
469  THROW_ERROR("pre", e.what());
470  return std::string(); // never reached
471  }
472 }

References name().

◆ pre() [3/3]

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

Definition at line 500 of file dae_builder.cpp.

500  {
501  try {
502  std::vector<std::string> r(name.size());
503  for (size_t i = 0; i < r.size(); ++i) r[i] = pre(name[i]);
504  return r;
505  } catch (std::exception& e) {
506  THROW_ERROR("pre", e.what());
507  return {}; // never reached
508  }
509 }
std::vector< std::string > pre(const std::vector< std::string > &name) const
Get the pre-variables of model variables.

References 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 390 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 201 of file dae_builder.cpp.

201  {
202  try {
203  casadi_assert(!symbolic(), "Functionality only applies to imported standard FMUs");
204  return (*this)->provides_directional_derivatives_;
205  } catch (std::exception& e) {
206  THROW_ERROR("provides_directional_derivatives", e.what());
207  return false;
208  }
209 }

References symbolic().

◆ prune()

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

Definition at line 238 of file dae_builder.cpp.

238  {
239  try {
240  (*this)->prune(prune_p, prune_u);
241  } catch (std::exception& e) {
242  THROW_ERROR("prune", e.what());
243  }
244 }

◆ q()

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

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

Definition at line 118 of file dae_builder.hpp.

118 {return all("q");}

References casadi::all().

◆ quad()

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

Definition at line 138 of file dae_builder.hpp.

138 {return outputs("quad");}

◆ reinit()

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

Definition at line 410 of file dae_builder.cpp.

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

References name().

◆ reorder()

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

Definition at line 333 of file dae_builder.cpp.

333  {
334  try {
335  (*this)->reorder(to_enum<Category>(cat), (*this)->find(v));
336  } catch (std::exception& e) {
337  THROW_ERROR("reorder", e.what());
338  }
339 }

Referenced by set_all().

◆ reset()

void casadi::DaeBuilder::reset ( )

Definition at line 1110 of file dae_builder.cpp.

1110  {
1111  try {
1112  (*this)->reset();
1113  } catch (std::exception& e) {
1114  THROW_ERROR("reset", e.what());
1115  }
1116 }

◆ sanity_check()

void casadi::DaeBuilder::sanity_check ( ) const

Definition at line 427 of file dae_builder.cpp.

427  {
428  try {
429  (*this)->sanity_check();
430  } catch (std::exception& e) {
431  THROW_ERROR("sanity_check", e.what());
432  }
433 }

◆ set() [1/4]

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

Definition at line 1126 of file dae_builder.cpp.

1126  {
1127  try {
1128  (*this)->set_string_attribute(Attribute::STRINGVALUE, name, val);
1129  } catch (std::exception& e) {
1130  THROW_ERROR("set", e.what());
1131  }
1132 }

References name(), and casadi::STRINGVALUE.

◆ set() [2/4]

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

Definition at line 1118 of file dae_builder.cpp.

1118  {
1119  try {
1120  (*this)->set_attribute(Attribute::VALUE, name, val);
1121  } catch (std::exception& e) {
1122  THROW_ERROR("set", e.what());
1123  }
1124 }

References 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 1134 of file dae_builder.cpp.

1134  {
1135  try {
1136  (*this)->set_attribute(Attribute::VALUE, name, val);
1137  } catch (std::exception& e) {
1138  THROW_ERROR("set", e.what());
1139  }
1140 }

References 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 1142 of file dae_builder.cpp.

1143  {
1144  try {
1145  (*this)->set_string_attribute(Attribute::STRINGVALUE, name, val);
1146  } catch (std::exception& e) {
1147  THROW_ERROR("set", e.what());
1148  }
1149 }

References name(), and casadi::STRINGVALUE.

◆ set_all()

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

Definition at line 281 of file dae_builder.cpp.

281  {
282  try {
283  // Get category enum
284  auto cat = to_enum<Category>(v);
285 
286  // Make sure no duplicate names
287  std::set<std::string> name_set(name.begin(), name.end());
288  casadi_assert(name_set.size() == name.size(), "Duplicate names");
289 
290  // For outputs, update causality
291  if (is_output_category(cat)) {
292  if (cat == Category::Y) {
293  for (auto&& n : name) set_causality(n, "output");
294  if (ny() != name.size()) {
295  for (auto&& n : y()) {
296  if (name_set.find(n) == name_set.end()) set_causality(n, "local");
297  }
298  }
299  } else {
300  casadi_error("Setting category '" + v + "' not supported");
301  }
302  } else if (is_input_category(cat)) {
303  // Update category
304  for (auto&& n : name) set_category(n, v);
305  // Remove any variables not in name from the category
306  auto all_in_cat = all(v);
307  if (all_in_cat.size() != name.size()) {
308  std::set<std::string> name_set(name.begin(), name.end());
309  for (auto&& n : all_in_cat) {
310  if (name_set.find(n) == name_set.end()) {
311  if (v == "x" || v == "q") {
312  // Move to unused derivatives
313  set_category(n, "");
314  } else if (v == "u" || v == "p") {
315  // Make constant
316  set_category(n, "c");
317  } else {
318  casadi_error("Cannot automatically remove '" + n + "' from category '" + v + "'");
319  }
320  }
321  }
322  }
323  } else {
324  casadi_error("Cannot set variables of category '" + v + "'");
325  }
326  // Make sure ordering is correct
327  reorder(v, name);
328  } catch (std::exception& e) {
329  THROW_ERROR("set_all", e.what());
330  }
331 }
void reorder(const std::string &cat, const std::vector< std::string > &v)
Reorder variables in a category.
void set_category(const std::string &name, const std::string &val)
Set the variable category, if permitted.
void set_causality(const std::string &name, const std::string &val)
Set the causality, if permitted.
casadi_int ny() const
Output variables.
bool is_input_category(Category cat)
bool is_output_category(Category cat)

References all(), casadi::is_input_category(), casadi::is_output_category(), name(), ny(), reorder(), set_category(), set_causality(), y(), and casadi::Y.

◆ set_attribute() [1/2]

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

Definition at line 949 of file dae_builder.cpp.

949  {
950  try {
951  (*this)->set_attribute(to_enum<Attribute>(a), name, val);
952  } catch (std::exception& e) {
953  THROW_ERROR("set_attribute", e.what());
954  }
955 }

References 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 957 of file dae_builder.cpp.

958  {
959  try {
960  (*this)->set_attribute(to_enum<Attribute>(a), name, val);
961  } catch (std::exception& e) {
962  THROW_ERROR("set_attribute", e.what());
963  }
964 }

References name().

◆ 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', quadrature states 'q' and no category '0'.

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

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

Definition at line 646 of file dae_builder.cpp.

646  {
647  try {
648  (*this)->set_category((*this)->find(name),
649  val.empty() ? Category::NUMEL : to_enum<Category>(val));
650  } catch (std::exception& e) {
651  THROW_ERROR("set_category", e.what());
652  }
653 }

References name(), and casadi::NUMEL.

Referenced by set_all().

◆ 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 612 of file dae_builder.cpp.

612  {
613  try {
614  (*this)->set_causality((*this)->find(name), to_enum<Causality>(val));
615  } catch (std::exception& e) {
616  THROW_ERROR("set_causality", e.what());
617  }
618 }

References name().

Referenced by set_all().

◆ set_description()

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

Get/set description

Definition at line 566 of file dae_builder.cpp.

566  {
567  (*this)->variable(name).description = val;
568 }

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 675 of file dae_builder.cpp.

675  {
676  (*this)->variable(name).display_unit = val;
677 }

References name().

◆ set_init()

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

Definition at line 419 of file dae_builder.cpp.

419  {
420  try {
421  (*this)->set_init(name, init_rhs);
422  } catch (std::exception& e) {
423  THROW_ERROR("set_init", e.what());
424  }
425 }
std::vector< MX > init_rhs() const
Initial conditions, right-hand-side.

References 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 659 of file dae_builder.cpp.

659  {
660  (*this)->variable(name).initial = to_enum<Initial>(val);
661 }

References name().

◆ set_max() [1/2]

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

Definition at line 1018 of file dae_builder.cpp.

1018  {
1019  try {
1020  (*this)->variable(name).max = val;
1021  } catch (std::exception& e) {
1022  THROW_ERROR("set_max", e.what());
1023  }
1024 }

References name().

◆ set_max() [2/2]

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

Definition at line 1026 of file dae_builder.cpp.

1026  {
1027  try {
1028  (*this)->set_attribute(Attribute::MAX, name, val);
1029  } catch (std::exception& e) {
1030  THROW_ERROR("set_max", e.what());
1031  }
1032 }

References casadi::MAX, and name().

◆ set_min() [1/2]

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

Definition at line 984 of file dae_builder.cpp.

984  {
985  try {
986  (*this)->variable(name).min = val;
987  } catch (std::exception& e) {
988  THROW_ERROR("set_min", e.what());
989  }
990 }

References name().

◆ set_min() [2/2]

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

Definition at line 992 of file dae_builder.cpp.

992  {
993  try {
994  (*this)->set_attribute(Attribute::MIN, name, val);
995  } catch (std::exception& e) {
996  THROW_ERROR("set_min", e.what());
997  }
998 }

References casadi::MIN, and name().

◆ set_nominal() [1/2]

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

Definition at line 1052 of file dae_builder.cpp.

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

References name().

◆ set_nominal() [2/2]

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

Definition at line 1060 of file dae_builder.cpp.

1060  {
1061  try {
1062  (*this)->set_attribute(Attribute::NOMINAL, name, val);
1063  } catch (std::exception& e) {
1064  THROW_ERROR("set_mininal", e.what());
1065  }
1066 }

References name(), and casadi::NOMINAL.

◆ set_start() [1/3]

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

Definition at line 1094 of file dae_builder.cpp.

1094  {
1095  try {
1096  (*this)->set_attribute(Attribute::START, std::vector<std::string>{name}, val);
1097  } catch (std::exception& e) {
1098  THROW_ERROR("set_start", e.what());
1099  }
1100 }

References name(), and casadi::START.

◆ set_start() [2/3]

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

Definition at line 1086 of file dae_builder.cpp.

1086  {
1087  try {
1088  (*this)->set_attribute(Attribute::START, name, val);
1089  } catch (std::exception& e) {
1090  THROW_ERROR("set_start", e.what());
1091  }
1092 }

References 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 1102 of file dae_builder.cpp.

1102  {
1103  try {
1104  (*this)->set_attribute(Attribute::START, name, val);
1105  } catch (std::exception& e) {
1106  THROW_ERROR("set_start", e.what());
1107  }
1108 }

References name(), and casadi::START.

◆ set_start_time()

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

Definition at line 696 of file dae_builder.cpp.

696  {
697  try {
698  (*this)->start_time_ = val;
699  } catch (std::exception& e) {
700  THROW_ERROR("set_start_time", e.what());
701  }
702 }

◆ set_step_size()

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

Definition at line 747 of file dae_builder.cpp.

747  {
748  try {
749  (*this)->step_size_ = val;
750  } catch (std::exception& e) {
751  THROW_ERROR("set_step_size", e.what());
752  }
753 }

◆ set_stop_time()

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

Definition at line 713 of file dae_builder.cpp.

713  {
714  try {
715  (*this)->stop_time_ = val;
716  } catch (std::exception& e) {
717  THROW_ERROR("set_stop_time", e.what());
718  }
719 }

◆ set_tolerance()

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

Definition at line 730 of file dae_builder.cpp.

730  {
731  try {
732  (*this)->tolerance_ = val;
733  } catch (std::exception& e) {
734  THROW_ERROR("set_tolerance", e.what());
735  }
736 }

◆ set_type()

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

Get/set the type

Definition at line 581 of file dae_builder.cpp.

581  {
582  // Fallback to FMI 2, if necessary
583  if (has_enum<TypeFmi2>(val) && !has_enum<Type>(val)) {
584  (*this)->variable(name).type = from_fmi2(to_enum<TypeFmi2>(val));
585  }
586  // Assume FMI 3
587  (*this)->variable(name).type = to_enum<Type>(val);
588 }
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 667 of file dae_builder.cpp.

667  {
668  (*this)->variable(name).unit = val;
669 }

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 558 of file dae_builder.cpp.

558  {
559  (*this)->variable(name).value_reference = val;
560 }

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 629 of file dae_builder.cpp.

629  {
630  try {
631  (*this)->set_variability((*this)->find(name), to_enum<Variability>(val));
632  } catch (std::exception& e) {
633  THROW_ERROR("set_variability", e.what());
634  }
635 }

References name().

◆ set_y()

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

Definition at line 147 of file dae_builder.hpp.

147 {set_all("y", name);}
void set_all(const std::string &v, const std::vector< std::string > &name)
Set all variables within a a category.

◆ sort()

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

Definition at line 538 of file dae_builder.cpp.

538  {
539  try {
540  (*this)->sort(to_enum<Category>(cat));
541  } catch (std::exception& e) {
542  THROW_ERROR("sort", e.what());
543  }
544 }

◆ start() [1/2]

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

Definition at line 1068 of file dae_builder.cpp.

1068  {
1069  try {
1070  return (*this)->attribute(Attribute::START, std::vector<std::string>{name});
1071  } catch (std::exception& e) {
1072  THROW_ERROR("start", e.what());
1073  return {}; // never reached
1074  }
1075 }

References casadi::START.

◆ start() [2/2]

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

Definition at line 1077 of file dae_builder.cpp.

1077  {
1078  try {
1079  return (*this)->attribute(Attribute::START, name);
1080  } catch (std::exception& e) {
1081  THROW_ERROR("start", e.what());
1082  return {}; // never reached
1083  }
1084 }

References name(), and casadi::START.

◆ start_time()

double casadi::DaeBuilder::start_time ( ) const

Definition at line 687 of file dae_builder.cpp.

687  {
688  try {
689  return (*this)->start_time_;
690  } catch (std::exception& e) {
691  THROW_ERROR("start_time", e.what());
692  return nan;
693  }
694 }
const double nan
Not a number.
Definition: calculus.hpp:53

References casadi::nan.

◆ step_size()

double casadi::DaeBuilder::step_size ( ) const

Definition at line 738 of file dae_builder.cpp.

738  {
739  try {
740  return (*this)->step_size_;
741  } catch (std::exception& e) {
742  THROW_ERROR("step_size", e.what());
743  return nan;
744  }
745 }

References casadi::nan.

◆ stop_time()

double casadi::DaeBuilder::stop_time ( ) const

Definition at line 704 of file dae_builder.cpp.

704  {
705  try {
706  return (*this)->stop_time_;
707  } catch (std::exception& e) {
708  THROW_ERROR("stop_time", e.what());
709  return nan;
710  }
711 }

References casadi::nan.

◆ swap()

Definition at line 105 of file generic_shared_impl.hpp.

131  {
132  GenericShared<Shared, Internal> temp = *this;
133  *this = other;
134  other = temp;
135  }

◆ symbolic()

bool casadi::DaeBuilder::symbolic ( ) const

Definition at line 1198 of file dae_builder.cpp.

1198  {
1199  try {
1200  return (*this)->symbolic_;
1201  } catch (std::exception& e) {
1202  THROW_ERROR("symbolic", e.what());
1203  return false; // never reached
1204  }
1205 }

Referenced by get(), and provides_directional_derivatives().

◆ 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 246 of file dae_builder.cpp.

246  {
247  try {
248  (*this)->tear();
249  } catch (std::exception& e) {
250  THROW_ERROR("tear", e.what());
251  }
252 }

◆ test_cast()

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

Definition at line 900 of file dae_builder.cpp.

900  {
901  return dynamic_cast<const DaeBuilderInternal*>(ptr) != nullptr;
902 }

◆ 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 }

◆ tolerance()

double casadi::DaeBuilder::tolerance ( ) const

Definition at line 721 of file dae_builder.cpp.

721  {
722  try {
723  return (*this)->tolerance_;
724  } catch (std::exception& e) {
725  THROW_ERROR("tolerance", e.what());
726  return nan;
727  }
728 }

References casadi::nan.

◆ transition() [1/3]

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

Definition at line 462 of file dae_builder.hpp.

462 {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 891 of file dae_builder.cpp.

891  {
892  try {
893  return (*this)->transition(fname);
894  } catch (std::exception& e) {
895  THROW_ERROR("transition", e.what());
896  return Function(); // never reached
897  }
898 }

◆ transition() [3/3]

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

Definition at line 882 of file dae_builder.cpp.

882  {
883  try {
884  return (*this)->transition(fname, index);
885  } catch (std::exception& e) {
886  THROW_ERROR("transition", e.what());
887  return Function(); // never reached
888  }
889 }

◆ type()

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

Get/set the type

Definition at line 570 of file dae_builder.cpp.

570  {
571  // Check version
572  casadi_assert(fmi_version == 2 || fmi_version == 3, "Only FMI version 2 or 3 supported");
573  // Handle FMI 2
574  if (fmi_version == 2) {
575  return to_string(to_fmi2((*this)->variable(name).type));
576  }
577  // Assume FMI 3
578  return to_string((*this)->variable(name).type);
579 }
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 153 of file dae_builder.hpp.

153 {return all("u");}

References casadi::all().

◆ unit()

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

Get/set the unit

Definition at line 663 of file dae_builder.cpp.

663  {
664  return (*this)->variable(name).unit;
665 }

References name().

◆ value_reference()

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

Get/set value reference

Definition at line 554 of file dae_builder.cpp.

554  {
555  return (*this)->variable(name).value_reference;
556 }

References name().

◆ var()

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

Get variable expression by name

Definition at line 435 of file dae_builder.cpp.

435  {
436  try {
437  return (*this)->variable(name).v;
438  } catch (std::exception& e) {
439  THROW_ERROR("var", e.what());
440  return MX(); // never reached
441  }
442 }

References name().

◆ variability()

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

Definition at line 620 of file dae_builder.cpp.

620  {
621  try {
622  return to_string((*this)->variability((*this)->find(name)));
623  } catch (std::exception& e) {
624  THROW_ERROR("variability", e.what());
625  return std::string(); // never reached
626  }
627 }

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

Referenced by add().

◆ w()

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

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

Definition at line 185 of file dae_builder.hpp.

185 {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 109 of file dae_builder.cpp.

109  {
110  try {
111  return (*this)->outputs(Category::WDEF);
112  } catch (std::exception& e) {
113  THROW_ERROR("wdef", e.what());
114  return {}; // never reached
115  }
116 }

References casadi::WDEF.

◆ weak()

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

Definition at line 130 of file generic_shared_impl.hpp.

143  {
144  return (*this)->weak();
145  }

◆ when()

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

Definition at line 393 of file dae_builder.cpp.

393  {
394  try {
395  (*this)->when(cond, eqs, opts);
396  } catch (std::exception& e) {
397  THROW_ERROR("when", e.what());
398  }
399 }

◆ 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
inline

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

Definition at line 108 of file dae_builder.hpp.

108 {return all("y");}

References casadi::all().

Referenced by set_all().

◆ ydef()

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

Definition at line 144 of file dae_builder.hpp.

144 {return outputs("y");}

◆ z()

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

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

Definition at line 113 of file dae_builder.hpp.

113 {return all("z");}

References casadi::all().

◆ zero()

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

Definition at line 141 of file dae_builder.hpp.

141 {return outputs("zero");}

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