38 ecolab::array<int>
sidx, fidx;
39 ecolab::array<double>
m;
48 template <
class GodleyIterator>
49 void initialiseGodleys
50 (
const GodleyIterator& begin,
const GodleyIterator& end,
57 void eval(
double* sv,
const double* fv)
const;
76 int id()
const {
return it->id();}
79 const std::vector<std::vector<std::string> >& data()
const;
81 bool signConventionReversed(
int col)
const;
82 bool initialConditionRow(
int row)
const;
85 string valueId(
const std::string& x)
const {
return it->valueId(x);}
103 void checkShared(
const string& name,
AssetClass ac);
112 bool updateColDefs(
const string& col,
const FlowCoef& fc);
115 void checkSharedColDefs()
const;
120 (
const GodleyIterator& begin,
const GodleyIterator& end,
130 for (GodleyIterator g=begin; g!=end; ++g)
132 if (g.data().empty())
continue;
135 for (std::size_t col=1; col<g.data()[0].size(); ++col)
136 if (!
trimWS(g.data()[0][col]).empty())
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)
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);
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)
155 if (!compatibility &&
159 iidx.insert(sv->second->idx());
160 sidx<<=sv->second->idx();
161 fidx<<=fv->second->idx();
177 #include "evalGodley.cd" 178 #include "evalGodley.xcd"
bool operator!=(const GodleyIteratorAdaptor &x) const
bool updateColDefs(const string &col, const FlowCoef &fc)
update col defs, give column name, and flow variable entry
ecolab::array< int > sidx
representation of matrix connecting flow variables to stock variables
std::map< string, AssetClass > colAssetType
asset type of previously seen column of this name
bool compatibility
if compatibility is true, then consttrainst between Godley tables is not applied, and shared columns ...
void checkShared(const string &name, AssetClass ac)
check whether column name has already been seen, and if it has, whether it is allowed to be shared by...
for checking shared columns between tables
GodleyIteratorAdaptor< T > makeGodleyIt(const T &it)
void initialiseGodleys(const GodleyIterator &begin, const GodleyIterator &end, const VariableValues &values)
initialise this to a sequence of Godley tables - adaptors provided below
std::string trimWS(const std::string &s)
void checkSharedColDefs() const
check shared columns are equivalently defined
GodleyAssetClass::AssetClass AssetClass
std::set< string > sharedCol
indicates a column is shared between Godley tables
#define CLASSDESC_ACCESS(type)
string valueId(const std::string &x) const
returns valueid for variable reference in table
represents a numerical coefficient times a variable (a "flow")
ecolab::array< int > initIdx
index of stock variables that need to be zeroed at start of eval
ecolab::array< double > m
GodleyIteratorAdaptor(const T &it)
adaptor suitable for initialiseGodleys
ConstMap< string, std::map< string, double > > colDef
store the sum of flow var contributions for each colum here. Used for checking that shared column def...