List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
casadi::Fmu3 Class Reference

Interface to a binary FMU, adhering to FMI version 2.0. More...

#include <fmu3.hpp>

Detailed Description

Author
Joel Andersson
Date
2024

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

Definition at line 42 of file fmu3.hpp.

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

Classes

struct  Value
 

Public Types

using weak_ref_type = WeakRefInternal
 

Public Member Functions

 Fmu3 (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)
 
 ~Fmu3 () override
 Destructor. More...
 
std::string class_name () const override
 Get type name. More...
 
void init (const DaeBuilderInternal *dae) override
 
void load_functions () override
 
std::string system_infix () const override
 
void * instantiate () const override
 
void free_instance (void *instance) const override
 
int reset (void *instance)
 
int enter_initialization_mode (void *instance) const override
 
int exit_initialization_mode (void *instance) const override
 
int enter_continuous_time_mode (void *instance) const override
 
int update_discrete_states (void *instance, EventMemory *eventmem) const override
 
int set_real (void *instance, const unsigned int *vr, size_t n_vr, const double *values, size_t n_values) const override
 
int get_real (void *instance, const unsigned int *vr, size_t n_vr, double *values, size_t n_values) const override
 
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 override
 
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 override
 
int set_values (void *instance) const override
 
int get_aux (void *instance) override
 
void get_stats (FmuMemory *m, Dict *stats, const std::vector< std::string > &name_in, const InputStruct *in) const override
 Get stats. More...
 
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
 
template<typename T >
T * load_function (const std::string &symname)
 
int discrete_states_iter (void *instance) const
 
int init_mem (FmuMemory *m) const
 Initalize memory block. More...
 
void set (FmuMemory *m, size_t ind, const double *value) const
 
void request (FmuMemory *m, size_t ind) 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
 
void serialize (SerializingStream &s) const
 
virtual void serialize_type (SerializingStream &s) const
 
virtual void serialize_body (SerializingStream &s) const
 
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 void log_message_callback (fmi3InstanceEnvironment instanceEnvironment, fmi3Status status, fmi3String category, fmi3String message)
 
static std::string dll_suffix ()
 
static FmuInternaldeserialize (DeserializingStream &s)
 

Public Attributes

std::vector< fmi3ValueReference > vr_real_
 
std::vector< fmi3ValueReference > vr_integer_
 
std::vector< fmi3ValueReference > vr_boolean_
 
std::vector< fmi3ValueReference > vr_string_
 
std::vector< fmi3Float64 > init_real_
 
std::vector< fmi3Int32 > init_integer_
 
std::vector< fmi3Boolean > init_boolean_
 
std::vector< std::string > init_string_
 
std::vector< std::string > vn_aux_real_
 
std::vector< std::string > vn_aux_integer_
 
std::vector< std::string > vn_aux_boolean_
 
std::vector< std::string > vn_aux_string_
 
std::vector< fmi3ValueReference > vr_aux_real_
 
std::vector< fmi3ValueReference > vr_aux_integer_
 
std::vector< fmi3ValueReference > vr_aux_boolean_
 
std::vector< fmi3ValueReference > vr_aux_string_
 
fmi3InstantiateModelExchangeTYPE * instantiate_model_exchange_
 
fmi3FreeInstanceTYPE * free_instance_
 
fmi3ResetTYPE * reset_
 
fmi3EnterInitializationModeTYPE * enter_initialization_mode_
 
fmi3ExitInitializationModeTYPE * exit_initialization_mode_
 
fmi3EnterContinuousTimeModeTYPE * enter_continuous_time_mode_
 
fmi3SetTimeTYPE * set_time_
 
fmi3GetFloat64TYPE * get_float64_
 
fmi3SetFloat64TYPE * set_float64_
 
fmi3GetBooleanTYPE * get_boolean_
 
fmi3SetBooleanTYPE * set_boolean_
 
fmi3GetInt32TYPE * get_int32_
 
fmi3SetInt32TYPE * set_int32_
 
fmi3GetStringTYPE * get_string_
 
fmi3SetStringTYPE * set_string_
 
fmi3GetDirectionalDerivativeTYPE * get_directional_derivative_
 
fmi3GetAdjointDerivativeTYPE * get_adjoint_derivative_
 
fmi3UpdateDiscreteStatesTYPE * update_discrete_states_
 
Value aux_value_
 

Protected Member Functions

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_
 
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_
 
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_
 

Member Typedef Documentation

◆ weak_ref_type

Definition at line 152 of file shared_object.hpp.

Constructor & Destructor Documentation

◆ Fmu3()

casadi::Fmu3::Fmu3 ( 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 457 of file fmu3.cpp.

462  : FmuInternal(name, scheme_in, scheme_out, scheme, aux) {
464  free_instance_ = 0;
465  reset_ = 0;
469  set_time_ = 0;
470  set_float64_ = 0;
471  set_boolean_ = 0;
472  get_float64_ = 0;
476 }
fmi3InstantiateModelExchangeTYPE * instantiate_model_exchange_
Definition: fmu3.hpp:77
fmi3ExitInitializationModeTYPE * exit_initialization_mode_
Definition: fmu3.hpp:81
fmi3SetFloat64TYPE * set_float64_
Definition: fmu3.hpp:85
fmi3EnterContinuousTimeModeTYPE * enter_continuous_time_mode_
Definition: fmu3.hpp:82
fmi3SetTimeTYPE * set_time_
Definition: fmu3.hpp:83
fmi3GetFloat64TYPE * get_float64_
Definition: fmu3.hpp:84
fmi3SetBooleanTYPE * set_boolean_
Definition: fmu3.hpp:87
fmi3GetDirectionalDerivativeTYPE * get_directional_derivative_
Definition: fmu3.hpp:92
fmi3ResetTYPE * reset_
Definition: fmu3.hpp:79
fmi3GetAdjointDerivativeTYPE * get_adjoint_derivative_
Definition: fmu3.hpp:93
fmi3UpdateDiscreteStatesTYPE * update_discrete_states_
Definition: fmu3.hpp:94
fmi3FreeInstanceTYPE * free_instance_
Definition: fmu3.hpp:78
fmi3EnterInitializationModeTYPE * enter_initialization_mode_
Definition: fmu3.hpp:80
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: fmu.cpp:432

References enter_continuous_time_mode_, enter_initialization_mode_, exit_initialization_mode_, free_instance_, get_adjoint_derivative_, get_directional_derivative_, get_float64_, instantiate_model_exchange_, reset_, set_boolean_, set_float64_, set_time_, and update_discrete_states_.

◆ ~Fmu3()

casadi::Fmu3::~Fmu3 ( )
override

Definition at line 32 of file fmu3.cpp.

32  {
33 }

Member Function Documentation

◆ all_nominal_in()

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

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

Definition at line 665 of file fmu.cpp.

665  {
666  auto&& ind = ired_.at(i);
667  std::vector<double> n;
668  n.reserve(ind.size());
669  for (size_t k : ind) n.push_back(nominal_in_.at(k));
670  return n;
671 }
std::vector< std::vector< size_t > > ired_
Definition: fmu_impl.hpp:327
std::vector< double > nominal_in_
Definition: fmu_impl.hpp:317

References casadi::FmuInternal::ired_, and casadi::FmuInternal::nominal_in_.

◆ all_nominal_out()

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

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

Definition at line 673 of file fmu.cpp.

673  {
674  auto&& ind = ored_.at(i);
675  std::vector<double> n;
676  n.reserve(ind.size());
677  for (size_t k : ind) n.push_back(nominal_out_.at(k));
678  return n;
679 }
std::vector< std::vector< size_t > > ored_
Definition: fmu_impl.hpp:327
std::vector< double > nominal_out_
Definition: fmu_impl.hpp:317

References casadi::FmuInternal::nominal_out_, and casadi::FmuInternal::ored_.

◆ class_name()

std::string casadi::Fmu3::class_name ( ) const
inlineoverridevirtual

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

Implements casadi::SharedObjectInternal.

Definition at line 55 of file fmu3.hpp.

55 { return "Fmu3";}

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

162  {
163  // Note: i != this because of something something multiple inheritance
164  return str( (casadi_int)(i)) + "/" + static_cast<const Internal*>(this)->class_name();
165  }
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
inherited

Definition at line 694 of file fmu.cpp.

694  {
695  // Create description
696  if (more) {
697  // Detailed description
698  std::stringstream ss;
699  ss << vn_in_[id] << " = " << m->ibuf_[id] << " (nominal " << nominal_in_[id]
700  << ", min " << min_in_[id] << ", max " << max_in_[id] << ")";
701  return ss.str();
702  } else {
703  return vn_in_[id];
704  }
705 }
std::vector< double > max_in_
Definition: fmu_impl.hpp:319
std::vector< std::string > vn_in_
Definition: fmu_impl.hpp:320
std::vector< double > min_in_
Definition: fmu_impl.hpp:318

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

Referenced by casadi::FmuInternal::eval_fd().

◆ deserialize()

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

Definition at line 1417 of file fmu.cpp.

1417  {
1418  std::string class_name;
1419  s.unpack("FmuInternal::type", class_name);
1420  if (class_name=="Fmu2") {
1421 #ifdef WITH_FMI2
1422  return Fmu2::deserialize(s);
1423 #else
1424  casadi_error("CasADi was not compiled with WITH_FMI2=ON.");
1425 #endif // WITH_FMI2
1426  } else if (class_name=="Fmu3") {
1427 #ifdef WITH_FMI3
1428  casadi_error("Not implemented");
1429 #else
1430  casadi_error("CasADi was not compiled with WITH_FMI2=ON.");
1431 #endif // WITH_FMI3
1432  } else {
1433  casadi_error("Cannot deserialize type '" + class_name + "'");
1434  }
1435 }
static Fmu2 * deserialize(DeserializingStream &s)
Definition: fmu2.cpp:468
virtual std::string class_name() const =0
Readable name of the internal class.

References casadi::SharedObjectInternal::class_name(), casadi::Fmu2::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
inherited

Definition at line 1075 of file fmu.cpp.

1075  {
1076  // Helper function: update_discrete_states
1077  EventMemory eventmem;
1078  const size_t max_update_iter = 10;
1079  for (size_t update_iter = 0; update_iter < max_update_iter; ++update_iter) {
1080  if (update_discrete_states(instance, &eventmem)) {
1081  casadi_warning("update_discrete_states");
1082  return 1;
1083  }
1084  // Not implemented
1085  if (eventmem.discrete_states_need_update)
1086  casadi_warning("Discrete state update not implemented");
1087  if (eventmem.terminate_simulation)
1088  casadi_warning("Terminate solution not implemented");
1089  if (eventmem.nominals_of_continuous_states_changed)
1090  casadi_warning("Update of nominals of states not implemented");
1091  if (eventmem.values_of_continuous_states_changed)
1092  casadi_warning("Update of values of continuous states not implemented");
1093  if (eventmem.next_event_time_defined)
1094  casadi_warning("Ignoring next time defined: " + std::to_string(eventmem.next_event_time));
1095  // Successful return
1096  if (!eventmem.discrete_states_need_update) {
1097  return 0;
1098  }
1099  }
1100  // Too many iterations
1101  casadi_warning("Discrete state update failed");
1102  return 1;
1103 }
virtual int update_discrete_states(void *instance, EventMemory *eventmem) const =0

References casadi::EventMemory::discrete_states_need_update, casadi::EventMemory::next_event_time, casadi::EventMemory::next_event_time_defined, casadi::EventMemory::nominals_of_continuous_states_changed, casadi::EventMemory::terminate_simulation, casadi::FmuInternal::update_discrete_states(), and casadi::EventMemory::values_of_continuous_states_changed.

Referenced by casadi::FmuInternal::init_mem().

◆ disp()

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

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

Implements casadi::SharedObjectInternal.

Definition at line 609 of file fmu.cpp.

609  {
610  (void)more; // unused
611  stream << name_ << " " << class_name();
612 }
std::string name_
Instance name.
Definition: fmu_impl.hpp:274

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

◆ dll_suffix()

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

Definition at line 681 of file fmu.cpp.

681  {
682 #if defined(_WIN32)
683  // Windows system
684  return ".dll";
685 #elif defined(__APPLE__)
686  // OSX
687  return ".dylib";
688 #else
689  // Linux
690  return ".so";
691 #endif
692 }

Referenced by casadi::FmuInternal::finalize().

◆ enter_continuous_time_mode()

int casadi::Fmu3::enter_continuous_time_mode ( void *  instance) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 258 of file fmu3.cpp.

258  {
259  auto c = static_cast<fmi3Instance>(instance);
260  fmi3Status status = enter_continuous_time_mode_(c);
261  if (status != fmi3OK) {
262  casadi_warning("fmi3EnterContinuousTimeMode failed");
263  return 1;
264  }
265  return 0;
266 }

References enter_continuous_time_mode_.

◆ enter_initialization_mode()

int casadi::Fmu3::enter_initialization_mode ( void *  instance) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 238 of file fmu3.cpp.

238  {
239  auto c = static_cast<fmi3Instance>(instance);
240  fmi3Status status = enter_initialization_mode_(c, fmutol_ > 0, fmutol_, 0., fmi3True, 1.);
241  if (status != fmi3OK) {
242  casadi_warning("fmi3EnterInitializationMode failed: " + str(status));
243  return 1;
244  }
245  return 0;
246 }

References enter_initialization_mode_, casadi::FmuInternal::fmutol_, and casadi::str().

◆ eval()

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

Definition at line 1179 of file fmu.cpp.

1179  {
1180  // Gather inputs and outputs
1181  gather_io(m);
1182  // Number of inputs and outputs
1183  size_t n_set = m->id_in_.size();
1184  size_t n_out = m->id_out_.size();
1185  // Set all variables
1186  if (set_real(m->instance, get_ptr(m->vr_in_), n_set, get_ptr(m->v_in_), n_set)) {
1187  casadi_warning("Setting FMU variables failed");
1188  return 1;
1189  }
1190  // Quick return if nothing requested
1191  if (n_out == 0) return 0;
1192  // Calculate all variables
1193  m->v_out_.resize(n_out);
1194  if (get_real(m->instance, get_ptr(m->vr_out_), n_out, get_ptr(m->v_out_), n_out)) {
1195  casadi_warning("Evaluation failed");
1196  return 1;
1197  }
1198  // Collect requested variables
1199  auto it = m->v_out_.begin();
1200  for (size_t id : m->id_out_) {
1201  m->obuf_[id] = *it++;
1202  }
1203  // Successful return
1204  return 0;
1205 }
virtual int get_real(void *instance, const unsigned int *vr, size_t n_vr, double *values, size_t n_values) const =0
void gather_io(FmuMemory *m) const
Definition: fmu.cpp:1251
virtual int set_real(void *instance, const unsigned int *vr, size_t n_vr, const double *values, size_t n_values) const =0
size_t n_out() const
Get the number of scheme outputs.
Definition: fmu_impl.hpp:129
T * get_ptr(std::vector< T > &v)
Get a pointer to the data contained in the vector.

References casadi::FmuInternal::gather_io(), casadi::get_ptr(), casadi::FmuInternal::get_real(), casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::instance, casadi::FmuInternal::n_out(), casadi::FmuMemory::obuf_, casadi::FmuInternal::set_real(), casadi::FmuMemory::v_in_, casadi::FmuMemory::v_out_, casadi::FmuMemory::vr_in_, and casadi::FmuMemory::vr_out_.

◆ eval_ad()

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

Definition at line 746 of file fmu.cpp.

746  {
747  // Number of inputs and outputs
748  size_t n_known = m->id_in_.size();
749  size_t n_unknown = m->id_out_.size();
750  // Quick return if nothing to be calculated
751  if (n_unknown == 0) return 0;
752  // Evalute (should not be necessary)
753  if (get_real(m->instance, get_ptr(m->vr_out_), n_unknown, get_ptr(m->v_out_), n_unknown)) {
754  casadi_warning("FMU evaluation failed");
755  return 1;
756  }
757  // Evaluate directional derivatives
758  if (get_directional_derivative(m->instance,
759  get_ptr(m->vr_out_), n_unknown,
760  get_ptr(m->vr_in_), n_known,
761  get_ptr(m->d_in_), n_known,
762  get_ptr(m->d_out_), n_unknown)) {
763  casadi_warning("FMU directional derivative failed");
764  return 1;
765  }
766  // Collect requested variables
767  auto it = m->d_out_.begin();
768  for (size_t id : m->id_out_) {
769  m->osens_[id] = *it++;
770  }
771  // Successful return
772  return 0;
773 }
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

References casadi::FmuMemory::d_in_, casadi::FmuMemory::d_out_, casadi::FmuInternal::get_directional_derivative(), casadi::get_ptr(), casadi::FmuInternal::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 casadi::FmuInternal::eval_fwd().

◆ eval_adj()

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

Definition at line 723 of file fmu.cpp.

723  {
724  // Gather input and output indices
725  gather_adj(m);
726  // Quick return if nothing to be calculated
727  if (m->id_in_.size() == 0) return 0;
728  // Evaluate adjoint derivatives
729  if (get_adjoint_derivative(m->instance,
730  get_ptr(m->vr_out_), m->id_out_.size(),
731  get_ptr(m->vr_in_), m->id_in_.size(),
732  get_ptr(m->d_out_), m->id_out_.size(),
733  get_ptr(m->d_in_), m->id_in_.size())) {
734  casadi_warning("FMU adjoint derivative failed");
735  return 1;
736  }
737  // Collect requested variables
738  auto it = m->d_in_.begin();
739  for (size_t id : m->id_in_) {
740  m->isens_[id] = *it++;
741  }
742  // Successful return
743  return 0;
744 }
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:562
void gather_adj(FmuMemory *m) const
Definition: fmu.cpp:1295

References casadi::FmuMemory::d_in_, casadi::FmuMemory::d_out_, casadi::FmuInternal::gather_adj(), casadi::FmuInternal::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
inherited

Definition at line 775 of file fmu.cpp.

775  {
776  // Number of inputs and outputs
777  size_t n_known = m->id_in_.size();
778  size_t n_unknown = m->id_out_.size();
779  // Quick return if nothing to be calculated
780  if (n_unknown == 0) return 0;
781  // Evalute (should not be necessary)
782  if (get_real(m->instance, get_ptr(m->vr_out_), n_unknown, get_ptr(m->v_out_), n_unknown)) {
783  casadi_warning("Evaluating FMU failed");
784  return 1;
785  }
786  // Make outputs dimensionless
787  for (size_t k = 0; k < n_unknown; ++k) m->v_out_[k] /= nominal_out_[m->id_out_[k]];
788  // Number of points in FD stencil
789  casadi_int n_points = n_fd_points(m->self.fd_);
790  // Offset for points
791  casadi_int offset = fd_offset(m->self.fd_);
792  // Memory for perturbed outputs
793  m->fd_out_.resize(n_points * n_unknown);
794  // Which inputs are in bounds
795  m->in_bounds_.resize(n_known);
796  // Memory for perturbed inputs
797  m->v_pert_.resize(n_known);
798  // Do any any inputs need flipping?
799  m->flip_.resize(n_known);
800  size_t first_flip = -1;
801  for (size_t i = 0; i < n_known; ++i) {
802  // Try to take step
803  double test = m->v_in_[i] + m->self.step_ * m->d_in_[i];
804  // Check if in bounds
805  size_t id = m->id_in_[i];
806  if (test >= min_in_[id] && test <= max_in_[id]) {
807  // Positive perturbation is fine
808  m->flip_[i] = false;
809  } else {
810  // Try negative direction instead
811  test = m->v_in_[i] - m->self.step_ * m->d_in_[i];
812  casadi_assert(test >= min_in_[id] && test <= max_in_[id],
813  "Cannot perturb " + vn_in_[id] + " at " + str(m->v_in_[i]) + ", min " + str(min_in_[id])
814  + ", max " + str(max_in_[id]) + ", nominal " + str(nominal_in_[id]));
815  m->flip_[i] = true;
816  if (first_flip == size_t(-1)) first_flip = i;
817  }
818  }
819  // If seeds are not independent, we have to flip the sign for all of the seeds or none
820  if (first_flip != size_t(-1) && !independent_seeds) {
821  // Flip the rest of the seeds
822  for (size_t i = 0; i < n_known; ++i) {
823  if (!m->flip_[i]) {
824  // Test negative direction
825  double test = m->v_in_[i] - m->self.step_ * m->d_in_[i];
826  size_t id = m->id_in_[i];
827  casadi_assert(test >= min_in_[id] && test <= max_in_[id],
828  "Cannot perturb both " + vn_in_[id] + " and " + vn_in_[first_flip]);
829  // Flip it too
830  m->flip_[i] = true;
831  }
832  }
833  }
834  // All perturbed outputs
835  const double* yk_all[5] = {0};
836 
837  // Calculate all perturbed outputs
838  for (casadi_int k = 0; k < n_points; ++k) {
839  // Where to save the perturbed outputs
840  double* yk = &m->fd_out_[n_unknown * k];
841  casadi_assert_dev(k < 5);
842  yk_all[k] = yk;
843  // If unperturbed output, quick return
844  if (k == offset) {
845  casadi_copy(get_ptr(m->v_out_), n_unknown, yk);
846  continue;
847  }
848  // Perturbation size
849  double pert = (k - offset) * m->self.step_;
850  // Perturb inputs, if allowed
851  for (size_t i = 0; i < n_known; ++i) {
852  // Try to take step
853  double sign = m->flip_[i] ? -1 : 1;
854  double test = m->v_in_[i] + pert * sign * m->d_in_[i];
855  // Check if in bounds
856  size_t id = m->id_in_[i];
857  m->in_bounds_[i] = test >= min_in_[id] && test <= max_in_[id];
858  // Take step, if allowed
859  m->v_pert_[i] = m->in_bounds_[i] ? test : m->v_in_[i];
860  }
861  // Pass perturbed inputs to FMU
862  if (set_real(m->instance, get_ptr(m->vr_in_), n_known, get_ptr(m->v_pert_), n_known)) {
863  casadi_warning("Setting FMU variables failed");
864  return 1;
865  }
866  // Evaluate perturbed FMU
867  if (get_real(m->instance, get_ptr(m->vr_out_), n_unknown, yk, n_unknown)) {
868  casadi_warning("Evaluation failed");
869  return 1;
870  }
871  // Post-process yk if there was any scaling
872  if (independent_seeds) {
873  for (size_t i = 0; i < n_unknown; ++i) {
874  // Variable id
875  size_t id = m->id_out_[i];
876  // Differentiation with respect to what variable
877  size_t wrt_id = m->wrt_.at(id);
878  // Find the corresponding input variable
879  size_t wrt_i;
880  for (wrt_i = 0; wrt_i < n_known; ++wrt_i) {
881  if (m->id_in_[wrt_i] == wrt_id) break;
882  }
883  // Check if in bounds
884  if (m->in_bounds_.at(wrt_i)) {
885  // Input was in bounds: Keep output, make dimensionless
886  yk[i] /= nominal_out_[m->id_out_[i]];
887  } else {
888  // Input was out of bounds: Discard output
889  yk[i] = nan;
890  }
891  }
892  }
893  }
894  // Restore FMU inputs
895  if (set_real(m->instance, get_ptr(m->vr_in_), n_known, get_ptr(m->v_in_), n_known)) {
896  casadi_warning("Setting FMU variables failed");
897  return 1;
898  }
899  // Step size
900  double h = m->self.step_;
901 
902  // Calculate FD approximation
903  finite_diff(m->self.fd_, yk_all, get_ptr(m->d_out_), h, n_unknown, eps);
904 
905  // If seeds are dependent, quick return
906  if (!independent_seeds) {
907  // Simpy copy the results to output (no validation)
908  for (size_t ind = 0; ind < m->id_out_.size(); ++ind) {
909  m->osens_[m->id_out_[ind]] = m->d_out_[ind];
910  }
911  return 0;
912  }
913 
914  // Collect requested variables
915  for (size_t ind = 0; ind < m->id_out_.size(); ++ind) {
916  // Variable id
917  size_t id = m->id_out_[ind];
918  // With respect to what variable
919  size_t wrt = m->wrt_[id];
920  // Find the corresponding input variable
921  size_t wrt_i;
922  for (wrt_i = 0; wrt_i < n_known; ++wrt_i) {
923  if (m->id_in_[wrt_i] == wrt) break;
924  }
925  // Nominal value
926  double n = nominal_out_[id];
927  // Get the value
928  double d_fd = m->d_out_[ind] * n;
929  // Correct sign, if necessary
930  if (m->flip_[wrt_i]) d_fd = -d_fd;
931  // Use FD instead of AD or to compare with AD
932  if (m->self.validate_forward_) {
933  // Value to compare with
934  double d_ad = m->osens_[id];
935  // Nominal value used as seed
936  d_ad /= nominal_in_[wrt];
937  d_fd /= nominal_in_[wrt];
938  // Is it a not a number?
939  bool d_is_nan = d_ad != d_ad;
940  // Magnitude of derivatives
941  double d_max = std::fmax(std::fabs(d_fd), std::fabs(d_ad));
942  // Check if NaN or error exceeds thresholds
943  if (d_is_nan || (d_max > n * m->self.abstol_
944  && std::fabs(d_ad - d_fd) > d_max * m->self.reltol_)) {
945  // Offset for printing the stencil
946  double off = m->fd_out_.at(ind + offset * n_unknown);
947  // Warning or add to file
948  std::stringstream ss;
949  if (m->self.validate_ad_file_.empty()) {
950  // Issue warning
951  ss << (d_is_nan ? "NaN" : "Inconsistent") << " derivatives of " << vn_out_[id]
952  << " w.r.t. " << desc_in(m, wrt) << ", got " << d_ad
953  << " for AD vs. " << d_fd << " for FD[" << to_string(m->self.fd_) << "].";
954  // Print the stencil:
955  ss << "\nValues for step size " << h << ": " << (n * off) << " + [";
956  for (casadi_int k = 0; k < n_points; ++k) {
957  if (k > 0) ss << ", ";
958  ss << (n * (m->fd_out_.at(ind + k * n_unknown) - off));
959  }
960  ss << "]";
961  // Issue warning
962  casadi_warning(ss.str());
963  } else {
964  // Output
965  ss << vn_out_[id] << " ";
966  // Input
967  ss << vn_in_[wrt] << " ";
968  // Value
969  ss << m->ibuf_[wrt] << " ";
970  // Noninal
971  ss << nominal_in_[wrt] << " ";
972  // Min
973  ss << min_in_[wrt] << " ";
974  // Max
975  ss << max_in_[wrt] << " ";
976  // AD
977  ss << d_ad << " ";
978  // FD
979  ss << d_fd << " ";
980  // Step
981  ss << h << " ";
982  // Offset
983  ss << off << " ";
984  // Stencil
985  ss << "[";
986  for (casadi_int k = 0; k < n_points; ++k) {
987  if (k > 0) ss << ",";
988  ss << (n * (m->fd_out_.at(ind + k * n_unknown) - off));
989  }
990  ss << "]" << std::endl;
991  // Append to file
992  std::ofstream valfile;
993  valfile.open(m->self.validate_ad_file_, std::ios_base::app);
994  valfile << ss.str();
995  }
996  }
997  } else {
998  // Use instead of AD
999  m->osens_[id] = d_fd;
1000  }
1001  }
1002  // Successful return
1003  return 0;
1004 }
std::string desc_in(FmuMemory *m, size_t id, bool more=true) const
Definition: fmu.cpp:694
std::vector< std::string > vn_out_
Definition: fmu_impl.hpp:320
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:264
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_, casadi::FmuInternal::desc_in(), casadi::eps, casadi::FmuFunction::fd_, casadi::fd_offset(), casadi::FmuMemory::fd_out_, casadi::finite_diff(), casadi::FmuMemory::flip_, casadi::get_ptr(), casadi::FmuInternal::get_real(), casadi::FmuMemory::ibuf_, casadi::FmuMemory::id_in_, casadi::FmuMemory::id_out_, casadi::FmuMemory::in_bounds_, casadi::FmuMemory::instance, casadi::FmuInternal::max_in_, casadi::FmuInternal::min_in_, casadi::n_fd_points(), casadi::nan, casadi::FmuInternal::nominal_in_, casadi::FmuInternal::nominal_out_, casadi::FmuMemory::osens_, casadi::FmuFunction::reltol_, casadi::FmuMemory::self, casadi::FmuInternal::set_real(), 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_, casadi::FmuInternal::vn_in_, casadi::FmuInternal::vn_out_, casadi::FmuMemory::vr_in_, casadi::FmuMemory::vr_out_, and casadi::FmuMemory::wrt_.

Referenced by casadi::FmuInternal::eval_fwd().

◆ eval_fwd()

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

Definition at line 707 of file fmu.cpp.

707  {
708  // Gather input and output indices
709  gather_fwd(m);
710  // Calculate derivatives using FMU directional derivative support
711  if (m->self.uses_directional_derivatives_) {
712  // Evaluate using AD
713  if (eval_ad(m)) return 1;
714  }
715  // Calculate derivatives using finite differences
716  if (!m->self.uses_directional_derivatives_ || m->self.validate_forward_) {
717  // Evaluate using FD
718  if (eval_fd(m, independent_seeds)) return 1;
719  }
720  return 0;
721 }
void gather_fwd(FmuMemory *m) const
Definition: fmu.cpp:1276
int eval_fd(FmuMemory *m, bool independent_seeds) const
Definition: fmu.cpp:775
int eval_ad(FmuMemory *m) const
Definition: fmu.cpp:746

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

◆ exit_initialization_mode()

int casadi::Fmu3::exit_initialization_mode ( void *  instance) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 248 of file fmu3.cpp.

248  {
249  auto c = static_cast<fmi3Instance>(instance);
250  fmi3Status status = exit_initialization_mode_(c);
251  if (status != fmi3OK) {
252  casadi_warning("fmi3ExitInitializationMode failed");
253  return 1;
254  }
255  return 0;
256 }

References exit_initialization_mode_.

◆ finalize()

void casadi::FmuInternal::finalize ( )
inherited

Definition at line 569 of file fmu.cpp.

569  {
570  // Load DLL
571  std::string instance_name_no_dot = instance_name_;
572  std::replace(instance_name_no_dot.begin(), instance_name_no_dot.end(), '.', '_');
573  std::string dll_path = resource_.path() + "/binaries/" + system_infix()
574  + "/" + instance_name_no_dot + dll_suffix();
575  li_ = Importer(dll_path, "dll");
576 
577  // Get FMI C functions
578  load_functions();
579 
580  // Path to resource directory
581  if (Filesystem::is_enabled()) {
582  resource_loc_ = "file://" + Filesystem::absolute(resource_.path()) + "/resources";
583  } else {
584  resource_loc_ = "file://" + resource_.path();
585  }
586 
587  // Create a temporary instance
588  void* c = instantiate();
589  // Set all values
590  if (set_values(c)) {
591  casadi_error("FmuInternal::set_values failed");
592  }
593  // Initialization mode begins
594  if (enter_initialization_mode(c)) {
595  casadi_error("FmuInternal::enter_initialization_mode failed");
596  }
597  // Get input values
598  if (get_real(c, get_ptr(vr_in_), vr_in_.size(), get_ptr(value_in_), value_in_.size())) {
599  casadi_error("FmuInternal::get_in failed");
600  }
601  // Get auxilliary variables
602  if (get_aux(c)) {
603  casadi_error("FmuInternal::get_aux failed");
604  }
605  // Free memory
606  free_instance(c);
607 }
static std::string absolute(const std::string &path)
Definition: filesystem.cpp:78
static bool is_enabled()
Definition: filesystem.cpp:83
virtual void free_instance(void *c) const =0
virtual int get_aux(void *instance)=0
virtual void load_functions()=0
std::vector< unsigned int > vr_in_
Definition: fmu_impl.hpp:321
virtual void * instantiate() const =0
virtual int set_values(void *instance) const =0
std::string resource_loc_
Definition: fmu_impl.hpp:284
static std::string dll_suffix()
Definition: fmu.cpp:681
std::vector< double > value_in_
Definition: fmu_impl.hpp:324
Importer li_
DLL.
Definition: fmu_impl.hpp:308
virtual int enter_initialization_mode(void *instance) const =0
std::string instance_name_
Definition: fmu_impl.hpp:290
virtual std::string system_infix() const =0
const std::string & path() const
Get path for a consumer.
Definition: resource.cpp:70

References casadi::Filesystem::absolute(), casadi::FmuInternal::dll_suffix(), casadi::FmuInternal::enter_initialization_mode(), casadi::FmuInternal::free_instance(), casadi::FmuInternal::get_aux(), casadi::get_ptr(), casadi::FmuInternal::get_real(), casadi::FmuInternal::instance_name_, casadi::FmuInternal::instantiate(), casadi::Filesystem::is_enabled(), casadi::FmuInternal::li_, casadi::FmuInternal::load_functions(), casadi::Resource::path(), casadi::FmuInternal::resource_, casadi::FmuInternal::resource_loc_, casadi::FmuInternal::set_values(), casadi::FmuInternal::system_infix(), casadi::FmuInternal::value_in_, and casadi::FmuInternal::vr_in_.

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

◆ free_instance()

void casadi::Fmu3::free_instance ( void *  instance) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 219 of file fmu3.cpp.

219  {
220  if (free_instance_) {
221  auto c = static_cast<fmi3Instance>(instance);
222  free_instance_(c);
223  } else {
224  casadi_warning("No free_instance function pointer available");
225  }
226 }

References free_instance_.

◆ gather_adj()

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

Definition at line 1295 of file fmu.cpp.

1295  {
1296  // Gather input and output indices
1297  gather_io(m);
1298  // Number of inputs and outputs
1299  size_t n_known = m->id_in_.size();
1300  size_t n_unknown = m->id_out_.size();
1301  // Get/clear seeds
1302  m->d_out_.clear();
1303  for (size_t id : m->id_out_) {
1304  m->d_out_.push_back(m->osens_[id]);
1305  m->osens_[id] = 0;
1306  }
1307  // Ensure at least one seed
1308  casadi_assert(n_unknown != 0, "No seeds");
1309  // Allocate result vectors
1310  m->v_in_.resize(n_known);
1311  m->d_in_.resize(n_known);
1312 }

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

Referenced by casadi::FmuInternal::eval_adj().

◆ gather_fwd()

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

Definition at line 1276 of file fmu.cpp.

1276  {
1277  // Gather input and output indices
1278  gather_io(m);
1279  // Number of inputs and outputs
1280  size_t n_known = m->id_in_.size();
1281  size_t n_unknown = m->id_out_.size();
1282  // Get/clear seeds
1283  m->d_in_.clear();
1284  for (size_t id : m->id_in_) {
1285  m->d_in_.push_back(m->isens_[id]);
1286  m->isens_[id] = 0;
1287  }
1288  // Ensure at least one seed
1289  casadi_assert(n_known != 0, "No seeds");
1290  // Allocate result vectors
1291  m->v_out_.resize(n_unknown);
1292  m->d_out_.resize(n_unknown);
1293 }

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

Referenced by casadi::FmuInternal::eval_fwd().

◆ gather_io()

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

Definition at line 1251 of file fmu.cpp.

1251  {
1252  // Collect input indices and corresponding value references and values
1253  m->id_in_.clear();
1254  m->vr_in_.clear();
1255  m->v_in_.clear();
1256  for (size_t id = 0; id < m->imarked_.size(); ++id) {
1257  if (m->imarked_[id]) {
1258  m->id_in_.push_back(id);
1259  m->vr_in_.push_back(vr_in_[id]);
1260  m->v_in_.push_back(m->ibuf_[id]);
1261  m->imarked_[id] = false;
1262  }
1263  }
1264  // Collect output indices, corresponding value references
1265  m->id_out_.clear();
1266  m->vr_out_.clear();
1267  for (size_t id = 0; id < m->omarked_.size(); ++id) {
1268  if (m->omarked_[id]) {
1269  m->id_out_.push_back(id);
1270  m->vr_out_.push_back(vr_out_[id]);
1271  m->omarked_[id] = false;
1272  }
1273  }
1274 }
std::vector< unsigned int > vr_out_
Definition: fmu_impl.hpp:321

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

Referenced by casadi::FmuInternal::eval(), casadi::FmuInternal::gather_adj(), and casadi::FmuInternal::gather_fwd().

◆ get()

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

Definition at line 1207 of file fmu.cpp.

1207  {
1208  // Save to return
1209  for (size_t id : ored_[ind]) {
1210  *value++ = m->obuf_.at(id);
1211  }
1212 }

References casadi::FmuMemory::obuf_, and casadi::FmuInternal::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
inherited

Definition at line 1059 of file fmu.cpp.

1059  {
1060  for (casadi_int i = 0; i < nsens; ++i) {
1061  *v++ = m->isens_.at(*id++);
1062  }
1063 }

References casadi::FmuMemory::isens_.

Referenced by casadi::FmuInternal::get_adj().

◆ get_adj() [2/2]

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

Definition at line 1065 of file fmu.cpp.

1065  {
1066  // Quick return if not needed
1067  if (!v) return;
1068  // Retrieve all sensitivities FIXME(@jaeandersson): should use compatible types
1069  for (size_t id : ired_[ind]) {
1070  casadi_int id2 = id;
1071  get_adj(m, 1, &id2, v++);
1072  }
1073 }
void get_adj(FmuMemory *m, casadi_int nsens, const casadi_int *id, double *v) const
Definition: fmu.cpp:1059

References casadi::FmuInternal::get_adj(), and casadi::FmuInternal::ired_.

◆ get_adjoint_derivative()

int casadi::Fmu3::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
overridevirtual

Reimplemented from casadi::FmuInternal.

Definition at line 320 of file fmu3.cpp.

322  {
323  fmi3Status status = get_adjoint_derivative_(instance, vr_out, n_out, vr_in, n_in,
324  seed, n_seed, sensitivity, n_sensitivity);
325  return status != fmi3OK;
326 }
size_t n_in() const
Get the number of scheme inputs.
Definition: fmu_impl.hpp:124

References get_adjoint_derivative_, casadi::FmuInternal::n_in(), and casadi::FmuInternal::n_out().

◆ get_aux()

int casadi::Fmu3::get_aux ( void *  instance)
overridevirtual

Implements casadi::FmuInternal.

Definition at line 372 of file fmu3.cpp.

372  {
373  auto c = static_cast<fmi3Instance>(instance);
374  // Get real auxilliary variables
375  if (!vr_aux_real_.empty()) {
376  fmi3Status status = get_float64_(c, get_ptr(vr_aux_real_), vr_aux_real_.size(),
378  if (status != fmi3OK) {
379  casadi_warning("fmi3GetFloat64 failed");
380  return 1;
381  }
382  }
383  // Get integer/enum auxilliary variables
384  if (!vr_aux_integer_.empty()) {
385  fmi3Status status = get_int32_(c, get_ptr(vr_aux_integer_), vr_aux_integer_.size(),
387  if (status != fmi3OK) {
388  casadi_warning("fmi3GetInt32 failed");
389  return 1;
390  }
391  }
392  // Get boolean auxilliary variables
393  if (!vr_aux_boolean_.empty()) {
394  casadi_error("Broken");
395  // nullptr -> get_ptr(v->v_boolean)
396  fmi3Status status = get_boolean_(c, get_ptr(vr_aux_boolean_), vr_aux_boolean_.size(),
397  nullptr, vr_aux_boolean_.size());
398  if (status != fmi3OK) {
399  casadi_warning("fmi3GetBoolean failed");
400  return 1;
401  }
402  }
403  // Get string auxilliary variables
404  for (size_t k = 0; k < vr_aux_string_.size(); ++k) {
405  fmi3ValueReference vr = vr_aux_string_[k];
406  fmi3String value = aux_value_.v_string.at(k).c_str();
407  fmi3Status status = set_string_(c, &vr, 1, &value, 1);
408  if (status != fmi3OK) {
409  casadi_error("fmi3GetString failed for value reference " + str(vr));
410  }
411  }
412  // Successful return
413  return 0;
414 }
Value aux_value_
Definition: fmu3.hpp:104
std::vector< fmi3ValueReference > vr_aux_real_
Definition: fmu3.hpp:72
std::vector< fmi3ValueReference > vr_aux_string_
Definition: fmu3.hpp:72
fmi3GetInt32TYPE * get_int32_
Definition: fmu3.hpp:88
fmi3SetStringTYPE * set_string_
Definition: fmu3.hpp:91
std::vector< fmi3ValueReference > vr_aux_boolean_
Definition: fmu3.hpp:72
std::vector< fmi3ValueReference > vr_aux_integer_
Definition: fmu3.hpp:72
fmi3GetBooleanTYPE * get_boolean_
Definition: fmu3.hpp:86
std::vector< fmi3Float64 > v_real
Definition: fmu3.hpp:98
std::vector< std::string > v_string
Definition: fmu3.hpp:101
std::vector< fmi3Int32 > v_integer
Definition: fmu3.hpp:99

References aux_value_, get_boolean_, get_float64_, get_int32_, casadi::get_ptr(), set_string_, casadi::str(), casadi::Fmu3::Value::v_integer, casadi::Fmu3::Value::v_real, casadi::Fmu3::Value::v_string, vr_aux_boolean_, vr_aux_integer_, vr_aux_real_, and vr_aux_string_.

◆ get_directional_derivative()

int casadi::Fmu3::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
overridevirtual

Implements casadi::FmuInternal.

Definition at line 312 of file fmu3.cpp.

314  {
315  fmi3Status status = get_directional_derivative_(instance, vr_out, n_out, vr_in, n_in,
316  seed, n_seed, sensitivity, n_sensitivity);
317  return status != fmi3OK;
318 }

References get_directional_derivative_, casadi::FmuInternal::n_in(), and casadi::FmuInternal::n_out().

◆ get_fwd() [1/2]

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

Definition at line 1006 of file fmu.cpp.

1006  {
1007  for (casadi_int i = 0; i < nsens; ++i) {
1008  *v++ = m->osens_.at(*id++);
1009  }
1010 }

References casadi::FmuMemory::osens_.

Referenced by casadi::FmuInternal::get_fwd().

◆ get_fwd() [2/2]

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

Definition at line 1012 of file fmu.cpp.

1012  {
1013  // Quick return if not needed
1014  if (!v) return;
1015  // Retrieve all sensitivities FIXME(@jaeandersson): should use compatible types
1016  for (size_t id : ored_[ind]) {
1017  casadi_int id2 = id;
1018  get_fwd(m, 1, &id2, v++);
1019  }
1020 }
void get_fwd(FmuMemory *m, casadi_int nsens, const casadi_int *id, double *v) const
Definition: fmu.cpp:1006

References casadi::FmuInternal::get_fwd(), and casadi::FmuInternal::ored_.

◆ get_real()

int casadi::Fmu3::get_real ( void *  instance,
const unsigned int *  vr,
size_t  n_vr,
double *  values,
size_t  n_values 
) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 306 of file fmu3.cpp.

307  {
308  fmi3Status status = get_float64_(instance, vr, n_vr, values, n_values);
309  return status != fmi3OK;
310 }

References get_float64_.

◆ get_stats()

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

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

Implements casadi::FmuInternal.

Definition at line 416 of file fmu3.cpp.

417  {
418  // To do: Use auxillary variables from last evaluation
419  (void)m; // unused
420  // Auxilliary values to be copied
421  const Value& v = aux_value_;
422  // Collect auxilliary variables
423  Dict aux;
424  // Real
425  for (size_t k = 0; k < vn_aux_real_.size(); ++k) {
426  aux[vn_aux_real_[k]] = static_cast<double>(v.v_real[k]);
427  }
428  // Integer
429  for (size_t k = 0; k < vn_aux_integer_.size(); ++k) {
430  aux[vn_aux_integer_[k]] = static_cast<casadi_int>(v.v_integer[k]);
431  }
432  // Boolean
433  for (size_t k = 0; k < vn_aux_boolean_.size(); ++k) {
434  aux[vn_aux_boolean_[k]] = static_cast<bool>(v.v_boolean[k]);
435  }
436  // String
437  for (size_t k = 0; k < vn_aux_string_.size(); ++k) {
438  aux[vn_aux_string_[k]] = v.v_string[k];
439  }
440  // Copy to stats
441  (*stats)["aux"] = aux;
442  // Loop over input variables
443  for (size_t k = 0; k < name_in.size(); ++k) {
444  // Only consider regular inputs
445  if (in[k].type == InputType::REG) {
446  // Get the indices
447  const std::vector<size_t>& iind = ired_.at(in[k].ind);
448  // Collect values
449  std::vector<double> v(iind.size());
450  for (size_t i = 0; i < v.size(); ++i) v[i] = value_in_.at(iind[i]);
451  // Save to stats
452  (*stats)[name_in[k]] = v;
453  }
454  }
455 }
std::vector< std::string > vn_aux_boolean_
Definition: fmu3.hpp:71
std::vector< std::string > vn_aux_real_
Definition: fmu3.hpp:71
std::vector< std::string > vn_aux_integer_
Definition: fmu3.hpp:71
std::vector< std::string > vn_aux_string_
Definition: fmu3.hpp:71
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.

References aux_value_, casadi::FmuInternal::ired_, casadi::REG, casadi::Fmu3::Value::v_boolean, casadi::Fmu3::Value::v_integer, casadi::Fmu3::Value::v_real, casadi::Fmu3::Value::v_string, casadi::FmuInternal::value_in_, vn_aux_boolean_, vn_aux_integer_, vn_aux_real_, and vn_aux_string_.

◆ getCount()

Definition at line 60 of file generic_shared_internal.hpp.

186  {
187  return static_cast<const Internal*>(this)->count;
188  }

◆ hess_sparsity()

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

Definition at line 654 of file fmu.cpp.

655  {
656  // Convert to casadi_int type
657  std::vector<casadi_int> r1(r.begin(), r.end());
658  std::vector<casadi_int> c1(c.begin(), c.end());
659  // Index mapping (not used)
660  std::vector<casadi_int> mapping;
661  // Get selection
662  return hess_sp_.sub(r1, c1, mapping);
663 }
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 casadi::FmuInternal::hess_sp_, and casadi::Sparsity::sub().

◆ index_in()

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

Definition at line 623 of file fmu.cpp.

623  {
624  // Linear search for the input
625  for (size_t i = 0; i < scheme_in_.size(); ++i) {
626  if (scheme_in_[i] == n) return i;
627  }
628  // Not found
629  casadi_error("No such input: " + n);
630  return -1;
631 }
std::vector< std::string > scheme_in_
Definition: fmu_impl.hpp:277

References casadi::FmuInternal::scheme_in_.

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

◆ index_out()

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

Definition at line 633 of file fmu.cpp.

633  {
634  // Linear search for the input
635  for (size_t i = 0; i < scheme_out_.size(); ++i) {
636  if (scheme_out_[i] == n) return i;
637  }
638  // Not found
639  casadi_error("No such output: " + n);
640  return -1;
641 }
std::vector< std::string > scheme_out_
Definition: fmu_impl.hpp:277

References casadi::FmuInternal::scheme_out_.

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

◆ init()

void casadi::Fmu3::init ( const DaeBuilderInternal dae)
overridevirtual

Allocate numerical values for initial auxilliary variables

Reimplemented from casadi::FmuInternal.

Definition at line 74 of file fmu3.cpp.

74  {
75  // Initialize base classes
76  FmuInternal::init(dae);
77 
78  // Collect input and parameter values
79  vr_real_.clear();
80  vr_integer_.clear();
81  vr_boolean_.clear();
82  vr_string_.clear();
83  init_real_.clear();
84  init_integer_.clear();
85  init_boolean_.clear();
86  init_string_.clear();
87  for (size_t i = 0; i < dae->n_variables(); ++i) {
88  const Variable& v = dae->variable(i);
89  casadi_assert(v.numel == 1, "Vector variable support not implemented");
90  // Skip if the wrong type
91  if (v.causality != Causality::PARAMETER && v.causality != Causality::INPUT) continue;
92  // Variable has not been set - keep default value
93  if (!v.is_set()) continue;
94  // Value reference
95  fmi3ValueReference vr = v.value_reference;
96  // Get value
97  switch (to_fmi2(v.type)) {
98  case TypeFmi2::REAL:
99  init_real_.push_back(static_cast<fmi3Float64>(v.value.front()));
100  vr_real_.push_back(vr);
101  break;
102  case TypeFmi2::INTEGER:
103  case TypeFmi2::ENUM:
104  init_integer_.push_back(static_cast<fmi3Int32>(v.value.front()));
105  vr_integer_.push_back(vr);
106  break;
107  case TypeFmi2::BOOLEAN:
108  init_boolean_.push_back(static_cast<fmi3Boolean>(v.value.front()));
109  vr_boolean_.push_back(vr);
110  break;
111  case TypeFmi2::STRING:
112  init_string_.push_back(v.stringvalue);
113  vr_string_.push_back(vr);
114  break;
115  default:
116  casadi_warning("Ignoring " + v.name + ", type: " + to_string(v.type));
117  }
118  }
119 
120  // Collect auxilliary variables
121  vn_aux_real_.clear();
122  vn_aux_integer_.clear();
123  vn_aux_boolean_.clear();
124  vn_aux_string_.clear();
125  vr_aux_real_.clear();
126  vr_aux_integer_.clear();
127  vr_aux_boolean_.clear();
128  vr_aux_string_.clear();
129  for (auto&& s : aux_) {
130  const Variable& v = dae->variable(s);
131  // Convert to expected type
132  fmi3ValueReference vr = v.value_reference;
133  // Sort by type
134  switch (to_fmi2(v.type)) {
135  case TypeFmi2::REAL:
136  // Real
137  vn_aux_real_.push_back(v.name);
138  vr_aux_real_.push_back(vr);
139  break;
140  case TypeFmi2::INTEGER:
141  case TypeFmi2::ENUM:
142  // Integer or enum
143  vn_aux_integer_.push_back(v.name);
144  vr_aux_integer_.push_back(vr);
145  break;
146  case TypeFmi2::BOOLEAN:
147  // Boolean
148  vn_aux_boolean_.push_back(v.name);
149  vr_aux_boolean_.push_back(vr);
150  break;
151  case TypeFmi2::STRING:
152  // String
153  vn_aux_string_.push_back(v.name);
154  vr_aux_string_.push_back(vr);
155  break;
156  default:
157  casadi_warning("Ignoring " + v.name + ", type: " + to_string(v.type));
158  }
159  }
160 
162  aux_value_.v_real.resize(vn_aux_real_.size());
163  aux_value_.v_integer.resize(vn_aux_integer_.size());
164  aux_value_.v_boolean.resize(vn_aux_boolean_.size());
165  aux_value_.v_string.resize(vn_aux_string_.size());
166 }
std::vector< fmi3ValueReference > vr_string_
Definition: fmu3.hpp:64
std::vector< fmi3ValueReference > vr_boolean_
Definition: fmu3.hpp:64
std::vector< fmi3Boolean > init_boolean_
Definition: fmu3.hpp:67
std::vector< fmi3Int32 > init_integer_
Definition: fmu3.hpp:66
std::vector< std::string > init_string_
Definition: fmu3.hpp:68
std::vector< fmi3ValueReference > vr_integer_
Definition: fmu3.hpp:64
std::vector< fmi3ValueReference > vr_real_
Definition: fmu3.hpp:64
std::vector< fmi3Float64 > init_real_
Definition: fmu3.hpp:65
std::vector< std::string > aux_
Definition: fmu_impl.hpp:281
virtual void init(const DaeBuilderInternal *dae)
Definition: fmu.cpp:443
struct VariableStruct Variable
TypeFmi2 to_fmi2(Type v)
std::vector< fmi3Boolean > v_boolean
Definition: fmu3.hpp:100

References casadi::FmuInternal::aux_, aux_value_, casadi::BOOLEAN, casadi::Variable::causality, casadi::ENUM, casadi::FmuInternal::init(), init_boolean_, init_integer_, init_real_, init_string_, casadi::INPUT, casadi::INTEGER, casadi::Variable::is_set(), casadi::DaeBuilderInternal::n_variables(), casadi::Variable::name, casadi::Variable::numel, casadi::PARAMETER, casadi::REAL, casadi::STRING, casadi::Variable::stringvalue, casadi::to_fmi2(), casadi::to_string(), casadi::Variable::type, casadi::Fmu3::Value::v_boolean, casadi::Fmu3::Value::v_integer, casadi::Fmu3::Value::v_real, casadi::Fmu3::Value::v_string, casadi::Variable::value, casadi::Variable::value_reference, casadi::DaeBuilderInternal::variable(), vn_aux_boolean_, vn_aux_integer_, vn_aux_real_, vn_aux_string_, vr_aux_boolean_, vr_aux_integer_, vr_aux_real_, vr_aux_string_, vr_boolean_, vr_integer_, vr_real_, and vr_string_.

◆ init_mem()

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

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

Definition at line 1105 of file fmu.cpp.

1105  {
1106  // Ensure not already instantiated
1107  casadi_assert(m->instance == 0, "Already instantiated");
1108  // Create instance
1109  m->instance = instantiate();
1110  // Set all values
1111  if (set_values(m->instance)) {
1112  casadi_warning("FmuInternal::set_values failed");
1113  return 1;
1114  }
1115  // Initialization mode begins
1116  if (enter_initialization_mode(m->instance)) return 1;
1117  // Initialization mode ends
1118  if (exit_initialization_mode(m->instance)) return 1;
1119  // Initial event iteration
1120  if (discrete_states_iter(m->instance)) return 1;
1121  // Continuous-time mode
1122  if (enter_continuous_time_mode(m->instance)) return 1;
1123  // Allocate/reset input buffer
1124  m->ibuf_.resize(iind_.size());
1125  std::fill(m->ibuf_.begin(), m->ibuf_.end(), casadi::nan);
1126  // Allocate/reset output buffer
1127  m->obuf_.resize(oind_.size());
1128  std::fill(m->obuf_.begin(), m->obuf_.end(), casadi::nan);
1129  // Maximum input or output
1130  size_t max_io = std::max(iind_.size(), oind_.size());
1131  // Allocate/reset seeds
1132  m->isens_.resize(max_io);
1133  std::fill(m->isens_.begin(), m->isens_.end(), 0);
1134  // Allocate/reset sensitivities
1135  m->osens_.resize(max_io);
1136  std::fill(m->osens_.begin(), m->osens_.end(), 0);
1137  // Allocate/reset changed
1138  m->imarked_.resize(max_io);
1139  std::fill(m->imarked_.begin(), m->imarked_.end(), false);
1140  // Allocate/reset requested
1141  m->omarked_.resize(max_io);
1142  std::fill(m->omarked_.begin(), m->omarked_.end(), false);
1143  // Also allocate memory for corresponding Jacobian entry (for debugging)
1144  m->wrt_.resize(max_io);
1145  // Successful return
1146  return 0;
1147 }
std::vector< size_t > iind_
Definition: fmu_impl.hpp:311
int discrete_states_iter(void *instance) const
Definition: fmu.cpp:1075
std::vector< size_t > oind_
Definition: fmu_impl.hpp:311
virtual int exit_initialization_mode(void *instance) const =0
virtual int enter_continuous_time_mode(void *instance) const =0

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

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

void * casadi::Fmu3::instantiate ( ) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 206 of file fmu3.cpp.

206  {
207  // Instantiate FMU
208  fmi3String instanceName = instance_name_.c_str();
209  fmi3String instantiationToken = instantiation_token_.c_str();
210  fmi3String resourcePath = resource_loc_.c_str();
211  fmi3Boolean visible = fmi3False;
212  fmi3InstanceEnvironment instanceEnvironment = 0;
213  fmi3Instance c = instantiate_model_exchange_(instanceName, instantiationToken, resourcePath,
214  visible, logging_on_, instanceEnvironment, log_message_callback);
215  if (c == 0) casadi_error("fmi3Instantiate failed");
216  return c;
217 }
static void log_message_callback(fmi3InstanceEnvironment instanceEnvironment, fmi3Status status, fmi3String category, fmi3String message)
Definition: fmu3.cpp:200
std::string instantiation_token_
Definition: fmu_impl.hpp:293

References casadi::FmuInternal::instance_name_, instantiate_model_exchange_, casadi::FmuInternal::instantiation_token_, log_message_callback(), casadi::FmuInternal::logging_on_, and casadi::FmuInternal::resource_loc_.

◆ jac_sparsity()

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

Definition at line 643 of file fmu.cpp.

644  {
645  // Convert to casadi_int type
646  std::vector<casadi_int> osub1(osub.begin(), osub.end());
647  std::vector<casadi_int> isub1(isub.begin(), isub.end());
648  // Index mapping (not used)
649  std::vector<casadi_int> mapping;
650  // Get selection
651  return jac_sp_.sub(osub1, isub1, mapping);
652 }

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

◆ load_function()

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

Definition at line 334 of file fmu_impl.hpp.

334  {
335  // Load the function
336  signal_t f = li_.get_function(symname);
337  // Ensure that it was found
338  casadi_assert(f != 0, "Cannot retrieve '" + symname + "'");
339  // Return function with the right type
340  return reinterpret_cast<T*>(f);
341 }
signal_t get_function(const std::string &symname)
Get a function pointer for numerical evaluation.
Definition: importer.cpp:79
void(* signal_t)(void)
Function pointer types for the C API.

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

◆ load_functions()

void casadi::Fmu3::load_functions ( )
overridevirtual

Implements casadi::FmuInternal.

Definition at line 168 of file fmu3.cpp.

168  {
169  instantiate_model_exchange_ = load_function<fmi3InstantiateModelExchangeTYPE>(
170  "fmi3InstantiateModelExchange");
171  free_instance_ = load_function<fmi3FreeInstanceTYPE>("fmi3FreeInstance");
172  reset_ = load_function<fmi3ResetTYPE>("fmi3Reset");
173  enter_initialization_mode_ = load_function<fmi3EnterInitializationModeTYPE>(
174  "fmi3EnterInitializationMode");
175  exit_initialization_mode_ = load_function<fmi3ExitInitializationModeTYPE>(
176  "fmi3ExitInitializationMode");
177  enter_continuous_time_mode_ = load_function<fmi3EnterContinuousTimeModeTYPE>(
178  "fmi3EnterContinuousTimeMode");
179  set_time_ = load_function<fmi3SetTimeTYPE>("fmi3SetTime");
180  get_float64_ = load_function<fmi3GetFloat64TYPE>("fmi3GetFloat64");
181  set_float64_ = load_function<fmi3SetFloat64TYPE>("fmi3SetFloat64");
182  get_int32_ = load_function<fmi3GetInt32TYPE>("fmi3GetInt32");
183  set_int32_ = load_function<fmi3SetInt32TYPE>("fmi3SetInt32");
184  get_boolean_ = load_function<fmi3GetBooleanTYPE>("fmi3GetBoolean");
185  set_boolean_ = load_function<fmi3SetBooleanTYPE>("fmi3SetBoolean");
186  get_string_ = load_function<fmi3GetStringTYPE>("fmi3GetString");
187  set_string_ = load_function<fmi3SetStringTYPE>("fmi3SetString");
190  load_function<fmi3GetDirectionalDerivativeTYPE>("fmi3GetDirectionalDerivative");
191  }
194  load_function<fmi3GetAdjointDerivativeTYPE>("fmi3GetAdjointDerivative");
195  }
197  load_function<fmi3UpdateDiscreteStatesTYPE>("fmi3UpdateDiscreteStates");
198 }
fmi3GetStringTYPE * get_string_
Definition: fmu3.hpp:90
fmi3SetInt32TYPE * set_int32_
Definition: fmu3.hpp:89
bool provides_adjoint_derivatives_
Definition: fmu_impl.hpp:302
bool provides_directional_derivatives_
Definition: fmu_impl.hpp:302

References enter_continuous_time_mode_, enter_initialization_mode_, exit_initialization_mode_, free_instance_, get_adjoint_derivative_, get_boolean_, get_directional_derivative_, get_float64_, get_int32_, get_string_, instantiate_model_exchange_, casadi::FmuInternal::provides_adjoint_derivatives_, casadi::FmuInternal::provides_directional_derivatives_, reset_, set_boolean_, set_float64_, set_int32_, set_string_, set_time_, and update_discrete_states_.

◆ log_message_callback()

void casadi::Fmu3::log_message_callback ( fmi3InstanceEnvironment  instanceEnvironment,
fmi3Status  status,
fmi3String  category,
fmi3String  message 
)
static

Definition at line 200 of file fmu3.cpp.

201  {
202  // Print message content
203  uout() << "[" << category << "] " << message << std::endl;
204 }
std::ostream & uout()

References casadi::uout().

Referenced by instantiate().

◆ n_in()

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

◆ n_out()

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

◆ request()

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

Definition at line 1170 of file fmu.cpp.

1170  {
1171  for (size_t id : ored_[ind]) {
1172  // Mark as requested
1173  m->omarked_.at(id) = true;
1174  // Also log corresponding input index
1175  m->wrt_.at(id) = -1;
1176  }
1177 }

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

◆ request_adj() [1/2]

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

Definition at line 1050 of file fmu.cpp.

1050  {
1051  // Request all sensitivities FIXME(@jaeandersson): should use compatible types
1052  casadi_int wrt_id = -1;
1053  for (size_t id : ired_[ind]) {
1054  casadi_int id2 = id;
1055  request_adj(m, 1, &id2, &wrt_id);
1056  }
1057 }
void request_adj(FmuMemory *m, casadi_int nsens, const casadi_int *id, const casadi_int *wrt_id) const
Definition: fmu.cpp:1041

References casadi::FmuInternal::ired_, and casadi::FmuInternal::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
inherited

Definition at line 1041 of file fmu.cpp.

1042  {
1043  for (casadi_int i = 0; i < nsens; ++i) {
1044  m->imarked_.at(*id) = true;
1045  m->wrt_.at(*id) = *wrt_id++;
1046  id++;
1047  }
1048 }

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

Referenced by casadi::FmuInternal::request_adj().

◆ request_fwd() [1/2]

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

Definition at line 1242 of file fmu.cpp.

1242  {
1243  // Request all sensitivities FIXME(@jaeandersson): should use compatible types
1244  casadi_int wrt_id = -1;
1245  for (size_t id : ored_[ind]) {
1246  casadi_int id2 = id;
1247  request_fwd(m, 1, &id2, &wrt_id);
1248  }
1249 }
void request_fwd(FmuMemory *m, casadi_int nsens, const casadi_int *id, const casadi_int *wrt_id) const
Definition: fmu.cpp:1233

References casadi::FmuInternal::ored_, and casadi::FmuInternal::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
inherited

Definition at line 1233 of file fmu.cpp.

1234  {
1235  for (casadi_int i = 0; i < nsens; ++i) {
1236  m->omarked_.at(*id) = true;
1237  m->wrt_.at(*id) = *wrt_id++;
1238  id++;
1239  }
1240 }

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

Referenced by casadi::FmuInternal::request_fwd().

◆ reset()

int casadi::Fmu3::reset ( void *  instance)

Definition at line 228 of file fmu3.cpp.

228  {
229  auto c = static_cast<fmi3Instance>(instance);
230  fmi3Status status = reset_(c);
231  if (status != fmi3OK) {
232  casadi_warning("fmi3Reset failed");
233  return 1;
234  }
235  return 0;
236 }

References reset_.

◆ serialize()

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

Definition at line 1328 of file fmu.cpp.

1328  {
1329  serialize_type(s);
1330  serialize_body(s);
1331 }
virtual void serialize_body(SerializingStream &s) const
Definition: fmu.cpp:1337
virtual void serialize_type(SerializingStream &s) const
Definition: fmu.cpp:1333

References casadi::FmuInternal::serialize_body(), and casadi::FmuInternal::serialize_type().

◆ serialize_body()

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

Reimplemented in casadi::Fmu2.

Definition at line 1337 of file fmu.cpp.

1337  {
1338  s.version("FmuInternal", 3);
1339  s.pack("FmuInternal::name", name_);
1340  s.pack("FmuInternal::scheme_in", scheme_in_);
1341  s.pack("FmuInternal::scheme_out", scheme_out_);
1342  s.pack("FmuInternal::scheme", scheme_);
1343  s.pack("FmuInternal::aux", aux_);
1344  s.pack("FmuInternal::iind", iind_);
1345  s.pack("FmuInternal::iind_map", iind_map_);
1346  s.pack("FmuInternal::oind", oind_);
1347  s.pack("FmuInternal::oind_map", oind_map_);
1348  s.pack("FmuInternal::nominal_in", nominal_in_);
1349  s.pack("FmuInternal::nominal_out", nominal_out_);
1350  s.pack("FmuInternal::min_in", min_in_);
1351  s.pack("FmuInternal::min_out", min_out_);
1352  s.pack("FmuInternal::max_in", max_in_);
1353  s.pack("FmuInternal::max_out", max_out_);
1354  s.pack("FmuInternal::vn_in", vn_in_);
1355  s.pack("FmuInternal::vn_out", vn_out_);
1356  s.pack("FmuInternal::vr_in", vr_in_);
1357  s.pack("FmuInternal::vr_out", vr_out_);
1358 
1359  s.pack("FmuInternal::value_in", value_in_);
1360  s.pack("FmuInternal::ired", ired_);
1361  s.pack("FmuInternal::ored", ored_);
1362  s.pack("FmuInternal::jac_sp", jac_sp_);
1363  s.pack("FmuInternal::hess_sp", hess_sp_);
1364 
1365  s.pack("FmuInternal::resource", resource_);
1366  s.pack("FmuInternal::fmutol", fmutol_);
1367  s.pack("FmuInternal::instance_name", instance_name_);
1368  s.pack("FmuInternal::instantiation_token", instantiation_token_);
1369  s.pack("FmuInternal::logging_on", logging_on_);
1370  s.pack("FmuInternal::number_of_event_indicators", number_of_event_indicators_);
1371  s.pack("FmuInternal::provides_directional_derivatives", provides_directional_derivatives_);
1372  s.pack("FmuInternal::provides_adjoint_derivatives", provides_adjoint_derivatives_);
1373  s.pack("FmuInternal::can_be_instantiated_only_once_per_process",
1375 }
std::map< std::string, std::vector< size_t > > scheme_
Definition: fmu_impl.hpp:278
std::vector< double > min_out_
Definition: fmu_impl.hpp:318
bool can_be_instantiated_only_once_per_process_
Definition: fmu_impl.hpp:305
std::vector< double > max_out_
Definition: fmu_impl.hpp:319
casadi_int number_of_event_indicators_
Definition: fmu_impl.hpp:299
std::vector< size_t > oind_map_
Definition: fmu_impl.hpp:311
std::vector< size_t > iind_map_
Definition: fmu_impl.hpp:311

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

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

◆ serialize_type()

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

Definition at line 1333 of file fmu.cpp.

1333  {
1334  s.pack("FmuInternal::type", class_name());
1335 }

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

Referenced by casadi::FmuInternal::serialize().

◆ set()

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

Definition at line 1149 of file fmu.cpp.

1149  {
1150  if (value) {
1151  // Argument is given
1152  for (size_t id : ired_[ind]) {
1153  if (*value != m->ibuf_.at(id)) {
1154  m->ibuf_.at(id) = *value;
1155  m->imarked_.at(id) = true;
1156  }
1157  value++;
1158  }
1159  } else {
1160  // Argument is null - all zeros
1161  for (size_t id : ired_[ind]) {
1162  if (0 != m->ibuf_.at(id)) {
1163  m->ibuf_.at(id) = 0;
1164  m->imarked_.at(id) = true;
1165  }
1166  }
1167  }
1168 }

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

◆ set_adj() [1/2]

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

Definition at line 1022 of file fmu.cpp.

1023  {
1024  for (casadi_int i = 0; i < nseed; ++i) {
1025  m->osens_.at(*id) = *v++;
1026  m->omarked_.at(*id) = true;
1027  id++;
1028  }
1029 }

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

Referenced by casadi::FmuInternal::set_adj().

◆ set_adj() [2/2]

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

Definition at line 1031 of file fmu.cpp.

1031  {
1032  // If seeds are zero, no need to add to seed buffers
1033  if (!v) return;
1034  // Pass all seeds FIXME(@jaeandersson): should use compatible types
1035  for (size_t id : ored_[ind]) {
1036  casadi_int id2 = id;
1037  set_adj(m, 1, &id2, v++);
1038  }
1039 }
void set_adj(FmuMemory *m, casadi_int nseed, const casadi_int *id, const double *v) const
Definition: fmu.cpp:1022

References casadi::FmuInternal::ored_, and casadi::FmuInternal::set_adj().

◆ set_fwd() [1/2]

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

Definition at line 1214 of file fmu.cpp.

1215  {
1216  for (casadi_int i = 0; i < nseed; ++i) {
1217  m->isens_.at(*id) = *v++;
1218  m->imarked_.at(*id) = true;
1219  id++;
1220  }
1221 }

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

Referenced by casadi::FmuInternal::set_fwd().

◆ set_fwd() [2/2]

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

Definition at line 1223 of file fmu.cpp.

1223  {
1224  // If seeds are zero, no need to add to seed buffers
1225  if (!v) return;
1226  // Pass all seeds FIXME(@jaeandersson): should use compatible types
1227  for (size_t id : ired_[ind]) {
1228  casadi_int id2 = id;
1229  set_fwd(m, 1, &id2, v++);
1230  }
1231 }
void set_fwd(FmuMemory *m, casadi_int nseed, const casadi_int *id, const double *v) const
Definition: fmu.cpp:1214

References casadi::FmuInternal::ired_, and casadi::FmuInternal::set_fwd().

◆ set_real()

int casadi::Fmu3::set_real ( void *  instance,
const unsigned int *  vr,
size_t  n_vr,
const double *  values,
size_t  n_values 
) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 288 of file fmu3.cpp.

289  {
290  // Set time variable, if any
291  if (has_independent_ && n_vr > 0 && *vr == vr_in_[0]) {
292  // Update FMU time
293  fmi3Status status = set_time_(instance, *values);
294  if (status != fmi3OK) return 1;
295  // Skip when setting remaining variables
296  vr++;
297  n_vr--;
298  values++;
299  n_values--;
300  }
301  // Set remaining variables
302  fmi3Status status = set_float64_(instance, vr, n_vr, values, n_values);
303  return status != fmi3OK;
304 }

References casadi::FmuInternal::has_independent_, set_float64_, set_time_, and casadi::FmuInternal::vr_in_.

◆ set_values()

int casadi::Fmu3::set_values ( void *  instance) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 328 of file fmu3.cpp.

328  {
329  auto c = static_cast<fmi3Instance>(instance);
330  // Pass real values before initialization
331  if (!vr_real_.empty()) {
332  fmi3Status status = set_float64_(c, get_ptr(vr_real_), vr_real_.size(),
333  get_ptr(init_real_), init_real_.size());
334  if (status != fmi3OK) {
335  casadi_warning("fmi3SetFloat64 failed");
336  return 1;
337  }
338  }
339  // Pass integer values before initialization (also enums)
340  if (!vr_integer_.empty()) {
341  fmi3Status status = set_int32_(c, get_ptr(vr_integer_), vr_integer_.size(),
343  if (status != fmi3OK) {
344  casadi_warning("fmi3SetInt32 failed");
345  return 1;
346  }
347  }
348  // Pass boolean values before initialization
349  if (!vr_boolean_.empty()) {
350  casadi_error("Broken");
351  // nullptr -> get_ptr(init_boolean_)
352  fmi3Status status = set_boolean_(c, get_ptr(vr_boolean_), vr_boolean_.size(),
353  nullptr, init_boolean_.size());
354  if (status != fmi3OK) {
355  casadi_warning("fmi3SetBoolean failed");
356  return 1;
357  }
358  }
359  // Pass string values before initialization
360  for (size_t k = 0; k < vr_string_.size(); ++k) {
361  fmi3ValueReference vr = vr_string_[k];
362  fmi3String value = init_string_[k].c_str();
363  fmi3Status status = set_string_(c, &vr, 1, &value, 1);
364  if (status != fmi3OK) {
365  casadi_error("fmi3SetString failed for value reference " + str(vr));
366  }
367  }
368  // Successful return
369  return 0;
370 }

References casadi::get_ptr(), init_boolean_, init_integer_, init_real_, init_string_, set_boolean_, set_float64_, set_int32_, set_string_, casadi::str(), vr_boolean_, vr_integer_, vr_real_, and vr_string_.

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

std::string casadi::Fmu3::system_infix ( ) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 35 of file fmu3.cpp.

35  {
36  // Architecture
37  std::string arch;
38 #if defined(__arm64__) || defined(__aarch64__)
39  // ARM 64-bit Architecture
40  arch = "aarch64";
41 #elif __arm__
42  if (sizeof(void*) == 4) {
43  // ARM 32-bit Architecture
44  arch = "aarch32";
45  } else {
46  // ARM 64-bit Architecture
47  arch = "aarch64";
48  }
49 #else
50  if (sizeof(void*) == 4) {
51  // Intel/AMD x86 32-bit
52  arch = "x86";
53  } else {
54  // Intel/AMD x86 64-bit
55  arch = "x86_64";
56  }
57 #endif
58  // Operating system
59  std::string sys;
60 #if defined(_WIN32)
61  // Microsoft Windows
62  sys = "windows";
63 #elif defined(__APPLE__)
64  // Darwin (macOS, iOS, watchOS, tvOS, audioOS)
65  sys = "darwin";
66 #else
67  // Linux
68  sys = "linux";
69 #endif
70  // Return platform tuple, according to Section 2.5.1.4.1. of the FMI 3 specification
71  return arch + "-" + sys;
72 }

◆ update_discrete_states()

int casadi::Fmu3::update_discrete_states ( void *  instance,
EventMemory eventmem 
) const
overridevirtual

Implements casadi::FmuInternal.

Definition at line 268 of file fmu3.cpp.

268  {
269  auto c = static_cast<fmi3Instance>(instance);
270  // Return arguments in FMI types
271  fmi3Boolean discreteStatesNeedUpdate, terminateSimulation, nominalsOfContinuousStatesChanged,
272  valuesOfContinuousStatesChanged, nextEventTimeDefined;
273  fmi3Float64 nextEventTime;
274  // Call FMU
275  fmi3Status status = update_discrete_states_(c, &discreteStatesNeedUpdate, &terminateSimulation,
276  &nominalsOfContinuousStatesChanged, &valuesOfContinuousStatesChanged, &nextEventTimeDefined,
277  &nextEventTime);
278  // Pass to event iteration memory
279  eventmem->discrete_states_need_update = discreteStatesNeedUpdate;
280  eventmem->terminate_simulation = terminateSimulation;
281  eventmem->nominals_of_continuous_states_changed = nominalsOfContinuousStatesChanged;
282  eventmem->values_of_continuous_states_changed = valuesOfContinuousStatesChanged;
283  eventmem->next_event_time_defined = nextEventTimeDefined;
284  eventmem->next_event_time = nextEventTime;
285  return status != fmi3OK;
286 }

References casadi::EventMemory::discrete_states_need_update, casadi::EventMemory::next_event_time, casadi::EventMemory::next_event_time_defined, casadi::EventMemory::nominals_of_continuous_states_changed, casadi::EventMemory::terminate_simulation, update_discrete_states_, and casadi::EventMemory::values_of_continuous_states_changed.

◆ weak()

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

Definition at line 67 of file generic_shared_internal.hpp.

191  {
192  if (weak_ref_==nullptr) {
193  weak_ref_ = new GenericWeakRef<Shared, Internal>(static_cast<Internal*>(this));
194  }
195  return weak_ref_;
196  }

Member Data Documentation

◆ aux_

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

◆ aux_value_

Value casadi::Fmu3::aux_value_

Definition at line 104 of file fmu3.hpp.

Referenced by get_aux(), get_stats(), and init().

◆ can_be_instantiated_only_once_per_process_

bool casadi::FmuInternal::can_be_instantiated_only_once_per_process_
protectedinherited

◆ enter_continuous_time_mode_

fmi3EnterContinuousTimeModeTYPE* casadi::Fmu3::enter_continuous_time_mode_

Definition at line 82 of file fmu3.hpp.

Referenced by enter_continuous_time_mode(), Fmu3(), and load_functions().

◆ enter_initialization_mode_

fmi3EnterInitializationModeTYPE* casadi::Fmu3::enter_initialization_mode_

Definition at line 80 of file fmu3.hpp.

Referenced by enter_initialization_mode(), Fmu3(), and load_functions().

◆ exit_initialization_mode_

fmi3ExitInitializationModeTYPE* casadi::Fmu3::exit_initialization_mode_

Definition at line 81 of file fmu3.hpp.

Referenced by exit_initialization_mode(), Fmu3(), and load_functions().

◆ fmutol_

double casadi::FmuInternal::fmutol_
protectedinherited

◆ free_instance_

fmi3FreeInstanceTYPE* casadi::Fmu3::free_instance_

Definition at line 78 of file fmu3.hpp.

Referenced by Fmu3(), free_instance(), and load_functions().

◆ get_adjoint_derivative_

fmi3GetAdjointDerivativeTYPE* casadi::Fmu3::get_adjoint_derivative_

Definition at line 93 of file fmu3.hpp.

Referenced by Fmu3(), get_adjoint_derivative(), and load_functions().

◆ get_boolean_

fmi3GetBooleanTYPE* casadi::Fmu3::get_boolean_

Definition at line 86 of file fmu3.hpp.

Referenced by get_aux(), and load_functions().

◆ get_directional_derivative_

fmi3GetDirectionalDerivativeTYPE* casadi::Fmu3::get_directional_derivative_

Definition at line 92 of file fmu3.hpp.

Referenced by Fmu3(), get_directional_derivative(), and load_functions().

◆ get_float64_

fmi3GetFloat64TYPE* casadi::Fmu3::get_float64_

Definition at line 84 of file fmu3.hpp.

Referenced by Fmu3(), get_aux(), get_real(), and load_functions().

◆ get_int32_

fmi3GetInt32TYPE* casadi::Fmu3::get_int32_

Definition at line 88 of file fmu3.hpp.

Referenced by get_aux(), and load_functions().

◆ get_string_

fmi3GetStringTYPE* casadi::Fmu3::get_string_

Definition at line 90 of file fmu3.hpp.

Referenced by load_functions().

◆ has_independent_

bool casadi::FmuInternal::has_independent_
protectedinherited

Definition at line 314 of file fmu_impl.hpp.

Referenced by casadi::FmuInternal::init(), and set_real().

◆ hess_sp_

Sparsity casadi::FmuInternal::hess_sp_
protectedinherited

◆ iind_

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

◆ iind_map_

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

◆ init_boolean_

std::vector<fmi3Boolean> casadi::Fmu3::init_boolean_

Definition at line 67 of file fmu3.hpp.

Referenced by init(), and set_values().

◆ init_integer_

std::vector<fmi3Int32> casadi::Fmu3::init_integer_

Definition at line 66 of file fmu3.hpp.

Referenced by init(), and set_values().

◆ init_real_

std::vector<fmi3Float64> casadi::Fmu3::init_real_

Definition at line 65 of file fmu3.hpp.

Referenced by init(), and set_values().

◆ init_string_

std::vector<std::string> casadi::Fmu3::init_string_

Definition at line 68 of file fmu3.hpp.

Referenced by init(), and set_values().

◆ instance_name_

std::string casadi::FmuInternal::instance_name_
protectedinherited

◆ instantiate_model_exchange_

fmi3InstantiateModelExchangeTYPE* casadi::Fmu3::instantiate_model_exchange_

Definition at line 77 of file fmu3.hpp.

Referenced by Fmu3(), instantiate(), and load_functions().

◆ instantiation_token_

std::string casadi::FmuInternal::instantiation_token_
protectedinherited

◆ ired_

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

◆ jac_sp_

Sparsity casadi::FmuInternal::jac_sp_
protectedinherited

◆ li_

Importer casadi::FmuInternal::li_
protectedinherited

◆ logging_on_

bool casadi::FmuInternal::logging_on_
protectedinherited

◆ max_in_

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

◆ max_out_

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

◆ min_in_

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

◆ min_out_

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

◆ name_

std::string casadi::FmuInternal::name_
protectedinherited

◆ nominal_in_

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

◆ nominal_out_

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

◆ number_of_event_indicators_

casadi_int casadi::FmuInternal::number_of_event_indicators_
protectedinherited

◆ oind_

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

◆ oind_map_

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

◆ ored_

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

◆ provides_adjoint_derivatives_

bool casadi::FmuInternal::provides_adjoint_derivatives_
protectedinherited

◆ provides_directional_derivatives_

bool casadi::FmuInternal::provides_directional_derivatives_
protectedinherited

◆ reset_

fmi3ResetTYPE* casadi::Fmu3::reset_

Definition at line 79 of file fmu3.hpp.

Referenced by Fmu3(), load_functions(), and reset().

◆ resource_

Resource casadi::FmuInternal::resource_
protectedinherited

◆ resource_loc_

std::string casadi::FmuInternal::resource_loc_
protectedinherited

◆ scheme_

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

◆ scheme_in_

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

◆ scheme_out_

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

◆ set_boolean_

fmi3SetBooleanTYPE* casadi::Fmu3::set_boolean_

Definition at line 87 of file fmu3.hpp.

Referenced by Fmu3(), load_functions(), and set_values().

◆ set_float64_

fmi3SetFloat64TYPE* casadi::Fmu3::set_float64_

Definition at line 85 of file fmu3.hpp.

Referenced by Fmu3(), load_functions(), set_real(), and set_values().

◆ set_int32_

fmi3SetInt32TYPE* casadi::Fmu3::set_int32_

Definition at line 89 of file fmu3.hpp.

Referenced by load_functions(), and set_values().

◆ set_string_

fmi3SetStringTYPE* casadi::Fmu3::set_string_

Definition at line 91 of file fmu3.hpp.

Referenced by get_aux(), load_functions(), and set_values().

◆ set_time_

fmi3SetTimeTYPE* casadi::Fmu3::set_time_

Definition at line 83 of file fmu3.hpp.

Referenced by Fmu3(), load_functions(), and set_real().

◆ update_discrete_states_

fmi3UpdateDiscreteStatesTYPE* casadi::Fmu3::update_discrete_states_

Definition at line 94 of file fmu3.hpp.

Referenced by Fmu3(), load_functions(), and update_discrete_states().

◆ value_in_

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

◆ vn_aux_boolean_

std::vector<std::string> casadi::Fmu3::vn_aux_boolean_

Definition at line 71 of file fmu3.hpp.

Referenced by get_stats(), and init().

◆ vn_aux_integer_

std::vector<std::string> casadi::Fmu3::vn_aux_integer_

Definition at line 71 of file fmu3.hpp.

Referenced by get_stats(), and init().

◆ vn_aux_real_

std::vector<std::string> casadi::Fmu3::vn_aux_real_

Definition at line 71 of file fmu3.hpp.

Referenced by get_stats(), and init().

◆ vn_aux_string_

std::vector<std::string> casadi::Fmu3::vn_aux_string_

Definition at line 71 of file fmu3.hpp.

Referenced by get_stats(), and init().

◆ vn_in_

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

◆ vn_out_

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

◆ vr_aux_boolean_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_aux_boolean_

Definition at line 72 of file fmu3.hpp.

Referenced by get_aux(), and init().

◆ vr_aux_integer_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_aux_integer_

Definition at line 72 of file fmu3.hpp.

Referenced by get_aux(), and init().

◆ vr_aux_real_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_aux_real_

Definition at line 72 of file fmu3.hpp.

Referenced by get_aux(), and init().

◆ vr_aux_string_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_aux_string_

Definition at line 72 of file fmu3.hpp.

Referenced by get_aux(), and init().

◆ vr_boolean_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_boolean_

Definition at line 64 of file fmu3.hpp.

Referenced by init(), and set_values().

◆ vr_in_

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

◆ vr_integer_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_integer_

Definition at line 64 of file fmu3.hpp.

Referenced by init(), and set_values().

◆ vr_out_

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

◆ vr_real_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_real_

Definition at line 64 of file fmu3.hpp.

Referenced by init(), and set_values().

◆ vr_string_

std::vector<fmi3ValueReference> casadi::Fmu3::vr_string_

Definition at line 64 of file fmu3.hpp.

Referenced by init(), and set_values().


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