omnetpp.scave.results¶
Provides access to simulation results loaded from OMNeT++ result files (.sca,
.vec). The results are returned as Pandas DataFrame’s of various formats.
The module can be used in several ways, depending on the environment it is run in, and on whether the set of result files to query are specified in a stateful or a stateless way:
Inside a chart script in the Analysis Tool in the Simulation IDE. In that mode, the set of result files to take as input are defined on the “Inputs” page of the editor. The
get_results(),get_scalars()and similar methods are invoked with a filter string as first argument to select the appropriate subset of results from the result files. Note that this mode of operation is stateful: The state is set up appropriately by the IDE before the chart script is run.A similar thing happens when charts in an analysis (.anf) file are run from within
opp_charttool: the tool sets up the module state before running the chart script, so that the getter methods invoked with a filter string will return result from the set of result files saved as “inputs” in the anf file.Standalone stateful mode. In order to use
get_results(),get_scalars()and similar methods with a filter string, the module needs to be configured via theset_inputs()/add_inputs()functions to tell it the set of result files to use as input for the queries. (Doing so is analogous to filling in the “Inputs” page in the IDE).Stateless mode. It is possible to load the result files (in whole or a subset of results in them) into memory as a “raw”
DataFrameusingread_result_files(), and then useget_scalars(),get_vectors()and other getter functions with the dataframe as their first argument to produceDataFrame’s of other formats. Note that when going this route, a filter string can be specified toread_result_files()but not to the getter methods. However, Pandas already provides several ways for filtering the rows of a dataframe, for example by indexing with logical operators on columns, or using thedf.query(),df.pipe()ordf.apply()methods.
Filter expressions
The filter_or_dataframe parameters in all functions must contain either a
filter string, or a “raw” dataframe produced by read_result_files(). When it
contains a filter string, the function operates on the set of result files
configured earlier (see stateful mode above).
Filter strings of all functions have the same syntax. It is always evaluated
independently on every loaded result item or metadata entry, and its value
determines whether the given item or piece of metadata is included in the
returned DataFrame.
A filter expression is composed of terms that can be combined with the AND,
OR, NOT operators, and parentheses. A term filters for the value of some
property of the item, and has the form <property> =~ <pattern>, or simply
<pattern>. The latter is equivalent to name =~ <pattern>.
The following properties are available:
name: Name of the result or item.module: Full path of the result’s module.type: Type of the item. Value is one of:scalar,vector,parameter,histogram,statistics.isfield:trueis the item is a synthetic scalar that represents a field of statistic or a vector,falseif not.file: File name of the result or item.run: Unique run ID of the run that contains the result or item.runattr:<name>: Run attribute of the run that contains the result or item. Example:runattr:measurement.attr:<name>: Attribute of the result. Example:attr:unit.itervar:<name>: Iteration variable of the run that contains the result or item. Example:itervar:numHosts.config:<key>: Configuration key of the run that contains the result or item. Example:config:sim-time-limit,config:**.sendIaTime.
Patterns may contain the following wildcards:
?matches any character except ‘.’*matches zero or more characters except ‘.’**matches zero or more characters (any character){a-z}matches a character in range a-z{^a-z}matches a character not in range a-z{32..255}any number (i.e. sequence of digits) in range 32..255 (e.g.99)[32..255]any number in square brackets in range 32..255 (e.g.[99])\takes away the special meaning of the subsequent character
Patterns only need to be surrounded with quotes if they contain whitespace or other characters that would cause ambiguity in parsing the expression.
Example: module =~ "**.host*" AND (name =~ "pkSent*" OR name =~ "pkRecvd*")
The “raw” dataframe format
This dataframe format is a central one, because the content of “raw” dataframes
correspond exactly to the content result files, i.e. it is possible to convert
between result files and the “raw” dataframe format without data loss. The “raw”
dataframe format also corresponds in a one-to-one manner to the “CSV-R” export
format of the Simulation IDE and opp_scavetool.
The outputs of the get_results() and read_result_files() functions are in
this format, and the dataframes that can be passed as input into certain query
functions (get_scalars(), get_vectors(), get_runs(), etc.) are also
expected in the same format.
Columns of the DataFrame:
runID(string): Identifies the simulation runtype(string): Row type, one of the following: scalar, vector, statistics, histogram, runattr, itervar, param, attrmodule(string): Hierarchical name (a.k.a. full path) of the module that recorded the result itemname(string): Name of the result item (scalar, statistic, histogram or vector)attrname(string): Name of the run attribute or result item attribute (in the latter case, the module and name columns identify the result item the attribute belongs to)attrvalue(string): Value of run and result item attributes, iteration variables, saved ini param settings (runattr, attr, itervar, param)value(double or string): Output scalar or parameter valuecount,sumweights,mean,min,max,stddev(double): Fields of the statistics or histogrambinedges,binvalues(np.array): Histogram bin edges and bin values.len(binedges)==len(binvalues)+1underflows,overflows(double): Sum of weights (or counts) of underflown and overflown samples of histogramsvectime,vecvalue(np.array): Output vector time and value arrays
Requesting metadata columns
Several query functions have the include_attrs, include_runattrs,
include_itervars, include_param_assignments, and include_config_entries
boolean options. When such an option is turned on, it will add extra columns
into the returned DataFrame, one for each result attribute, run attribute,
iteration variable, etc. When there is a name clash among items of different
types, the column name for the second one will be modified by adding its type
after an underscore (_runattr, _itervar, _config, _param).
include_attrs: Adds the attributes of the result in questioninclude_runattrs: Adds the run attributes of the (result’s) runinclude_itervars: Adds the iteration variables of the (result’s) runinclude_config_entries: Adds all configuration entries of the (result’s) run, including parameter parameter assignments and per-object configuration options. If this option is turned on,include_param_assignmentshas no effect.include_param_assignments: Adds the configuration entries that set module or channel parameters. This is a subset of the entries added byinclude_config_entries.
Note that values in metadata columns are generally strings (with missing values
represented as None or nan). The Pandas to_numeric() function or
utils.to_numeric() can be used to convert values to float or int where
needed.
Attributes¶
Exceptions¶
Inappropriate argument value (of correct type). |
Functions¶
Returns an integer that is incremented every time the set of loaded results |
|
|
Specifies the set of simulation result files (.vec, .sca) to use as input |
|
Appends to the set of simulation result files (.vec, .sca) to use as input |
|
Loads the simulation result files specified in the first argument |
|
Returns a filtered set of results and metadata in a Pandas |
|
Returns a filtered list of runs, identified by their run ID. |
|
Returns a filtered list of run attributes. |
|
Returns a filtered list of iteration variables. |
|
Returns a filtered list of scalar results. |
|
Returns a filtered list of parameters - actually computed values of |
|
Returns a filtered list of vector results. |
|
Returns a filtered list of statistics results. |
|
Returns a filtered list of histogram results. |
|
Returns a filtered list of config entries. That is: parameter assignment |
|
Returns a filtered list of parameter assignment patterns. The result is a |
Module Contents¶
-
STATISTIC_COLUMN_NAMES =
['runID', 'module', 'name', 'count', 'sumweights', 'mean', 'stddev', 'min', 'max', 'unit'][source]¶
-
HISTOGRAM_COLUMN_NAMES =
['runID', 'module', 'name', 'count', 'sumweights', 'mean', 'stddev', 'min', 'max', 'underflows',...[source]¶
- get_serial()[source]¶
Returns an integer that is incremented every time the set of loaded results changes, typically as a result of the IDE loading, reloading or unloading a scalar or vector result file. The serial can be used for invalidating cached intermediate results when their input changes.
- set_inputs(filenames)[source]¶
Specifies the set of simulation result files (.vec, .sca) to use as input for the query functions. The argument may be a single string or a list of strings. Each string is interpreted as a file or directory path and may also contain wildcards. In addition to
?and*,**(which is able to match several directory levels) is also accepted as a wildcard. If a path corresponds to a directory, it is interpreted as[ "<dir>/**/*.sca", "<dir>/**/*.vec" ], that is, all result files will be loaded from that directory and recursively all its subdirectories.Examples:
set_inputs("results/"),set_inputs("results/**.sca"),set_inputs(["config1/*.sca", *config2/*.sca"]).
- add_inputs(filenames)[source]¶
Appends to the set of simulation result files (.vec, .sca) to use as input for the query functions. The argument may be a single string or a list of strings. Each string is interpreted as a file or directory path and may also contain wildcards (
?,*,**). Seeset_inputs()for more details.
-
read_result_files(filenames, filter_expression=
None, include_fields_as_scalars=False, vector_start_time=-inf, vector_end_time=inf)[source]¶ Loads the simulation result files specified in the first argument
filenamesand returns the filtered set of results and metadata as a PandasDataFrame.The
filenamesargument specifies the set of simulation result files (.vec, .sca) to load. The argument may be a single string or a list of strings. Each string is interpreted as a file or directory path and may also contain wildcards (?,*,**). Seeset_inputs()for more details on this format.It is possible to limit the set of results to return by specifying a filter expression and vector start/end times.
Parameters:
filenames(string or list of strings): Specifies the result files to load.filter_expression(string): The filter expression to select the desired items to load. Example:module =~ "*host*" AND name =~ "numPacket*"include_fields_as_scalars(bool): Optional. IfTrue, the fields of statistics and histograms (:min,:mean, etc.) are also returned as synthetic scalars.vector_start_time,vector_end_time(double): Optional time limits to trim the data of vector type results. The unit is seconds, the interval is left-closed, right-open.
Returns: a
DataFramein the “raw” format (see the corresponding section of the module documentation for details).
-
get_results(filter_or_dataframe=
'', row_types=None, omit_unused_columns=True, include_fields_as_scalars=False, start_time=-inf, end_time=inf)[source]¶ Returns a filtered set of results and metadata in a Pandas
DataFrame. The items can be any type, even mixed together in a singleDataFrame. They are selected from the complete set of data referenced by the analysis file (.anf), including only those for which the givenfilter_or_dataframeevaluates toTrue.Parameters:
filter_or_dataframe(string or dataframe): The filter expression to select the desired items from the inputs, or a dataframe in the “raw” format. Example:module =~ "*host*" AND name =~ "numPacket*"row_types: Optional. When given, filters the returned rows by type. Should be a unique list, containing any number of these strings:"runattr","itervar","config","scalar","vector","statistic","histogram","param","attr"omit_unused_columns(bool): Optional. IfTrue, all columns that would only containNoneare removed from the returned DataFrameinclude_fields_as_scalars(bool): Optional. IfTrue, the fields of statistics and histograms (:min,:mean, etc.) are also returned as synthetic scalars.start_time,end_time(double): Optional time limits to trim the data of vector type results. The unit is seconds, the interval is left-closed, right-open.
Returns: a
DataFramein the “raw” format (see the corresponding section of the module documentation for details).
-
get_runs(filter_or_dataframe=
'', include_runattrs=False, include_itervars=False, include_param_assignments=False, include_config_entries=False)[source]¶ Returns a filtered list of runs, identified by their run ID.
Parameters:
filter_or_dataframe(string or dataframe): The filter expression to select the desired run from the inputs, or a dataframe in the “raw” format (e.g. one returned byread_result_files()). Example:runattr:network =~ "Aloha" AND config:Aloha.slotTime =~ 0include_runattrs,include_itervars,include_param_assignments,include_config_entries(bool): Optional. When set toTrue, additional pieces of metadata about the run is appended to the result, pivoted into columns. See the “Metadata columns” section of the module documentation for details.
Columns of the returned DataFrame:
runID(string): Identifies the simulation runAdditional metadata items (run attributes, iteration variables, etc.), as requested
-
get_runattrs(filter_or_dataframe=
'', include_runattrs=False, include_itervars=False, include_param_assignments=False, include_config_entries=False)[source]¶ Returns a filtered list of run attributes.
The set of run attributes is fixed:
configname,datetime,experiment,inifile,iterationvars,iterationvarsf,measurement,network,processid,repetition,replication,resultdir,runnumber,seedset.Parameters:
filter_or_dataframe(string or dataframe): The filter expression to select the desired run attributes from the inputs, or a dataframe in the “raw” format. Example:name =~ *date* AND config:Aloha.slotTime =~ 0include_runattrs,include_itervars,include_param_assignments,include_config_entries(bool): Optional. When set toTrue, additional pieces of metadata about the run is appended to the result, pivoted into columns. See the “Metadata columns” section of the module documentation for details.
Columns of the returned DataFrame:
runID(string): Identifies the simulation runname(string): The name of the run attributevalue(string): The value of the run attributeAdditional metadata items (run attributes, iteration variables, etc.)
-
get_itervars(filter_or_dataframe=
'', include_runattrs=False, include_itervars=False, include_param_assignments=False, include_config_entries=False)[source]¶ Returns a filtered list of iteration variables.
Parameters:
filter_or_dataframe(string or dataframe): The filter expression to select the desired iteration variables from the inputs, or a dataframe in the “raw” format. Example:name =~ iaMean AND config:Aloha.slotTime =~ 0include_runattrs,include_itervars,include_param_assignments,include_config_entries(bool): Optional. When set toTrue, additional pieces of metadata about the run is appended to the result, pivoted into columns. See the “Metadata columns” section of the module documentation for details.
Columns of the returned DataFrame:
runID(string): Identifies the simulation runname(string): The name of the iteration variablevalue(string): The value of the iteration variable.Additional metadata items (run attributes, iteration variables, etc.), as requested
-
get_scalars(filter_or_dataframe=
'', include_attrs=False, include_fields=False, include_runattrs=False, include_itervars=False, include_param_assignments=False, include_config_entries=False, convert_to_base_unit=True)[source]¶ Returns a filtered list of scalar results.
Parameters:
filter_or_dataframe(string): The filter expression to select the desired scalars, or a dataframe in the “raw” format. Example:name =~ "channelUtilization*" AND runattr:replication =~ "#0"include_attrs(bool): Optional. When set toTrue, result attributes (likeunitfor example) are appended to the DataFrame, pivoted into columns.include_fields(bool): Optional. IfTrue, the fields of statistics and histograms (:min,:mean, etc.) are also returned as synthetic scalars.include_runattrs,include_itervars,include_param_assignments,include_config_entries(bool): Optional. When set toTrue, additional pieces of metadata about the run is appended to the DataFrame, pivoted into columns. See the “Metadata columns” section of the module documentation for details.convert_to_base_unit(bool): Optional. IfTrue, the values of the scalars are converted to their base unit (e.g.mstos,mWtoW, etc.)
Columns of the returned DataFrame:
runID(string): Identifies the simulation runmodule(string): Hierarchical name (a.k.a. full path) of the module that recorded the result itemname(string): The name of the scalarvalue(double): The value of the scalarAdditional metadata items (result attributes, run attributes, iteration variables, etc.), as requested
-
get_parameters(filter_or_dataframe=
'', include_attrs=False, include_runattrs=False, include_itervars=False, include_param_assignments=False, include_config_entries=False)[source]¶ Returns a filtered list of parameters - actually computed values of individual
cParinstances in the fully built network.Parameters are considered “pseudo-results”, similar to scalars - except their values are strings. Even though they act mostly as input to the actual simulation run, the actually assigned value of individual
cParinstances is valuable information, as it is the result of the network setup process. For example, even if a parameter is set up as an expression likenormal(3, 0.4)fromomnetpp.ini, the returned DataFrame will contain the single concrete value picked for every instance of the parameter.Parameters:
filter_or_dataframe(string): The filter expression to select the desired parameters, or a dataframe in the “raw” format. Example:name =~ "x" AND module =~ Aloha.serverinclude_attrs(bool): Optional. When set toTrue, result attributes (likeunit) are appended to the DataFrame, pivoted into columns.include_runattrs,include_itervars,include_param_assignments,include_config_entries(bool): Optional. When set toTrue, additional pieces of metadata about the run is appended to the DataFrame, pivoted into columns. See the “Metadata columns” section of the module documentation for details.
Columns of the returned DataFrame:
runID(string): Identifies the simulation runmodule(string): Hierarchical name (a.k.a. full path) of the module that recorded the result itemname(string): The name of the parametervalue(string): The value of the parameter.Additional metadata items (result attributes, run attributes, iteration variables, etc.), as requested
-
get_vectors(filter_or_dataframe=
'', include_attrs=False, include_runattrs=False, include_itervars=False, include_param_assignments=False, include_config_entries=False, start_time=-inf, end_time=inf, convert_to_base_unit=True, omit_empty_vectors=False)[source]¶ Returns a filtered list of vector results.
Parameters:
filter_or_dataframe(string): The filter expression to select the desired vectors, or a dataframe in the “raw” format. Example:name =~ "radioState*" AND runattr:replication =~ "#0"include_attrs(bool): Optional. When set toTrue, result attributes (likeunitorsource) are appended to the DataFrame, pivoted into columns.include_runattrs,include_itervars,include_param_assignments,include_config_entries(bool): Optional. When set toTrue, additional pieces of metadata about the run is appended to the DataFrame, pivoted into columns. See the “Metadata columns” section of the module documentation for details.start_time,end_time(double): Optional time limits to trim the data of vector type results. The unit is seconds, both thevectimeandvecvaluearrays will be affected, the interval is left-closed, right-open.convert_to_base_unit(bool): Optional. IfTrue, the values in the vectors are converted to their base unit (e.g.mstos,mWtoW, etc.)omit_empty_vectors(bool): Optional. IfTrue, empty vectors are discarded from the output.
Columns of the returned DataFrame:
runID(string): Identifies the simulation runmodule(string): Hierarchical name (a.k.a. full path) of the module that recorded the result itemname(string): The name of the vectorvectime,vecvalue(np.array): The simulation times and the corresponding values in the vectorAdditional metadata items (result attributes, run attributes, iteration variables, etc.), as requested
-
get_statistics(filter_or_dataframe=
'', include_attrs=False, include_runattrs=False, include_itervars=False, include_param_assignments=False, include_config_entries=False, convert_to_base_unit=True)[source]¶ Returns a filtered list of statistics results.
Parameters:
filter_or_dataframe(string): The filter expression to select the desired statistics, or a dataframe in the “raw” format. Example:name =~ "collisionLength:stat" AND itervar:iaMean =~ "5"include_attrs(bool): Optional. When set toTrue, result attributes (likeunitorsource) are appended to the DataFrame, pivoted into columns.include_runattrs,include_itervars,include_param_assignments,include_config_entries(bool): Optional. When set toTrue, additional pieces of metadata about the run is appended to the DataFrame, pivoted into columns. See the “Metadata columns” section of the module documentation for details.convert_to_base_unit(bool): Optional. IfTrue, some fields of the statistics (in themin,max,mean, andstddevcolumns) are converted to their base unit (e.g.mstos,mWtoW, etc.)
Columns of the returned DataFrame:
runID(string): Identifies the simulation runmodule(string): Hierarchical name (a.k.a. full path) of the module that recorded the result itemname(string): The name of the statisticcount,sumweights,mean,stddev,min,max(double): The characteristic mathematical properties of the statistics resultAdditional metadata items (result attributes, run attributes, iteration variables, etc.), as requested
-
get_histograms(filter_or_dataframe=
'', include_attrs=False, include_runattrs=False, include_itervars=False, include_param_assignments=False, include_config_entries=False, convert_to_base_unit=True)[source]¶ Returns a filtered list of histogram results.
Parameters:
filter_or_dataframe(string): The filter expression to select the desired histograms, or a dataframe in the “raw” format. Example:name =~ "collisionMultiplicity:histogram" AND itervar:iaMean =~ "2"include_attrs(bool): Optional. When set toTrue, result attributes (likeunitorsourcefor example) are appended to the DataFrame, pivoted into columns.include_runattrs,include_itervars,include_param_assignments,include_config_entries(bool): Optional. When set toTrue, additional pieces of metadata about the run is appended to the DataFrame, pivoted into columns. See the “Metadata columns” section of the module documentation for details.convert_to_base_unit(bool): Optional. IfTrue, some fields of the histograms (in themin,max,mean,stddev, andbinedgescolumns) are converted to their base unit (e.g.mstos,mWtoW, etc.)
Columns of the returned DataFrame:
runID(string): Identifies the simulation runmodule(string): Hierarchical name (a.k.a. full path) of the module that recorded the result itemname(string): The name of the vectorcount,sumweights,mean,stddev,min,max(double): The characteristic mathematical properties of the histogrambinedges,binvalues(np.array): The histogram edge locations and the weighted sum of the collected samples in each bin.len(binedges) == len(binvalues) + 1underflows,overflows(double): The weighted sum of the samples that fell outside of the histogram bin range in the two directionsAdditional metadata items (result attributes, run attributes, iteration variables, etc.), as requested
-
get_config_entries(filter_or_dataframe, include_runattrs=
False, include_itervars=False, include_param_assignments=False, include_config_entries=False)[source]¶ Returns a filtered list of config entries. That is: parameter assignment patterns; and global and per-object config options.
Parameters:
filter_or_dataframe(string): The filter expression to select the desired config entries, or a dataframe in the “raw” format. Example:name =~ sim-time-limit AND itervar:numHosts =~ 10include_runattrs,include_itervars,include_param_assignments,include_config_entries(bool): Optional. When set toTrue, additional pieces of metadata about the run is appended to the result, pivoted into columns. See the “Metadata columns” section of the module documentation for details.
Columns of the returned DataFrame:
runID(string): Identifies the simulation runname(string): The name of the config entryvalue(string): The value of the config entryAdditional metadata items (run attributes, iteration variables, etc.), as requested
-
get_param_assignments(filter_or_dataframe, include_runattrs=
False, include_itervars=False, include_param_assignments=False, include_config_entries=False)[source]¶ Returns a filtered list of parameter assignment patterns. The result is a subset of what
get_config_entrieswould return with the same arguments.Parameters:
filter_or_dataframe(string): The filter expression to select the desired parameter assignments, or a dataframe in the “raw” format. Example:name =~ **.flowID AND itervar:numHosts =~ 10include_runattrs,include_itervars,include_param_assignments,include_config_entries(bool): Optional. When set toTrue, additional pieces of metadata about the run is appended to the result, pivoted into columns. See the “Metadata columns” section of the module documentation for details.
Columns of the returned DataFrame:
runID(string): Identifies the simulation runname(string): The parameter assignment patternvalue(string): The assigned valueAdditional metadata items (run attributes, iteration variables, etc.), as requested