rapid.robustness.evaluator package

Submodules

rapid.robustness.evaluator.calc module

Helper functions for calculating robustness from performance values

rapid.robustness.evaluator.calc.f_to_R(f_df, R_dict)

Calculates robustness from performance values.

Uses a set of performance values, f, determined from simulations across multiple decision alternatives, l, different scenarios, s, and calculates robustness, R, using a variety of given robustness metrics.

Parameters:
  • f_df (pandas.DataFrame) – A dataframe of performance values, f, with indexes for the scenario, s, and decision alternative, l. Must include any other variables to be used during calculation of robustness (referred to as ‘varX_name’ below). Columns: [‘s_idx’, ‘l_idx’, ‘<f1_name>’, ‘<f2_name>’, …, ‘<var1_name>’, ‘<var2_name>’, …]
  • R_dict (dict of dict) –

    A mapping of robustness metric (R) names to information about those robustness metrics including ‘f’: string

    the corresponding performance metric to use
    ’maximise’: bool
    whether the aim of that performance metric is to be maximised
    ’threshold’: None or string
    the name of the column in f_df containing thresholds OR None if not using a threshold or threshold is given in kwargs
    ’func’: func
    the robustness metric function
    ’kwargs’: dict
    keyword arguments required for calculating R e.g. {‘t1_kwargs’: {‘threshold’: 5.2}}
    would pass a threshold kwarg to the t1 transformation if using the custom_R_metric

    Note that all performance metric names must be listed here. E.g.

    {‘<R1_name>’: {‘f’: <f1_name>, ‘maximise’: <bool>, ‘threshold’: None, ‘func’: <func>, ‘kwargs’: {‘kwarg1’: <arg>}}, ‘<R2_name>’: {‘f’: <f1_name>, ‘maximise’: <bool>, ‘threshold’: ‘critical’, ‘func’: <func>, ‘kwargs’: {}}, …}
Returns:

A dataframe of robustness values, R, with indexes for the decision alternative, l, and a column for the performance metric name, f_name. Columns: [‘l_idx’, ‘f_name’, ‘<R1_name>’, ‘<R2_name>’, …]

Return type:

pandas.DataFrame

rapid.robustness.evaluator.calc.get_f_df_details(f_df)

Gets the unique s_idx and l_idx values in f_df.

Also checks that for each s_idx, each unique l_idx exists (and vice versa).

Parameters:f_df (pandas.DataFrame) – A dataframe of performance values, f, with indexes for the scenario, s, and decision alternative, l. Columns: [‘s_idx’, ‘l_idx’, ‘<f1_name>’, ‘<f2_name>’, …]
Returns:
  • s_idxs (list of int) – Number of scenario (s) idxs
  • l_idxs (list of int) – List decision alternative (l) idxs
rapid.robustness.evaluator.calc.sort_f_df(f_df)

Sorts f_df by s_idx first then by l_idx.

E.g. for scenario 0, see all decision alternatives in order, then scenario 1, scenario 2, etc.

Parameters:f_df (pandas.DataFrame) – A dataframe of performance values, f, with indexes for the scenario, s, and decision alternative, l. Columns: [‘s_idx’, ‘l_idx’, ‘<f1_name>’, ‘<f2_name>’, …]

Module contents

Functions to help evaluate Robustness