| Title: | Import System-Dynamics Models and Convert Them to Edge Lists |
|---|---|
| Description: | Imports causal and system-dynamics models from 'Vensim', 'Stella' / 'iThink' and 'Powersim Studio' ('XMILE'), 'AnyLogic' and 'GoldSim' (exported 'XML'), and converts them into a two-column edge list of cause-to-effect links. 'Vensim' models are read from their native diagram files; 'Powersim Studio' and 'GoldSim' are also now read from their native diagram files in addition to exported 'XMILE' or 'XML'. Provides an 'RStudio' add-in with a simple point-and-click interface, together with command-line functions that return a data frame or write it to 'CSV' or 'Excel'. |
| Authors: | Taddias Prince Mpofu [aut, cre, cph], Mawuko Bonoukpoe Joel Sokame [aut], Frank Chidawanyika [aut], Joel Cornelius Runyu [aut], Marc Marin Agbodjan [aut] |
| Maintainer: | Taddias Prince Mpofu <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.3 |
| Built: | 2026-09-19 08:44:08 UTC |
| Source: | https://github.com/cran/CLDedgelister |
Opens a small window to pick a Vensim, Stella, Powersim, AnyLogic or
GoldSim model, preview the resulting INPUT -> OUTPUT edge list, and
optionally save it as CSV or Excel. The chosen edge list is returned as a
data.frame when the gadget closes, so it can be captured with
el <- cld_edgelist_addin().
cld_edgelist_addin()cld_edgelist_addin()
A data.frame of INPUT/OUTPUT edges (invisibly NULL if
cancelled). When launched from the RStudio Addins menu the result is
returned to the console.
Supported model formats
cld_formats()cld_formats()
A character vector of the format labels the package understands.
cld_formats()cld_formats()
Detect GoldSim's native binary model.
looks_like_goldsim_binary(path)looks_like_goldsim_binary(path)
path |
Path to the model file. |
Formats are told apart by CONTENT rather than by extension. Powersim and
GoldSim both use .sim for different formats: Powersim writes an OLE2
compound document and GoldSim does not, so each file reaches the right reader.
A single logical value.
Detect a Powersim Studio project file. A .sip/.sim is an OLE2 compound document holding
IFF-chunked streams, not XMILE. Variable names decode cleanly from the
FTXT chunks; the links do not, because Powersim indirects their
endpoints through an undocumented symbol table. Export to XMILE from Powersim
Studio for a model that can be read exactly.
looks_like_powersim(path)looks_like_powersim(path)
path |
Path to a |
A single logical value.
Before XMILE, isee systems saved models in a proprietary binary format whose
files begin with the signature TL2STM2. Such a file is not XML and
cannot be read by an XML parser, so it must be routed to parse_stm
rather than to the XMILE reader.
looks_like_stm(path)looks_like_stm(path)
path |
Path to a candidate model file. |
A single logical value: TRUE when the file carries the legacy
Stella binary signature TL2STM2, otherwise FALSE.
p <- tempfile(fileext = ".stmx") writeLines("<xmile><model/></xmile>", p) looks_like_stm(p)p <- tempfile(fileext = ".stmx") writeLines("<xmile><model/></xmile>", p) looks_like_stm(p)
Reads a model from Vensim, Stella / iThink, Powersim Studio, AnyLogic or GoldSim and returns a two-column data.frame of INPUT (cause) and OUTPUT (effect) links - the same edge list produced by the SDM Network Analyzer.
model_to_edgelist(path, format = NULL)model_to_edgelist(path, format = NULL)
path |
Path to the model file. |
format |
One of |
A data.frame with columns INPUT and OUTPUT. Node
diagram positions, when available, are attached as
attr(x, "positions").
# Convert the bundled example Vensim model to an edge list mdl <- system.file("extdata", "example_model.mdl", package = "CLDedgelister") el <- model_to_edgelist(mdl) head(el)# Convert the bundled example Vensim model to an edge list mdl <- system.file("extdata", "example_model.mdl", package = "CLDedgelister") el <- model_to_edgelist(mdl) head(el)
Convert a model file and write the edge list to disk
model_to_edgelist_file(path, out_path = NULL, format = NULL)model_to_edgelist_file(path, out_path = NULL, format = NULL)
path |
Path to the model file. |
out_path |
Output file (.csv or .xlsx). If |
format |
See |
(invisibly) the edge list data.frame.
mdl <- system.file("extdata", "example_model.mdl", package = "CLDedgelister") out <- tempfile(fileext = ".csv") model_to_edgelist_file(mdl, out)mdl <- system.file("extdata", "example_model.mdl", package = "CLDedgelister") out <- tempfile(fileext = ".csv") model_to_edgelist_file(mdl, out)
Read a compressed AnyLogic project (.alpx).
parse_alpx(path)parse_alpx(path)
path |
Path to the model file. |
Formats are told apart by CONTENT rather than by extension. Powersim and
GoldSim both use .sim for different formats: Powersim writes an OLE2
compound document and GoldSim does not, so each file reaches the right reader.
A two-column data.frame of INPUT and OUTPUT.
Read a Powersim Studio project (.sip / .sim). A .sip/.sim is an OLE2 compound document holding
IFF-chunked streams, not XMILE. Variable names decode cleanly from the
FTXT chunks; the links do not, because Powersim indirects their
endpoints through an undocumented symbol table. Export to XMILE from Powersim
Studio for a model that can be read exactly.
parse_powersim(path)parse_powersim(path)
path |
Path to a |
A two-column data.frame of INPUT and OUTPUT, empty when no links could be recovered, with the variables in the variables attribute.
Reads the pre-XMILE binary format used by Stella and iThink, whose files begin
with the signature TL2STM2.
parse_stm(path)parse_stm(path)
path |
Path to a |
Variable names and equations both come out of the binary cleanly. The mapping BETWEEN them does not: the name records and the equation records are not interleaved one-for-one, and the remaining links are held in an undocumented binary dependency section. Measured on two published models, only 22% and 42% of variables could be matched to their own equation.
Pairing them by proximity anyway yields a network that looks plausible and is partly wrong, with links attributed to the wrong variable. This reader therefore returns an edge list only when the pairing is unambiguous for the great majority of variables, and otherwise stops with an explanation.
To convert such a model, open it in Stella or iThink and use
File > Save As to write a .stmx (XMILE) file, which is read
exactly.
A two-column data.frame with columns INPUT (cause) and
OUTPUT (effect), one row per link.
looks_like_stm, model_to_edgelist
p <- tempfile(fileext = ".STM") writeBin(c(charToRaw("TL2STM2"), as.raw(rep(0, 60))), p) looks_like_stm(p) try(parse_stm(p))p <- tempfile(fileext = ".STM") writeBin(c(charToRaw("TL2STM2"), as.raw(rep(0, 60))), p) looks_like_stm(p) try(parse_stm(p))
Read a Vensim XML model (.vmfx).
parse_vmfx(path)parse_vmfx(path)
path |
Path to the model file. |
Formats are told apart by CONTENT rather than by extension. Powersim and
GoldSim both use .sim for different formats: Powersim writes an OLE2
compound document and GoldSim does not, so each file reaches the right reader.
A two-column data.frame of INPUT and OUTPUT.
Read the links from a Powersim Studio diagram.
powersim_links(path)powersim_links(path)
path |
Path to the model file. |
Formats are told apart by CONTENT rather than by extension. Powersim and
GoldSim both use .sim for different formats: Powersim writes an OLE2
compound document and GoldSim does not, so each file reaches the right reader.
A two-column data.frame of INPUT and OUTPUT, empty when the file carries no readable diagram.
Read variable names from a Powersim Studio project. A .sip/.sim is an OLE2 compound document holding
IFF-chunked streams, not XMILE. Variable names decode cleanly from the
FTXT chunks; the links do not, because Powersim indirects their
endpoints through an undocumented symbol table. Export to XMILE from Powersim
Studio for a model that can be read exactly.
powersim_variables(path)powersim_variables(path)
path |
Path to a |
A character vector of variable names.