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 109 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 123 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 767 of file fmu_function.cpp.

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

◆ cend

size_t casadi::OutputStruct::cend

Definition at line 117 of file fmu_function.hpp.

◆ ind

size_t casadi::OutputStruct::ind

◆ rbegin

size_t casadi::OutputStruct::rbegin

Definition at line 117 of file fmu_function.hpp.

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

◆ rend

size_t casadi::OutputStruct::rend

Definition at line 117 of file fmu_function.hpp.

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

◆ type

OutputType casadi::OutputStruct::type

Definition at line 111 of file fmu_function.hpp.

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

◆ wrt

size_t casadi::OutputStruct::wrt

Definition at line 115 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: