Minsky
minsky::SharedColumnCheck Struct Reference

for checking shared columns between tables More...

#include <evalGodley.h>

Inheritance diagram for minsky::SharedColumnCheck:
Inheritance graph
Collaboration diagram for minsky::SharedColumnCheck:
Collaboration graph

Public Types

typedef GodleyAssetClass::AssetClass AssetClass
 
- Public Types inherited from minsky::GodleyAssetClass
enum  AssetClass { noAssetClass, asset, liability, equity }
 
enum  DisplayStyle { DRCR, sign }
 

Public Member Functions

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 business rules More...
 
bool updateColDefs (const string &col, const FlowCoef &fc)
 update col defs, give column name, and flow variable entry More...
 
void checkSharedColDefs () const
 check shared columns are equivalently defined More...
 

Public Attributes

std::map< string, AssetClasscolAssetType
 asset type of previously seen column of this name More...
 
std::set< string > sharedCol
 indicates a column is shared between Godley tables More...
 
ConstMap< string, std::map< string, double > > colDef
 store the sum of flow var contributions for each colum here. Used for checking that shared column definitions are equivalent More...
 

Detailed Description

for checking shared columns between tables

Definition at line 93 of file evalGodley.h.

Member Typedef Documentation

◆ AssetClass

Member Function Documentation

◆ checkShared()

void minsky::SharedColumnCheck::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 business rules

Definition at line 41 of file evalGodley.cc.

References minsky::anonymous_namespace{evalGodley.cc}::throwInvalidAssetLiabilityPair().

Referenced by minsky::EvalGodley::initialiseGodleys().

42  {
43  if (name.empty() || name==":_")
44  return; // ignore blank columns
45  if (!colAssetType.insert(make_pair(name, ac)).second)
46  {
47  switch (ac)
48  {
49  case liability:
50  if (colAssetType[name]!=asset)
52  break;
53  case asset:
54  if (colAssetType[name]!=liability)
56  break;
57  case equity:
58  break; // do not check duplicate column
59  default:
60  throw error("duplicated column %s detected",name.c_str());
61  }
62  // At this point, a shared pair of columns is OK
63  if (!sharedCol.insert(name).second)
64  throw error("More than two columns %s detected" ,name.c_str());
65  }
66  }
void throwInvalidAssetLiabilityPair(const string &name)
Definition: evalGodley.cc:34
std::map< string, AssetClass > colAssetType
asset type of previously seen column of this name
Definition: evalGodley.h:98
std::set< string > sharedCol
indicates a column is shared between Godley tables
Definition: evalGodley.h:100
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkSharedColDefs()

void minsky::SharedColumnCheck::checkSharedColDefs ( ) const

check shared columns are equivalently defined

Definition at line 78 of file evalGodley.cc.

Referenced by minsky::EvalGodley::initialiseGodleys().

79  {
80  // check that shared column definitions sum to zero
81  for (set<string>::iterator i=sharedCol.begin(); i!=sharedCol.end(); ++i)
82  {
83  const map<string, double>& cdef=colDef[*i];
84  for (map<string, double>::const_iterator j=cdef.begin();
85  j!=cdef.end(); ++j)
86  if (abs(j->second)>1e-30)
87  throw error("column %s has mismatched flow %s",
88  i->c_str(), j->first.c_str());
89  }
90  }
std::set< string > sharedCol
indicates a column is shared between Godley tables
Definition: evalGodley.h:100
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...
Definition: evalGodley.h:109
Here is the caller graph for this function:

◆ updateColDefs()

bool minsky::SharedColumnCheck::updateColDefs ( const string &  col,
const FlowCoef fc 
)

update col defs, give column name, and flow variable entry

Returns
true if col has been seen before

Definition at line 68 of file evalGodley.cc.

References minsky::FlowCoef::coef, and minsky::FlowCoef::name.

Referenced by minsky::EvalGodley::initialiseGodleys().

69  {
70  const bool alreadySeen=sharedCol.contains(col);
71  if (alreadySeen)
72  colDef[col][fc.name]-=fc.coef;
73  else
74  colDef[col][fc.name]+=fc.coef;
75  return alreadySeen;
76  }
std::set< string > sharedCol
indicates a column is shared between Godley tables
Definition: evalGodley.h:100
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...
Definition: evalGodley.h:109
Here is the caller graph for this function:

Member Data Documentation

◆ colAssetType

std::map<string, AssetClass> minsky::SharedColumnCheck::colAssetType

asset type of previously seen column of this name

Definition at line 98 of file evalGodley.h.

◆ colDef

ConstMap<string, std::map<string, double> > minsky::SharedColumnCheck::colDef

store the sum of flow var contributions for each colum here. Used for checking that shared column definitions are equivalent

Definition at line 109 of file evalGodley.h.

◆ sharedCol

std::set<string> minsky::SharedColumnCheck::sharedCol

indicates a column is shared between Godley tables

Definition at line 100 of file evalGodley.h.


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