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 111 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=0, std::vector< std::string > *name_out=0)
 

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 125 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 = 0,
std::vector< std::string > *  name_out = 0 
)
static

Definition at line 654 of file fmu_function.cpp.

655  {
656  // Return value
657  OutputStruct s;
658  // Look for prefix
659  if (has_prefix(n)) {
660  // Get the prefix
661  std::string pref, rem;
662  pref = pop_prefix(n, &rem);
663  if (pref == "jac") {
664  // Jacobian block
665  casadi_assert(has_prefix(rem), "Two arguments expected for Jacobian block");
666  pref = pop_prefix(rem, &rem);
667  if (pref == "adj") {
668  // Jacobian of adjoint sensitivity
669  casadi_assert(has_prefix(rem), "Two arguments expected for Jacobian block");
670  pref = pop_prefix(rem, &rem);
671  if (has_prefix(rem)) {
672  // Jacobian with respect to a sensitivity seed
673  std::string sens = pref;
674  pref = pop_prefix(rem, &rem);
675  if (pref == "adj") {
676  // Jacobian of adjoint sensitivity w.r.t. adjoint seed -> Transpose of Jacobian
677  s.type = OutputType::JAC_TRANS;
678  s.ind = fmu ? fmu->index_out(rem) : -1;
679  if (name_out) name_out->push_back(rem);
680  s.wrt = fmu ? fmu->index_in(sens) : -1;
681  if (name_in) name_in->push_back(sens);
682  } else if (pref == "out") {
683  // Jacobian w.r.t. to dummy output
684  s.type = OutputType::JAC_ADJ_OUT;
685  s.ind = fmu ? fmu->index_in(sens) : -1;
686  if (name_in) name_in->push_back(sens);
687  s.wrt = fmu ? fmu->index_out(rem) : -1;
688  if (name_in) name_out->push_back(rem);
689  } else {
690  casadi_error("No such prefix: " + pref);
691  }
692  } else {
693  // Hessian output
694  s.type = OutputType::HESS;
695  s.ind = fmu ? fmu->index_in(pref) : -1;
696  if (name_in) name_in->push_back(pref);
697  s.wrt = fmu ? fmu->index_in(rem) : -1;
698  if (name_in) name_in->push_back(rem);
699  }
700  } else {
701  if (has_prefix(rem)) {
702  std::string out = pref;
703  pref = pop_prefix(rem, &rem);
704  if (pref == "adj") {
705  // Jacobian of regular output w.r.t. adjoint sensitivity seed
706  s.type = OutputType::JAC_REG_ADJ;
707  s.ind = fmu ? fmu->index_out(out) : -1;
708  if (name_out) name_out->push_back(out);
709  s.wrt = fmu ? fmu->index_out(rem) : -1;
710  if (name_out) name_out->push_back(rem);
711  } else {
712  casadi_error("No such prefix: " + pref);
713  }
714  } else {
715  // Regular Jacobian
716  s.type = OutputType::JAC;
717  s.ind = fmu ? fmu->index_out(pref) : -1;
718  if (name_out) name_out->push_back(pref);
719  s.wrt = fmu ? fmu->index_in(rem) : -1;
720  if (name_in) name_in->push_back(rem);
721  }
722  }
723  } else if (pref == "fwd") {
724  // Forward sensitivity
725  s.type = OutputType::FWD;
726  s.ind = fmu ? fmu->index_out(rem) : -1;
727  if (name_out) name_out->push_back(rem);
728  } else if (pref == "adj") {
729  // Adjoint sensitivity
730  s.type = OutputType::ADJ;
731  s.wrt = fmu ? fmu->index_in(rem) : -1;
732  if (name_in) name_in->push_back(rem);
733  } else {
734  // No such prefix
735  casadi_error("No such prefix: " + pref);
736  }
737  } else {
738  // No prefix - regular output
739  s.type = OutputType::REG;
740  s.ind = fmu ? fmu->index_out(n) : -1;
741  if (name_out) name_out->push_back(n);
742  }
743  // Return output struct
744  return s;
745 }
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 119 of file fmu_function.hpp.

◆ cend

size_t casadi::OutputStruct::cend

Definition at line 119 of file fmu_function.hpp.

◆ ind

size_t casadi::OutputStruct::ind

◆ rbegin

size_t casadi::OutputStruct::rbegin

Definition at line 119 of file fmu_function.hpp.

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

◆ rend

size_t casadi::OutputStruct::rend

Definition at line 119 of file fmu_function.hpp.

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

◆ type

OutputType casadi::OutputStruct::type

Definition at line 113 of file fmu_function.hpp.

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

◆ wrt

size_t casadi::OutputStruct::wrt

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