List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends
casadi::FmuInternal Class Referenceabstract

Interface to binary FMU. More...

#include <fmu_impl.hpp>

Detailed Description

Internal API.

Author
Joel Andersson
Date
2023

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

Definition at line 61 of file fmu_impl.hpp.

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

Public Types

using weak_ref_type = WeakRefInternal
 

Public Member Functions

 FmuInternal (const std::string &name, const std::vector< std::string > &scheme_in, const std::vector< std::string > &scheme_out, const std::map< std::string, std::vector< size_t >> &scheme, const std::vector< std::string > &aux)
 
 ~FmuInternal () override
 Destructor. More...
 
virtual void init (const DaeBuilderInternal *dae)
 
virtual void load_functions ()=0
 
virtual int enter_initialization_mode (void *instance) const =0
 
virtual int exit_initialization_mode (void *instance) const =0
 
virtual int enter_continuous_time_mode (void *instance) const =0
 
virtual int update_discrete_states (void *instance, EventMemory *eventmem) const =0
 
virtual int get_derivatives (void *instance, double *derivatives, size_t nx) const =0
 
virtual int set_time (void *instance, double t) const =0
 
virtual int set_real (void *instance, const unsigned int *vr, size_t n_vr, const double *values, size_t n_values) const =0
 
virtual int get_real (void *instance, const unsigned int *vr, size_t n_vr, double *values, size_t n_values, FmuMemory *m=nullptr) const =0
 
virtual int get_directional_derivative (void *instance, const unsigned int *vr_out, size_t n_out, const unsigned int *vr_in, size_t n_in, const double *seed, size_t n_seed, double *sensitivity, size_t n_sensitivity) const =0
 
virtual int get_adjoint_derivative (void *instance, const unsigned int *vr_out, size_t n_out, const unsigned int *vr_in, size_t n_in, const double *seed, size_t n_seed, double *sensitivity, size_t n_sensitivity) const
 
virtual int set_values (void *instance) const =0
 
virtual int get_aux (void *instance)=0
 
virtual void finalize ()
 
void disp (std::ostream &stream, bool more) const override
 Print. More...
 
size_t n_in () const
 Get the number of scheme inputs. More...
 
size_t n_out () const
 Get the number of scheme outputs. More...
 
size_t index_in (const std::string &n) const
 
size_t index_out (const std::string &n) const
 
Sparsity jac_sparsity (const std::vector< size_t > &osub, const std::vector< size_t > &isub) const
 
Sparsity hess_sparsity (const std::vector< size_t > &r, const std::vector< size_t > &c) const
 
std::string desc_in (FmuMemory *m, size_t id, bool more=true) const
 
virtual std::string system_infix () const =0
 
template<typename T >
T * load_function (const std::string &symname)
 
int discrete_states_iter (void *instance) const
 
virtual int init_mem (FmuMemory *m) const
 Initalize memory block. More...
 
virtual FmuMemoryalloc_mem (const FmuFunction &f) const =0
 Create memory block. More...
 
virtual void free_mem (void *mem) const =0
 Free memory block. More...
 
virtual void * instantiate () const =0
 
virtual void free_instance (void *c) const =0
 
void set (FmuMemory *m, size_t ind, const double *value) const
 
void request (FmuMemory *m, size_t ind) const
 
int set_all (FmuMemory *m, const double *values, size_t n_values) const
 
int get_all (FmuMemory *m, double *values, size_t n_values) const
 
int eval (FmuMemory *m) const
 
void get (FmuMemory *m, size_t id, double *value) const
 
void set_fwd (FmuMemory *m, casadi_int nseed, const casadi_int *id, const double *v) const
 
void set_fwd (FmuMemory *m, size_t ind, const double *v) const
 
void request_fwd (FmuMemory *m, casadi_int nsens, const casadi_int *id, const casadi_int *wrt_id) const
 
void request_fwd (FmuMemory *m, casadi_int ind) const
 
int eval_fwd (FmuMemory *m, bool independent_seeds) const
 
int eval_ad (FmuMemory *m) const
 
int eval_fd (FmuMemory *m, bool independent_seeds) const
 
void get_fwd (FmuMemory *m, casadi_int nsens, const casadi_int *id, double *v) const
 
void get_fwd (FmuMemory *m, size_t ind, double *v) const
 
void set_adj (FmuMemory *m, casadi_int nseed, const casadi_int *id, const double *v) const
 
void set_adj (FmuMemory *m, size_t ind, const double *v) const
 
void request_adj (FmuMemory *m, casadi_int nsens, const casadi_int *id, const casadi_int *wrt_id) const
 
void request_adj (FmuMemory *m, casadi_int ind) const
 
int eval_adj (FmuMemory *m) const
 
void get_adj (FmuMemory *m, casadi_int nsens, const casadi_int *id, double *v) const
 
void get_adj (FmuMemory *m, size_t ind, double *v) const
 
void gather_fwd (FmuMemory *m) const
 
void gather_adj (FmuMemory *m) const
 
void gather_io (FmuMemory *m) const
 
virtual void get_stats (FmuMemory *m, Dict *stats, const std::vector< std::string > &name_in, const InputStruct *in) const =0
 Get stats. More...
 
void serialize (SerializingStream &s) const
 
virtual void serialize_type (SerializingStream &s) const
 
virtual void serialize_body (SerializingStream &s) const
 
virtual std::string class_name () const =0
 Readable name of the internal class. More...
 
casadi_int getCount () const
 Get the reference count. More...
 
std::string debug_repr (const SharedObjectInternal *) const
 
GenericWeakRef< SharedObject, SharedObjectInternal > * weak ()
 Get a weak reference to the object. More...
 
std::vector< double > all_nominal_in (size_t i) const
 Retreive nominal values. More...
 
std::vector< double > all_nominal_out (size_t i) const
 Retreive nominal values. More...
 

Static Public Member Functions

static std::string dll_suffix ()
 
static Dict compile_fmu (const std::string &name, const Dict &files, const Dict &opts)
 
static std::string pack_fmu (const Dict &files, const std::string &path)
 
static FmuInternaldeserialize (DeserializingStream &s)
 

Protected Member Functions

 FmuInternal (DeserializingStream &s)
 
void initSingleton ()
 
void destroySingleton ()
 
shared_from_this ()
 Get a shared object from the current internal object. More...
 
const B shared_from_this () const
 Get a shared object from the current internal object. More...
 

Protected Attributes

Resource resource_
 
std::string name_
 Instance name. More...
 
std::vector< std::string > scheme_in_
 
std::vector< std::string > scheme_out_
 
std::map< std::string, std::vector< size_t > > scheme_
 
std::vector< std::string > aux_
 
std::string resource_loc_
 
double fmutol_
 
std::string instance_name_
 
std::string instantiation_token_
 
bool logging_on_
 
casadi_int number_of_event_indicators_
 
bool provides_directional_derivatives_
 
bool provides_adjoint_derivatives_
 
bool can_be_instantiated_only_once_per_process_
 
double start_time_
 
Importer li_
 DLL. More...
 
std::vector< size_t > iind_
 
std::vector< size_t > iind_map_
 
std::vector< size_t > oind_
 
std::vector< size_t > oind_map_
 
bool has_independent_
 
unsigned int independent_vr_
 
std::vector< double > nominal_in_
 
std::vector< double > nominal_out_
 
std::vector< double > min_in_
 
std::vector< double > min_out_
 
std::vector< double > max_in_
 
std::vector< double > max_out_
 
std::vector< std::string > vn_in_
 
std::vector< std::string > vn_out_
 
std::vector< unsigned int > vr_in_
 
std::vector< unsigned int > vr_out_
 
std::vector< double > value_in_
 
std::vector< std::vector< size_t > > ired_
 
std::vector< std::vector< size_t > > ored_
 
Sparsity jac_sp_
 
Sparsity hess_sp_
 
bool warning_fired_discrete_states_need_update_
 
bool warning_fired_terminate_simulation_
 
bool warning_fired_nominals_of_continuous_states_changed_
 
bool warning_fired_values_of_continuous_states_changed_
 
bool warning_fired_next_event_time_defined_
 
size_t nx_
 
bool do_evaluation_dance_
 

Friends

class Fmu
 

Member Typedef Documentation

◆ weak_ref_type

Definition at line 152 of file shared_object.hpp.

Constructor & Destructor Documentation

◆ FmuInternal() [1/2]

casadi::FmuInternal::FmuInternal ( const std::string &  name,
const std::vector< std::string > &  scheme_in,
const std::vector< std::string > &  scheme_out,
const std::map< std::string, std::vector< size_t >> &  scheme,
const std::vector< std::string > &  aux 
)

Definition at line 442 of file fmu.cpp.

447  : name_(name), scheme_in_(scheme_in), scheme_out_(scheme_out), scheme_(scheme), aux_(aux) {
448 }
std::vector< std::string > scheme_out_
Definition: fmu_impl.hpp:308
std::string name_
Instance name.
Definition: fmu_impl.hpp:305
std::vector< std::string > aux_
Definition: fmu_impl.hpp:312
std::map< std::string, std::vector< size_t > > scheme_
Definition: fmu_impl.hpp:309
std::vector< std::string > scheme_in_
Definition: fmu_impl.hpp:308

◆ ~FmuInternal()

casadi::FmuInternal::~FmuInternal ( )
override

Definition at line 450 of file fmu.cpp.

450  {
451 }

◆ FmuInternal() [2/2]

casadi::FmuInternal::FmuInternal ( DeserializingStream s)
explicitprotected

Definition at line 1550 of file fmu.cpp.

1550  {
1551  s.version("FmuInternal", 4);
1552  s.unpack("FmuInternal::name", name_);
1553  s.unpack("FmuInternal::scheme_in", scheme_in_);
1554  s.unpack("FmuInternal::scheme_out", scheme_out_);
1555  s.unpack("FmuInternal::scheme", scheme_);
1556  s.unpack("FmuInternal::aux", aux_);
1557  s.unpack("FmuInternal::iind", iind_);
1558  s.unpack("FmuInternal::iind_map", iind_map_);
1559  s.unpack("FmuInternal::oind", oind_);
1560  s.unpack("FmuInternal::oind_map", oind_map_);
1561  s.unpack("FmuInternal::has_independent", has_independent_);
1562  s.unpack("FmuInternal::nominal_in", nominal_in_);
1563  s.unpack("FmuInternal::nominal_out", nominal_out_);
1564  s.unpack("FmuInternal::min_in", min_in_);
1565  s.unpack("FmuInternal::min_out", min_out_);
1566  s.unpack("FmuInternal::max_in", max_in_);
1567  s.unpack("FmuInternal::max_out", max_out_);
1568  s.unpack("FmuInternal::vn_in", vn_in_);
1569  s.unpack("FmuInternal::vn_out", vn_out_);
1570  s.unpack("FmuInternal::vr_in", vr_in_);
1571  s.unpack("FmuInternal::vr_out", vr_out_);
1572 
1573  s.unpack("FmuInternal::value_in", value_in_);
1574  s.unpack("FmuInternal::ired", ired_);
1575  s.unpack("FmuInternal::ored", ored_);
1576  s.unpack("FmuInternal::jac_sp", jac_sp_);
1577  s.unpack("FmuInternal::hess_sp", hess_sp_);
1578 
1579  s.unpack("FmuInternal::resource", resource_);
1580  s.unpack("FmuInternal::fmutol", fmutol_);
1581  s.unpack("FmuInternal::instance_name", instance_name_);
1582  s.unpack("FmuInternal::instantiation_token", instantiation_token_);
1583  s.unpack("FmuInternal::logging_on", logging_on_);
1584  s.unpack("FmuInternal::number_of_event_indicators", number_of_event_indicators_);
1585  s.unpack("FmuInternal::provides_directional_derivatives", provides_directional_derivatives_);
1586  s.unpack("FmuInternal::provides_adjoint_derivatives", provides_adjoint_derivatives_);
1587  s.unpack("FmuInternal::can_be_instantiated_only_once_per_process",
1589  s.unpack("FmuInternal::start_time", start_time_);
1590  s.unpack("FmuInternal::nx", nx_);
1591  s.unpack("FmuInternal::do_evaluation_dance", do_evaluation_dance_);
1592 }
std::string instantiation_token_
Definition: fmu_impl.hpp:324
std::vector< double > max_in_
Definition: fmu_impl.hpp:356
bool provides_adjoint_derivatives_
Definition: fmu_impl.hpp:333
std::vector< unsigned int > vr_out_
Definition: fmu_impl.hpp:358
std::vector< std::string > vn_out_
Definition: fmu_impl.hpp:357
std::vector< size_t > iind_
Definition: fmu_impl.hpp:345
std::vector< std::vector< size_t > > ired_
Definition: fmu_impl.hpp:364
std::vector< std::vector< size_t > > ored_
Definition: fmu_impl.hpp:364
std::vector< double > nominal_out_
Definition: fmu_impl.hpp:354
std::vector< std::string > vn_in_
Definition: fmu_impl.hpp:357
std::vector< size_t > oind_
Definition: fmu_impl.hpp:345
std::vector< unsigned int > vr_in_
Definition: fmu_impl.hpp:358
std::vector< double > min_out_
Definition: fmu_impl.hpp:355
bool can_be_instantiated_only_once_per_process_
Definition: fmu_impl.hpp:336
std::vector< double > nominal_in_
Definition: fmu_impl.hpp:354
std::vector< double > max_out_
Definition: fmu_impl.hpp:356
std::vector< double > min_in_
Definition: fmu_impl.hpp:355
std::vector< double > value_in_
Definition: fmu_impl.hpp:361
casadi_int number_of_event_indicators_
Definition: fmu_impl.hpp:330
std::vector< size_t > oind_map_
Definition: fmu_impl.hpp:345
std::string instance_name_
Definition: fmu_impl.hpp:321
bool provides_directional_derivatives_
Definition: fmu_impl.hpp:333
std::vector< size_t > iind_map_
Definition: fmu_impl.hpp:345

References aux_, can_be_instantiated_only_once_per_process_, do_evaluation_dance_, fmutol_, has_independent_, hess_sp_, iind_, iind_map_, instance_name_, instantiation_token_, ired_, jac_sp_, logging_on_, max_in_, max_out_, min_in_, min_out_, name_, nominal_in_, nominal_out_, number_of_event_indicators_, nx_, oind_, oind_map_, ored_, provides_adjoint_derivatives_, provides_directional_derivatives_, resource_, scheme_, scheme_in_, scheme_out_, start_time_, casadi::DeserializingStream::unpack(), value_in_, casadi::DeserializingStream::version(), vn_in_, vn_out_, vr_in_, and vr_out_.

Member Function Documentation

◆ all_nominal_in()

std::vector< double > casadi::FmuInternal::all_nominal_in ( size_t  i) const

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

Definition at line 707 of file fmu.cpp.

707  {
708  auto&& ind = ired_.at(i);
709  std::vector<double> n;
710  n.reserve(ind.size());
711  for (size_t k : ind) n.push_back(nominal_in_.at(k));
712  return n;
713 }

References ired_, and nominal_in_.

◆ all_nominal_out()

std::vector< double > casadi::FmuInternal::all_nominal_out ( size_t  i) const

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

Definition at line 715 of file fmu.cpp.

715  {
716  auto&& ind = ored_.at(i);
717  std::vector<double> n;
718  n.reserve(ind.size());
719  for (size_t k : ind) n.push_back(nominal_out_.at(k));
720  return n;
721 }

References nominal_out_, and ored_.

◆ alloc_mem()

virtual FmuMemory* casadi::FmuInternal::alloc_mem ( const FmuFunction f) const
pure virtual

◆ class_name()

virtual std::string casadi::SharedObjectInternal::class_name ( ) const
pure virtualinherited

Implemented in casadi::SymbolicQr, casadi::Sqpmethod, casadi::ShellCompiler, casadi::Scpgen, casadi::RungeKutta, casadi::Qrsqp, casadi::Qrqp, casadi::QpToNlp, casadi::Newton, casadi::Lsqr, casadi::LinsolTridiag, casadi::LinsolQr, casadi::LinsolLdl, casadi::LinearInterpolantJac, casadi::LinearInterpolant, casadi::Ipqp, casadi::ImplicitToNlp, casadi::Feasiblesqpmethod, casadi::FastNewton, casadi::Collocation, casadi::BSplineInterpolant, casadi::XpressInterface, casadi::WorhpInterface, casadi::UnoInterface, casadi::TinyXmlInterface, casadi::SuperscsInterface, casadi::KinsolInterface, casadi::IdasInterface, casadi::CvodesInterface, casadi::SqicInterface, casadi::SnoptInterface, casadi::SlicotExpm, casadi::SlicotDple, casadi::SLEQPInterface, casadi::QpoasesInterface, casadi::ProxqpInterface, casadi::PiqpInterface, casadi::OsqpInterface, casadi::OnnxRuntimeInterface, casadi::OoqpInterface, casadi::Onnx, casadi::MumpsInterface, casadi::MosekInterface, casadi::MadnlpInterface, casadi::LapackQr, casadi::LapackLu, casadi::LaceModelica, casadi::KnitroInterface, casadi::IpoptInterface, casadi::Ma27Interface, casadi::HpmpcInterface, casadi::HpipmInterface, casadi::HighsInterface, casadi::GurobiInterface, casadi::FatropInterface, casadi::FatropConicInterface, casadi::DaqpInterface, casadi::CsparseInterface, casadi::CSparseCholeskyInterface, casadi::CplexInterface, casadi::ClpInterface, casadi::ClarabelInterface, casadi::ClangCompiler, casadi::MadmpecInterface, casadi::CbcInterface, casadi::BonminInterface, casadi::Blocksqp, casadi::AmplInterface, casadi::AlpaqaInterface, casadi::SXFunction, casadi::Switch, casadi::SparsityInternal, casadi::WeakRefInternal, casadi::ZipMemResource, casadi::ZipResource, casadi::TemporaryDirResource, casadi::DirResource, casadi::OptiNode, casadi::Nlpsol, casadi::MXNode, casadi::MXFunction, casadi::MapSum, casadi::ThreadMap, casadi::OmpMap, casadi::Map, casadi::JitFunction, casadi::Interpolant, casadi::DllLibrary, casadi::ImporterInternal, casadi::GraphModelInternal, casadi::GraphBuilderInternal, casadi::GenericTypeInternal< ID, T >, casadi::FmuFunction, casadi::Fmu3, casadi::Fmu2, casadi::Smoothing, casadi::CentralDiff, casadi::BackwardDiff, casadi::ForwardDiff, casadi::External, casadi::DaeBuilderInternal, casadi::CallbackInternal, and casadi::BlazingSplineFunction.

Referenced by casadi::FunctionInternal::call_forward(), casadi::FunctionInternal::call_reverse(), casadi::FunctionInternal::codegen_body(), casadi::ProtoFunction::construct(), deserialize(), casadi::ResourceInternal::deserialize(), casadi::LinsolInternal::det(), disp(), casadi::FunctionInternal::disp(), casadi::LinsolInternal::disp(), casadi::XmlFileInternal::dump(), casadi::FunctionInternal::eval(), casadi::FunctionInternal::eval_dm(), casadi::FunctionInternal::eval_sx(), casadi::FunctionInternal::export_code(), casadi::LinsolInternal::generate(), casadi::FunctionInternal::generate_dependencies(), casadi::LinsolInternal::generate_det(), casadi::Conic::generateNativeCode(), get_adjoint_derivative(), casadi::FunctionInternal::get_forward(), casadi::FunctionInternal::get_function(), casadi::FunctionInternal::get_jacobian(), casadi::FunctionInternal::get_reverse(), casadi::FiniteDiff::init(), casadi::FunctionInternal::instruction_constant(), casadi::FunctionInternal::instruction_id(), casadi::FunctionInternal::instruction_input(), casadi::FunctionInternal::instruction_MX(), casadi::FunctionInternal::instruction_output(), casadi::FunctionInternal::instructions_sx(), casadi::LinsolInternal::linsol_eval_sx(), casadi::FunctionInternal::n_instructions(), casadi::FunctionInternal::n_nodes(), casadi::LinsolInternal::neig(), casadi::LinsolInternal::nfact(), casadi::FunctionInternal::oracle(), casadi::XmlFileInternal::parse(), casadi::ModelicaParserInternal::parse(), serialize_type(), casadi::ResourceInternal::serialize_type(), casadi::FunctionInternal::simplify_passes(), and casadi::LinsolInternal::solve().

◆ compile_fmu()

Dict casadi::FmuInternal::compile_fmu ( const std::string &  name,
const Dict files,
const Dict opts 
)
static

Definition at line 736 of file fmu.cpp.

736  {
737  // Options
738  Dict compiler_opts;
739  std::string compiler_plugin = "shell";
740  std::vector<std::string> include_dirs;
741  for (auto&& op : opts) {
742  if (op.first == "compiler") {
743  compiler_plugin = op.second.to_string();
744  } else if (op.first == "compiler_options") {
745  compiler_opts = op.second;
746  } else if (op.first == "include_dirs") {
747  include_dirs = op.second.to_string_vector();
748  } else {
749  casadi_error("No such option: " + op.first);
750  }
751  }
752  // The C sources to compile are the .c entries of the export_fmu map (flat in CWD)
753  std::vector<std::string> csources;
754  for (auto&& kv : files) {
755  const std::string& local = kv.first;
756  if (local.size() > 2 && local.substr(local.size() - 2) == ".c") csources.push_back(local);
757  }
758  // Amalgamation translation unit: a single .c that #includes every generated source,
759  // because the shell Importer compiles exactly one source file. The compile runs in
760  // the working directory, so quoted includes resolve against the loose files there.
761  // This is a build scratch file, NOT FMU content, so it is removed below.
762  std::string amalg = name + "_all.c";
763  {
764  auto f = Filesystem::ofstream_ptr(amalg);
765  for (const std::string& c : csources) *f << "#include \"" << c << "\"\n";
766  }
767  // Compile the amalgamation into a shared library via the Importer plugin.
768  // Pass include dirs through the OS-agnostic 'include_dirs' option (the plugin
769  // prefixes each with the compiler's own include flag: -I on gcc/clang, /I on MSVC).
770  Dict cop = compiler_opts;
771  if (!include_dirs.empty()) cop["include_dirs"] = include_dirs;
772  Importer compiler(amalg, compiler_plugin, cop);
773  // Lift the binary to a stable path before the Importer destructor removes it, then
774  // discard the amalgamation scratch file (compilation is done once the Importer exists)
775  std::string dll = name + dll_suffix();
776  Filesystem::copy_file(compiler.library(), dll);
777  Filesystem::remove(amalg);
778  // Augment the file map with the compiled binary
779  // (FMI-3 layout: binaries/<dll_infix>/<modelIdentifier><suffix>)
780  Dict ret = files;
781  ret[dll] = "binaries/" + Fmu3::dll_infix() + "/" + name + dll_suffix();
782  return ret;
783 }
static void copy_file(const std::string &src, const std::string &dest)
Definition: filesystem.cpp:144
static std::unique_ptr< std::ostream > ofstream_ptr(const std::string &path, std::ios_base::openmode mode=std::ios_base::out)
Definition: filesystem.cpp:115
static bool remove(const std::string &path)
Definition: filesystem.cpp:43
static std::string dll_infix()
Definition: fmu3.cpp:61
static std::string dll_suffix()
Definition: fmu.cpp:723
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.

References casadi::Filesystem::copy_file(), casadi::Fmu3::dll_infix(), dll_suffix(), casadi::Importer::library(), casadi::Filesystem::ofstream_ptr(), and casadi::Filesystem::remove().

Referenced by casadi::DaeBuilderInternal::compile_fmu().

◆ debug_repr()

std::string casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::debug_repr ( const Internal *  i) const
inherited

Definition at line 62 of file generic_shared_internal.hpp.

175  {
176  // Note: i != this because of something something multiple inheritance
177  return str( (casadi_int)(i)) + "/" + static_cast<const Internal*>(this)->class_name();
178  }
std::string str(const T &v)
String representation, any type.

◆ desc_in()

std::string casadi::FmuInternal::desc_in ( FmuMemory m,
size_t  id,
bool  more = true 
) const

Definition at line 805 of file fmu.cpp.

805  {
806  // Create description
807  if (more) {
808  // Detailed description
809  std::stringstream ss;
810  ss << vn_in_[id] << " = " << m->ibuf_[id] << " (nominal " << nominal_in_[id]
811  << ", min " << min_in_[id] << ", max " << max_in_[id] << ")";
812  return ss.str();
813  } else {
814  return vn_in_[id];
815  }
816 }

References casadi::FmuMemory::ibuf_, max_in_, min_in_, nominal_in_, and vn_in_.

Referenced by eval_fd().

◆ deserialize()

FmuInternal * casadi::FmuInternal::deserialize ( DeserializingStream s)
static

Definition at line 1594 of file fmu.cpp.

1594  {
1595  std::string class_name;
1596  s.unpack("FmuInternal::type", class_name);
1597  if (class_name=="Fmu2") {
1598 #ifdef WITH_FMI2
1599  return Fmu2::deserialize(s);
1600 #else
1601  casadi_error("CasADi was not compiled with WITH_FMI2=ON.");
1602 #endif // WITH_FMI2
1603  } else if (class_name=="Fmu3") {
1604 #ifdef WITH_FMI3
1605 return Fmu3::deserialize(s);
1606 #else
1607  casadi_error("CasADi was not compiled with WITH_FMI2=ON.");
1608 #endif // WITH_FMI3
1609  } else {
1610  casadi_error("Cannot deserialize type '" + class_name + "'");
1611  }
1612 }
static Fmu2 * deserialize(DeserializingStream &s)
Definition: fmu2.cpp:553
static Fmu3 * deserialize(DeserializingStream &s)
Definition: fmu3.cpp:533
virtual std::string class_name() const =0
Readable name of the internal class.

References casadi::SharedObjectInternal::class_name(), casadi::Fmu2::deserialize(), casadi::Fmu3::deserialize(), and casadi::DeserializingStream::unpack().

Referenced by casadi::Fmu::deserialize().

◆ destroySingleton()

void casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::destroySingleton ( )
inlineprotectedinherited

Called in the destructor of singletons

Definition at line 77 of file generic_shared_internal.hpp.

77  {
78  static_cast<Internal*>(this)->count--;
79  }

◆ discrete_states_iter()

int casadi::FmuInternal::discrete_states_iter ( void *  instance) const

Definition at line 1197 of file fmu.cpp.

1197  {
1198  // Helper function: update_discrete_states
1199  EventMemory eventmem;
1200  const size_t max_update_iter = 10;
1201  for (size_t update_iter = 0; update_iter < max_update_iter; ++update_iter) {
1202  if (update_discrete_states(instance, &eventmem)) {
1203  casadi_warning("update_discrete_states");
1204  return 1;
1205  }
1206  // Not implemented
1207  if (eventmem.discrete_states_need_update) {
1210  casadi_warning("Discrete state update not implemented");
1211  }
1212  }
1213  if (eventmem.terminate_simulation) {
1216  casadi_warning("Terminate simulation not implemented");
1217  }
1218  }
1219  if (eventmem.nominals_of_continuous_states_changed) {
1222  casadi_warning("Nominals of continuous states not implemented");
1223  }
1224  }
1225  if (eventmem.values_of_continuous_states_changed) {
1228  casadi_warning("Values of continuous states not implemented");
1229  }
1230  }
1231  if (eventmem.next_event_time_defined) {
1234  casadi_warning("Next event time not implemented");
1235  }
1236  }
1237  // Successful return
1238  if (!eventmem.discrete_states_need_update) {
1239  return 0;
1240  }
1241  }
1242  // Too many iterations
1243  casadi_warning("Discrete state update failed");
1244  return 1;
1245 }
bool warning_fired_values_of_continuous_states_changed_
Definition: fmu_impl.hpp:372
bool warning_fired_next_event_time_defined_
Definition: fmu_impl.hpp:373
bool warning_fired_nominals_of_continuous_states_changed_
Definition: fmu_impl.hpp:371
bool warning_fired_terminate_simulation_
Definition: fmu_impl.hpp:370
bool warning_fired_discrete_states_need_update_
Definition: fmu_impl.hpp:369
virtual int update_discrete_states(void *instance, EventMemory *eventmem) const =0

References casadi::EventMemory::discrete_states_need_update, casadi::EventMemory::next_event_time_defined, casadi::EventMemory::nominals_of_continuous_states_changed, casadi::EventMemory::terminate_simulation, update_discrete_states(), casadi::EventMemory::values_of_continuous_states_changed, warning_fired_discrete_states_need_update_, warning_fired_next_event_time_defined_, warning_fired_nominals_of_continuous_states_changed_, warning_fired_terminate_simulation_, and warning_fired_values_of_continuous_states_changed_.

Referenced by init_mem().

◆ disp()

void casadi::FmuInternal::disp ( std::ostream &  stream,
bool  more 
) const
overridevirtual

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

Implements casadi::SharedObjectInternal.

Definition at line 651 of file fmu.cpp.

651  {
652  (void)more; // unused
653  stream << name_ << " " << class_name();
654 }

References casadi::SharedObjectInternal::class_name(), and name_.

◆ dll_suffix()

std::string casadi::FmuInternal::dll_suffix ( )
static

Definition at line 723 of file fmu.cpp.

723  {
724 #if defined(_WIN32)
725  // Windows system
726  return ".dll";
727 #elif defined(__APPLE__)
728  // OSX
729  return ".dylib";
730 #else
731  // Linux
732  return ".so";
733 #endif
734 }

Referenced by compile_fmu(), and finalize().

◆ enter_continuous_time_mode()

virtual int casadi::FmuInternal::enter_continuous_time_mode ( void *  instance) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by init_mem().

◆ enter_initialization_mode()

virtual int casadi::FmuInternal::enter_initialization_mode ( void *  instance) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by finalize(), and init_mem().

◆ eval()

int casadi::FmuInternal::eval ( FmuMemory m) const

Definition at line 1361 of file fmu.cpp.

1361  {
1362  // Gather inputs and outputs
1363  gather_io(m);
1364  // Pass inputs to FMU
1365  if (set_all(m, get_ptr(m->v_in_), m->v_in_.size())) return 1;
1366  // Get outputs from FMU
1367  if (get_all(m, get_ptr(m->v_out_), m->v_out_.size())) return 1;
1368  // Collect requested variables
1369  auto it = m->v_out_.begin();
1370  for (size_t id : m->id_out_) {
1371  m->obuf_[id] = *it++;
1372  }
1373  // Successful return
1374  return 0;
1375 }
int get_all(FmuMemory *m, double *values, size_t n_values) const
Definition: fmu.cpp:1349
void gather_io(FmuMemory *m) const
Definition: fmu.cpp:1424
int set_all(FmuMemory *m, const double *values, size_t n_values) const
Definition: fmu.cpp:1321
T * get_ptr(std::vector< T > &v)
Get a pointer to the data contained in the vector.

References gather_io(), get_all(), casadi::get_ptr(), casadi::FmuMemory::id_out_, casadi::FmuMemory::obuf_, set_all(), casadi::FmuMemory::v_in_, and casadi::FmuMemory::v_out_.

◆ eval_ad()

int casadi::FmuInternal::eval_ad ( FmuMemory m) const

Definition at line 863 of file fmu.cpp.

863  {
864  // Number of inputs and outputs
865  size_t n_known = m->id_in_.size();
866  size_t n_unknown = m->id_out_.size();
867  // Quick return if nothing to be calculated
868  if (n_unknown == 0) return 0;
869  // Quick return if no seeds
870  if (n_known == 0) {
871  std::fill(m->d_out_.begin(), m->d_out_.end(), 0);
872  return 0;
873  }
874  // Evalute (should not be necessary)
875  if (get_real(m->instance, get_ptr(m->vr_out_), n_unknown, get_ptr(m->v_out_), n_unknown, m)) {
876  casadi_warning("FMU evaluation failed");
877  return 1;
878  }
879  // Evaluate directional derivatives
880  if (get_directional_derivative(m->instance,
881  get_ptr(m->vr_out_), n_unknown,
882  get_ptr(m->vr_in_), n_known,
883  get_ptr(m->d_in_), n_known,
884  get_ptr(m->d_out_), n_unknown)) {
885  casadi_warning("FMU directional derivative failed");
886  return 1;
887  }
888  // Collect requested variables
889  auto it = m->d_out_.begin();
890  for (size_t id : m->id_out_) {
891  m->osens_[id] = *it++;
892  }
893  // Successful return
894  return 0;
895 }
virtual int get_directional_derivative(void *instance, const unsigned int *vr_out, size_t n_out, const unsigned int *vr_in, size_t n_in, const double *seed, size_t n_seed, double *sensitivity, size_t n_sensitivity) const =0
virtual int get_real(void *instance, const unsigned int *vr, size_t n_vr, double *values, size_t n_values, FmuMemory *m=nullptr) const =0

References casadi::FmuMemory::d_in_, casadi::FmuMemory::d_out_, get_directional_derivative(), casadi::get_ptr(), get_real(), casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::instance, casadi::FmuMemory::osens_, casadi::FmuMemory::v_out_, casadi::FmuMemory::vr_in_, and casadi::FmuMemory::vr_out_.

Referenced by eval_fwd().

◆ eval_adj()

int casadi::FmuInternal::eval_adj ( FmuMemory m) const

Definition at line 834 of file fmu.cpp.

834  {
835  // Gather input and output indices
836  gather_adj(m);
837  // Quick return if nothing to be calculated
838  if (m->id_in_.size() == 0) return 0;
839  // Check if no seeds
840  if (m->id_out_.size() == 0) {
841  // Sensitivities are zero, trivially
842  std::fill(m->d_in_.begin(), m->d_in_.end(), 0);
843  } else {
844  // Evaluate adjoint derivatives
845  if (get_adjoint_derivative(m->instance,
846  get_ptr(m->vr_out_), m->id_out_.size(),
847  get_ptr(m->vr_in_), m->id_in_.size(),
848  get_ptr(m->d_out_), m->id_out_.size(),
849  get_ptr(m->d_in_), m->id_in_.size())) {
850  casadi_warning("FMU adjoint derivative failed");
851  return 1;
852  }
853  }
854  // Collect requested variables
855  auto it = m->d_in_.begin();
856  for (size_t id : m->id_in_) {
857  m->isens_[id] = *it++;
858  }
859  // Successful return
860  return 0;
861 }
virtual int get_adjoint_derivative(void *instance, const unsigned int *vr_out, size_t n_out, const unsigned int *vr_in, size_t n_in, const double *seed, size_t n_seed, double *sensitivity, size_t n_sensitivity) const
Definition: fmu.cpp:586
void gather_adj(FmuMemory *m) const
Definition: fmu.cpp:1467

References casadi::FmuMemory::d_in_, casadi::FmuMemory::d_out_, gather_adj(), get_adjoint_derivative(), casadi::get_ptr(), casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::instance, casadi::FmuMemory::isens_, casadi::FmuMemory::vr_in_, and casadi::FmuMemory::vr_out_.

◆ eval_fd()

int casadi::FmuInternal::eval_fd ( FmuMemory m,
bool  independent_seeds 
) const

Definition at line 897 of file fmu.cpp.

897  {
898  // Number of inputs and outputs
899  size_t n_known = m->id_in_.size();
900  size_t n_unknown = m->id_out_.size();
901  // Quick return if nothing to be calculated
902  if (n_unknown == 0) return 0;
903  // Quick return if no seeds
904  if (n_known == 0) {
905  std::fill(m->d_out_.begin(), m->d_out_.end(), 0);
906  return 0;
907  }
908  // Evalute (should not be necessary)
909  if (get_real(m->instance, get_ptr(m->vr_out_), n_unknown, get_ptr(m->v_out_), n_unknown, m)) {
910  casadi_warning("Evaluating FMU failed");
911  return 1;
912  }
913  // Make outputs dimensionless
914  for (size_t k = 0; k < n_unknown; ++k) m->v_out_[k] /= nominal_out_[m->id_out_[k]];
915  // Number of points in FD stencil
916  casadi_int n_points = n_fd_points(m->self.fd_);
917  // Offset for points
918  casadi_int offset = fd_offset(m->self.fd_);
919  // Memory for perturbed outputs
920  m->fd_out_.resize(n_points * n_unknown);
921  // Which inputs are in bounds
922  m->in_bounds_.resize(n_known);
923  // Memory for perturbed inputs
924  m->v_pert_.resize(n_known);
925  // Do any any inputs need flipping?
926  m->flip_.resize(n_known);
927  size_t first_flip = -1;
928  for (size_t i = 0; i < n_known; ++i) {
929  // Try to take step
930  double test = m->v_in_[i] + m->self.step_ * m->d_in_[i];
931  // Check if in bounds
932  size_t id = m->id_in_[i];
933  if (test >= min_in_[id] && test <= max_in_[id]) {
934  // Positive perturbation is fine
935  m->flip_[i] = false;
936  } else {
937  // Try negative direction instead
938  test = m->v_in_[i] - m->self.step_ * m->d_in_[i];
939  casadi_assert(test >= min_in_[id] && test <= max_in_[id],
940  "Cannot perturb " + vn_in_[id] + " at " + str(m->v_in_[i]) + ", min " + str(min_in_[id])
941  + ", max " + str(max_in_[id]) + ", nominal " + str(nominal_in_[id]));
942  m->flip_[i] = true;
943  if (first_flip == size_t(-1)) first_flip = i;
944  }
945  }
946  // If seeds are not independent, we have to flip the sign for all of the seeds or none
947  if (first_flip != size_t(-1) && !independent_seeds) {
948  // Flip the rest of the seeds
949  for (size_t i = 0; i < n_known; ++i) {
950  if (!m->flip_[i]) {
951  // Test negative direction
952  double test = m->v_in_[i] - m->self.step_ * m->d_in_[i];
953  size_t id = m->id_in_[i];
954  casadi_assert(test >= min_in_[id] && test <= max_in_[id],
955  "Cannot perturb both " + vn_in_[id] + " and " + vn_in_[first_flip]);
956  // Flip it too
957  m->flip_[i] = true;
958  }
959  }
960  }
961  // All perturbed outputs
962  const double* yk_all[5] = {nullptr};
963 
964  // Calculate all perturbed outputs
965  for (casadi_int k = 0; k < n_points; ++k) {
966  // Where to save the perturbed outputs
967  double* yk = &m->fd_out_[n_unknown * k];
968  casadi_assert_dev(k < 5);
969  yk_all[k] = yk;
970  // If unperturbed output, quick return
971  if (k == offset) {
972  casadi_copy(get_ptr(m->v_out_), n_unknown, yk);
973  continue;
974  }
975  // Perturbation size
976  double pert = (k - offset) * m->self.step_;
977  // Perturb inputs, if allowed
978  for (size_t i = 0; i < n_known; ++i) {
979  // Try to take step
980  double sign = m->flip_[i] ? -1 : 1;
981  double test = m->v_in_[i] + pert * sign * m->d_in_[i];
982  // Check if in bounds
983  size_t id = m->id_in_[i];
984  m->in_bounds_[i] = test >= min_in_[id] && test <= max_in_[id];
985  // Take step, if allowed
986  m->v_pert_[i] = m->in_bounds_[i] ? test : m->v_in_[i];
987  }
988  // Pass perturbed inputs to FMU
989  if (set_all(m, get_ptr(m->v_pert_), m->v_pert_.size())) return 1;
990  // Evaluate perturbed FMU
991  if (get_all(m, yk, n_unknown)) return 1;
992  // Post-process yk if there was any scaling
993  if (independent_seeds) {
994  for (size_t i = 0; i < n_unknown; ++i) {
995  // Variable id
996  size_t id = m->id_out_[i];
997  // Differentiation with respect to what variable
998  size_t wrt_id = m->wrt_.at(id);
999  // Find the corresponding input variable
1000  size_t wrt_i;
1001  for (wrt_i = 0; wrt_i < n_known; ++wrt_i) {
1002  if (m->id_in_[wrt_i] == wrt_id) break;
1003  }
1004  // Check if in bounds
1005  if (m->in_bounds_.at(wrt_i) && (m->self.fd_flip_ || !m->flip_[i])) {
1006  // Input was in bounds: Keep output, make dimensionless
1007  yk[i] /= nominal_out_[m->id_out_[i]];
1008  } else {
1009  // Input was out of bounds: Discard output
1010  yk[i] = nan;
1011  }
1012  }
1013  }
1014  }
1015  // Restore FMU inputs
1016  if (set_all(m, get_ptr(m->v_in_), m->v_in_.size())) return 1;
1017  // Step size
1018  double h = m->self.step_;
1019 
1020  // Calculate FD approximation
1021  finite_diff(m->self.fd_, yk_all, get_ptr(m->d_out_), h, n_unknown, eps);
1022 
1023  // If seeds are dependent, quick return
1024  if (!independent_seeds) {
1025  // Simpy copy the results to output (no validation)
1026  for (size_t ind = 0; ind < m->id_out_.size(); ++ind) {
1027  m->osens_[m->id_out_[ind]] = m->d_out_[ind];
1028  }
1029  return 0;
1030  }
1031 
1032  // Collect requested variables
1033  for (size_t ind = 0; ind < m->id_out_.size(); ++ind) {
1034  // Variable id
1035  size_t id = m->id_out_[ind];
1036  // With respect to what variable
1037  size_t wrt = m->wrt_[id];
1038  // Find the corresponding input variable
1039  size_t wrt_i;
1040  for (wrt_i = 0; wrt_i < n_known; ++wrt_i) {
1041  if (m->id_in_[wrt_i] == wrt) break;
1042  }
1043  // Nominal value
1044  double n = nominal_out_[id];
1045  // Get the value
1046  double d_fd = m->d_out_[ind] * n;
1047  // Correct sign, if necessary
1048  if (m->flip_[wrt_i]) d_fd = -d_fd;
1049  // Use FD instead of AD or to compare with AD
1050  if (m->self.validate_forward_) {
1051  // Value to compare with
1052  double d_ad = m->osens_[id];
1053  // Nominal value used as seed
1054  d_ad /= nominal_in_[wrt];
1055  d_fd /= nominal_in_[wrt];
1056  // Is it a not a number?
1057  bool d_is_nan = d_ad != d_ad;
1058  // Magnitude of derivatives
1059  double d_max = std::fmax(std::fabs(d_fd), std::fabs(d_ad));
1060  // Check if NaN or error exceeds thresholds
1061  if (d_is_nan || (d_max > n * m->self.abstol_
1062  && std::fabs(d_ad - d_fd) > d_max * m->self.reltol_)) {
1063  // Offset for printing the stencil
1064  double off = m->fd_out_.at(ind + offset * n_unknown);
1065  // Warning or add to file
1066  std::stringstream ss;
1067  if (m->self.validate_ad_file_.empty()) {
1068  // Issue warning
1069  ss << (d_is_nan ? "NaN" : "Inconsistent") << " derivatives of " << vn_out_[id]
1070  << " w.r.t. " << desc_in(m, wrt) << ", got " << d_ad
1071  << " for AD vs. " << d_fd << " for FD[" << to_string(m->self.fd_) << "].";
1072  // Print the stencil:
1073  ss << "\nValues for step size " << h << ": " << (n * off) << " + [";
1074  for (casadi_int k = 0; k < n_points; ++k) {
1075  if (k > 0) ss << ", ";
1076  ss << (n * (m->fd_out_.at(ind + k * n_unknown) - off));
1077  }
1078  ss << "]";
1079  // Issue warning
1080  casadi_warning(ss.str());
1081  } else {
1082  // Output
1083  ss << vn_out_[id] << " ";
1084  // Input
1085  ss << vn_in_[wrt] << " ";
1086  // Value
1087  ss << m->ibuf_[wrt] << " ";
1088  // Noninal
1089  ss << nominal_in_[wrt] << " ";
1090  // Min
1091  ss << min_in_[wrt] << " ";
1092  // Max
1093  ss << max_in_[wrt] << " ";
1094  // AD
1095  ss << d_ad << " ";
1096  // FD
1097  ss << d_fd << " ";
1098  // Step
1099  ss << h << " ";
1100  // Offset
1101  ss << off << " ";
1102  // Stencil
1103  ss << "[";
1104  for (casadi_int k = 0; k < n_points; ++k) {
1105  if (k > 0) ss << ",";
1106  ss << (n * (m->fd_out_.at(ind + k * n_unknown) - off));
1107  }
1108  ss << "]" << std::endl;
1109  // Append to file
1110  auto valfile_ptr = Filesystem::ofstream_ptr(m->self.validate_ad_file_,
1111  std::ios_base::app);
1112  std::ostream& valfile = *valfile_ptr;
1113  valfile << ss.str();
1114  }
1115  }
1116  } else {
1117  // Use instead of AD
1118  m->osens_[id] = d_fd;
1119  }
1120  }
1121  // Successful return
1122  return 0;
1123 }
std::string desc_in(FmuMemory *m, size_t id, bool more=true) const
Definition: fmu.cpp:805
const double eps
Machine epsilon.
Definition: calculus.hpp:56
casadi_int n_fd_points(FdMode v)
Length of FD stencil, including unperturbed input.
casadi_int fd_offset(FdMode v)
Offset for FD stencil, i.e. index of unperturbed input.
double sign(double x)
Sign function, note that sign(nan) == nan.
Definition: calculus.hpp:270
void casadi_copy(const T1 *x, casadi_int n, T1 *y)
COPY: y <-x.
std::string to_string(TypeFmi2 v)
const double nan
Not a number.
Definition: calculus.hpp:53
CASADI_EXPORT void finite_diff(FdMode v, const T1 **yk, T1 *J, T1 h, casadi_int n_y, T1 smoothing)
Calculate FD estimate.

References casadi::FmuFunction::abstol_, casadi::casadi_copy(), casadi::FmuMemory::d_in_, casadi::FmuMemory::d_out_, desc_in(), casadi::eps, casadi::FmuFunction::fd_, casadi::FmuFunction::fd_flip_, casadi::fd_offset(), casadi::FmuMemory::fd_out_, casadi::finite_diff(), casadi::FmuMemory::flip_, get_all(), casadi::get_ptr(), get_real(), casadi::FmuMemory::ibuf_, casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::in_bounds_, casadi::FmuMemory::instance, max_in_, min_in_, casadi::n_fd_points(), casadi::nan, nominal_in_, nominal_out_, casadi::Filesystem::ofstream_ptr(), casadi::FmuMemory::osens_, casadi::FmuFunction::reltol_, casadi::FmuMemory::self, set_all(), casadi::sign(), casadi::FmuFunction::step_, casadi::str(), casadi::to_string(), casadi::FmuMemory::v_in_, casadi::FmuMemory::v_out_, casadi::FmuMemory::v_pert_, casadi::FmuFunction::validate_ad_file_, casadi::FmuFunction::validate_forward_, vn_in_, vn_out_, casadi::FmuMemory::vr_out_, and casadi::FmuMemory::wrt_.

Referenced by eval_fwd().

◆ eval_fwd()

int casadi::FmuInternal::eval_fwd ( FmuMemory m,
bool  independent_seeds 
) const

Definition at line 818 of file fmu.cpp.

818  {
819  // Gather input and output indices
820  gather_fwd(m);
821  // Calculate derivatives using FMU directional derivative support
822  if (m->self.uses_directional_derivatives_) {
823  // Evaluate using AD
824  if (eval_ad(m)) return 1;
825  }
826  // Calculate derivatives using finite differences
827  if (!m->self.uses_directional_derivatives_ || m->self.validate_forward_) {
828  // Evaluate using FD
829  if (eval_fd(m, independent_seeds)) return 1;
830  }
831  return 0;
832 }
void gather_fwd(FmuMemory *m) const
Definition: fmu.cpp:1451
int eval_fd(FmuMemory *m, bool independent_seeds) const
Definition: fmu.cpp:897
int eval_ad(FmuMemory *m) const
Definition: fmu.cpp:863

References eval_ad(), eval_fd(), gather_fwd(), casadi::FmuMemory::self, casadi::FmuFunction::uses_directional_derivatives_, and casadi::FmuFunction::validate_forward_.

◆ exit_initialization_mode()

virtual int casadi::FmuInternal::exit_initialization_mode ( void *  instance) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by init_mem().

◆ finalize()

void casadi::FmuInternal::finalize ( )
virtual

Reimplemented in casadi::Fmu3, and casadi::Fmu2.

Definition at line 593 of file fmu.cpp.

593  {
599  // Load DLL
600  std::string instance_name_no_dot = instance_name_;
601  std::replace(instance_name_no_dot.begin(), instance_name_no_dot.end(), '.', '_');
602  std::string dll_path = resource_.path() + "/binaries/" + system_infix()
603  + "/" + instance_name_no_dot + dll_suffix();
604  li_ = Importer(dll_path, "dll");
605 
606  // Get FMI C functions
607  load_functions();
608 
609  // Create a temporary instance
610  void* c = instantiate();
611  // Set all values
612  if (set_values(c)) {
613  casadi_error("FmuInternal::set_values failed");
614  }
615  // Initialization mode begins
616  if (enter_initialization_mode(c)) {
617  casadi_error("FmuInternal::enter_initialization_mode failed");
618  }
619  // Get input values
620  if (!value_in_.empty()) {
621  // Value references
622  const unsigned int* vr = get_ptr(vr_in_);
623  size_t n_vr = vr_in_.size();
624  // Values
625  double* value = get_ptr(value_in_);
626  size_t n_value = value_in_.size();
627  // Set time variable, if any
628  if (has_independent_) {
629  *value = start_time_;
630  // Skip when getting remaining inputs
631  vr++;
632  n_vr--;
633  value++;
634  n_value--;
635  }
636  // Set remaining
637  if (n_value > 0) {
638  if (get_real(c, vr, n_vr, value, n_value)) {
639  casadi_error("FmuInternal::get_in failed");
640  }
641  }
642  }
643  // Get auxilliary variables
644  if (get_aux(c)) {
645  casadi_error("FmuInternal::get_aux failed");
646  }
647  // Free memory
648  free_instance(c);
649 }
virtual void free_instance(void *c) const =0
virtual int get_aux(void *instance)=0
virtual void load_functions()=0
virtual void * instantiate() const =0
virtual int set_values(void *instance) const =0
Importer li_
DLL.
Definition: fmu_impl.hpp:342
virtual int enter_initialization_mode(void *instance) const =0
virtual std::string system_infix() const =0
const std::string & path() const
Get path for a consumer.
Definition: resource.cpp:70

References dll_suffix(), enter_initialization_mode(), free_instance(), get_aux(), casadi::get_ptr(), get_real(), has_independent_, instance_name_, instantiate(), li_, load_functions(), casadi::Resource::path(), resource_, set_values(), start_time_, system_infix(), value_in_, vr_in_, warning_fired_discrete_states_need_update_, warning_fired_next_event_time_defined_, warning_fired_nominals_of_continuous_states_changed_, warning_fired_terminate_simulation_, and warning_fired_values_of_continuous_states_changed_.

Referenced by casadi::Fmu2::finalize(), and casadi::Fmu3::finalize().

◆ free_instance()

virtual void casadi::FmuInternal::free_instance ( void *  c) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by finalize().

◆ free_mem()

virtual void casadi::FmuInternal::free_mem ( void *  mem) const
pure virtual

◆ gather_adj()

void casadi::FmuInternal::gather_adj ( FmuMemory m) const

Definition at line 1467 of file fmu.cpp.

1467  {
1468  // Gather input and output indices
1469  gather_io(m);
1470  // Number of inputs and outputs
1471  size_t n_known = m->id_in_.size();
1472  // Get/clear seeds
1473  m->d_out_.clear();
1474  for (size_t id : m->id_out_) {
1475  m->d_out_.push_back(m->osens_[id]);
1476  m->osens_[id] = 0;
1477  }
1478  // Allocate result vectors
1479  m->v_in_.resize(n_known);
1480  m->d_in_.resize(n_known);
1481 }

References casadi::FmuMemory::d_in_, casadi::FmuMemory::d_out_, gather_io(), casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::osens_, and casadi::FmuMemory::v_in_.

Referenced by eval_adj().

◆ gather_fwd()

void casadi::FmuInternal::gather_fwd ( FmuMemory m) const

Definition at line 1451 of file fmu.cpp.

1451  {
1452  // Gather input and output indices
1453  gather_io(m);
1454  // Number of outputs
1455  size_t n_unknown = m->id_out_.size();
1456  // Get/clear seeds
1457  m->d_in_.clear();
1458  for (size_t id : m->id_in_) {
1459  m->d_in_.push_back(m->isens_[id]);
1460  m->isens_[id] = 0;
1461  }
1462  // Allocate result vectors
1463  m->v_out_.resize(n_unknown);
1464  m->d_out_.resize(n_unknown);
1465 }

References casadi::FmuMemory::d_in_, casadi::FmuMemory::d_out_, gather_io(), casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::isens_, and casadi::FmuMemory::v_out_.

Referenced by eval_fwd().

◆ gather_io()

void casadi::FmuInternal::gather_io ( FmuMemory m) const

Definition at line 1424 of file fmu.cpp.

1424  {
1425  // Collect input indices and corresponding value references and values
1426  m->id_in_.clear();
1427  m->vr_in_.clear();
1428  m->v_in_.clear();
1429  for (size_t id = 0; id < m->imarked_.size(); ++id) {
1430  if (m->imarked_[id]) {
1431  m->id_in_.push_back(id);
1432  m->vr_in_.push_back(vr_in_[id]);
1433  m->v_in_.push_back(m->ibuf_[id]);
1434  m->imarked_[id] = false;
1435  }
1436  }
1437  // Collect output indices, corresponding value references
1438  m->id_out_.clear();
1439  m->vr_out_.clear();
1440  m->v_out_.clear();
1441  for (size_t id = 0; id < m->omarked_.size(); ++id) {
1442  if (m->omarked_[id]) {
1443  m->id_out_.push_back(id);
1444  m->vr_out_.push_back(vr_out_[id]);
1445  m->v_out_.push_back(nan);
1446  m->omarked_[id] = false;
1447  }
1448  }
1449 }

References casadi::FmuMemory::ibuf_, casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::imarked_, casadi::nan, casadi::FmuMemory::omarked_, casadi::FmuMemory::v_in_, casadi::FmuMemory::v_out_, casadi::FmuMemory::vr_in_, vr_in_, casadi::FmuMemory::vr_out_, and vr_out_.

Referenced by eval(), gather_adj(), and gather_fwd().

◆ get()

void casadi::FmuInternal::get ( FmuMemory m,
size_t  id,
double *  value 
) const

Definition at line 1377 of file fmu.cpp.

1377  {
1378  // Save to return
1379  for (size_t id : ored_[ind]) {
1380  *value++ = m->obuf_.at(id);
1381  }
1382 }

References casadi::FmuMemory::obuf_, and ored_.

Referenced by casadi::Fmu::get().

◆ get_adj() [1/2]

void casadi::FmuInternal::get_adj ( FmuMemory m,
casadi_int  nsens,
const casadi_int *  id,
double *  v 
) const

Definition at line 1181 of file fmu.cpp.

1181  {
1182  for (casadi_int i = 0; i < nsens; ++i) {
1183  *v++ = m->isens_.at(*id++);
1184  }
1185 }

References casadi::FmuMemory::isens_.

Referenced by get_adj().

◆ get_adj() [2/2]

void casadi::FmuInternal::get_adj ( FmuMemory m,
size_t  ind,
double *  v 
) const

Definition at line 1187 of file fmu.cpp.

1187  {
1188  // Quick return if not needed
1189  if (!v) return;
1190  // Retrieve all sensitivities FIXME(@jaeandersson): should use compatible types
1191  for (size_t id : ired_[ind]) {
1192  casadi_int id2 = id;
1193  get_adj(m, 1, &id2, v++);
1194  }
1195 }
void get_adj(FmuMemory *m, casadi_int nsens, const casadi_int *id, double *v) const
Definition: fmu.cpp:1181

References get_adj(), and ired_.

◆ get_adjoint_derivative()

int casadi::FmuInternal::get_adjoint_derivative ( void *  instance,
const unsigned int *  vr_out,
size_t  n_out,
const unsigned int *  vr_in,
size_t  n_in,
const double *  seed,
size_t  n_seed,
double *  sensitivity,
size_t  n_sensitivity 
) const
virtual

Reimplemented in casadi::Fmu3.

Definition at line 586 of file fmu.cpp.

588  {
589  casadi_error("Adjoint derivatives not supported for " + class_name());
590  return 1;
591 }

References casadi::SharedObjectInternal::class_name().

Referenced by eval_adj().

◆ get_all()

int casadi::FmuInternal::get_all ( FmuMemory m,
double *  values,
size_t  n_values 
) const

Definition at line 1349 of file fmu.cpp.

1349  {
1350  // Quick return if nothing to get
1351  if (n_values == 0) return 0;
1352  // Retrieve from FMU
1353  if (get_real(m->instance, get_ptr(m->vr_out_), m->vr_out_.size(), values, n_values, m)) {
1354  casadi_warning("Evaluation failed");
1355  return 1;
1356  }
1357  // Successful return
1358  return 0;
1359 }

References casadi::get_ptr(), get_real(), casadi::FmuMemory::instance, and casadi::FmuMemory::vr_out_.

Referenced by eval(), and eval_fd().

◆ get_aux()

virtual int casadi::FmuInternal::get_aux ( void *  instance)
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by finalize().

◆ get_derivatives()

virtual int casadi::FmuInternal::get_derivatives ( void *  instance,
double *  derivatives,
size_t  nx 
) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

◆ get_directional_derivative()

virtual int casadi::FmuInternal::get_directional_derivative ( void *  instance,
const unsigned int *  vr_out,
size_t  n_out,
const unsigned int *  vr_in,
size_t  n_in,
const double *  seed,
size_t  n_seed,
double *  sensitivity,
size_t  n_sensitivity 
) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by eval_ad().

◆ get_fwd() [1/2]

void casadi::FmuInternal::get_fwd ( FmuMemory m,
casadi_int  nsens,
const casadi_int *  id,
double *  v 
) const

Definition at line 1125 of file fmu.cpp.

1125  {
1126  for (casadi_int i = 0; i < nsens; ++i) {
1127  *v++ = m->osens_.at(*id++);
1128  }
1129 }

References casadi::FmuMemory::osens_.

Referenced by get_fwd().

◆ get_fwd() [2/2]

void casadi::FmuInternal::get_fwd ( FmuMemory m,
size_t  ind,
double *  v 
) const

Definition at line 1131 of file fmu.cpp.

1131  {
1132  // Quick return if not needed
1133  if (!v) return;
1134  // Retrieve all sensitivities FIXME(@jaeandersson): should use compatible types
1135  for (size_t id : ored_[ind]) {
1136  casadi_int id2 = id;
1137  get_fwd(m, 1, &id2, v++);
1138  }
1139 }
void get_fwd(FmuMemory *m, casadi_int nsens, const casadi_int *id, double *v) const
Definition: fmu.cpp:1125

References get_fwd(), and ored_.

◆ get_real()

virtual int casadi::FmuInternal::get_real ( void *  instance,
const unsigned int *  vr,
size_t  n_vr,
double *  values,
size_t  n_values,
FmuMemory m = nullptr 
) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by eval_ad(), eval_fd(), finalize(), and get_all().

◆ get_stats()

virtual void casadi::FmuInternal::get_stats ( FmuMemory m,
Dict stats,
const std::vector< std::string > &  name_in,
const InputStruct in 
) const
pure virtual

◆ getCount()

Definition at line 60 of file generic_shared_internal.hpp.

205  {
206  return static_cast<const Internal*>(this)->count;
207  }

◆ hess_sparsity()

Sparsity casadi::FmuInternal::hess_sparsity ( const std::vector< size_t > &  r,
const std::vector< size_t > &  c 
) const

Definition at line 696 of file fmu.cpp.

697  {
698  // Convert to casadi_int type
699  std::vector<casadi_int> r1(r.begin(), r.end());
700  std::vector<casadi_int> c1(c.begin(), c.end());
701  // Index mapping (not used)
702  std::vector<casadi_int> mapping;
703  // Get selection
704  return hess_sp_.sub(r1, c1, mapping);
705 }
Sparsity sub(const std::vector< casadi_int > &rr, const std::vector< casadi_int > &cc, std::vector< casadi_int > &mapping, bool ind1=false) const
Get a submatrix.
Definition: sparsity.cpp:334

References hess_sp_, and casadi::Sparsity::sub().

◆ index_in()

size_t casadi::FmuInternal::index_in ( const std::string &  n) const

Definition at line 665 of file fmu.cpp.

665  {
666  // Linear search for the input
667  for (size_t i = 0; i < scheme_in_.size(); ++i) {
668  if (scheme_in_[i] == n) return i;
669  }
670  // Not found
671  casadi_error("No such input: " + n);
672  return -1;
673 }

References scheme_in_.

Referenced by casadi::InputStruct::parse(), and casadi::OutputStruct::parse().

◆ index_out()

size_t casadi::FmuInternal::index_out ( const std::string &  n) const

Definition at line 675 of file fmu.cpp.

675  {
676  // Linear search for the input
677  for (size_t i = 0; i < scheme_out_.size(); ++i) {
678  if (scheme_out_[i] == n) return i;
679  }
680  // Not found
681  casadi_error("No such output: " + n);
682  return -1;
683 }

References scheme_out_.

Referenced by casadi::InputStruct::parse(), and casadi::OutputStruct::parse().

◆ init()

void casadi::FmuInternal::init ( const DaeBuilderInternal dae)
virtual

Reimplemented in casadi::Fmu3, and casadi::Fmu2.

Definition at line 453 of file fmu.cpp.

453  {
454  // Copy info from DaeBuilder
455  resource_ = dae->resource_;
456  fmutol_ = dae->fmutol_;
457  instance_name_ = dae->model_identifier_;
458  instantiation_token_ = dae->instantiation_token_;
459  logging_on_ = dae->debug_;
460  number_of_event_indicators_ = dae->nzero_;
461  provides_directional_derivatives_ = dae->provides_directional_derivatives_;
462  provides_adjoint_derivatives_ = dae->provides_adjoint_derivatives_;
463  can_be_instantiated_only_once_per_process_ = dae->can_be_instantiated_only_once_per_process_;
464  start_time_ = dae->start_time_;
465  nx_ = dae->size(Category::X);
466  do_evaluation_dance_ = dae->generation_tool_.rfind("Simulink", 0) == 0;
467 
468  // Mark input indices
469  size_t numel = 0;
470  std::vector<bool> lookup(dae->n_variables(), false);
471  for (auto&& n : scheme_in_) {
472  casadi_assert(scheme_.find(n) != scheme_.end(), "Unsupported input: '" + n + "'");
473  for (size_t i : scheme_.at(n)) {
474  casadi_assert(!lookup.at(i), "Duplicate variable: " + dae->variable(i).name);
475  lookup.at(i) = true;
476  numel++;
477  }
478  }
479  // Input mappings
480  iind_.reserve(numel);
481  iind_map_.reserve(lookup.size());
482  for (size_t k = 0; k < lookup.size(); ++k) {
483  if (lookup[k]) {
484  iind_map_.push_back(iind_.size());
485  iind_.push_back(k);
486  } else {
487  iind_map_.push_back(-1);
488  }
489  }
490  // Mark output indices
491  numel = 0;
492  std::fill(lookup.begin(), lookup.end(), false);
493  for (auto&& n : scheme_out_) {
494  casadi_assert(scheme_.find(n) != scheme_.end(), "Unsupported output: '" + n + "'");
495  for (size_t i : scheme_.at(n)) {
496  casadi_assert(!lookup.at(i), "Duplicate variable: " + dae->variable(i).name);
497  lookup.at(i) = true;
498  numel++;
499  }
500  }
501  // Construct mappings
502  oind_.reserve(numel);
503  oind_map_.reserve(lookup.size());
504  for (size_t k = 0; k < lookup.size(); ++k) {
505  if (lookup[k]) {
506  oind_map_.push_back(oind_.size());
507  oind_.push_back(k);
508  } else {
509  oind_map_.push_back(-1);
510  }
511  }
512  // Inputs
513  ired_.resize(scheme_in_.size());
514  for (size_t i = 0; i < ired_.size(); ++i) {
515  auto&& s = scheme_.at(scheme_in_[i]);
516  ired_[i].resize(s.size());
517  for (size_t k = 0; k < s.size(); ++k) {
518  ired_[i][k] = iind_map_.at(s[k]);
519  }
520  }
521  // Outputs
522  ored_.resize(scheme_out_.size());
523  for (size_t i = 0; i < ored_.size(); ++i) {
524  auto&& s = scheme_.at(scheme_out_[i]);
525  ored_[i].resize(s.size());
526  for (size_t k = 0; k < s.size(); ++k) {
527  ored_[i][k] = oind_map_.at(s[k]);
528  }
529  }
530 
531  // Is there an independent variable?
532  has_independent_ = false;
533 
534  // Collect meta information for inputs
535  nominal_in_.reserve(iind_.size());
536  min_in_.reserve(iind_.size());
537  max_in_.reserve(iind_.size());
538  vn_in_.reserve(iind_.size());
539  vr_in_.reserve(iind_.size());
540  for (size_t i : iind_) {
541  const Variable& v = dae->variable(i);
542  nominal_in_.push_back(v.nominal);
543  min_in_.push_back(v.min);
544  max_in_.push_back(v.max);
545  vn_in_.push_back(v.name);
546  vr_in_.push_back(v.value_reference);
547  if (v.causality == Causality::INDEPENDENT) {
548  if (i != 0) casadi_error("Independent variable must be the first model variable");
549  has_independent_ = true;
550  independent_vr_ = vr_in_.back();
551  }
552  }
553  // Collect meta information for outputs
554  nominal_out_.reserve(oind_.size());
555  min_out_.reserve(oind_.size());
556  max_out_.reserve(oind_.size());
557  vn_out_.reserve(oind_.size());
558  vr_out_.reserve(oind_.size());
559  for (size_t i : oind_) {
560  const Variable& v = dae->variable(i);
561  nominal_out_.push_back(v.nominal);
562  min_out_.push_back(v.min);
563  max_out_.push_back(v.max);
564  vn_out_.push_back(v.name);
565  vr_out_.push_back(v.value_reference);
566  }
567 
568  // Numerical values for inputs
569  value_in_.resize(iind_.size());
570 
571  // Get Jacobian sparsity information
572  jac_sp_ = dae->jac_sparsity(oind_, iind_);
573 
574  // Get Hessian sparsity information
575  hess_sp_ = dae->hess_sparsity(oind_, iind_);
576 
577  // Path to resource directory
580  resource_loc_ += "/resources";
581 
582  // Use forward slashes (supported by all file systems)
583  std::replace(resource_loc_.begin(), resource_loc_.end(), '\\', '/');
584 }
static std::string absolute(const std::string &path)
Definition: filesystem.cpp:78
static bool is_enabled()
Definition: filesystem.cpp:83
unsigned int independent_vr_
Definition: fmu_impl.hpp:351
std::string resource_loc_
Definition: fmu_impl.hpp:315
struct VariableStruct Variable

References casadi::Filesystem::absolute(), casadi::DaeBuilderInternal::can_be_instantiated_only_once_per_process_, can_be_instantiated_only_once_per_process_, casadi::Variable::causality, casadi::DaeBuilderInternal::debug_, do_evaluation_dance_, casadi::DaeBuilderInternal::fmutol_, fmutol_, casadi::DaeBuilderInternal::generation_tool_, has_independent_, hess_sp_, casadi::DaeBuilderInternal::hess_sparsity(), iind_, iind_map_, casadi::INDEPENDENT, independent_vr_, instance_name_, casadi::DaeBuilderInternal::instantiation_token_, instantiation_token_, ired_, casadi::Filesystem::is_enabled(), jac_sp_, casadi::DaeBuilderInternal::jac_sparsity(), logging_on_, casadi::Variable::max, max_in_, max_out_, casadi::Variable::min, min_in_, min_out_, casadi::DaeBuilderInternal::model_identifier_, casadi::DaeBuilderInternal::n_variables(), casadi::Variable::name, casadi::Variable::nominal, nominal_in_, nominal_out_, number_of_event_indicators_, nx_, casadi::DaeBuilderInternal::nzero_, oind_, oind_map_, ored_, casadi::Resource::path(), casadi::DaeBuilderInternal::provides_adjoint_derivatives_, provides_adjoint_derivatives_, casadi::DaeBuilderInternal::provides_directional_derivatives_, provides_directional_derivatives_, casadi::DaeBuilderInternal::resource_, resource_, resource_loc_, scheme_, scheme_in_, scheme_out_, casadi::DaeBuilderInternal::size(), casadi::DaeBuilderInternal::start_time_, start_time_, value_in_, casadi::Variable::value_reference, casadi::DaeBuilderInternal::variable(), vn_in_, vn_out_, vr_in_, vr_out_, and casadi::X.

Referenced by casadi::Fmu2::init(), and casadi::Fmu3::init().

◆ init_mem()

int casadi::FmuInternal::init_mem ( FmuMemory m) const
virtual

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

Reimplemented in casadi::Fmu3, and casadi::Fmu2.

Definition at line 1247 of file fmu.cpp.

1247  {
1248  // Ensure not already instantiated
1249  casadi_assert(m->instance == nullptr, "Already instantiated");
1250  // Create instance
1251  m->instance = instantiate();
1252  // Set all values
1253  if (set_values(m->instance)) {
1254  casadi_warning("FmuInternal::set_values failed");
1255  return 1;
1256  }
1257  // Initialization mode begins
1258  if (enter_initialization_mode(m->instance)) return 1;
1259  // Initialization mode ends
1260  if (exit_initialization_mode(m->instance)) return 1;
1261  // Initial event iteration
1262  if (discrete_states_iter(m->instance)) return 1;
1263  // Continuous-time mode
1264  if (enter_continuous_time_mode(m->instance)) return 1;
1265  // Allocate/reset input buffer
1266  m->ibuf_.resize(iind_.size());
1267  std::fill(m->ibuf_.begin(), m->ibuf_.end(), casadi::nan);
1268  // Allocate/reset output buffer
1269  m->obuf_.resize(oind_.size());
1270  std::fill(m->obuf_.begin(), m->obuf_.end(), casadi::nan);
1271  // Maximum input or output
1272  size_t max_io = std::max(iind_.size(), oind_.size());
1273  // Allocate/reset seeds
1274  m->isens_.resize(max_io);
1275  std::fill(m->isens_.begin(), m->isens_.end(), 0);
1276  // Allocate/reset sensitivities
1277  m->osens_.resize(max_io);
1278  std::fill(m->osens_.begin(), m->osens_.end(), 0);
1279  // Allocate/reset changed
1280  m->imarked_.resize(max_io);
1281  std::fill(m->imarked_.begin(), m->imarked_.end(), false);
1282  // Allocate/reset requested
1283  m->omarked_.resize(max_io);
1284  std::fill(m->omarked_.begin(), m->omarked_.end(), false);
1285  // Also allocate memory for corresponding Jacobian entry (for debugging)
1286  m->wrt_.resize(max_io);
1287  // Successful return
1288  return 0;
1289 }
int discrete_states_iter(void *instance) const
Definition: fmu.cpp:1197
virtual int exit_initialization_mode(void *instance) const =0
virtual int enter_continuous_time_mode(void *instance) const =0

References discrete_states_iter(), enter_continuous_time_mode(), enter_initialization_mode(), exit_initialization_mode(), casadi::FmuMemory::ibuf_, iind_, casadi::FmuMemory::imarked_, casadi::FmuMemory::instance, instantiate(), casadi::FmuMemory::isens_, casadi::nan, casadi::FmuMemory::obuf_, oind_, casadi::FmuMemory::omarked_, casadi::FmuMemory::osens_, set_values(), and casadi::FmuMemory::wrt_.

Referenced by casadi::Fmu2::init_mem(), and casadi::Fmu3::init_mem().

◆ initSingleton()

void casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::initSingleton ( )
inlineprotectedinherited

Called in the constructor of singletons to avoid that the counter reaches zero

Definition at line 71 of file generic_shared_internal.hpp.

71  {
72  casadi_assert_dev(static_cast<Internal*>(this)->count==0);
73  static_cast<Internal*>(this)->count++;
74  }

◆ instantiate()

virtual void* casadi::FmuInternal::instantiate ( ) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by finalize(), and init_mem().

◆ jac_sparsity()

Sparsity casadi::FmuInternal::jac_sparsity ( const std::vector< size_t > &  osub,
const std::vector< size_t > &  isub 
) const

Definition at line 685 of file fmu.cpp.

686  {
687  // Convert to casadi_int type
688  std::vector<casadi_int> osub1(osub.begin(), osub.end());
689  std::vector<casadi_int> isub1(isub.begin(), isub.end());
690  // Index mapping (not used)
691  std::vector<casadi_int> mapping;
692  // Get selection
693  return jac_sp_.sub(osub1, isub1, mapping);
694 }

References jac_sp_, and casadi::Sparsity::sub().

◆ load_function()

template<typename T >
T * casadi::FmuInternal::load_function ( const std::string &  symname)

Definition at line 381 of file fmu_impl.hpp.

381  {
382  // Load the function
383  signal_t f = li_.get_function(symname);
384  // Ensure that it was found
385  casadi_assert(f != nullptr, "Cannot retrieve '" + symname + "'");
386  // Return function with the right type
387  return reinterpret_cast<T*>(f);
388 }
signal_t get_function(const std::string &symname)
Get a function pointer for numerical evaluation.
Definition: importer.cpp:84
void(* signal_t)(void)
Function pointer types for the C API.

References casadi::Importer::get_function(), li_, and casadi::T.

◆ load_functions()

virtual void casadi::FmuInternal::load_functions ( )
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by finalize().

◆ n_in()

size_t casadi::FmuInternal::n_in ( ) const
inline

◆ n_out()

size_t casadi::FmuInternal::n_out ( ) const
inline

◆ pack_fmu()

std::string casadi::FmuInternal::pack_fmu ( const Dict files,
const std::string &  path 
)
static

Definition at line 785 of file fmu.cpp.

785  {
786  casadi_assert(Archiver::has_plugin("libzip"),
787  "pack_fmu requires libzip. Compile CasADi with WITH_LIBZIP=ON.");
788  // The {local_file -> archive path} map is exactly the set of zip entries: no staging
789  // directory or copies required.
790  std::vector<std::pair<std::string, std::string>> entries;
791  for (auto&& kv : files) {
792  std::string arc = kv.second.to_string();
793  if (arc.substr(0, 2) == "./") arc = arc.substr(2); // zip entries are root-relative
794  entries.push_back({kv.first, arc});
795  }
796  std::string out = path;
797  if (out.size() < 4 || out.substr(out.size() - 4) != ".fmu") out += ".fmu";
798  casadi_assert(Archiver::getPlugin("libzip").exposed.pack_entries(entries, out),
799  "Packing FMU '" + out + "' failed.");
800  // Clean up the loose files
801  for (auto&& e : entries) Filesystem::remove(e.first);
802  return out;
803 }
static bool has_plugin(const std::string &pname, bool verbose=false)
Check if a plugin is available or can be loaded.
static Plugin & getPlugin(const std::string &pname)
Load and get the creator function.
std::vector< casadi_int > path(const std::vector< casadi_int > &map, casadi_int i_start)

References casadi::PluginInterface< Archiver >::getPlugin(), casadi::PluginInterface< Archiver >::has_plugin(), casadi::path(), and casadi::Filesystem::remove().

Referenced by casadi::DaeBuilderInternal::pack_fmu().

◆ request()

void casadi::FmuInternal::request ( FmuMemory m,
size_t  ind 
) const

Definition at line 1312 of file fmu.cpp.

1312  {
1313  for (size_t id : ored_[ind]) {
1314  // Mark as requested
1315  m->omarked_.at(id) = true;
1316  // Also log corresponding input index
1317  m->wrt_.at(id) = -1;
1318  }
1319 }

References casadi::FmuMemory::omarked_, ored_, and casadi::FmuMemory::wrt_.

◆ request_adj() [1/2]

void casadi::FmuInternal::request_adj ( FmuMemory m,
casadi_int  ind 
) const

Definition at line 1172 of file fmu.cpp.

1172  {
1173  // Request all sensitivities FIXME(@jaeandersson): should use compatible types
1174  casadi_int wrt_id = -1;
1175  for (size_t id : ired_[ind]) {
1176  casadi_int id2 = id;
1177  request_adj(m, 1, &id2, &wrt_id);
1178  }
1179 }
void request_adj(FmuMemory *m, casadi_int nsens, const casadi_int *id, const casadi_int *wrt_id) const
Definition: fmu.cpp:1163

References ired_, and request_adj().

◆ request_adj() [2/2]

void casadi::FmuInternal::request_adj ( FmuMemory m,
casadi_int  nsens,
const casadi_int *  id,
const casadi_int *  wrt_id 
) const

Definition at line 1163 of file fmu.cpp.

1164  {
1165  for (casadi_int i = 0; i < nsens; ++i) {
1166  m->imarked_.at(*id) = true;
1167  m->wrt_.at(*id) = wrt_id ? *wrt_id++ : -1;
1168  id++;
1169  }
1170 }

References casadi::FmuMemory::imarked_, and casadi::FmuMemory::wrt_.

Referenced by request_adj().

◆ request_fwd() [1/2]

void casadi::FmuInternal::request_fwd ( FmuMemory m,
casadi_int  ind 
) const

Definition at line 1415 of file fmu.cpp.

1415  {
1416  // Request all sensitivities FIXME(@jaeandersson): should use compatible types
1417  casadi_int wrt_id = -1;
1418  for (size_t id : ored_[ind]) {
1419  casadi_int id2 = id;
1420  request_fwd(m, 1, &id2, &wrt_id);
1421  }
1422 }
void request_fwd(FmuMemory *m, casadi_int nsens, const casadi_int *id, const casadi_int *wrt_id) const
Definition: fmu.cpp:1406

References ored_, and request_fwd().

◆ request_fwd() [2/2]

void casadi::FmuInternal::request_fwd ( FmuMemory m,
casadi_int  nsens,
const casadi_int *  id,
const casadi_int *  wrt_id 
) const

Definition at line 1406 of file fmu.cpp.

1407  {
1408  for (casadi_int i = 0; i < nsens; ++i) {
1409  m->omarked_.at(*id) = true;
1410  m->wrt_.at(*id) = *wrt_id++;
1411  id++;
1412  }
1413 }

References casadi::FmuMemory::omarked_, and casadi::FmuMemory::wrt_.

Referenced by request_fwd().

◆ serialize()

void casadi::FmuInternal::serialize ( SerializingStream s) const

Definition at line 1497 of file fmu.cpp.

1497  {
1498  serialize_type(s);
1499  serialize_body(s);
1500 }
virtual void serialize_body(SerializingStream &s) const
Definition: fmu.cpp:1506
virtual void serialize_type(SerializingStream &s) const
Definition: fmu.cpp:1502

References serialize_body(), and serialize_type().

◆ serialize_body()

void casadi::FmuInternal::serialize_body ( SerializingStream s) const
virtual

Reimplemented in casadi::Fmu3, and casadi::Fmu2.

Definition at line 1506 of file fmu.cpp.

1506  {
1507  s.version("FmuInternal", 4);
1508  s.pack("FmuInternal::name", name_);
1509  s.pack("FmuInternal::scheme_in", scheme_in_);
1510  s.pack("FmuInternal::scheme_out", scheme_out_);
1511  s.pack("FmuInternal::scheme", scheme_);
1512  s.pack("FmuInternal::aux", aux_);
1513  s.pack("FmuInternal::iind", iind_);
1514  s.pack("FmuInternal::iind_map", iind_map_);
1515  s.pack("FmuInternal::oind", oind_);
1516  s.pack("FmuInternal::oind_map", oind_map_);
1517  s.pack("FmuInternal::has_independent", has_independent_);
1518  s.pack("FmuInternal::nominal_in", nominal_in_);
1519  s.pack("FmuInternal::nominal_out", nominal_out_);
1520  s.pack("FmuInternal::min_in", min_in_);
1521  s.pack("FmuInternal::min_out", min_out_);
1522  s.pack("FmuInternal::max_in", max_in_);
1523  s.pack("FmuInternal::max_out", max_out_);
1524  s.pack("FmuInternal::vn_in", vn_in_);
1525  s.pack("FmuInternal::vn_out", vn_out_);
1526  s.pack("FmuInternal::vr_in", vr_in_);
1527  s.pack("FmuInternal::vr_out", vr_out_);
1528 
1529  s.pack("FmuInternal::value_in", value_in_);
1530  s.pack("FmuInternal::ired", ired_);
1531  s.pack("FmuInternal::ored", ored_);
1532  s.pack("FmuInternal::jac_sp", jac_sp_);
1533  s.pack("FmuInternal::hess_sp", hess_sp_);
1534 
1535  s.pack("FmuInternal::resource", resource_);
1536  s.pack("FmuInternal::fmutol", fmutol_);
1537  s.pack("FmuInternal::instance_name", instance_name_);
1538  s.pack("FmuInternal::instantiation_token", instantiation_token_);
1539  s.pack("FmuInternal::logging_on", logging_on_);
1540  s.pack("FmuInternal::number_of_event_indicators", number_of_event_indicators_);
1541  s.pack("FmuInternal::provides_directional_derivatives", provides_directional_derivatives_);
1542  s.pack("FmuInternal::provides_adjoint_derivatives", provides_adjoint_derivatives_);
1543  s.pack("FmuInternal::can_be_instantiated_only_once_per_process",
1545  s.pack("FmuInternal::start_time", start_time_);
1546  s.pack("FmuInternal::nx", nx_);
1547  s.pack("FmuInternal::do_evaluation_dance", do_evaluation_dance_);
1548 }

References aux_, can_be_instantiated_only_once_per_process_, do_evaluation_dance_, fmutol_, has_independent_, hess_sp_, iind_, iind_map_, instance_name_, instantiation_token_, ired_, jac_sp_, logging_on_, max_in_, max_out_, min_in_, min_out_, name_, nominal_in_, nominal_out_, number_of_event_indicators_, nx_, oind_, oind_map_, ored_, casadi::SerializingStream::pack(), provides_adjoint_derivatives_, provides_directional_derivatives_, resource_, scheme_, scheme_in_, scheme_out_, start_time_, value_in_, casadi::SerializingStream::version(), vn_in_, vn_out_, vr_in_, and vr_out_.

Referenced by serialize(), casadi::Fmu2::serialize_body(), and casadi::Fmu3::serialize_body().

◆ serialize_type()

void casadi::FmuInternal::serialize_type ( SerializingStream s) const
virtual

Definition at line 1502 of file fmu.cpp.

1502  {
1503  s.pack("FmuInternal::type", class_name());
1504 }

References casadi::SharedObjectInternal::class_name(), and casadi::SerializingStream::pack().

Referenced by serialize().

◆ set()

void casadi::FmuInternal::set ( FmuMemory m,
size_t  ind,
const double *  value 
) const

Definition at line 1291 of file fmu.cpp.

1291  {
1292  if (value) {
1293  // Argument is given
1294  for (size_t id : ired_[ind]) {
1295  if (*value != m->ibuf_.at(id)) {
1296  m->ibuf_.at(id) = *value;
1297  m->imarked_.at(id) = true;
1298  }
1299  value++;
1300  }
1301  } else {
1302  // Argument is null - all zeros
1303  for (size_t id : ired_[ind]) {
1304  if (0 != m->ibuf_.at(id)) {
1305  m->ibuf_.at(id) = 0;
1306  m->imarked_.at(id) = true;
1307  }
1308  }
1309  }
1310 }

References casadi::FmuMemory::ibuf_, casadi::FmuMemory::imarked_, and ired_.

◆ set_adj() [1/2]

void casadi::FmuInternal::set_adj ( FmuMemory m,
casadi_int  nseed,
const casadi_int *  id,
const double *  v 
) const

Definition at line 1141 of file fmu.cpp.

1142  {
1143  for (casadi_int i = 0; i < nseed; ++i) {
1144  if (*v != 0.) {
1145  m->osens_.at(*id) = *v;
1146  m->omarked_.at(*id) = true;
1147  }
1148  id++;
1149  v++;
1150  }
1151 }

References casadi::FmuMemory::omarked_, and casadi::FmuMemory::osens_.

Referenced by set_adj().

◆ set_adj() [2/2]

void casadi::FmuInternal::set_adj ( FmuMemory m,
size_t  ind,
const double *  v 
) const

Definition at line 1153 of file fmu.cpp.

1153  {
1154  // If seeds are zero, no need to add to seed buffers
1155  if (!v) return;
1156  // Pass all seeds FIXME(@jaeandersson): should use compatible types
1157  for (size_t id : ored_[ind]) {
1158  casadi_int id2 = id;
1159  set_adj(m, 1, &id2, v++);
1160  }
1161 }
void set_adj(FmuMemory *m, casadi_int nseed, const casadi_int *id, const double *v) const
Definition: fmu.cpp:1141

References ored_, and set_adj().

◆ set_all()

int casadi::FmuInternal::set_all ( FmuMemory m,
const double *  values,
size_t  n_values 
) const

Definition at line 1321 of file fmu.cpp.

1321  {
1322  // Quick return if nothing to set
1323  if (n_values == 0) return 0;
1324  // Value references
1325  const unsigned int* vr = get_ptr(m->vr_in_);
1326  size_t n_vr = m->vr_in_.size();
1327  // Set time variable, if any
1328  if (has_independent_ && *vr == independent_vr_) {
1329  // Update FMU time
1330  if (set_time(m->instance, *values)) return 1;
1331  // Skip when setting remaining variables
1332  vr++;
1333  n_vr--;
1334  values++;
1335  n_values--;
1336  // Quick return if nothing left to set
1337  if (n_vr == 0) return 0;
1338  }
1339 
1340  // Set remaining variables
1341  if (set_real(m->instance, vr, n_vr, values, n_values)) {
1342  casadi_warning("Setting FMU variables failed");
1343  return 1;
1344  }
1345 
1346  return 0;
1347 }
virtual int set_time(void *instance, double t) const =0
virtual int set_real(void *instance, const unsigned int *vr, size_t n_vr, const double *values, size_t n_values) const =0

References casadi::get_ptr(), has_independent_, independent_vr_, casadi::FmuMemory::instance, set_real(), set_time(), and casadi::FmuMemory::vr_in_.

Referenced by eval(), and eval_fd().

◆ set_fwd() [1/2]

void casadi::FmuInternal::set_fwd ( FmuMemory m,
casadi_int  nseed,
const casadi_int *  id,
const double *  v 
) const

Definition at line 1384 of file fmu.cpp.

1385  {
1386  for (casadi_int i = 0; i < nseed; ++i) {
1387  if (*v != 0.) {
1388  m->isens_.at(*id) = *v;
1389  m->imarked_.at(*id) = true;
1390  }
1391  id++;
1392  v++;
1393  }
1394 }

References casadi::FmuMemory::imarked_, and casadi::FmuMemory::isens_.

Referenced by set_fwd().

◆ set_fwd() [2/2]

void casadi::FmuInternal::set_fwd ( FmuMemory m,
size_t  ind,
const double *  v 
) const

Definition at line 1396 of file fmu.cpp.

1396  {
1397  // If seeds are zero, no need to add to seed buffers
1398  if (!v) return;
1399  // Pass all seeds FIXME(@jaeandersson): should use compatible types
1400  for (size_t id : ired_[ind]) {
1401  casadi_int id2 = id;
1402  set_fwd(m, 1, &id2, v++);
1403  }
1404 }
void set_fwd(FmuMemory *m, casadi_int nseed, const casadi_int *id, const double *v) const
Definition: fmu.cpp:1384

References ired_, and set_fwd().

◆ set_real()

virtual int casadi::FmuInternal::set_real ( void *  instance,
const unsigned int *  vr,
size_t  n_vr,
const double *  values,
size_t  n_values 
) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by set_all().

◆ set_time()

virtual int casadi::FmuInternal::set_time ( void *  instance,
double  t 
) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by set_all().

◆ set_values()

virtual int casadi::FmuInternal::set_values ( void *  instance) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by finalize(), and init_mem().

◆ shared_from_this() [1/2]

B casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::shared_from_this ( )
inlineprotectedinherited

Definition at line 83 of file generic_shared_internal.hpp.

83  {
84  casadi_assert_dev(B::test_cast(static_cast<Internal*>(this)));
85  B ret;
86  ret.own(static_cast<Internal*>(this));
87  return ret;
88  }

◆ shared_from_this() [2/2]

const B casadi::GenericSharedInternal< SharedObject , SharedObjectInternal >::shared_from_this ( ) const
inlineprotectedinherited

Definition at line 92 of file generic_shared_internal.hpp.

92  {
93  casadi_assert_dev(B::test_cast(static_cast<const Internal*>(this)));
94  B ret;
95  ret.own(const_cast<Internal*>(static_cast<const Internal*>(this)));
96  return ret;
97  }

◆ system_infix()

virtual std::string casadi::FmuInternal::system_infix ( ) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

References casadi::T.

Referenced by finalize().

◆ update_discrete_states()

virtual int casadi::FmuInternal::update_discrete_states ( void *  instance,
EventMemory eventmem 
) const
pure virtual

Implemented in casadi::Fmu3, and casadi::Fmu2.

Referenced by discrete_states_iter().

◆ weak()

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

Definition at line 67 of file generic_shared_internal.hpp.

210  {
211 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
212  auto* w = weak_ref_.load(std::memory_order_acquire);
213  if (!w) {
214  auto* nw = new GenericWeakRef<Shared, Internal>(static_cast<Internal*>(this));
215  GenericWeakRef<Shared, Internal>* expected = nullptr;
216  if (weak_ref_.compare_exchange_strong(
217  expected, nw, std::memory_order_release, std::memory_order_acquire)) {
218  w = nw;
219  } else {
220  delete nw; // lost the race; another thread published first
221  w = expected;
222  }
223  }
224  return w;
225 #else
226  if (weak_ref_==nullptr) {
227  weak_ref_ = new GenericWeakRef<Shared, Internal>(static_cast<Internal*>(this));
228  }
229  return weak_ref_;
230 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
231  }

Friends And Related Function Documentation

◆ Fmu

friend class Fmu
friend

Definition at line 62 of file fmu_impl.hpp.

Member Data Documentation

◆ aux_

std::vector<std::string> casadi::FmuInternal::aux_
protected

Definition at line 312 of file fmu_impl.hpp.

Referenced by FmuInternal(), casadi::Fmu2::init(), casadi::Fmu3::init(), and serialize_body().

◆ can_be_instantiated_only_once_per_process_

bool casadi::FmuInternal::can_be_instantiated_only_once_per_process_
protected

Definition at line 336 of file fmu_impl.hpp.

Referenced by FmuInternal(), init(), and serialize_body().

◆ do_evaluation_dance_

bool casadi::FmuInternal::do_evaluation_dance_
protected

◆ fmutol_

double casadi::FmuInternal::fmutol_
protected

◆ has_independent_

bool casadi::FmuInternal::has_independent_
protected

◆ hess_sp_

Sparsity casadi::FmuInternal::hess_sp_
protected

Definition at line 367 of file fmu_impl.hpp.

Referenced by FmuInternal(), hess_sparsity(), init(), and serialize_body().

◆ iind_

std::vector<size_t> casadi::FmuInternal::iind_
protected

Definition at line 345 of file fmu_impl.hpp.

Referenced by FmuInternal(), init(), init_mem(), and serialize_body().

◆ iind_map_

std::vector<size_t> casadi::FmuInternal::iind_map_
protected

Definition at line 345 of file fmu_impl.hpp.

Referenced by FmuInternal(), init(), and serialize_body().

◆ independent_vr_

unsigned int casadi::FmuInternal::independent_vr_
protected

Definition at line 351 of file fmu_impl.hpp.

Referenced by init(), and set_all().

◆ instance_name_

std::string casadi::FmuInternal::instance_name_
protected

◆ instantiation_token_

std::string casadi::FmuInternal::instantiation_token_
protected

◆ ired_

std::vector<std::vector<size_t> > casadi::FmuInternal::ired_
protected

◆ jac_sp_

Sparsity casadi::FmuInternal::jac_sp_
protected

Definition at line 367 of file fmu_impl.hpp.

Referenced by FmuInternal(), init(), jac_sparsity(), and serialize_body().

◆ li_

Importer casadi::FmuInternal::li_
protected

Definition at line 342 of file fmu_impl.hpp.

Referenced by finalize(), and load_function().

◆ logging_on_

bool casadi::FmuInternal::logging_on_
protected

◆ max_in_

std::vector<double> casadi::FmuInternal::max_in_
protected

Definition at line 356 of file fmu_impl.hpp.

Referenced by desc_in(), eval_fd(), FmuInternal(), init(), and serialize_body().

◆ max_out_

std::vector<double> casadi::FmuInternal::max_out_
protected

Definition at line 356 of file fmu_impl.hpp.

Referenced by FmuInternal(), init(), and serialize_body().

◆ min_in_

std::vector<double> casadi::FmuInternal::min_in_
protected

Definition at line 355 of file fmu_impl.hpp.

Referenced by desc_in(), eval_fd(), FmuInternal(), init(), and serialize_body().

◆ min_out_

std::vector<double> casadi::FmuInternal::min_out_
protected

Definition at line 355 of file fmu_impl.hpp.

Referenced by FmuInternal(), init(), and serialize_body().

◆ name_

std::string casadi::FmuInternal::name_
protected

Definition at line 305 of file fmu_impl.hpp.

Referenced by disp(), FmuInternal(), and serialize_body().

◆ nominal_in_

std::vector<double> casadi::FmuInternal::nominal_in_
protected

Definition at line 354 of file fmu_impl.hpp.

Referenced by all_nominal_in(), desc_in(), eval_fd(), FmuInternal(), init(), and serialize_body().

◆ nominal_out_

std::vector<double> casadi::FmuInternal::nominal_out_
protected

Definition at line 354 of file fmu_impl.hpp.

Referenced by all_nominal_out(), eval_fd(), FmuInternal(), init(), and serialize_body().

◆ number_of_event_indicators_

casadi_int casadi::FmuInternal::number_of_event_indicators_
protected

Definition at line 330 of file fmu_impl.hpp.

Referenced by FmuInternal(), init(), and serialize_body().

◆ nx_

size_t casadi::FmuInternal::nx_
protected

◆ oind_

std::vector<size_t> casadi::FmuInternal::oind_
protected

Definition at line 345 of file fmu_impl.hpp.

Referenced by FmuInternal(), init(), init_mem(), and serialize_body().

◆ oind_map_

std::vector<size_t> casadi::FmuInternal::oind_map_
protected

Definition at line 345 of file fmu_impl.hpp.

Referenced by FmuInternal(), init(), and serialize_body().

◆ ored_

std::vector<std::vector<size_t> > casadi::FmuInternal::ored_
protected

◆ provides_adjoint_derivatives_

bool casadi::FmuInternal::provides_adjoint_derivatives_
protected

Definition at line 333 of file fmu_impl.hpp.

Referenced by FmuInternal(), init(), casadi::Fmu3::load_functions(), and serialize_body().

◆ provides_directional_derivatives_

bool casadi::FmuInternal::provides_directional_derivatives_
protected

◆ resource_

Resource casadi::FmuInternal::resource_
protected

Definition at line 302 of file fmu_impl.hpp.

Referenced by finalize(), FmuInternal(), init(), and serialize_body().

◆ resource_loc_

std::string casadi::FmuInternal::resource_loc_
protected

◆ scheme_

std::map<std::string, std::vector<size_t> > casadi::FmuInternal::scheme_
protected

Definition at line 309 of file fmu_impl.hpp.

Referenced by FmuInternal(), init(), and serialize_body().

◆ scheme_in_

std::vector<std::string> casadi::FmuInternal::scheme_in_
protected

Definition at line 308 of file fmu_impl.hpp.

Referenced by FmuInternal(), index_in(), init(), and serialize_body().

◆ scheme_out_

std::vector<std::string> casadi::FmuInternal::scheme_out_
protected

Definition at line 308 of file fmu_impl.hpp.

Referenced by FmuInternal(), index_out(), init(), and serialize_body().

◆ start_time_

double casadi::FmuInternal::start_time_
protected

Definition at line 339 of file fmu_impl.hpp.

Referenced by finalize(), FmuInternal(), init(), and serialize_body().

◆ value_in_

std::vector<double> casadi::FmuInternal::value_in_
protected

◆ vn_in_

std::vector<std::string> casadi::FmuInternal::vn_in_
protected

Definition at line 357 of file fmu_impl.hpp.

Referenced by desc_in(), eval_fd(), FmuInternal(), init(), and serialize_body().

◆ vn_out_

std::vector<std::string> casadi::FmuInternal::vn_out_
protected

Definition at line 357 of file fmu_impl.hpp.

Referenced by eval_fd(), FmuInternal(), init(), and serialize_body().

◆ vr_in_

std::vector<unsigned int> casadi::FmuInternal::vr_in_
protected

◆ vr_out_

std::vector<unsigned int> casadi::FmuInternal::vr_out_
protected

Definition at line 358 of file fmu_impl.hpp.

Referenced by FmuInternal(), gather_io(), init(), and serialize_body().

◆ warning_fired_discrete_states_need_update_

bool casadi::FmuInternal::warning_fired_discrete_states_need_update_
mutableprotected

Definition at line 369 of file fmu_impl.hpp.

Referenced by discrete_states_iter(), and finalize().

◆ warning_fired_next_event_time_defined_

bool casadi::FmuInternal::warning_fired_next_event_time_defined_
mutableprotected

Definition at line 373 of file fmu_impl.hpp.

Referenced by discrete_states_iter(), and finalize().

◆ warning_fired_nominals_of_continuous_states_changed_

bool casadi::FmuInternal::warning_fired_nominals_of_continuous_states_changed_
mutableprotected

Definition at line 371 of file fmu_impl.hpp.

Referenced by discrete_states_iter(), and finalize().

◆ warning_fired_terminate_simulation_

bool casadi::FmuInternal::warning_fired_terminate_simulation_
mutableprotected

Definition at line 370 of file fmu_impl.hpp.

Referenced by discrete_states_iter(), and finalize().

◆ warning_fired_values_of_continuous_states_changed_

bool casadi::FmuInternal::warning_fired_values_of_continuous_states_changed_
mutableprotected

Definition at line 372 of file fmu_impl.hpp.

Referenced by discrete_states_iter(), and finalize().


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