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 770 of file fmu_function.cpp.

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