Querying parameters
Access the parameters of past simulations two ways:
simulationsTable— reads the databases; best for readability.getAllParameterValues— reads every XML value; best for programmatic access.
simulationsTable
simulationsTable returns a table of simulation data. By default it shows only varied values and renames columns to be human-readable.
printSimulationsTable is a wrapper that prints the table directly. Use the sink keyword argument to redirect the output, e.g. to a file.
Monad-level: monadsTable
monadsTable is the monad-level analogue of simulationsTable: it returns one row per monad (a group of replicate simulations sharing the same parameters) rather than one row per simulation. Pass it any AbstractTrial (e.g. a Sampling), a vector of monad IDs, or nothing (for all monads):
monadsTable(sampling) # one row per monad in the sampling
monadsTable([1, 2, 3]; remove_constants=false) # by monad ID, keeping constant columnsprintMonadsTable prints the table directly, mirroring printSimulationsTable.
getAllParameterValues
getAllParameterValues returns every terminal element in the XML input files for a set of simulations, which must all belong to the same Sampling (i.e. use the same input files). Column names are the XML paths, so splitting one on / gives a path ready for DiscreteVariation:
df = getAllParameterValues(sampling)
col1 = names(df)[1] # get the name of the first column
xml_path = split(col1, "/") # convert to XML path format
dv = DiscreteVariation(xml_path, [0.0, 1.0]) # create a discrete variation using this parametercolumnName and columnNameToXMLPath convert between column names and XML paths. Both are exported by ModelManager and re-exported here, so they need no prefix.
The XML paths returned by getAllParameterValues as column names may include what look like attributes to distinguish between multiple children with the same tag. Find these by searching for column names containing ":temp_id:":
df = getAllParameterValues(sampling)
names_with_temp_id = filter(contains(":temp_id:"), names(df))