Skip to content

Query outputs

Christian Neuwirth edited this page Feb 20, 2017 · 26 revisions

Structure of output table 'sim_out'

One table column is created for every stock in the Vensim model. Also delays are interpreted as stocks by translator resources implemented in PySD (Houghton & Siegel, 2015). This means delays are written as results to ‘sim_out’ just like ordinary stocks.

If a SDL is involved in the simulation, one row of type array (PostgreSQL type ‘real[]’) is created for every instance of a simulation run. The array index corresponds to the time step of the simulation (see Fig. 4, Left).

Fig. 4 Fig. 4. Left: Output table 'sim_out', SDL involved; Right: Output table 'sim_out', TSL only

If only TSL are used in a simulation, one dataset row (of PostgreSQL type ‘numeric’) is created for every time step in the simulation (Fig. 4, Right).

Matching of input and output tables

Rows of input and output tables are related one-to-one. For this reason the primary key (‘gid’) of the input table is also copied as a foreign key to the output table (see Fig. 4). This is intended to simplify data querying.

Query and export TSL data

To export results from PostgreSQL to a spreadsheet, select data to be exported by using an SQL statement like

SELECT * FROM sim_out WHERE gid <= 100;

e.g. to select the first 100 rows. Then go to File/Export on the menu bar. Output files (csv or dat) can be edited and visualized using conventional spreadsheet software (see Fig. 5).

Fig. 5 Fig. 5. Sensitivity of teacher unemployment against variations in numbers of students

Clone this wiki locally