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

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