Minsky
minsky Namespace Reference

Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state changes. More...

Namespaces

 anonymous_namespace{addon.cc}
 
 anonymous_namespace{autoLayout.cc}
 
 anonymous_namespace{evalGodley.cc}
 
 anonymous_namespace{evalOp.cc}
 
 anonymous_namespace{getContext.cc}
 
 anonymous_namespace{godleyExport.cc}
 
 anonymous_namespace{godleyIcon.cc}
 
 anonymous_namespace{godleyTableWindow.cc}
 
 anonymous_namespace{grid.cc}
 
 anonymous_namespace{group.cc}
 
 anonymous_namespace{item.cc}
 
 anonymous_namespace{mdlReader.cc}
 
 anonymous_namespace{minsky.cc}
 
 anonymous_namespace{minskyTCL.cc}
 
 anonymous_namespace{minskyTensorOps.cc}
 
 anonymous_namespace{operation.cc}
 
 anonymous_namespace{plotWidget.cc}
 
 anonymous_namespace{pubTab.cc}
 
 anonymous_namespace{ravelWrap.cc}
 
 anonymous_namespace{renderNativeWindow.cc}
 
 anonymous_namespace{saver.cc}
 
 anonymous_namespace{userFunction.cc}
 
 anonymous_namespace{userFunction_units.cc}
 
 anonymous_namespace{variableValue.cc}
 
 anonymous_namespace{windowInformation.cc}
 
 anonymous_namespace{wire.cc}
 
 OperationTypeInfo
 
 VarAccessors
 

Classes

struct  AccumArgs
 
struct  AccumArgs< OperationType::add >
 
struct  AccumArgs< OperationType::and_ >
 
struct  AccumArgs< OperationType::divide >
 
struct  AccumArgs< OperationType::max >
 
struct  AccumArgs< OperationType::min >
 
struct  AccumArgs< OperationType::multiply >
 
struct  AccumArgs< OperationType::or_ >
 
struct  AccumArgs< OperationType::subtract >
 
struct  BackgroundSaver
 
struct  Bookmark
 
struct  BottomRightResizerItem
 
class  BoundingBox
 bounding box information (at zoom=1 scale) More...
 
struct  BusyCursor
 
class  ButtonWidget
 supports +/-/←/→/↓/↑ widget More...
 
struct  ButtonWidgetEnums
 
struct  CairoRenderer
 
struct  CallableFunction
 
class  Canvas
 
struct  ClickType
 represents whether a mouse click is on the item, on an output port (for wiring, or is actually outside the items boundary, and a lasso is intended More...
 
class  Clipboard
 An RAII wrapper around jtanx's libclipboard (https://github.com/jtanx/libclipboard) More...
 
struct  ConstantEvalOp
 
struct  ConstMap
 
class  Copy
 
struct  Correlation
 
struct  Coverage
 
class  CSVDialog
 
class  DataOp
 legacy data importer object More...
 
class  DataSpec
 
struct  DataSpecSchema
 
struct  DeflateZStream
 
class  Derivative
 
struct  DerivativeMixin
 support for partial derivatives needed for implicit method More...
 
struct  DerivativeNotDefined
 
struct  DrawBinOp
 helper class to draw port label symbols More...
 
struct  DummyBase
 
struct  EngNotation
 
class  EquationDisplay
 
class  EvalCommon
 A place to store common data shared between TensorVarVals within a give calculation. More...
 
class  EvalGodley
 
struct  EvalOp
 represents the operation when evaluating the equations More...
 
struct  EvalOpBase
 
struct  EvalOpPtr
 
struct  EvalOpVector
 
struct  EventInterface
 
struct  FailedToRewind
 
struct  FallBackToScalar
 
struct  FlowCoef
 represents a numerical coefficient times a variable (a "flow") More...
 
struct  FlowVarsResized
 exception throw if flowVars vector unexpectedly resized during evalEquations More...
 
class  FontDisplay
 
struct  GeneralTensorOp
 
struct  GeneralTensorOp< OperationType::all >
 
struct  GeneralTensorOp< OperationType::any >
 
struct  GeneralTensorOp< OperationType::correlation >
 
struct  GeneralTensorOp< OperationType::covariance >
 
struct  GeneralTensorOp< OperationType::difference >
 
struct  GeneralTensorOp< OperationType::differencePlus >
 
struct  GeneralTensorOp< OperationType::gather >
 
struct  GeneralTensorOp< OperationType::histogram >
 
struct  GeneralTensorOp< OperationType::index >
 
struct  GeneralTensorOp< OperationType::infimum >
 
struct  GeneralTensorOp< OperationType::infIndex >
 
struct  GeneralTensorOp< OperationType::innerProduct >
 
struct  GeneralTensorOp< OperationType::linearRegression >
 
struct  GeneralTensorOp< OperationType::mean >
 
struct  GeneralTensorOp< OperationType::median >
 
struct  GeneralTensorOp< OperationType::meld >
 
struct  GeneralTensorOp< OperationType::merge >
 
struct  GeneralTensorOp< OperationType::moment >
 
struct  GeneralTensorOp< OperationType::outerProduct >
 
struct  GeneralTensorOp< OperationType::product >
 
struct  GeneralTensorOp< OperationType::runningProduct >
 
struct  GeneralTensorOp< OperationType::runningSum >
 
struct  GeneralTensorOp< OperationType::shape >
 
struct  GeneralTensorOp< OperationType::size >
 
struct  GeneralTensorOp< OperationType::slice >
 
struct  GeneralTensorOp< OperationType::stdDev >
 
struct  GeneralTensorOp< OperationType::sum >
 
struct  GeneralTensorOp< OperationType::supIndex >
 
struct  GeneralTensorOp< OperationType::supremum >
 
struct  GetUtf8Char
 
struct  GodleyAssetClass
 
class  GodleyIcon
 
class  GodleyIteratorAdaptor
 adaptor suitable for initialiseGodleys More...
 
class  GodleyTable
 
class  GodleyTableEditor
 
class  GodleyTableWindow
 
class  Grid
 
class  Group
 
class  GroupItems
 
struct  HandleLockInfo
 
struct  has_empty
 
class  ICell
 Cell template parameter duck types this interface. More...
 
struct  IncrDecrCounter
 exception-safe increment/decrement of a counter in a block More...
 
struct  InflateFileZStream
 
struct  InflateZStream
 
struct  InputPort
 
class  Integral
 An integral is an additional stock variable, that integrates its flow variable. More...
 
class  IntOp
 
struct  IntOpAccessor
 
class  IntrusiveMap
 
struct  IntrusiveWrap
 
class  Item
 
struct  ItemExclude
 Item members excluded from reflection. More...
 
struct  ItemPortVector
 
struct  ItemT
 
struct  JustificationStruct
 
struct  KeyAssertion
 
struct  KeyAssertion< int >
 
struct  LassoBox
 represents rectangular region of a lasso operation More...
 
struct  LegendGeometry
 
struct  LocalMinsky
 RAII set the minsky object to a different one for the current scope. More...
 
class  Lock
 
class  Matrix
 convenience class for accessing matrix elements from a data array More...
 
class  Minsky
 
struct  Minsky_multipleEquities
 
struct  MinskyExclude
 
struct  MinskyTCL
 
struct  MinskyTensorOp
 
struct  MultiWireBinOp
 
struct  MultiWireInputPort
 
class  NamedOp
 base class for operations that have names More...
 
struct  NoAssign
 
class  NoteBase
 
struct  NSContext
 
struct  OnError
 handle reporting errors in loadValueFromCSVFileT when loading files More...
 
struct  OnStackExit
 arrange for a functional to be called on stack exit More...
 
class  Operation
 
class  OperationBase
 
class  OperationFactory
 factory class template, for creating objects of type T<O>. N is the maximum value of O More...
 
class  OperationPtr
 shared_ptr class for polymorphic operation objects. Note, you may assume that this pointer is always valid, although currently the implementation doesn't guarantee it (eg reset() is exposed). More...
 
struct  OperationType
 
struct  OpState
 
struct  Optional
 convenience class to omit writing XML records when data absent or empty More...
 
class  PannableTab
 Mixin implementing common panning functionality in tabs. More...
 
struct  PannableTabBase
 
struct  ParseCSV
 
class  PhillipsDiagram
 
class  PhillipsFlow
 
class  PhillipsStock
 
struct  PlotOptions
 
class  PlotWidget
 a container item for a plot widget More...
 
struct  PlotWidgetSuper
 
class  Port
 
struct  PortExclude
 components of Port excluded from reflection More...
 
class  Progress
 
class  ProgressUpdater
 
class  PubItem
 
class  PubTab
 
struct  PubTabBase
 
class  Ravel
 
class  RavelLockGroup
 
class  RavelPopup
 
class  RavelTensor
 
class  Reflect
 
class  RenderNativeWindow
 
class  RenderVariable
 
struct  RESTMinsky
 
struct  RKdata
 
class  Rotate
 rotate (x,y) by rot (in degrees) around the origin (x0, y0) can be used for rotating multiple points once constructed More...
 
class  RungeKutta
 
struct  RungeKuttaExclude
 components excluded from reflection More...
 
struct  Saver
 
struct  ScalarEvalOp
 Legacy EvalOp base interface. More...
 
struct  SchemaHelper
 
struct  Selection
 represents items that have been selected More...
 
struct  SetState
 
struct  SharedColumnCheck
 for checking shared columns between tables More...
 
class  Sheet
 
struct  Simulation
 
struct  Slider
 data structure supporting sliders - shared between constant operations and variables More...
 
struct  Summary
 summary for the variable tab (aka summary tab). More...
 
class  SVGRenderer
 
class  SwitchIcon
 
class  SwitchTensor
 
struct  TensorBinOp
 
class  TensorEval
 A helper to evaluate a variable value. More...
 
class  TensorOpFactory
 As it says on the tin, this is a factory for creating a TensorOp which can compute the result of op applied to its arguments and so on until all the argument terminate in variables. More...
 
struct  TensorsFromPort
 
struct  TensorVarVal
 
struct  TensorVarValBase
 
class  Time
 
struct  TimeOp
 
struct  TrackedIntrusiveMap
 
struct  Units
 represents the units (in sense of dimensional analysis) of a variable. More...
 
struct  UnitsExpressionWalker
 
class  UserFunction
 
struct  ValueVector
 
struct  VarConstant
 
class  Variable
 
class  VariableBase
 
class  VariableCaches
 caches need copy operations to be nobbled, because they hold a reference to the derived variable More...
 
class  VariableInstanceList
 
class  VariablePane
 
class  VariablePaneBase
 
class  VariablePaneCell
 
class  VariablePtr
 
struct  VariableType
 
class  VariableValue
 
struct  VariableValueData
 
struct  VariableValuePtr
 a shared_ptr that default constructs a default target, and is always valid More...
 
class  VariableValues
 
struct  ViewImpl
 
class  WindowInformation
 
struct  Winfo
 
class  Wire
 
struct  WireAccessor
 
struct  ZStream
 

Typedefs

typedef boost::geometry::model::d2::point_xy< float > Point
 
typedef std::vector< GroupPtrGroups
 
typedef std::shared_ptr< ItemItemPtr
 
typedef std::vector< ItemPtrItems
 
using FlowVar = Variable< VariableType::flow >
 
using StockVar = Variable< VariableType::stock >
 
typedef std::shared_ptr< GroupGroupPtr
 
typedef std::shared_ptr< WireWirePtr
 
typedef std::vector< WirePtrWires
 
using ConstTensorVarVal = TensorVarValBase<>
 

Enumerations

enum  ShowSlice { ShowSlice::head, ShowSlice::headAndTail, ShowSlice::tail }
 
enum  ItemType {
  wire, op, var, group,
  godley, plot
}
 

Functions

template<class T >
sqr (T x)
 
double clamp360 (double x)
 return x modulo 360 More...
 
int quadrant (double x)
 return quadrant x is in: 0=[-45,45),1=[45,135), etc More...
 
bool flipped (double rotation)
 returns if the angle (in degrees) is in the second or third quadrant More...
 
template<class T >
std::string str (T x)
 utility function to create a string representation of a numeric type More...
 
bool IsNotalnum (char x)
 
void stripNonAlnum (std::string &x)
 
std::string trimWS (const std::string &s)
 
std::string stripActive (const std::string &s)
 repaces characters that cause interpretation by TCL, backslashes are replaced by the set minus operator ∖, and spaces are replaced by ␣, as they cause problems More...
 
template<class F >
OnStackExit< F > onStackExit (F f)
 generator function More...
 
template<class T , class V >
void remove (std::vector< T > &x, const V &v)
 remove an element from a vector. V must be comparable to a T More...
 
template<class T , class D >
std::unique_ptr< T, D > uniqueDeleter (T *x, D d)
 
unsigned numBytes (unsigned char x)
 a wrapper around std::ofstream that checks the write succeeded, throwing an exception if not More...
 
size_t prevIndex (const std::string &str, size_t index)
 return index of previous character to index More...
 
std::istream & operator>> (std::istream &i, const GetUtf8Char &g)
 
void stripByteOrderingMarker (std::istream &s)
 checks if the input stream has the UTF-8 byte ordering marker, and removes it if present More...
 
std::string CSVQuote (const std::string &x, char sep)
 quotes a string if it contains a separator character, and double quotes quotes More...
 
void doOneEvent (bool idleTasksOnly)
 checks if any GUI events are waiting, and proces an event if so More...
 
std::ostream & operator<< (std::ostream &o, OperationType::Type t)
 
classdesc::pack_t decode (const classdesc::CDATA &)
 decode ascii-encoded representation to binary data More...
 
CDATA encode (const pack_t &buf)
 
template<class PreviousSchema , class CurrentSchema >
void loadSchema (CurrentSchema &currentSchema, classdesc::xml_unpack_t &data, const std::string &rootElement)
 
classdesc::CDATA encode (const classdesc::pack_t &)
 encode binary data to ascii-encoded More...
 
std::ostream & operator<< (std::ostream &o, const Units &u)
 
std::ostream & operator<< (std::ostream &o, VariableType::Type t)
 
void randomizeLayout (Group &)
 randomly place items on canvas More...
 
void layoutGroup (Group &)
 auto layout group items More...
 
void drawTriangle (cairo_t *cairo, double x, double y, const ecolab::cairo::Colour &col, double angle=0)
 
bool isNumerical (const std::string &s)
 
constexpr char control (char x)
 
void asgClonedPort (shared_ptr< Port > &p, const map< Item *, ItemPtr > &cloneMap)
 
template<class G , class M , class O >
bool GroupRecursiveDo (G &gp, M GroupItems::*map, O op)
 
Minskyminsky ()
 global minsky object More...
 
const Minskycminsky ()
 const version to help in const correctness More...
 
double yearToPTime (double x)
 
void zoom (float &val, float origin, float factor)
 base zooming transformation More...
 
cmd_data * getCommandData (const string &name)
 
template<class T >
int deleteTclObject (ClientData cd, Tcl_Interp *interp, int argc, const char **argv)
 
template int deleteTclObject< Item > (ClientData cd, Tcl_Interp *interp, int argc, const char **argv)
 
template int deleteTclObject< GodleyTableWindow > (ClientData cd, Tcl_Interp *interp, int argc, const char **argv)
 
void setTCL_objAttributes ()
 
tclvar TCL_obj_lib ("ecolab_library", ECOLAB_LIB)
 
 TCLTYPE (CSVDialog)
 
ecolab::TCL_obj_t & minskyTCL_obj ()
 a TCL_obj_t that provides a hook for detecting model edits More...
 
string to_string (CONST84 char *x)
 
string to_string (Tcl_Obj *x)
 
template<class AV >
void member_entry_hook (int argc, AV argv)
 
void chomp (string &buf)
 
bool getWholeLine (istream &input, string &line, const DataSpec &spec)
 
void escapeDoubledQuotes (std::string &, const DataSpec &)
 replace doubled quotes with escaped quotes More...
 
template<class P , class E , class S >
void loadValueFromCSVFileT (VariableValue &vv, S &stream, const DataSpec &spec, E &onError)
 
template<class S >
void loadValueFromCSVFileS (VariableValue &v, S &filenames, const DataSpec &spec)
 
void loadValueFromCSVFile (VariableValue &, const std::vector< std::string > &filenames, const DataSpec &)
 load a variableValue from a list of files according to data spec More...
 
void loadValueFromCSVFile (VariableValue &, std::istream &input, const DataSpec &)
 load a variableValue from a stream according to data spec More...
 
template<class P >
void reportFromCSVFileT (istream &input, ostream &output, const DataSpec &spec, uintmax_t fileSize)
 
void reportFromCSVFile (std::istream &input, std::ostream &output, const DataSpec &spec, uintmax_t fileSize)
 creates a report CSV file from input, with errors sorted at begining of file, with a column for error messages More...
 
EngNotation engExp (double value)
 return formatted mantissa and exponent in engineering format More...
 
std::string mantissa (double value, const EngNotation &, int digits=3)
 
std::string expMultiplier (int exp)
 
template<class T >
GodleyIteratorAdaptor< T > makeGodleyIt (const T &it)
 
bool operator> (std::size_t x, const UnitsExpressionWalker &y)
 
UnitsExpressionWalker root (const UnitsExpressionWalker &x, const UnitsExpressionWalker &y)
 
UnitsExpressionWalker pow (const UnitsExpressionWalker &x, const UnitsExpressionWalker &y)
 
UnitsExpressionWalker checkDimensionless (const UnitsExpressionWalker &x, const UnitsExpressionWalker &y)
 
UnitsExpressionWalker checkSameDims (const UnitsExpressionWalker &x, const UnitsExpressionWalker &y)
 
void exportToCSV (std::ostream &s, const GodleyTable &g)
 
void exportToLaTeX (std::ostream &f, const GodleyTable &g)
 
string defang (char c)
 
string latexToPangoNonItalicised (const char *input)
 
std::string latexToPangoNonItalicised (const std::string &x)
 
std::string latexToPango (const char *s)
 
std::string latexToPango (const std::string &x)
 interprets LaTeX sequences within, returning result as UTF-8 containing Pango markup. Only a small subset of LaTeX is implemented. More...
 
std::string defang (const std::string &s)
 
void readMdl (Group &group, Simulation &simParms, std::istream &mdlFile)
 import a Vensim mdl file into group, also populating simParms from the control block More...
 
template<template< OperationType::Type > class T, int op, int to>
classdesc::enable_if< Not< is_equal< op, to > >, void >::T registerOps (TensorOpFactory &tensorOpFactory)
 
template<template< OperationType::Type > class T, int op, int to>
classdesc::enable_if< is_equal< op, to >, void >::T registerOps (TensorOpFactory &tensorOpFactory)
 
bool isValueId (const std::string &name)
 check that name is a valid valueId (useful for assertions) More...
 
string canonicalName (const std::string &name)
 convert a raw name into a canonical name - this is not idempotent. More...
 
string valueIdCanonical (size_t scope, const std::string &name)
 construct a valueId @ name should be canonicalised More...
 
string valueId (const std::string &name)
 construct a valueId from fully qualified name @ name should not be canonicalised More...
 
string valueId (const GroupPtr &ref, const std::string &name)
 construct a valueId. @ name should not be canonicalised if name has leading :, then heirarchy is searched for matching local name More...
 
size_t scope (const std::string &name)
 extract scope from a qualified variable name More...
 
GroupPtr scope (GroupPtr ref, const std::string &name)
 starting from reference group ref, applying scoping rules to determine the actual scope of name If name prefixed by :, then search up group heirarchy for locally scoped var, otherwise return ref More...
 
string valueIdFromScope (const GroupPtr &scope, const std::string &name)
 value Id from scope and canonical name name More...
 
std::string uqName (const std::string &name)
 extract unqualified portion of name More...
 

Variables

constexpr float portRadius =6
 radius of circle marking ports at zoom=1 More...
 
constexpr float portRadiusMult =2.0f*portRadius
 
static std::unique_ptr< char[]> _defaultFont
 
static ptime epoch =microsec_clock::local_time()
 
static ptime accumulatedBlitTime =epoch
 
static const size_t maxNumTensorElementsToPlot =10
 
const double yearLength = 3600*24*365.2525
 
UnitsExpressionWalker timeUnit
 
int TCL_obj_minsky
 
TensorOpFactory tensorOpFactory
 
const char * schemaURL ="http://minsky.sf.net/minsky"
 
constexpr float sliderHandleRadius =3
 

Detailed Description

Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state changes.

Support the CSV import dialog

Provide support for the Godley Table spreadsheet window

A simple spreadsheet view

Utilities for walking an exprtk expression object.

To use, define the actions you want to happen for each type of expression

Typedef Documentation

◆ ConstTensorVarVal

Definition at line 123 of file minskyTensorOps.h.

◆ FlowVar

Definition at line 32 of file phillipsDiagram.h.

◆ GroupPtr

typedef std::shared_ptr< Group > minsky::GroupPtr

Definition at line 32 of file port.h.

◆ Groups

typedef std::vector<GroupPtr> minsky::Groups

Definition at line 54 of file group.h.

◆ ItemPtr

typedef std::shared_ptr<Item> minsky::ItemPtr

Definition at line 57 of file item.h.

◆ Items

typedef std::vector<ItemPtr> minsky::Items

Definition at line 366 of file item.h.

◆ Point

typedef boost::geometry::model::d2::point_xy<float> minsky::Point

Definition at line 34 of file geometry.h.

◆ StockVar

Definition at line 33 of file phillipsDiagram.h.

◆ WirePtr

typedef std::shared_ptr<Wire> minsky::WirePtr

Definition at line 102 of file wire.h.

◆ Wires

typedef std::vector<WirePtr> minsky::Wires

Definition at line 103 of file wire.h.

Enumeration Type Documentation

◆ ItemType

Enumerator
wire 
op 
var 
group 
godley 
plot 

Definition at line 121 of file minsky.h.

◆ ShowSlice

enum minsky::ShowSlice
strong
Enumerator
head 
headAndTail 
tail 

Definition at line 25 of file showSlice.h.

Function Documentation

◆ asgClonedPort()

void minsky::asgClonedPort ( shared_ptr< Port > &  p,
const map< Item *, ItemPtr > &  cloneMap 
)

Definition at line 106 of file group.cc.

Referenced by minsky::Group::copyUnowned().

107  {
108  auto clone=cloneMap.find(&p->item());
109  if (clone!=cloneMap.end())
110  {
111  for (size_t i=0; i<p->item().portsSize(); ++i)
112  if (p->item().ports(i).lock()==p)
113  {
114  // set the new port to have the equivalent position in the clone
115  p=clone->second->ports(i).lock();
116  assert(p);
117  }
118  }
119  }
Here is the caller graph for this function:

◆ canonicalName()

std::string minsky::canonicalName ( const string &  name)

convert a raw name into a canonical name - this is not idempotent.

Definition at line 63 of file valueId.cc.

References latexToPangoNonItalicised(), stripActive(), trimWS(), and uqName().

Referenced by minsky::UserFunction::compile(), minsky::Minsky::constructEquations(), minsky::VariableBase::name(), scope(), minsky::UserFunction::units(), valueId(), minsky::VariableValue::valueId(), and minsky::anonymous_namespace{minsky.cc}::GodleyIt::valueId().

64  {
65  return utf_to_utf<char>(stripActive(trimWS(latexToPangoNonItalicised(uqName(name)))));
66  }
std::string uqName(const std::string &name)
extract unqualified portion of name
Definition: valueId.cc:135
std::string trimWS(const std::string &s)
Definition: str.h:49
std::string stripActive(const std::string &s)
repaces characters that cause interpretation by TCL, backslashes are replaced by the set minus operat...
Definition: str.h:63
string latexToPangoNonItalicised(const char *input)
Definition: latexMarkup.cc:855
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkDimensionless()

UnitsExpressionWalker minsky::checkDimensionless ( const UnitsExpressionWalker x,
const UnitsExpressionWalker y 
)
inline

Definition at line 67 of file expressionWalker.h.

References minsky::UnitsExpressionWalker::checkDimensionless().

68  {x.checkDimensionless(); y.checkDimensionless(); return x;}
Here is the call graph for this function:

◆ checkSameDims()

UnitsExpressionWalker minsky::checkSameDims ( const UnitsExpressionWalker x,
const UnitsExpressionWalker y 
)
inline

Definition at line 70 of file expressionWalker.h.

References minsky::UnitsExpressionWalker::checkSameDims(), and minsky::UnitsExpressionWalker::units.

71  {x.checkSameDims(y); auto tmp=x; tmp.units.clear(); return tmp;}
Here is the call graph for this function:

◆ chomp()

void minsky::chomp ( string &  buf)

Definition at line 577 of file CSVParser.cc.

Referenced by getWholeLine(), and TCLcmd::NEWCMD().

578  {
579  if (!buf.empty() && buf.back()=='\r')
580  buf.erase(buf.size()-1);
581  }
Here is the caller graph for this function:

◆ clamp360()

double minsky::clamp360 ( double  x)
inline

return x modulo 360

Definition at line 87 of file geometry.h.

Referenced by quadrant().

88  {
89  // adjust x to be positive before taking modulus
90  if (x<0)
91  x+=(size_t(-x)/360+1)*360;
92  return std::fmod(x,360);
93  }
Here is the caller graph for this function:

◆ cminsky()

const Minsky& minsky::cminsky ( )
inline

const version to help in const correctness

Definition at line 549 of file minsky.h.

References minsky().

Referenced by minsky::PlotWidget::addConstantCurves(), minsky::Group::addIOVar(), minsky::PlotWidget::addPlotPt(), minsky::GroupItems::addWire(), minsky::GodleyTableEditor::copy(), minsky::TensorOpFactory::create(), minsky::VariableBase::definition(), minsky::Ravel::dimension(), minsky::Ravel::dimensionType(), minsky::Ravel::dimensionUnitsFormat(), minsky::ButtonWidget< row >::draw(), minsky::GodleyTableEditor::draw(), minsky::VariableBase::draw(), minsky::anonymous_namespace{minsky.cc}::Network::followWire(), minsky::Group::gotoBookmark_b(), minsky::Ravel::hypercube(), minsky::VariableValue::hypercube(), minsky::Operation< minsky::OperationType::integrate >::iconDraw(), minsky::PhillipsDiagram::init(), minsky::VariableBase::init(), minsky::VariableValue::init(), minsky::ButtonWidget< row >::invoke(), minsky::anonymous_namespace{group.cc}::isGlobal(), minsky::Ravel::joinLockGroup(), MathDAG::latexInit(), loadValueFromCSVFileT(), minsky::VariableBase::local(), minsky::Ravel::lockGroupColours(), minsky::VariablePtr::makeConsistentWithValue(), MathDAG::matlabInit(), minsky::GodleyTable::nameUnique(), minsky::GodleyTableEditor::paste(), minsky::Group::renameAllInstances(), minsky::Canvas::renameItem(), minsky::VariableValues::resetValue(), minsky::PlotWidget::scalePlot(), minsky::Ravel::setDimension(), minsky::VariableBase::sliderVisible(), minsky::GodleyIcon::stockVarUnits(), minsky::VariableValue::summary(), MathDAG::VariableDAG::tensorEval(), minsky::Item::throw_error(), minsky::UserFunction::units(), minsky::IntOp::units(), minsky::Time::units(), minsky::Derivative::units(), minsky::VariableBase::units(), minsky::VariablePane::update(), minsky::VariableBase::value(), and minsky::VariableBase::vValue().

549 {return minsky();}
Minsky & minsky()
global minsky object
Definition: minskyTCL.cc:51
Here is the call graph for this function:

◆ control()

constexpr char minsky::control ( char  x)
inline

Definition at line 631 of file godleyTableWindow.cc.

Referenced by minsky::GodleyTableEditor::keyPress().

631 {return x-'`';}
Here is the caller graph for this function:

◆ CSVQuote()

std::string minsky::CSVQuote ( const std::string &  x,
char  sep 
)
inline

quotes a string if it contains a separator character, and double quotes quotes

Definition at line 162 of file str.h.

Referenced by minsky::VariableValue::exportAsCSV(), and minsky::Minsky::openLogFile().

163  {
164  std::string r;
165  bool needsQuoting=false;
166  for (auto c: x)
167  {
168  r+=c;
169  if (c=='"') {r+='"'; needsQuoting=true;}
170  if (c==sep) needsQuoting=true;
171  }
172  if (needsQuoting) return "\""+r+"\"";
173  return r;
174  }
Here is the caller graph for this function:

◆ decode()

classdesc::pack_t minsky::decode ( const classdesc::CDATA &  data)

decode ascii-encoded representation to binary data

Definition at line 34 of file schemaHelper.cc.

References a85::from_a85(), and a85::size_for_bin().

Referenced by schema3::Item::convertTensorDataFromSchema2(), and schema3::Minsky::populateGroup().

35  {
36  string trimmed; //trim whitespace
37  for (auto c: data)
38  if (!isspace(c)) trimmed+=c;
39 
40  vector<unsigned char> zbuf(a85::size_for_bin(trimmed.size()));
41  // reverse transformation required to avoid the escape sequence ']]>'
42  replace(trimmed.begin(),trimmed.end(),'~',']');
43  a85::from_a85(trimmed.data(), trimmed.size(),zbuf.data());
44 
45  InflateZStream zs(zbuf);
46  zs.inflate();
47  return std::move(zs.output);
48  }
int size_for_bin(int textlen)
Definition: a85.cc:52
void from_a85(const char *text, int textlen, u8 *data)
Definition: a85.cc:56
Here is the call graph for this function:
Here is the caller graph for this function:

◆ defang() [1/2]

std::string minsky::defang ( const std::string &  s)
inline

Definition at line 39 of file latexMarkup.h.

References defang().

39  {
40  std::string r;
41  for (auto& c: s) r+=defang(c);
42  return r;
43  }
std::string defang(const std::string &s)
Definition: latexMarkup.h:39
Here is the call graph for this function:

◆ defang() [2/2]

std::string minsky::defang ( char  c)

Definition at line 842 of file latexMarkup.cc.

Referenced by minsky::PlotWidget::addConstantCurves(), defang(), minsky::GodleyTableEditor::draw(), anonymous_namespace{latexMarkup.cc}::Result::processLaTeX(), minsky::GodleyTableEditor::textIdx(), and anonymous_namespace{latexMarkup.cc}::utf8char().

843  {
844  switch (c)
845  {
846  case '<': return "&lt;";
847  case '>': return "&gt;";
848  case '&': return "&amp;";
849  case '\'': return "&apos;";
850  case '\"': return "&quot;";
851  default: return string{&c,1};
852  }
853  }
Here is the caller graph for this function:

◆ deleteTclObject()

template<class T >
int minsky::deleteTclObject ( ClientData  cd,
Tcl_Interp *  interp,
int  argc,
const char **  argv 
)

Definition at line 75 of file minskyTCL.cc.

77  {
78  assert( strcmp(argv[0]+strlen(argv[0])-strlen(".delete"),
79  ".delete")==0);
80  const std::string s(argv[0]);
81  ecolab::TCL_obj_deregister(s.substr(0,s.length()-strlen(".delete")));
82  delete (T*)cd;
83  return TCL_OK;
84  }

◆ deleteTclObject< GodleyTableWindow >()

template int minsky::deleteTclObject< GodleyTableWindow > ( ClientData  cd,
Tcl_Interp *  interp,
int  argc,
const char **  argv 
)

◆ deleteTclObject< Item >()

template int minsky::deleteTclObject< Item > ( ClientData  cd,
Tcl_Interp *  interp,
int  argc,
const char **  argv 
)

Referenced by minsky::MinskyTCL::TCLItem().

Here is the caller graph for this function:

◆ doOneEvent()

void minsky::doOneEvent ( bool  idletasksOnly)

checks if any GUI events are waiting, and proces an event if so

Definition at line 161 of file tclmain.cc.

Referenced by MathDAG::ConstantDAG::addEvalOps(), MathDAG::VariableDAG::addEvalOps(), MathDAG::IntegralInputVariableDAG::addEvalOps(), MathDAG::OperationDAGBase::addEvalOps(), and minsky::RungeKutta::rkstep().

162  {
163  Tcl_DoOneEvent(TCL_DONT_WAIT | (idletasksOnly? TCL_IDLE_EVENTS: 0));
164  }
Here is the caller graph for this function:

◆ drawTriangle()

void minsky::drawTriangle ( cairo_t *  cairo,
double  x,
double  y,
const ecolab::cairo::Colour &  col,
double  angle = 0 
)

Referenced by minsky::SwitchIcon::draw(), minsky::Ravel::draw(), and minsky::PlotWidget::draw().

Here is the caller graph for this function:

◆ encode() [1/2]

CDATA minsky::encode ( const pack_t &  buf)

Definition at line 51 of file schemaHelper.cc.

References a85::size_for_a85(), and a85::to_a85().

Referenced by schema3::Item::convertTensorDataFromSchema2(), and schema3::Item::packTensorInit().

52  {
53  vector<unsigned char> zbuf(buf.size());
54  DeflateZStream zs(buf, zbuf);
55  zs.deflate();
56 
57  vector<char> cbuf(a85::size_for_a85(zs.total_out,false));
58  a85::to_a85(zbuf.data(),zs.total_out, cbuf.data(), false);
59  // this ensures that the escape sequence ']]>' never appears in the data
60  replace(cbuf.begin(),cbuf.end(),']','~');
61  return CDATA(cbuf.begin(),cbuf.end());
62  }
void to_a85(const u8 *data, int binlen, char *text, bool append_null)
Definition: a85.cc:12
int size_for_a85(int binlen, bool append_null)
Definition: a85.cc:8
Here is the call graph for this function:
Here is the caller graph for this function:

◆ encode() [2/2]

classdesc::CDATA minsky::encode ( const classdesc::pack_t &  )

encode binary data to ascii-encoded

◆ engExp()

EngNotation minsky::engExp ( double  value)

return formatted mantissa and exponent in engineering format

Definition at line 383 of file variableValue.cc.

References minsky::EngNotation::engExp, MathDAG::log(), and minsky::EngNotation::sciExp.

Referenced by minsky::GodleyTableEditor::draw(), and minsky::VariableBase::engExp().

384  {
385  EngNotation r;
386  r.sciExp=(v!=0)? floor(log(fabs(v))/log(10)): 0;
387  if (r.sciExp==3) // special case for dates
388  r.engExp=0;
389  else
390  r.engExp=r.sciExp>=0? 3*(r.sciExp/3): 3*((r.sciExp+1)/3-1);
391  return r;
392  }
Expr log(const Expr &x)
Definition: expr.h:120
Here is the call graph for this function:
Here is the caller graph for this function:

◆ escapeDoubledQuotes()

void minsky::escapeDoubledQuotes ( std::string &  line,
const DataSpec spec 
)

replace doubled quotes with escaped quotes

Definition at line 605 of file CSVParser.cc.

References minsky::DataSpecSchema::escape, minsky::DataSpecSchema::quote, and minsky::DataSpecSchema::separator.

Referenced by getWholeLine().

606  {
607  // replace doubled quotes with escape quote
608  for (size_t i=1; i<line.size(); ++i)
609  if (line[i]==spec.quote && line[i-1]==spec.quote &&
610  ((i==1 && (i==line.size()-1|| line[i+1]!=spec.quote)) || // deal with leading ""
611  (i>1 &&
612  ((line[i-2]!=spec.quote && line[i-2]!=spec.escape &&
613  (line[i-2]!=spec.separator || i==line.size()-1|| line[i+1]!=spec.quote)) // deal with ,''
614  || // deal with "" middle or end
615  (line[i-2]==spec.quote && (i==2 || line[i-3]==spec.separator || line[i-3]==spec.escape)))))) // deal with leading """
616  line[i-1]=spec.escape;
617  }
Here is the caller graph for this function:

◆ expMultiplier()

string minsky::expMultiplier ( int  exp)

Definition at line 413 of file variableValue.cc.

References MathDAG::exp(), and to_string().

Referenced by minsky::GodleyTableEditor::draw(), minsky::VariableBase::draw(), and minsky::RenderVariable::RenderVariable().

414  {return exp!=0? "×10<sup>"+std::to_string(exp)+"</sup>": "";}
Expr exp(const Expr &x)
Definition: expr.h:126
string to_string(CONST84 char *x)
Definition: minskyTCLObj.h:33
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exportToCSV()

void minsky::exportToCSV ( std::ostream &  s,
const GodleyTable g 
)

Definition at line 61 of file godleyExport.cc.

References minsky::GodleyTable::_assetClass(), minsky::GodleyTable::cols(), minsky::GodleyTable::doubleEntryCompliant, minsky::anonymous_namespace{godleyExport.cc}::fcStr(), minsky::GodleyTable::getCell(), latexToPango(), minsky::GodleyTable::rows(), minsky::anonymous_namespace{godleyExport.cc}::trim(), and uqName().

Referenced by minsky::GodleyTable::exportToCSV().

62  {
63  s<<'"'<<g.getCell(0,0)<<'"';
64  for (unsigned i=1; i<g.cols(); ++i)
65  s<<",\""<<trim(latexToPango(uqName(g.getCell(0,i))))<<'"';
66  s<<'\n';
67  if (g.doubleEntryCompliant)
68  {
69  s<<"Asset Class";
70  for (unsigned i=1; i<g.cols(); ++i)
71  s<<","<<enum_keysData<GodleyAssetClass::AssetClass>::
72  keysData[g._assetClass(i)].name;
73  s<<"\n";
74  }
75  for (unsigned r=1; r<g.rows(); ++r)
76  {
77  s<<g.getCell(r,0);
78  for (unsigned c=1; c<g.cols(); ++c)
79  s<<",\""<<trim(latexToPango(fcStr(FlowCoef(g.getCell(r,c)))))<<'"';
80  s<<'\n';
81  }
82  }
std::string latexToPango(const char *s)
Definition: latexMarkup.h:30
std::string uqName(const std::string &name)
extract unqualified portion of name
Definition: valueId.cc:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exportToLaTeX()

void minsky::exportToLaTeX ( std::ostream &  f,
const GodleyTable g 
)

Definition at line 84 of file godleyExport.cc.

References minsky::GodleyTable::_assetClass(), minsky::GodleyTable::cols(), minsky::GodleyTable::doubleEntryCompliant, f, minsky::anonymous_namespace{godleyExport.cc}::fcStr(), minsky::GodleyTable::getCell(), minsky::GodleyTable::rows(), and uqName().

Referenced by minsky::GodleyTable::exportToLaTeX().

85  {
86  f<<"\\documentclass{article}\n\\begin{document}\n";
87  f<<"\\begin{tabular}{|c|";
88  for (unsigned i=1; i<g.cols(); ++i)
89  f<<'c';
90  f<<"|}\n\\hline\n";
91  f<<"Flows $\\downarrow$ / Stock Variables $\\rightarrow$";
92  for (unsigned i=1; i<g.cols(); ++i)
93  f<<"&\\multicolumn{1}{|c|}{$"<<uqName(g.getCell(0,i))<<"$}";
94 
95  // asset class descriptors
96  if (g.doubleEntryCompliant)
97  {
98  f<<"\\\\\\cline{2-"<<g.cols()<<"}Asset Class";
99  unsigned repeat=0;
100  GodleyAssetClass::AssetClass asset=GodleyAssetClass::noAssetClass;
101 
102  auto outputAC=[&]() {
103  if (repeat>0)
104  f<<"&\\multicolumn{"<<repeat<<"}{|c|}{"<<
105  enum_keysData<GodleyAssetClass::AssetClass>::
106  keysData[asset].name<<'}';
107  };
108 
109  for (unsigned i=1; i<g.cols(); ++i)
110  if (g._assetClass(i)!=asset)
111  {
112  outputAC();
113  asset=g._assetClass(i);
114  repeat=1;
115  }
116  else
117  repeat++;
118 
119  // now output last column
120  outputAC();
121  }
122 
123  f<<"\\\\\\hline\n";
124  for (unsigned r=1; r<g.rows(); ++r)
125  {
126  f<<g.getCell(r,0);
127  for (unsigned c=1; c<g.cols(); ++c)
128  f<<"&$"<<fcStr(FlowCoef(g.getCell(r,c)))<<'$';
129  f<<"\\\\\n";
130  }
131  f<<"\\hline\n\\end{tabular}\n";
132  f<<"\\end{document}\n";
133  }
function f
Definition: canvas.m:1
std::string uqName(const std::string &name)
extract unqualified portion of name
Definition: valueId.cc:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flipped()

bool minsky::flipped ( double  rotation)
inline

returns if the angle (in degrees) is in the second or third quadrant

Definition at line 102 of file geometry.h.

Referenced by minsky::VariableBase::clickType(), minsky::SwitchIcon::draw(), minsky::OperationBase::draw(), minsky::VariableBase::draw(), minsky::Group::draw(), minsky::Item::draw(), minsky::DrawBinOp::drawPort(), minsky::OperationBase::drawUserFunction(), schema3::populateItem(), minsky::Item::rotationAsRadians(), minsky::Minsky::setDefinition(), and minsky::Canvas::zoomToFit().

103  {
104  const double fm=std::fmod(rotation,360);
105  return std::abs(fm)>90 && std::abs(fm)<270;
106  }
Here is the caller graph for this function:

◆ getCommandData()

cmd_data * minsky::getCommandData ( const string &  name)

Definition at line 62 of file minskyTCL.cc.

Referenced by minsky::Minsky::commandHook(), minsky::MinskyTCL::getCommandData(), member_entry_hook(), and setTCL_objAttributes().

63  {
64  Tcl_CmdInfo info;
65  if (Tcl_GetCommandInfo(interp(),name.c_str(),&info))
66  {
67  if (info.isNativeObjectProc)
68  return (cmd_data*)info.objClientData;
69  return (cmd_data*)info.clientData;
70  }
71  return nullptr;
72  }
Here is the caller graph for this function:

◆ getWholeLine()

bool minsky::getWholeLine ( istream &  input,
string &  line,
const DataSpec spec 
)

Definition at line 584 of file CSVParser.cc.

References chomp(), escapeDoubledQuotes(), and minsky::DataSpecSchema::quote.

Referenced by minsky::ParseCSV< P >::parse(), and reportFromCSVFileT().

585  {
586  line.clear();
587  bool r=getline(input,line).good();
588  chomp(line);
589  while (r)
590  {
591  int quoteCount=0;
592  for (auto i: line)
593  if (i==spec.quote)
594  ++quoteCount;
595  if (quoteCount%2==0) break; // data line correctly terminated
596  string buf;
597  r=getline(input,buf).good(); // read next line and append
598  chomp(buf);
599  line+=buf;
600  }
601  escapeDoubledQuotes(line,spec);
602  return r || !line.empty();
603  }
Definition: input.py:1
void escapeDoubledQuotes(std::string &line, const DataSpec &spec)
replace doubled quotes with escaped quotes
Definition: CSVParser.cc:605
void chomp(string &buf)
Definition: CSVParser.cc:577
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GroupRecursiveDo()

template<class G , class M , class O >
bool minsky::GroupRecursiveDo ( G &  gp,
M GroupItems::*  map,
op 
)

Definition at line 203 of file group.h.

References op.

Referenced by minsky::GroupItems::recursiveDo().

204  {
205  for (auto i=(gp.*map).begin(); i!=(gp.*map).end(); ++i)
206  {
207  assert(*i);
208  if (op(gp.*map,i))
209  return true;
210  }
211  for (auto& g: gp.groups)
212  {
213  assert(g);
214  if (g->recursiveDo(map, op))
215  return true;
216  }
217  return false;
218  }
Here is the caller graph for this function:

◆ IsNotalnum()

bool minsky::IsNotalnum ( char  x)
inline

Definition at line 42 of file str.h.

Referenced by stripNonAlnum().

42 {return !std::isalnum(x);}
Here is the caller graph for this function:

◆ isNumerical()

bool minsky::isNumerical ( const std::string &  s)

Definition at line 338 of file CSVParser.cc.

References anonymous_namespace{CSVParser.cc}::quotedStoD(), and anonymous_namespace{CSVParser.cc}::stripWSAndDecimalSep().

Referenced by minsky::CSVDialog::classifyColumns().

339  {
340  size_t charsProcd=0;
341  const string stripped=stripWSAndDecimalSep(s);
342  try
343  {
344  quotedStoD(stripped, charsProcd);
345  }
346  catch (...) {return false;}
347  return charsProcd==stripped.size();
348  }
string stripWSAndDecimalSep(const string &s)
Definition: CSVParser.cc:294
double quotedStoD(const string &s, size_t &charsProcd)
Definition: CSVParser.cc:272
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValueId()

bool minsky::isValueId ( const string &  name)

check that name is a valid valueId (useful for assertions)

Definition at line 33 of file valueId.cc.

Referenced by MathDAG::VariableDAG::addEvalOps(), minsky::Minsky::convertVarType(), minsky::VariableBase::ensureValueExists(), minsky::VariableBase::init(), MathDAG::SystemOfEquations::makeDAG(), MathDAG::SystemOfEquations::populateEvalOpVector(), minsky::VariableBase::setUnits(), minsky::VariableValues::validEntries(), and minsky::VariableBase::value().

34  {
35  // original code, left for reference
36  // static regex pattern("((constant)?\\d*:[^:\\ \f\n\r\t\v]+)");
37  // return name.length()>1 && name.substr(name.length()-2)!=":_" &&
38  // regex_match(utf_to_utf<char>(name), pattern); // Leave curly braces in valueIds. For ticket 1165
39  if (name.substr(name.length()-2)==":_") return false;
40 
41  static const string constantPrefix="constant:", tempPrefix="temp:";
42  auto nameCStr=name.c_str();
43  const char* endp=nullptr;
44  strtoull(nameCStr,&const_cast<char*&>(endp),10);
45  if (*endp==':' || name.starts_with(constantPrefix)||name.starts_with(tempPrefix))
46  {
47  if (*endp!=':')
48  {
49  if (name[constantPrefix.length()-1]==':')
50  endp=nameCStr+constantPrefix.length()-1;
51  else
52  endp=nameCStr+tempPrefix.length()-1;
53  }
54  // check unqualified name portion has no verboten characters
55  for (auto c=endp+1; *c!='\0'; ++c)
56  if (strchr(":\\ \f\n\r\t\v",*c))
57  return false;
58  return true;
59  }
60  return false;
61  }
Here is the caller graph for this function:

◆ latexToPango() [1/2]

◆ latexToPango() [2/2]

std::string minsky::latexToPango ( const std::string &  x)
inline

interprets LaTeX sequences within, returning result as UTF-8 containing Pango markup. Only a small subset of LaTeX is implemented.

Definition at line 34 of file latexMarkup.h.

References latexToPango().

35  {return latexToPango(x.c_str());}
std::string latexToPango(const std::string &x)
interprets LaTeX sequences within, returning result as UTF-8 containing Pango markup. Only a small subset of LaTeX is implemented.
Definition: latexMarkup.h:34
Here is the call graph for this function:

◆ latexToPangoNonItalicised() [1/2]

std::string minsky::latexToPangoNonItalicised ( const std::string &  x)
inline

Definition at line 27 of file latexMarkup.h.

References latexToPangoNonItalicised().

28  {return latexToPangoNonItalicised(x.c_str());}
std::string latexToPangoNonItalicised(const std::string &x)
Definition: latexMarkup.h:27
Here is the call graph for this function:

◆ latexToPangoNonItalicised() [2/2]

std::string minsky::latexToPangoNonItalicised ( const char *  input)

Definition at line 855 of file latexMarkup.cc.

References anonymous_namespace{latexMarkup.cc}::utf8char().

Referenced by canonicalName(), latexToPango(), latexToPangoNonItalicised(), minsky::PlotWidget::xlabel(), minsky::PlotWidget::y1label(), and minsky::PlotWidget::ylabel().

856  {
857  if (input[0]=='\0')
858  return ""; // do not wrap with italic environment
859  Result r;
860  while (*input!='\0')
861  switch (*input)
862  {
863  case '\\':
864  r.processLaTeX(input);
865  break;
866  case '_':
867  r.push("sub", ++input);
868  break;
869  case '^':
870  r.push("sup", ++input);
871  break;
872  case '{':
873  r.push("{", ++input);
874  break;
875  case '}':
876  input++;
877  r.pop();
878  break;
879  default:
880  r+=utf8char(input);
881  break;
882  }
883 
884  // take care of mismatched braces
885  while (!r.stack.empty()) r.pop();
886  return r;
887  }
Definition: input.py:1
string utf8char(const char *&input)
Definition: latexMarkup.cc:705
Here is the call graph for this function:
Here is the caller graph for this function:

◆ layoutGroup()

void minsky::layoutGroup ( Group g)

auto layout group items

Definition at line 101 of file autoLayout.cc.

References minsky::GroupItems::groups, minsky::GroupItems::items, pyminsky::minsky, minsky::Item::moveTo(), minsky::ProgressUpdater::setProgress(), MathDAG::sqrt(), minsky::anonymous_namespace{autoLayout.cc}::totalArea(), and minsky::GroupItems::wires.

Referenced by minsky::Group::autoLayout().

102  {
103  if (g.items.size()+g.groups.size()<2) return;
104  const double layoutSize=sqrt(10*totalArea(g)); //half width of square to emplace the items
105 
106  Graph gg;
107  map<Item*, decltype(gg.add_vertex())> vertexMap;
108  for (auto& i: g.items)
109  vertexMap.emplace(i.get(), gg.add_vertex(i.get()));
110  for (auto& i: g.groups)
111  {
112  vertexMap.emplace(i.get(), gg.add_vertex(i.get()));
113  // add I/O variables, as these may be wired too.
114  for (auto& j: i->inVariables)
115  vertexMap.emplace(j.get(), gg.add_vertex(j.get()));
116  for (auto& j: i->outVariables)
117  vertexMap.emplace(j.get(), gg.add_vertex(j.get()));
118  }
119 
120  for (auto& w: g.wires)
121  gg.add_edge(vertexMap[&w->from()->item()], vertexMap[&w->to()->item()]);
122 
123  // add some additional vertices representing classes: functions, parameters, flowVars, stockVars etc
124  Item functions, parameters, flowVars, intVars;
125  functions.moveTo(-0.5*layoutSize,-0.5*layoutSize);
126  parameters.moveTo(-0.5*layoutSize,0.5*layoutSize);
127  flowVars.moveTo(-0.5*layoutSize,0.5*layoutSize);
128  intVars.moveTo(0.5*layoutSize,0.5*layoutSize);
129  vertexMap.emplace(&functions, gg.add_vertex(&functions));
130  vertexMap.emplace(&parameters, gg.add_vertex(&parameters));
131  vertexMap.emplace(&flowVars, gg.add_vertex(&flowVars));
132  vertexMap.emplace(&intVars, gg.add_vertex(&intVars));
133 
134  // now bind items without outputs to this fixtures
135  for (auto& i: g.items)
136  {
137  if (dynamic_cast<UserFunction*>(i.get()) && i->ports(0).lock()->wires().empty())
138  gg.add_edge(vertexMap[&functions], vertexMap[i.get()]);
139  else if (auto v=i->variableCast())
140  if ((i->portsSize()>0 && i->ports(0).lock()->wires().empty()) || (i->portsSize()>1 && !i->ports(1).lock()->wires().empty()))
141  switch (v->type())
142  {
143  case VariableType::parameter:
144  gg.add_edge(vertexMap[&parameters], vertexMap[i.get()]);
145  break;
146  case VariableType::flow:
147  gg.add_edge(vertexMap[&flowVars], vertexMap[i.get()]);
148  break;
149  case VariableType::integral:
150  gg.add_edge(vertexMap[&intVars], vertexMap[i.get()]);
151  break;
152  default:
153  break;
154  }
155  }
156 
157 
158  using Topology=square_topology<>;
159 
160  using PosMap=std::map<decltype(gg.add_vertex()), Topology::point_type>;
161  PosMap positions;
162  const boost::associative_property_map<PosMap> pm(positions);
163 
164  for (auto& i: vertexMap)
165  {
166  Topology::point_type p;
167  p[0]=i.first->x();
168  p[1]=i.first->y();
169  positions[i.second]=p;
170  }
171 
172  double temp=10;
173  // use the cooling schedule to drive the progress bar
174  ProgressUpdater pu(minsky().progressState, "Autolaying out...", 100);
175  fruchterman_reingold_force_directed_layout
176  (gg,pm, Topology(layoutSize), attractive_force(WireForce()).repulsive_force(RepulsiveForce()).
177  cooling([&temp,&pu](){pu.setProgress(0.1*(10-temp)); return std::max(0., temp-=0.1);}));
178  // maybe not needed
179  //.force_pairs(boost::all_force_pairs())
180 
181  // move items to result of algorithm
182  auto vertexRange=vertices(gg);
183  for (auto i=vertexRange.first; i!=vertexRange.second; ++i)
184  {
185  auto p=pm[*i];
186  gg[*i]->moveTo(p[0]+layoutSize,p[1]+layoutSize);
187  }
188 
189  // TODO should we recursively descend into groups or not? If so,
190  // then we need to be aware of group's size
191 // for (auto& i: g.groups)
192 // layoutGroup(*i);
193  }
Expr sqrt(const Expr &x)
Definition: expr.h:154
minsky::Minsky minsky
Definition: pyminsky.cc:28
boost::directed_graph< Item * > Graph
Definition: autoLayout.cc:44
Groups groups
Definition: group.h:79
void moveTo(float x, float y)
Definition: item.cc:256
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadSchema()

template<class PreviousSchema , class CurrentSchema >
void minsky::loadSchema ( CurrentSchema &  currentSchema,
classdesc::xml_unpack_t &  data,
const std::string &  rootElement 
)

Definition at line 99 of file schemaHelper.h.

References xml_unpack().

101  {
102  xml_unpack(data, rootElement, currentSchema);
103  if (currentSchema.schemaVersion < currentSchema.version)
104  {
105  PreviousSchema prevSchema(data);
106  currentSchema=prevSchema;
107  }
108  else if (currentSchema.schemaVersion > currentSchema.version)
109  throw error("Minsky schema version %d not supported",currentSchema.schemaVersion);
110  }
void xml_unpack(classdesc::xml_unpack_t &, const classdesc::string &, classdesc::ref< ecolab::urand > &)
Here is the call graph for this function:

◆ loadValueFromCSVFile() [1/2]

void minsky::loadValueFromCSVFile ( VariableValue v,
const vector< string > &  filenames,
const DataSpec spec 
)

load a variableValue from a list of files according to data spec

Definition at line 1058 of file CSVParser.cc.

References loadValueFromCSVFileS().

Referenced by minsky::VariableBase::importFromCSV().

1059  {loadValueFromCSVFileS(v,filenames,spec);}
void loadValueFromCSVFileS(VariableValue &v, S &filenames, const DataSpec &spec)
Definition: CSVParser.cc:1049
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadValueFromCSVFile() [2/2]

void minsky::loadValueFromCSVFile ( VariableValue v,
istream &  input,
const DataSpec spec 
)

load a variableValue from a stream according to data spec

Definition at line 1060 of file CSVParser.cc.

References loadValueFromCSVFileS().

1061  {loadValueFromCSVFileS(v,input,spec);}
void loadValueFromCSVFileS(VariableValue &v, S &filenames, const DataSpec &spec)
Definition: CSVParser.cc:1049
Definition: input.py:1
Here is the call graph for this function:

◆ loadValueFromCSVFileS()

template<class S >
void minsky::loadValueFromCSVFileS ( VariableValue v,
S &  filenames,
const DataSpec spec 
)

Definition at line 1049 of file CSVParser.cc.

References minsky::DataSpecSchema::separator.

Referenced by loadValueFromCSVFile().

1050  {
1051  OnError onError;
1052  if (spec.separator==' ')
1053  loadValueFromCSVFileT<SpaceSeparatorParser>(v,filenames,spec,onError);
1054  else
1055  loadValueFromCSVFileT<Parser>(v,filenames,spec,onError);
1056  }
handle reporting errors in loadValueFromCSVFileT when loading files
Definition: CSVParser.cc:620
Here is the caller graph for this function:

◆ loadValueFromCSVFileT()

template<class P , class E , class S >
void minsky::loadValueFromCSVFileT ( VariableValue vv,
S &  stream,
const DataSpec spec,
E &  onError 
)

Definition at line 925 of file CSVParser.cc.

References minsky::Minsky::abort, cminsky(), minsky::DataSpecSchema::dimensionCols, minsky::DataSpecSchema::dimensionNames, minsky::ParseCSV< P >::dimLabels, minsky::ParseCSV< P >::hc, minsky::DataSpecSchema::horizontalDimName, minsky::VariableValue::hypercube(), minsky::VariableValue::index(), minsky::anonymous_namespace{userFunction.cc}::isnan(), MathDAG::log(), minsky(), minsky::DataSpecSchema::missingValue, minsky::VariableValueData::tensorInit, and minsky::ParseCSV< P >::tmpData.

926  {
927  const BusyCursor busy(minsky());
928  const ProgressUpdater pu(minsky().progressState, "Importing CSVs",4);
929 
930  {
931  // check dimension names are all distinct
932  set<string> dimNames{spec.horizontalDimName};
933  for (auto i: spec.dimensionCols)
934  if (!dimNames.insert(spec.dimensionNames[i]).second)
935  throw runtime_error("Duplicate dimension: "+spec.dimensionNames[i]);
936  }
937 
938  try
939  {
940  ParseCSV<P> parseCSV(stream,spec,0/*not used*/,onError);
941 
942  auto& tmpData=parseCSV.tmpData;
943  auto& dimLabels=parseCSV.dimLabels;
944  auto& hc=parseCSV.hc;
945 
946  // remove zero length dimensions
947  auto d=dimLabels.begin();
948  assert(hc.xvectors.size()==dimLabels.size());
949  for (auto i=hc.xvectors.begin(); i!=hc.xvectors.end();)
950  if (i->size()<2)
951  {
952  hc.xvectors.erase(i);
953  }
954  else
955  {
956  ++i;
957  ++d;
958  }
959  assert(hc.xvectors.size()<=dimLabels.size());
960 
961  for (auto& xv: hc.xvectors)
962  xv.imposeDimension();
963  ++minsky().progressState;
964 
965  if (hc.logNumElements()>log(numeric_limits<size_t>::max()))
966  throw runtime_error("Hypercube dimensionality exceeds maximum size, results are likely to be garbage.\n"
967  "Suggest rolling up one or more axes by ignoring them, and setting 'Duplicate Key Action' as appropriate");
968 
969  if (log(tmpData.size())-hc.logNumElements()>=log(0.5))
970  { // dense case
971  vv.index({});
972  if (cminsky().checkMemAllocation(2*hc.numElements()*sizeof(double))==Minsky::abort)
973  throw MemoryExhausted();
974  vv.hypercube(hc);
975  // stash the data into vv tensorInit field
976  vv.tensorInit.index({});
977  vv.tensorInit.hypercube(hc);
978  for (auto& i: vv.tensorInit)
979  i=spec.missingValue;
980  auto dims=vv.hypercube().dims();
981  const ProgressUpdater pu(minsky().progressState,"Loading data",tmpData.size());
982  for (auto& i: tmpData)
983  {
984  size_t idx=0;
985  assert (hc.rank()<=i.first.size());
986  assert(dimLabels.size()>=hc.rank());
987  int j=hc.rank()-1, k=i.first.size()-1;
988  while (j>=0 && k>=0)
989  {
990  while (dimLabels[k].size()<2) --k; // skip over elided dimensions
991  auto dimLabel=dimLabels[k].find(i.first[k]);
992  assert(dimLabel!=dimLabels[k].end());
993  idx = (idx*dims[j]) + dimLabel->second;
994  --j; --k;
995  }
996  vv.tensorInit[idx]=i.second;
997  ++minsky().progressState;
998  }
999  }
1000  else
1001  { // sparse case
1002  if (cminsky().checkMemAllocation(6*tmpData.size()*sizeof(double))==Minsky::abort)
1003  throw MemoryExhausted();
1004  auto dims=hc.dims();
1005  const ProgressUpdater pu(minsky().progressState,"Indexing and loading",tmpData.size()+1);
1006 
1007  map<size_t,double,less<size_t>,LibCAllocator<pair<const size_t,double>>> indexValue; // intermediate stash to sort index vector
1008  {
1009  for (auto& i: tmpData)
1010  {
1011  size_t idx=0;
1012  assert (dims.size()<=i.first.size());
1013  assert(dimLabels.size()>=dims.size());
1014  int j=dims.size()-1, k=i.first.size()-1;
1015  while (j>=0 && k>=0) // changed from for loop to while loop at CodeQL's insistence
1016  {
1017  while (dimLabels[k].size()<2) --k; // skip over elided dimensions
1018  auto dimLabel=dimLabels[k].find(i.first[k]);
1019  assert(dimLabel!=dimLabels[k].end());
1020  idx = (idx*dims[j]) + dimLabel->second;
1021  --j;
1022  --k;
1023  }
1024  if (!isnan(i.second))
1025  indexValue.emplace(idx, i.second);
1026  ++minsky().progressState;
1027  }
1028 
1029  vv.tensorInit=indexValue;
1030  vv.index(indexValue);
1031  vv.tensorInit.hypercube(hc);
1032  ++minsky().progressState;
1033  }
1034  }
1035  minsky().progressState.title="Cleaning up";
1036  minsky().progressState.displayProgress();
1037  }
1038  catch (const std::bad_alloc&)
1039  { // replace with a more user friendly error message
1040  throw MemoryExhausted();
1041  }
1042  catch (const std::length_error&)
1043  { // replace with a more user friendly error message
1044  throw MemoryExhausted();
1045  }
1046  }
const Hypercube & hypercube() const override
minsky::Minsky minsky
Definition: pyminsky.cc:28
std::string horizontalDimName
TensorVal tensorInit
when init is a tensor of values, this overrides the init string
Definition: variableValue.h:50
const Index & index(Index &&i) override
const Minsky & cminsky()
const version to help in const correctness
Definition: minsky.h:549
std::vector< std::string > dimensionNames
Expr log(const Expr &x)
Definition: expr.h:120
std::set< unsigned > dimensionCols
rows and columns that are comment lines to be ignored
Here is the call graph for this function:

◆ makeGodleyIt()

template<class T >
GodleyIteratorAdaptor<T> minsky::makeGodleyIt ( const T &  it)

Definition at line 89 of file evalGodley.h.

90  {return GodleyIteratorAdaptor<T>(it);}

◆ mantissa()

string minsky::mantissa ( double  value,
const EngNotation e,
int  digits = 3 
)

Definition at line 394 of file variableValue.cc.

References pow().

Referenced by minsky::GodleyTableEditor::draw(), and minsky::VariableBase::mantissa().

395  {
396  int width, decimal_places;
397  digits=std::max(digits, 3);
398  switch (e.sciExp-e.engExp)
399  {
400  case -3: width=digits+4; decimal_places=digits+1; break;
401  case -2: width=digits+3; decimal_places=digits; break;
402  case 0: case -1: width=digits+2; decimal_places=digits-1; break;
403  case 1: width=digits+2; decimal_places=digits-2; break;
404  case 2: case 3: width=digits+2; decimal_places=digits-3; break;
405  default: return ""; // shouldn't be here...
406  }
407  char val[80];
408  const char conv[]="%*.*f";
409  snprintf(val,sizeof(val),conv,width,decimal_places,value*pow(10,-e.engExp));
410  return val;
411  }
UnitsExpressionWalker pow(const UnitsExpressionWalker &x, const UnitsExpressionWalker &y)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ member_entry_hook()

template<class AV >
void minsky::member_entry_hook ( int  argc,
AV  argv 
)

Definition at line 38 of file minskyTCLObj.h.

References minsky::Minsky::commandHook(), minsky::MinskyTCL::eventRecord, getCommandData(), minsky(), minskyTCL_obj(), minsky::Minsky::pushHistory(), minsky::MinskyTCL::rebuildTCLcommands, and to_string().

39  {
40  string argv0=to_string(argv[0]);
41  MinskyTCL& m=static_cast<MinskyTCL&>(minsky());
42  if (argv0.find("godleyWindow")==0)
43  {
44  if (argv0.find(".undo")!=std::string::npos) return; // do not record undo in history
45  if (argv0.find(".keyRelease")!=std::string::npos) return;
46  // support undo/redo in a Godley edit window
47  auto i=argv0.find('.');
48  if (i==std::string::npos) i=argv0.length();
49  auto t=dynamic_cast<member_entry_base*>(getCommandData(argv0.substr(0,i)));
50  if (!t || (!t->is_const && (!t->is_setterGetter || argc>1)))
51  if (auto gtw=t->memberPtrCasted<GodleyTableWindow>())
52  gtw->pushHistory();
53  return;
54  }
55 
56  if (m.commandHook(argv0,argc-1) && m.eventRecord.get() && argv0!="minsky.startRecording")
57  {
58  for (int i=0; i<argc; ++i)
59  (*m.eventRecord) << "{"<<to_string(argv[i]) <<"} ";
60  (*m.eventRecord)<<endl;
61  }
62 
63  if (m.rebuildTCLcommands)
64  {
65  TCL_obj(minskyTCL_obj(), "minsky", m);
66  m.rebuildTCLcommands=false;
67  }
68  }
minsky::Minsky minsky
Definition: pyminsky.cc:28
ecolab::TCL_obj_t & minskyTCL_obj()
a TCL_obj_t that provides a hook for detecting model edits
Definition: minskyTCLObj.h:70
string to_string(Tcl_Obj *x)
Definition: minskyTCLObj.h:34
cmd_data * getCommandData(const string &name)
Definition: minskyTCL.cc:62
Here is the call graph for this function:

◆ minsky()

Minsky & minsky::minsky ( )

global minsky object

Definition at line 51 of file minskyTCL.cc.

References minsky::anonymous_namespace{minskyTCL.cc}::l_minsky, and minsky::anonymous_namespace{addon.cc}::s_minsky.

Referenced by MathDAG::ConstantDAG::addEvalOps(), MathDAG::VariableDAG::addEvalOps(), MathDAG::OperationDAGBase::addEvalOps(), minsky::anonymous_namespace{userFunction.cc}::addTimeVariables(), cminsky(), minsky::Ravel::collapseAllHandles(), minsky::UserFunction::compile(), minsky::IntOp::description(), minsky::Progress::displayProgress(), minsky::Sheet::draw(), minsky::VariablePaneCell::emplace(), minsky::VariableBase::ensureValueExists(), minsky::VariableBase::exportAsCSV(), anonymous_namespace{sheet.cc}::formattedStr(), minsky::DataSpec::givenTFguessRemainder(), minsky::VariableInstanceList::gotoInstance(), handleSignal(), minsky::VariableBase::importFromCSV(), minsky::PhillipsDiagram::init(), minsky::VariableBase::init(), loadValueFromCSVFileT(), MathDAG::SystemOfEquations::makeDAG(), minsky::GodleyTable::markEdited(), member_entry_hook(), minsky::RavelPopup::mouseOver(), minsky::PhillipsDiagram::mouseUp(), MathDAG::anonymous_namespace{equations.cc}::NoArgument::NoArgument(), minsky::Ravel::onKeyPress(), minsky::VariableBase::onKeyPress(), minsky::VariableBase::onMouseMotion(), minsky::ParseCSV< P >::parse(), minsky::ParseCSV< P >::ParseCSV(), minsky::Ravel::pickSliceLabels(), minsky::Ravel::Ravel(), minsky::PubTab::removeSelf(), reportFromCSVFileT(), minsky::VariableBase::retype(), minsky::Ravel::setDimension(), minsky::VariableBase::setUnits(), minsky::Ravel::sortByValue(), MathDAG::SystemOfEquations::SystemOfEquations(), minsky::IntOp::toggleCoupled(), minsky::Lock::toggleLocked(), minsky::VariableBase::units(), minsky::GodleyIcon::updateVars(), minsky::VariableBase::value(), and minsky::VariableBase::vValue().

52  {
53  static MinskyTCL s_minsky;
54  if (l_minsky)
55  return *l_minsky;
56  return s_minsky;
57  }
Here is the caller graph for this function:

◆ minskyTCL_obj()

TCL_obj_t & minsky::minskyTCL_obj ( )
inline

a TCL_obj_t that provides a hook for detecting model edits

Definition at line 70 of file minskyTCLObj.h.

Referenced by minsky::MinskyTCL::getValue(), minsky::MinskyTCL::getWireAt(), minsky::MinskyTCL::listAllInstances(), member_entry_hook(), minsky::MinskyTCL::openGodley(), minsky::MinskyTCL::openGroupInCanvas(), minsky::MinskyTCL::openModelInCanvas(), minsky::MinskyTCL::registerRef(), and minsky::MinskyTCL::TCLItem().

71  {
72  static TCL_obj_t t;
73  static int dum=(
74  t.member_entry_hook=member_entry_hook<CONST84 char**>,
75  t.member_entry_thook=member_entry_hook<Tcl_Obj* const *>,
76  1);
77  return t;
78  }
Here is the caller graph for this function:

◆ numBytes()

unsigned minsky::numBytes ( unsigned char  x)
inline

a wrapper around std::ofstream that checks the write succeeded, throwing an exception if not

number of bytes in a UTF-8 character encoding

Definition at line 100 of file str.h.

Referenced by minsky::GodleyTableEditor::handleBackspace(), minsky::GodleyTableEditor::handleDelete(), minsky::GodleyTableEditor::keyPress(), operator>>(), prevIndex(), and minsky::GodleyTableEditor::textIdx().

101  {
102  if ((x&0xF8) == 0xF0)
103  return 4;
104  if ((x&0xF0) == 0xE0)
105  return 3;
106  if ((x&0xE0) == 0xC0)
107  return 2;
108  return 1;
109  }
Here is the caller graph for this function:

◆ onStackExit()

template<class F >
OnStackExit<F> minsky::onStackExit ( f)

generator function

Definition at line 85 of file str.h.

References f.

Referenced by minsky::Minsky::reset().

85 {return OnStackExit<F>(f);}
function f
Definition: canvas.m:1
Here is the caller graph for this function:

◆ operator<<() [1/3]

std::ostream& minsky::operator<< ( std::ostream &  o,
VariableType::Type  t 
)
inline

Definition at line 31 of file variableType.h.

References minsky::VariableType::typeName().

32  {return o<<VariableType::typeName(t);}
Here is the call graph for this function:

◆ operator<<() [2/3]

std::ostream& minsky::operator<< ( std::ostream &  o,
const Units u 
)
inline

Definition at line 51 of file units.h.

52  {
53  bool first=true;
54  for (auto& i: u)
55  {
56  if (i.first.empty() || i.second==0) continue; // don't display empty units
57  if (!first) o<<" ";
58  first=false;
59  o<<i.first;
60  if (i.second!=1)
61  o<<"^"<<i.second;
62  }
63  return o;
64  }

◆ operator<<() [3/3]

std::ostream& minsky::operator<< ( std::ostream &  o,
OperationType::Type  t 
)
inline

Definition at line 70 of file operationType.h.

References minsky::OperationType::typeName().

71  {return o<<OperationType::typeName(t);}
Here is the call graph for this function:

◆ operator>()

bool minsky::operator> ( std::size_t  x,
const UnitsExpressionWalker y 
)
inline

Definition at line 33 of file expressionWalker.h.

References minsky::UnitsExpressionWalker::value.

33 {return x>y.value;}

◆ operator>>()

std::istream& minsky::operator>> ( std::istream &  i,
const GetUtf8Char g 
)
inline

Definition at line 128 of file str.h.

References minsky::GetUtf8Char::c, and numBytes().

129  {
130  char c;
131  g.c->clear();
132  if (i.get(c))
133  {
134  *g.c+=c;
135  unsigned n=numBytes(c)-1;
136  for (unsigned j=0; j<n; ++j)
137  {
138  if (i.get(c))
139  *g.c+=c;
140  }
141  }
142  return i;
143  }
unsigned numBytes(unsigned char x)
a wrapper around std::ofstream that checks the write succeeded, throwing an exception if not ...
Definition: str.h:100
Here is the call graph for this function:

◆ pow()

UnitsExpressionWalker minsky::pow ( const UnitsExpressionWalker x,
const UnitsExpressionWalker y 
)
inline

Definition at line 51 of file expressionWalker.h.

References minsky::UnitsExpressionWalker::checkDimensionless(), root(), and minsky::UnitsExpressionWalker::value.

Referenced by minsky::EvalOp< minsky::OperationType::constant >::d1(), minsky::EvalOp< minsky::OperationType::constant >::d2(), minsky::OperationBase::draw(), minsky::EvalOp< minsky::OperationType::constant >::evaluate(), minsky::GeneralTensorOp< OperationType::moment >::GeneralTensorOp(), MathDAG::latex(), mantissa(), and minsky::OperationBase::unitsBinOpCase().

52  {
53  if (y.value<1) return root(x,1/y.value);
54  auto exponent=int(y.value);
55  if (exponent==y.value)
56  {
57  auto tmp=x;
58  for (auto& i: tmp.units)
59  i.second*=exponent;
60  return tmp;
61  }
62  x.checkDimensionless();
63  y.checkDimensionless();
64  return x;
65  }
minsky::UnitsExpressionWalker root(const minsky::UnitsExpressionWalker x, const minsky::UnitsExpressionWalker y)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prevIndex()

size_t minsky::prevIndex ( const std::string &  str,
size_t  index 
)
inline

return index of previous character to index

Definition at line 112 of file str.h.

References numBytes(), and str().

Referenced by minsky::GodleyTableEditor::handleBackspace(), and minsky::GodleyTableEditor::keyPress().

113  {
114  if (index>str.length()) return prevIndex(str, str.length());
115  for (size_t i=4; i>1; --i)
116  if (index>=i && numBytes(str[index-i])==i)
117  return index-i;
118  return index>0? index-1: 0;
119  }
unsigned numBytes(unsigned char x)
a wrapper around std::ofstream that checks the write succeeded, throwing an exception if not ...
Definition: str.h:100
size_t prevIndex(const std::string &str, size_t index)
return index of previous character to index
Definition: str.h:112
std::string str(T x)
utility function to create a string representation of a numeric type
Definition: str.h:33
Here is the call graph for this function:
Here is the caller graph for this function:

◆ quadrant()

int minsky::quadrant ( double  x)
inline

return quadrant x is in: 0=[-45,45),1=[45,135), etc

Definition at line 96 of file geometry.h.

References clamp360().

Referenced by minsky::BottomRightResizerItem::resizeHandleCoords().

97  {
98  return int(clamp360(x+45)/90);
99  }
double clamp360(double x)
return x modulo 360
Definition: geometry.h:87
Here is the call graph for this function:
Here is the caller graph for this function:

◆ randomizeLayout()

void minsky::randomizeLayout ( Group g)

randomly place items on canvas

Definition at line 88 of file autoLayout.cc.

References minsky::GroupItems::groups, minsky::GroupItems::items, MathDAG::sqrt(), and minsky::anonymous_namespace{autoLayout.cc}::totalArea().

Referenced by minsky::Group::randomLayout().

89  {
90  const double layoutSize=sqrt(3*totalArea(g));
91  default_random_engine gen;
92  uniform_real_distribution<double> rng(0,1);
93  for (auto& i: g.items)
94  i->moveTo(layoutSize*rng(gen), layoutSize*rng(gen));
95  for (auto& i: g.groups)
96  i->moveTo(layoutSize*rng(gen), layoutSize*rng(gen));
97  }
Expr sqrt(const Expr &x)
Definition: expr.h:154
Groups groups
Definition: group.h:79
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readMdl()

void minsky::readMdl ( Group group,
Simulation simParms,
istream &  mdlFile 
)

import a Vensim mdl file into group, also populating simParms from the control block

Definition at line 250 of file mdlReader.cc.

References minsky::anonymous_namespace{mdlReader.cc}::addDefinitionToPort(), minsky::anonymous_namespace{mdlReader.cc}::collapseWS(), minsky::anonymous_namespace{mdlReader.cc}::defineLookupFunction(), minsky::anonymous_namespace{mdlReader.cc}::functionsAdded, minsky::anonymous_namespace{mdlReader.cc}::identifier(), TCLcmd::trap::init, minsky::anonymous_namespace{mdlReader.cc}::readToken(), minsky::Simulation::stepMax, minsky::Simulation::t0, minsky::Simulation::timeUnit, minsky::Simulation::tmax, and trimWS().

Referenced by minsky::Minsky::importVensim().

251  {
252  set<string> integrationVariables;
253  const regex integ(R"(\s*integ\s*\(([^,]*),([^,]*)\))");
254  const regex number(R"(\d*\.?\d+[Ee]?\d*)");
255  const regex unitFieldPattern(R"(([^\[\]]*)(\[.*\])?)");
256  const regex sliderSpecPattern(R"(\[([^,]*),?([^,]*),?([^,]*)\])");
257  const regex lookupPattern(R"(([^(]*)\((.*)\))");
258  smatch match;
259  functionsAdded.clear();
260 
261  string c;
262  string currentMDLGroup;
263  while (mdlFile>>GetUtf8Char(c))
264  {
265  if (isspace(c[0])) continue;
266  switch (c[0])
267  {
268  case '{':
269  // check this is a UTF-8 file
270  if (trimWS(readToken(mdlFile,'}'))!="UTF-8")
271  throw runtime_error("only UTF-8 file encoding is supported");
272  continue;
273 
274  case '*':
275  // group leadin
276  for (; c[0]=='*'; mdlFile>>GetUtf8Char(c));
277  currentMDLGroup=trimWS(readToken(mdlFile,'*'));
278 
279  while (mdlFile>>GetUtf8Char(c))
280  if (c[0]=='|')
281  {
282  c.clear();
283  break; // end of group leadin
284  }
285  break;
286  }
287 
288  // macros?
289  // read variable name
290  string nameStr=readToken(mdlFile,'=',true /* append delimiter */);
291  const string name=collapseWS(trimWS(c+nameStr.substr(0,nameStr.length()-1)));
292  if (name.substr(0,9)==R"(\\\---///)")
293  break; // we don't parse the sketch information - not used in Minsky
294  string definition;
295  if (nameStr.back()=='=')
296  // only read definition if this was a variable definition
297  definition=collapseWS(trimWS(readToken(mdlFile,'~')));
298  switch (definition[0])
299  {
300  case '=': case ':': // for now, treat constant assignment and data assignment equally to numeric assignment
301  definition.erase(definition.begin());
302  break;
303  default:
304  break;
305  }
306  auto unitField=trimWS(readToken(mdlFile,'~'));
307  regex_match(unitField,match,unitFieldPattern);
308  const string units=trimWS(match[1]);
309  string sliderSpec;
310  if (match.size()>1)
311  sliderSpec=match[2];
312 
313  const string comments=trimWS(readToken(mdlFile,'|'));
314 
315 
316  if (currentMDLGroup==".Control")
317  {
318  if (name=="timeStep")
319  {
320  simParms.timeUnit=units;
321  if (regex_match(definition,match,number))
322  simParms.stepMax=stod(definition);
323  }
324  if (!regex_match(definition,match,number)) continue;
325  if (name=="initialTime") simParms.t0=stod(definition);
326  if (name=="finalTime") simParms.tmax=stod(definition);
327  continue;
328  }
329  if (regex_match(name,match,lookupPattern))
330  defineLookupFunction(group, match[1], match[2]);
331  else if (regex_match(definition,match,integ))
332  {
333  auto intOp=new IntOp;
334  group.addItem(intOp);
335  intOp->description(name);
336  intOp->detailedText(comments);
337  auto& v=intOp->intVar;
338  integrationVariables.insert(name);
339  auto integrand=match[1].str();
340  addDefinitionToPort(group, intOp->ports(1).lock(), "Integrand of "+name,integrand);
341 
342  auto init=match[2].str();
343  if (regex_match(init,match,identifier))
344  v->init(init);
345  else
346  {
347  // we need to add another variable, and attach it to a function block
348  addDefinitionToPort(group, intOp->ports(2).lock(), "Initial value of "+name, init);
349  }
350  try // absorb any errors in units - we have a chance to fix these later
351  {
352  v->setUnits(units);
353  }
354  catch (...) {}
355  v->detailedText(comments);
356 
357  }
358  else if (regex_match(definition,match,number))
359  {
360  const VariablePtr v(VariableBase::parameter, name);
361  group.addItem(v);
362  v->init(definition);
363  try // absorb any errors in units - we have a chance to fix these later
364  {
365  v->setUnits(units);
366  }
367  catch (...) {}
368  v->detailedText(comments);
369  if (auto vv=v->vValue())
370  {
371  if (regex_match(sliderSpec,match,sliderSpecPattern))
372  {
373  vector<string> spec;
374  for (size_t i=1; i<=match.size(); ++i) spec.push_back(match[i]);
375  if (!spec.empty() && regex_match(spec[0],match,number))
376  vv->sliderMin=stod(spec[0]);
377  else
378  vv->sliderMin=0.1*stod(definition);
379  if (spec.size()>1 && regex_match(spec[1],match,number))
380  vv->sliderMax=stod(spec[1]);
381  else
382  vv->sliderMax=10*stod(definition);
383  if (spec.size()>2 && regex_match(spec[2],match,number))
384  vv->sliderStep=stod(spec[2]);
385  }
386  vv->adjustSliderBounds();
387  }
388  }
389  else
390  {
391  const VariablePtr v(VariableBase::flow, name);
392  group.addItem(v);
393  addDefinitionToPort(group, v->ports(1).lock(), "Def: "+name, definition);
394  try // absorb any errors in units - we have a chance to fix these later
395  {
396  v->setUnits(units);
397  }
398  catch (...) {}
399  v->detailedText(comments);
400  }
401  }
402 
403  }
string readToken(istream &mdlFile, char delim, bool appendDelim=false)
Definition: mdlReader.cc:35
struct TCLcmd::trap::init_t init
std::string trimWS(const std::string &s)
Definition: str.h:49
void defineLookupFunction(Group &group, const std::string &name, const std::string &data)
Definition: mdlReader.cc:193
void addDefinitionToPort(Group &group, const shared_ptr< Port > &port, const string &name, const string &definition)
Definition: mdlReader.cc:166
string collapseWS(const string &x)
Definition: mdlReader.cc:69
regex identifier(R"([A-Za-z][A-Za-z0-9._]*[A-Za-z0-9_])")
Definition: group.tcl:84
Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerOps() [1/2]

template<template< OperationType::Type > class T, int op, int to>
classdesc::enable_if<Not<is_equal<op, to> >, void>::T minsky::registerOps ( TensorOpFactory tensorOpFactory)

Definition at line 317 of file minskyTensorOps.cc.

References op, and tensorOpFactory.

318  {
319  tensorOpFactory.registerType<T<OperationType::Type(op)>>(OperationType::Type(op));
320  registerOps<T, op+1, to>(tensorOpFactory);
321  }
TensorOpFactory tensorOpFactory

◆ registerOps() [2/2]

template<template< OperationType::Type > class T, int op, int to>
classdesc::enable_if<is_equal<op, to>, void>::T minsky::registerOps ( TensorOpFactory tensorOpFactory)

Definition at line 325 of file minskyTensorOps.cc.

326  {} //terminates recursion

◆ remove()

template<class T , class V >
void minsky::remove ( std::vector< T > &  x,
const V &  v 
)

remove an element from a vector. V must be comparable to a T

Definition at line 89 of file str.h.

Referenced by minsky::Minsky::save(), classdesc::typescriptTypep(), anonymous_namespace{CSVDialog.cc}::CacheEntry::~CacheEntry(), and minsky::Minsky::~Minsky().

90  {x.erase(std::remove(x.begin(),x.end(),v),x.end());}
void remove(std::vector< T > &x, const V &v)
remove an element from a vector. V must be comparable to a T
Definition: str.h:89
Here is the caller graph for this function:

◆ reportFromCSVFile()

void minsky::reportFromCSVFile ( istream &  input,
ostream &  output,
const DataSpec spec,
uintmax_t  fileSize 
)

creates a report CSV file from input, with errors sorted at begining of file, with a column for error messages

Definition at line 1161 of file CSVParser.cc.

References minsky::DataSpecSchema::separator.

Referenced by minsky::CSVDialog::reportFromFile().

1162  {
1163  if (spec.separator==' ')
1164  reportFromCSVFileT<SpaceSeparatorParser>(input,output,spec,fileSize);
1165  else
1166  reportFromCSVFileT<Parser>(input,output,spec,fileSize);
1167  }
Definition: input.py:1
Here is the caller graph for this function:

◆ reportFromCSVFileT()

template<class P >
void minsky::reportFromCSVFileT ( istream &  input,
ostream &  output,
const DataSpec spec,
uintmax_t  fileSize 
)

update a map of keys to first rows for duplicate key processing

Definition at line 1069 of file CSVParser.cc.

References getWholeLine(), minsky::DataSpecSchema::headerRow, minsky(), minsky::DataSpec::nRowAxes(), minsky::DataSpecSchema::separator, and minsky::ProgressUpdater::setProgress().

1070  {
1071  const BusyCursor busy(minsky());
1072  const ProgressUpdater pu(minsky().progressState, "Generating report",3);
1073  // set up off-heap memory allocator, and ensure it is torn down at exit
1074 // TrackingAllocatorBase::allocatePool();
1075 // auto onExit=onStackExit([](){TrackingAllocatorBase::deallocatePool();});
1076 
1077  struct ErrorReporter //: public OnError // using duck typing, not dynamic polymorphism
1078  {
1079  Map<size_t> firstRow;
1080  map<size_t,Key> duplicates;
1081  map<size_t,string> invalidData;
1082  void operator()(const DuplicateKey& ex, size_t row) {
1083  duplicates.emplace(firstRow[ex.key],ex.key);
1084  duplicates.emplace(row,ex.key);
1085  }
1086  void operator()(const InvalidData& ex, size_t row) {invalidData.emplace(row, ex.msg);}
1087  void operator()(const ShortLine& ex, size_t row) {invalidData.emplace(row, ex.msg);}
1089  void rowKeyInsert(const Key& key, size_t row) {firstRow.emplace(key,row);}
1090  } onError;
1091 
1092  // parse file to extract error locations
1093  ParseCSV<P> parseCSV(input, spec, fileSize, onError, /*checkValues=*/true);
1094 
1095  input.clear();
1096  input.seekg(0);
1097  if (!input) throw FailedToRewind();
1098  string buf;
1099  size_t row=0;
1100  const string sep{spec.separator};
1101  multimap<Key,string> duplicateLines;
1102  vector<string> invalidDataLines;
1103 
1104  {
1105  // extract all error lines
1106  ProgressUpdater pu(minsky().progressState, "Extracting errors",3);
1107  size_t bytesRead=0;
1108  for (; getWholeLine(input, buf, spec); ++row)
1109  {
1110  if (onError.duplicates.contains(row))
1111  {
1112  string msg="Duplicate key";
1113  msg+=sep; msg+=buf;
1114  duplicateLines.emplace(onError.duplicates[row],msg);
1115  }
1116  if (onError.invalidData.contains(row))
1117  {
1118  string msg=onError.invalidData[row];
1119  msg+=sep; msg+=buf;
1120  invalidDataLines.push_back(msg);
1121  }
1122  bytesRead+=buf.size();
1123  pu.setProgress(double(bytesRead)/fileSize);
1124  }
1125  }
1126 
1127  // now output report
1128  input.clear();
1129  input.seekg(0);
1130  if (!input) throw FailedToRewind();
1131  {
1132  ProgressUpdater pu(minsky().progressState, "Writing report",3);
1133  size_t bytesRead=0;
1134  // process header
1135  for (row=0; row<spec.nRowAxes() && getWholeLine(input, buf, spec); ++row)
1136  {
1137  if (row==spec.headerRow)
1138  output<<"Error"<<sep;
1139  output<<buf<<endl;
1140  bytesRead+=buf.size();
1141  pu.setProgress(double(bytesRead)/fileSize);
1142  }
1143 
1144  // process invalid data
1145  for (auto& i: invalidDataLines)
1146  output<<i<<endl;
1147  // process duplicates
1148  for (auto& i: duplicateLines)
1149  output<<i.second<<endl;
1150  // process remaining good part of the file
1151  for (; getWholeLine(input, buf, spec); ++row)
1152  {
1153  if (!onError.duplicates.contains(row) && !onError.invalidData.contains(row))
1154  output<<sep+buf<<endl;
1155  bytesRead+=buf.size();
1156  pu.setProgress(double(bytesRead)/fileSize);
1157  }
1158  }
1159  }
Definition: input.py:1
minsky::Minsky minsky
Definition: pyminsky.cc:28
std::size_t headerRow
number of header rows
bool getWholeLine(istream &input, string &line, const DataSpec &spec)
Definition: CSVParser.cc:584
std::size_t nRowAxes() const
start row of the data area
Definition: CSVParser.h:46
vector< SliceLabelToken, LibCAllocator< SliceLabelToken > > Key
Definition: CSVParser.cc:225
Here is the call graph for this function:

◆ root()

UnitsExpressionWalker minsky::root ( const UnitsExpressionWalker x,
const UnitsExpressionWalker y 
)
inline

Definition at line 35 of file expressionWalker.h.

References to_string(), minsky::UnitsExpressionWalker::units, and minsky::UnitsExpressionWalker::value.

Referenced by pow(), and exprtk::details::numeric::root().

36  {
37  if (x.units.empty()) return {};
38  int index=y.value;
39  if (index!=y.value)
40  throw std::runtime_error("index must be an integer for roots of dimensioned quanitites");
41  UnitsExpressionWalker r;
42  for (auto& i: x.units)
43  {
44  if (i.second % index)
45  throw std::runtime_error("input dimension "+i.first+" not a power to the index "+std::to_string(index));
46  r.units[i.first]=i.second/index;
47  }
48  return r;
49  }
string to_string(CONST84 char *x)
Definition: minskyTCLObj.h:33
Here is the call graph for this function:
Here is the caller graph for this function:

◆ scope() [1/2]

size_t minsky::scope ( const std::string &  name)

extract scope from a qualified variable name

Exceptions
ifname is unqualified

Definition at line 83 of file valueId.cc.

Referenced by minsky::Minsky::balanceColumns(), minsky::VariableBase::ensureValueExists(), minsky::Minsky::matchingTableColumns(), minsky::Group::renameAllInstances(), minsky::VariableValue::summary(), minsky::VariableValue::VariableValue(), and minsky::VariableValuePtr::VariableValuePtr().

84  {
85  if (name.starts_with("temp:")) return 0; // temporaries are "global"
86  auto nm=utf_to_utf<char>(name);
87  auto nameCStr=nm.c_str();
88  char* endp=nullptr;
89  const size_t r=strtoull(nameCStr,&endp,10);
90  if (endp && *endp==':')
91  return r;
92  throw error("scope requested for local variable");
93  // old implementation left for reference
94  // smatch m;
95  // if (regex_search(nm, m, regex(R"((\d*)]?:.*)")))
96  // if (m.size()>1 && m[1].matched && !m[1].str().empty())
97  // return stoull(m[1].str());
98  // else
99  // return 0;
100  // else
101  // // no scope information is present
102  // throw error("scope requested for local variable");
103  }
Here is the caller graph for this function:

◆ scope() [2/2]

GroupPtr minsky::scope ( GroupPtr  scope,
const string &  a_name 
)

starting from reference group ref, applying scoping rules to determine the actual scope of name If name prefixed by :, then search up group heirarchy for locally scoped var, otherwise return ref

Definition at line 105 of file valueId.cc.

References canonicalName().

Referenced by valueId(), valueIdCanonical(), and valueIdFromScope().

106  {
107  auto name=canonicalName(a_name);
108  if (a_name[0]==':' && scope)
109  {
110  // find maximum enclosing scope that has this same-named variable
111  for (auto g=scope->group.lock(); g; g=g->group.lock())
112  for (auto& i: g->items)
113  if (auto v=i->variableCast())
114  {
115  if (v->canonicalName()==name)
116  {
117  scope=g;
118  goto break_outerloop;
119  }
120  }
121  scope.reset(); // global var
122  break_outerloop: ;
123  }
124  return scope;
125  }
string canonicalName(const string &name)
convert a raw name into a canonical name - this is not idempotent.
Definition: valueId.cc:63
GroupPtr scope(GroupPtr scope, const string &a_name)
starting from reference group ref, applying scoping rules to determine the actual scope of name If na...
Definition: valueId.cc:105
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTCL_objAttributes()

void minsky::setTCL_objAttributes ( )

Definition at line 104 of file minskyTCL.cc.

References getCommandData().

105  {
106  // setting this helps a lot in avoiding unnecessary callbacks, and
107  // also avoiding annoying "do you want to save the model message
108  // when closing Minsky
109  if (auto t=getCommandData("minsky.wire.coords"))
110  t->is_setterGetter=true;
111  if (auto t=getCommandData("minsky.var.name"))
112  t->is_setterGetter=true;
113  if (auto t=getCommandData("minsky.var.init"))
114  t->is_setterGetter=true;
115  if (auto t=getCommandData("minsky.var.value"))
116  t->is_setterGetter=true;
117  if (auto t=getCommandData("minsky.integral.description"))
118  t->is_setterGetter=true;
119  if (auto t=getCommandData("minsky.resetEdited"))
120  t->is_const=true;
121  if (auto t=getCommandData("minsky.initGroupList"))
122  t->is_const=true;
123  if (auto t=getCommandData("minsky.godley.mouseFocus"))
124  t->is_const=true;
125  if (auto t=getCommandData("minsky.godley.table.setDEmode"))
126  t->is_const=true;
127  if (auto t=getCommandData("minsky.resetNotNeeded"))
128  t->is_const=true;
129  }
cmd_data * getCommandData(const string &name)
Definition: minskyTCL.cc:62
Here is the call graph for this function:

◆ sqr()

◆ str()

template<class T >
std::string minsky::str ( x)

utility function to create a string representation of a numeric type

Definition at line 33 of file str.h.

Referenced by minsky::PlotWidget::addConstantCurves(), minsky::anonymous_namespace{operation.cc}::CheckConsistent::CheckConsistent(), anonymous_namespace{sheet.cc}::ClippedPango::ClippedPango(), minsky::GodleyTableEditor::copy(), civita::createRavelChain(), minsky::anonymous_namespace{mdlReader.cc}::defineLookupFunction(), minsky::GodleyTableEditor::delSelection(), MathDAG::differentiateName(), minsky::Sheet::draw(), minsky::Minsky::exportAllPlotsAsCSV(), minsky::VariableValue::exportAsCSV(), minsky::anonymous_namespace{godleyExport.cc}::fcStr(), anonymous_namespace{sheet.cc}::formattedStr(), minsky::GodleyTableEditor::handleBackspace(), minsky::GodleyTableEditor::handleDelete(), minsky::Item::id(), minsky::GodleyTableEditor::keyPress(), MathDAG::latex(), MathDAG::latexInit(), MathDAG::matlabInit(), minsky::GodleyTableEditor::mouseDown(), minsky::anonymous_namespace{plotWidget.cc}::TimeFormatter::operator()(), schema3::pack(), minsky::ParseCSV< P >::parse(), minsky::GodleyTableEditor::paste(), minsky::OperationBase::portValues(), prevIndex(), minsky::Minsky::renderAllPlotsAsSVG(), minsky::GodleyIcon::rowSum(), minsky::FlowCoef::str(), minsky::GodleyTableEditor::textIdx(), minsky::VarConstant::value(), and minsky::VarConstant::valueId().

33  {
34  std::ostringstream s;
35  s<<x;
36  return s.str();
37  }
Here is the caller graph for this function:

◆ stripActive()

std::string minsky::stripActive ( const std::string &  s)
inline

repaces characters that cause interpretation by TCL, backslashes are replaced by the set minus operator ∖, and spaces are replaced by ␣, as they cause problems

Definition at line 63 of file str.h.

Referenced by canonicalName().

63  {
64  std::string r; r.reserve(s.length());
65  for (size_t i=0; i<s.length(); ++i)
66  if (s[i]=='\\')
67  r+="∖";
68  else if (isspace(s[i]))
69  r+="␣";
70  else
71  r+=s[i];
72  if (r.empty()) return "_";
73  return r;
74  }
Here is the caller graph for this function:

◆ stripByteOrderingMarker()

void minsky::stripByteOrderingMarker ( std::istream &  s)
inline

checks if the input stream has the UTF-8 byte ordering marker, and removes it if present

Definition at line 147 of file str.h.

Referenced by minsky::DataSpec::guessFromFile(), minsky::Minsky::insertGroupFromFile(), minsky::Minsky::load(), minsky::CSVDialog::loadFileFromName(), and minsky::CSVDialog::reportFromFile().

148  {
149  char bom[4]="\0\0\0";
150  s.get(bom,4);
151  if (strcmp(bom,"\357\273\277")==0) return; //skipped BOM
152  if (memcmp(bom,"\0\0\376",3)==0)
153  if (s && s.get()=='\377') // UTF-32(BE) file detected
154  throw std::runtime_error("Only UTF-8 encoded files supported");
155  if (strncmp(bom,"\376\377",2)==0 || strncmp(bom,"\377\376",2)==0)
156  // UTF-16 or UTF-32(LE) file detected
157  throw std::runtime_error("Only UTF-8 encoded files supported");
158  s.seekg(0); //rewind input stream
159  }
Here is the caller graph for this function:

◆ stripNonAlnum()

void minsky::stripNonAlnum ( std::string &  x)
inline

Definition at line 44 of file str.h.

References IsNotalnum().

44  {
45  x.erase(std::remove_if(x.begin(), x.end(), IsNotalnum), x.end());
46  }
bool IsNotalnum(char x)
Definition: str.h:42
Here is the call graph for this function:

◆ TCL_obj_lib()

tclvar minsky::TCL_obj_lib ( "ecolab_library"  ,
ECOLAB_LIB   
)

◆ TCLTYPE()

minsky::TCLTYPE ( CSVDialog  )

◆ to_string() [1/2]

string minsky::to_string ( CONST84 char *  x)
inline

◆ to_string() [2/2]

string minsky::to_string ( Tcl_Obj *  x)
inline

Definition at line 34 of file minskyTCLObj.h.

34 {return Tcl_GetString(x);}

◆ trimWS()

std::string minsky::trimWS ( const std::string &  s)
inline

Definition at line 49 of file str.h.

Referenced by minsky::Minsky::balanceColumns(), minsky::Minsky::balanceDuplicateColumns(), canonicalName(), minsky::Sheet::draw(), minsky::FlowCoef::FlowCoef(), minsky::GodleyTable::getColumnVariables(), minsky::Minsky::importDuplicateColumn(), minsky::EvalGodley::initialiseGodleys(), minsky::VariableValues::initValue(), minsky::ParseCSV< P >::parse(), MathDAG::SystemOfEquations::processGodleyTable(), readMdl(), minsky::GodleyIcon::rowSum(), and minsky::GodleyIcon::update().

50  {
51  int start=0, end=s.length()-1;
52  while (start<int(s.length()) && isspace(s[start])) ++start;
53  while (end>=0 && isspace(s[end])) --end;
54  if (end>=start)
55  return s.substr(start,end-start+1);
56  else
57  return "";
58  }
Here is the caller graph for this function:

◆ uniqueDeleter()

template<class T , class D >
std::unique_ptr<T,D> minsky::uniqueDeleter ( T *  x,
d 
)

Definition at line 93 of file str.h.

94  {return std::unique_ptr<T,D>(x,d);}

◆ uqName()

std::string minsky::uqName ( const std::string &  name)

extract unqualified portion of name

Definition at line 135 of file valueId.cc.

Referenced by minsky::Group::addIOVar(), minsky::PlotWidget::availableMarkers(), minsky::Minsky::balanceColumns(), canonicalName(), exportToCSV(), exportToLaTeX(), minsky::anonymous_namespace{godleyExport.cc}::fcStr(), MathDAG::SystemOfEquations::makeDAG(), MathDAG::SystemOfEquations::processGodleyTable(), minsky::PlotWidget::scalePlot(), and MathDAG::SystemOfEquations::SystemOfEquations().

136  {
137  const string::size_type p=name.rfind(':');
138  if (p==string::npos)
139  return utf_to_utf<char>(name);
140  return utf_to_utf<char>(name).substr(p+1);
141  }
Here is the caller graph for this function:

◆ valueId() [1/2]

std::string minsky::valueId ( const string &  name)

construct a valueId from fully qualified name @ name should not be canonicalised

Definition at line 75 of file valueId.cc.

References canonicalName(), scope(), and valueIdCanonical().

Referenced by minsky::PlotWidget::addConstantCurves(), MathDAG::VariableDAG::addEvalOps(), minsky::PlotWidget::addPlotPt(), minsky::Minsky::definingVar(), minsky::IntOp::description(), minsky::GodleyTableEditor::draw(), MathDAG::SystemOfEquations::getNodeFromIntVar(), minsky::MinskyTCL::getValue(), minsky::VariableValue::hypercube(), minsky::VariableValue::init(), minsky::VariableValues::initValue(), minsky::VariablePtr::makeConsistentWithValue(), MathDAG::SystemOfEquations::makeDAG(), minsky::VariableValues::newName(), minsky::Minsky::paste(), MathDAG::SystemOfEquations::processGodleyTable(), minsky::Canvas::renameAllInstances(), minsky::Group::renameAllInstances(), minsky::GroupItems::renameVar(), minsky::GodleyIcon::rowSum(), minsky::Minsky::setDefinition(), minsky::GodleyIcon::stockVarUnits(), minsky::VariableValue::summary(), MathDAG::VariableDAG::tensorEval(), minsky::VariableBase::units(), minsky::GodleyIcon::update(), minsky::GodleyIcon::valueId(), minsky::VariableBase::valueId(), minsky::MinskyTCL::valueId(), minsky::VariableBase::valueIdInCurrentScope(), and minsky::VariableInstanceList::VariableInstanceList().

76  {
77  return valueIdCanonical(scope(name), canonicalName(name));
78  }
string valueIdCanonical(size_t scope, const string &name)
construct a valueId @ name should be canonicalised
Definition: valueId.cc:68
string canonicalName(const string &name)
convert a raw name into a canonical name - this is not idempotent.
Definition: valueId.cc:63
GroupPtr scope(GroupPtr scope, const string &a_name)
starting from reference group ref, applying scoping rules to determine the actual scope of name If na...
Definition: valueId.cc:105
Here is the call graph for this function:
Here is the caller graph for this function:

◆ valueId() [2/2]

std::string minsky::valueId ( const GroupPtr ref,
const string &  name 
)

construct a valueId. @ name should not be canonicalised if name has leading :, then heirarchy is searched for matching local name

Definition at line 80 of file valueId.cc.

References canonicalName(), scope(), and valueIdFromScope().

81  {return valueIdFromScope(scope(ref,utf_to_utf<char>(name)), canonicalName(name));}
string canonicalName(const string &name)
convert a raw name into a canonical name - this is not idempotent.
Definition: valueId.cc:63
string valueIdFromScope(const GroupPtr &scope, const std::string &name)
value Id from scope and canonical name name
Definition: valueId.cc:128
GroupPtr scope(GroupPtr scope, const string &a_name)
starting from reference group ref, applying scoping rules to determine the actual scope of name If na...
Definition: valueId.cc:105
Here is the call graph for this function:

◆ valueIdCanonical()

std::string minsky::valueIdCanonical ( size_t  scope,
const string &  name 
)

construct a valueId @ name should be canonicalised

Definition at line 68 of file valueId.cc.

References scope(), and to_string().

Referenced by valueId(), and valueIdFromScope().

69  {
70  auto tmp=":"+name;
71  if (scope==0) return tmp;
72  return to_string(scope)+tmp;
73  }
string to_string(CONST84 char *x)
Definition: minskyTCLObj.h:33
GroupPtr scope(GroupPtr scope, const string &a_name)
starting from reference group ref, applying scoping rules to determine the actual scope of name If na...
Definition: valueId.cc:105
Here is the call graph for this function:
Here is the caller graph for this function:

◆ valueIdFromScope()

std::string minsky::valueIdFromScope ( const GroupPtr scope,
const std::string &  name 
)

value Id from scope and canonical name name

Definition at line 128 of file valueId.cc.

References scope(), and valueIdCanonical().

Referenced by minsky::UserFunction::compile(), minsky::Minsky::constructEquations(), minsky::UserFunction::units(), valueId(), minsky::VariableValue::valueId(), and minsky::anonymous_namespace{minsky.cc}::GodleyIt::valueId().

129  {
130  if (name.empty() || !scope || !scope->group.lock())
131  return valueIdCanonical(0,name); // retain previous global var id
132  return valueIdCanonical(size_t(scope.get()), name);
133 }
string valueIdCanonical(size_t scope, const string &name)
construct a valueId @ name should be canonicalised
Definition: valueId.cc:68
GroupPtr scope(GroupPtr scope, const string &a_name)
starting from reference group ref, applying scoping rules to determine the actual scope of name If na...
Definition: valueId.cc:105
Here is the call graph for this function:
Here is the caller graph for this function:

◆ yearToPTime()

double minsky::yearToPTime ( double  x)
inline

Definition at line 38 of file plotWidget.h.

References yearLength.

Referenced by minsky::PlotWidget::addConstantCurves(), minsky::PlotWidget::addPlotPt(), and minsky::PlotWidget::scalePlot().

38 {return (x-1970)*yearLength;}
const double yearLength
Definition: plotWidget.h:37
Here is the caller graph for this function:

◆ zoom()

void minsky::zoom ( float &  val,
float  origin,
float  factor 
)
inline

base zooming transformation

Definition at line 26 of file zoom.h.

Referenced by minsky::Group::zoom().

27  {val = (val-origin)*factor + origin;}
Here is the caller graph for this function:

Variable Documentation

◆ _defaultFont

std::unique_ptr<char[]> minsky::_defaultFont
static

Definition at line 1736 of file minsky.cc.

Referenced by minsky::Minsky::defaultFont().

◆ accumulatedBlitTime

ptime minsky::accumulatedBlitTime =epoch
static

Definition at line 431 of file plotWidget.cc.

Referenced by minsky::PlotWidget::addPlotPt().

◆ epoch

ptime minsky::epoch =microsec_clock::local_time()
static

Definition at line 431 of file plotWidget.cc.

◆ maxNumTensorElementsToPlot

const size_t minsky::maxNumTensorElementsToPlot =10
static

◆ portRadius

constexpr float minsky::portRadius =6

radius of circle marking ports at zoom=1

Definition at line 69 of file item.h.

Referenced by minsky::PlotWidget::clickType(), minsky::Item::clickType(), minsky::Item::drawPorts(), and minsky::Item::resizeHandleSize().

◆ portRadiusMult

constexpr float minsky::portRadiusMult =2.0f*portRadius

Definition at line 70 of file item.h.

◆ schemaURL

const char * minsky::schemaURL ="http://minsky.sf.net/minsky"

Definition at line 26 of file saver.cc.

Referenced by minsky::Minsky::copy(), and minsky::Minsky::exportSchema().

◆ sliderHandleRadius

constexpr float minsky::sliderHandleRadius =3

Definition at line 24 of file slider.h.

Referenced by minsky::VariableBase::draw().

◆ TCL_obj_minsky

int minsky::TCL_obj_minsky
Initial value:
=
(
TCL_obj_init(minsky()),
::TCL_obj(minskyTCL_obj(),"minsky",static_cast<MinskyTCL&>(minsky())),
1
)
minsky::Minsky minsky
Definition: pyminsky.cc:28
ecolab::TCL_obj_t & minskyTCL_obj()
a TCL_obj_t that provides a hook for detecting model edits
Definition: minskyTCLObj.h:70
void setTCL_objAttributes()
Definition: minskyTCL.cc:104

Definition at line 133 of file minskyTCL.cc.

◆ tensorOpFactory

◆ timeUnit

◆ yearLength

const double minsky::yearLength = 3600*24*365.2525

Definition at line 37 of file plotWidget.h.

Referenced by yearToPTime().