Minsky: 3.17.0
minsky::EvalGodley Class Reference

#include <evalGodley.h>

Collaboration diagram for minsky::EvalGodley:
Collaboration graph

Public Member Functions

template<class GodleyIterator >
void initialiseGodleys (const GodleyIterator &begin, const GodleyIterator &end, const VariableValues &values)
 initialise this to a sequence of Godley tables - adaptors provided below More...
 
void eval (double *sv, const double *fv) const
 evaluate Godley tables on sv (of type double[]) and current value of fv (of type double[]), storing result in output variable (of fv). sv is assume to be of size stockVars and fv is assumed to be of size flowVars. More...
 
 EvalGodley ()
 

Public Attributes

bool compatibility
 if compatibility is true, then consttrainst between Godley tables is not applied, and shared columns are merely summed More...
 

Private Member Functions

 CLASSDESC_ACCESS (EvalGodley)
 

Private Attributes

ecolab::array< int > sidx
 representation of matrix connecting flow variables to stock variables More...
 
ecolab::array< int > fidx
 
ecolab::array< double > m
 
ecolab::array< int > initIdx
 index of stock variables that need to be zeroed at start of eval More...
 

Detailed Description

Definition at line 35 of file evalGodley.h.

Constructor & Destructor Documentation

◆ EvalGodley()

minsky::EvalGodley::EvalGodley ( )
inline

Definition at line 59 of file evalGodley.h.

59 : compatibility(false) {}
bool compatibility
if compatibility is true, then consttrainst between Godley tables is not applied, and shared columns ...
Definition: evalGodley.h:62

Member Function Documentation

◆ CLASSDESC_ACCESS()

minsky::EvalGodley::CLASSDESC_ACCESS ( EvalGodley  )
private

◆ eval()

void minsky::EvalGodley::eval ( double *  sv,
const double *  fv 
) const

evaluate Godley tables on sv (of type double[]) and current value of fv (of type double[]), storing result in output variable (of fv). sv is assume to be of size stockVars and fv is assumed to be of size flowVars.

Definition at line 92 of file evalGodley.cc.

93  {
94  for (size_t i=0; i<initIdx.size(); ++i)
95  sv[initIdx[i]]=0;
96 
97  for (size_t i=0; i<sidx.size(); ++i)
98  sv[sidx[i]] += fv[fidx[i]] * m[i];
99  }
ecolab::array< int > fidx
Definition: evalGodley.h:38
ecolab::array< int > sidx
representation of matrix connecting flow variables to stock variables
Definition: evalGodley.h:38
ecolab::array< int > initIdx
index of stock variables that need to be zeroed at start of eval
Definition: evalGodley.h:42
ecolab::array< double > m
Definition: evalGodley.h:39

◆ initialiseGodleys()

template<class GodleyIterator >
void minsky::EvalGodley::initialiseGodleys ( const GodleyIterator &  begin,
const GodleyIterator &  end,
const VariableValues values 
)

initialise this to a sequence of Godley tables - adaptors provided below

Definition at line 120 of file evalGodley.h.

References minsky::SharedColumnCheck::checkShared(), minsky::SharedColumnCheck::checkSharedColDefs(), minsky::trimWS(), and minsky::SharedColumnCheck::updateColDefs().

122  {
123  SharedColumnCheck scCheck;
124  sidx.resize(0);
125  fidx.resize(0);
126  m.resize(0);
127 
128  std::set<int> iidx;
129 
130  for (GodleyIterator g=begin; g!=end; ++g)
131  {
132  if (g.data().empty()) continue;
133  // check for shared columns
134  if (!compatibility)
135  for (std::size_t col=1; col<g.data()[0].size(); ++col)
136  if (!trimWS(g.data()[0][col]).empty())
137  scCheck.checkShared(g.valueId(trimWS(g.data()[0][col])), g.assetClass(col));
138 
139  for (std::size_t row=1; row<g.data().size(); ++row)
140  if (!g.initialConditionRow(row))
141  for (std::size_t col=1; col<g.data()[row].size(); ++col)
142  {
143  FlowCoef fvc(g.data()[row][col]);
144  auto svName=col<g.data()[0].size()? trimWS(g.data()[0][col]): "";
145  if (fvc.name.empty() || svName.empty()) continue;
146  fvc.name=g.valueId(fvc.name);
147  svName=g.valueId(svName);
148 
149  auto fv=values.find(fvc.name);
150  auto sv=values.find(svName);
151  if (fv!=values.end() && sv!=values.end() &&
152  fv->second->idx()>=0 && sv->second->idx()>=0)
153  {
154  // check for compatible column definitions
155  if (!compatibility &&
156  scCheck.updateColDefs(svName, fvc))
157  continue;
158 
159  iidx.insert(sv->second->idx());
160  sidx<<=sv->second->idx();
161  fidx<<=fv->second->idx();
162  m<<=fvc.coef;
163  }
164  }
165  }
166 
167  initIdx.clear();
168  for (auto i: iidx)
169  initIdx<<=i;
170 
171  if (!compatibility)
172  scCheck.checkSharedColDefs();
173  }
ecolab::array< int > fidx
Definition: evalGodley.h:38
ecolab::array< int > sidx
representation of matrix connecting flow variables to stock variables
Definition: evalGodley.h:38
bool compatibility
if compatibility is true, then consttrainst between Godley tables is not applied, and shared columns ...
Definition: evalGodley.h:62
std::string trimWS(const std::string &s)
Definition: str.h:49
ecolab::array< int > initIdx
index of stock variables that need to be zeroed at start of eval
Definition: evalGodley.h:42
ecolab::array< double > m
Definition: evalGodley.h:39
Here is the call graph for this function:

Member Data Documentation

◆ compatibility

bool minsky::EvalGodley::compatibility

if compatibility is true, then consttrainst between Godley tables is not applied, and shared columns are merely summed

Definition at line 62 of file evalGodley.h.

◆ fidx

ecolab::array<int> minsky::EvalGodley::fidx
private

Definition at line 38 of file evalGodley.h.

◆ initIdx

ecolab::array<int> minsky::EvalGodley::initIdx
private

index of stock variables that need to be zeroed at start of eval

Definition at line 42 of file evalGodley.h.

◆ m

ecolab::array<double> minsky::EvalGodley::m
private

Definition at line 39 of file evalGodley.h.

◆ sidx

ecolab::array<int> minsky::EvalGodley::sidx
private

representation of matrix connecting flow variables to stock variables

Definition at line 38 of file evalGodley.h.


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