List of all members | Public Member Functions | Static Public Member Functions | Public Attributes
casadi::OutputStruct Struct Reference

#include <fmu_function.hpp>

Detailed Description

Definition at line 112 of file fmu_function.hpp.

Public Member Functions

 OutputStruct ()
 

Static Public Member Functions

static OutputStruct parse (const std::string &n, const Fmu *fmu, std::vector< std::string > *name_in=nullptr, std::vector< std::string > *name_out=nullptr)
 

Public Attributes

OutputType type
 
size_t ind
 
size_t wrt
 
size_t rbegin
 
size_t rend
 
size_t cbegin
 
size_t cend
 

Constructor & Destructor Documentation

◆ OutputStruct()

casadi::OutputStruct::OutputStruct ( )
inline

Definition at line 126 of file fmu_function.hpp.

Member Function Documentation

◆ parse()

OutputStruct casadi::OutputStruct::parse ( const std::string &  n,
const Fmu *  fmu,
std::vector< std::string > *  name_in = nullptr,
std::vector< std::string > *  name_out = nullptr 
)
static

Definition at line 774 of file fmu_function.cpp.

775  {
776  // Return value
777  OutputStruct s;
778  // Look for prefix
779  if (has_prefix(n)) {
780  // Get the prefix
781  std::string pref, rem;
782  pref = pop_prefix(n, &rem);
783  if (pref == "jac") {
784  // Jacobian block
785  casadi_assert(has_prefix(rem), "Two arguments expected for Jacobian block");
786  pref = pop_prefix(rem, &rem);
787  if (pref == "adj") {
788  // Jacobian of adjoint sensitivity
789  casadi_assert(has_prefix(rem), "Two arguments expected for Jacobian block");
790  pref = pop_prefix(rem, &rem);
791  if (has_prefix(rem)) {
792  // Jacobian with respect to a sensitivity seed
793  std::string sens = pref;
794  pref = pop_prefix(rem, &rem);
795  if (pref == "adj") {
796  // Jacobian of adjoint sensitivity w.r.t. adjoint seed -> Transpose of Jacobian
797  s.type = OutputType::JAC_TRANS;
798  s.ind = fmu ? fmu->index_out(rem) : -1;
799  if (name_out) name_out->push_back(rem);
800  s.wrt = fmu ? fmu->index_in(sens) : -1;
801  if (name_in) name_in->push_back(sens);
802  } else if (pref == "out") {
803  // Jacobian w.r.t. to dummy output
804  s.type = OutputType::JAC_ADJ_OUT;
805  s.ind = fmu ? fmu->index_in(sens) : -1;
806  if (name_in) name_in->push_back(sens);
807  s.wrt = fmu ? fmu->index_out(rem) : -1;
808  if (name_in) name_out->push_back(rem);
809  } else {
810  casadi_error("No such prefix: " + pref);
811  }
812  } else {
813  // Hessian output
814  s.type = OutputType::HESS;
815  s.ind = fmu ? fmu->index_in(pref) : -1;
816  if (name_in) name_in->push_back(pref);
817  s.wrt = fmu ? fmu->index_in(rem) : -1;
818  if (name_in) name_in->push_back(rem);
819  }
820  } else {
821  if (has_prefix(rem)) {
822  std::string out = pref;
823  pref = pop_prefix(rem, &rem);
824  if (pref == "adj") {
825  // Jacobian of regular output w.r.t. adjoint sensitivity seed
826  s.type = OutputType::JAC_REG_ADJ;
827  s.ind = fmu ? fmu->index_out(out) : -1;
828  if (name_out) name_out->push_back(out);
829  s.wrt = fmu ? fmu->index_out(rem) : -1;
830  if (name_out) name_out->push_back(rem);
831  } else {
832  casadi_error("No such prefix: " + pref);
833  }
834  } else {
835  // Regular Jacobian
836  s.type = OutputType::JAC;
837  s.ind = fmu ? fmu->index_out(pref) : -1;
838  if (name_out) name_out->push_back(pref);
839  s.wrt = fmu ? fmu->index_in(rem) : -1;
840  if (name_in) name_in->push_back(rem);
841  }
842  }
843  } else if (pref == "fwd") {
844  // Forward sensitivity
845  s.type = OutputType::FWD;
846  s.ind = fmu ? fmu->index_out(rem) : -1;
847  if (name_out) name_out->push_back(rem);
848  } else if (pref == "adj") {
849  // Adjoint sensitivity
850  s.type = OutputType::ADJ;
851  s.wrt = fmu ? fmu->index_in(rem) : -1;
852  if (name_in) name_in->push_back(rem);
853  } else {
854  // No such prefix
855  casadi_error("No such prefix: " + pref);
856  }
857  } else {
858  // No prefix - regular output
859  s.type = OutputType::REG;
860  s.ind = fmu ? fmu->index_out(n) : -1;
861  if (name_out) name_out->push_back(n);
862  }
863  // Return output struct
864  return s;
865 }
bool has_prefix(const std::string &s)
std::string pop_prefix(const std::string &s, std::string *rem)

References casadi::ADJ, casadi::FWD, casadi::has_prefix(), casadi::HESS, ind, casadi::FmuInternal::index_in(), casadi::FmuInternal::index_out(), casadi::JAC, casadi::JAC_ADJ_OUT, casadi::JAC_REG_ADJ, casadi::JAC_TRANS, casadi::pop_prefix(), casadi::REG, type, and wrt.

Referenced by casadi::FmuFunction::FmuFunction(), and casadi::FmuFunction::identify_io().

Member Data Documentation

◆ cbegin

size_t casadi::OutputStruct::cbegin

Definition at line 120 of file fmu_function.hpp.

◆ cend

size_t casadi::OutputStruct::cend

Definition at line 120 of file fmu_function.hpp.

◆ ind

size_t casadi::OutputStruct::ind

◆ rbegin

size_t casadi::OutputStruct::rbegin

Definition at line 120 of file fmu_function.hpp.

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

◆ rend

size_t casadi::OutputStruct::rend

Definition at line 120 of file fmu_function.hpp.

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

◆ type

OutputType casadi::OutputStruct::type

Definition at line 114 of file fmu_function.hpp.

Referenced by casadi::FmuFunction::init(), and parse().

◆ wrt

size_t casadi::OutputStruct::wrt

Definition at line 118 of file fmu_function.hpp.

Referenced by casadi::FmuFunction::get_sparsity_out(), and parse().


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