parameters

parameters and collections of parameters

class ema_workbench.em_framework.parameters.Parameter(name, lower_bound, upper_bound, resolution=None, default=None, variable_name=None, pff=False)

Base class for any model input parameter

Parameters:
  • name (str) –
  • lower_bound (int or float) –
  • upper_bound (int or float) –
  • resolution (collection) –
  • pff (bool) – if true, sample over this parameter using resolution in case of partial factorial sampling
Raises:
  • ValueError – if lower bound is larger than upper bound
  • ValueError – if entries in resolution are outside range of lower_bound and upper_bound
class ema_workbench.em_framework.parameters.RealParameter(name, lower_bound, upper_bound, resolution=None, default=None, variable_name=None, pff=False)

real valued model input parameter

Parameters:
  • name (str) –
  • lower_bound (int or float) –
  • upper_bound (int or float) –
  • resolution (iterable) –
  • variable_name (str, or list of str) –
Raises:
  • ValueError – if lower bound is larger than upper bound
  • ValueError – if entries in resolution are outside range of lower_bound and upper_bound
class ema_workbench.em_framework.parameters.IntegerParameter(name, lower_bound, upper_bound, resolution=None, default=None, variable_name=None, pff=False)

integer valued model input parameter

Parameters:
  • name (str) –
  • lower_bound (int) –
  • upper_bound (int) –
  • resolution (iterable) –
  • variable_name (str, or list of str) –
Raises:
  • ValueError – if lower bound is larger than upper bound
  • ValueError – if entries in resolution are outside range of lower_bound and upper_bound, or not an numbers.Integral instance
  • ValueError – if lower_bound or upper_bound is not an numbers.Integral instance
class ema_workbench.em_framework.parameters.BooleanParameter(name, default=None, variable_name=None, pff=False)

boolean model input parameter

A BooleanParameter is similar to a CategoricalParameter, except the category values can only be True or False.

Parameters:
  • name (str) –
  • variable_name (str, or list of str) –
class ema_workbench.em_framework.parameters.CategoricalParameter(name, categories, default=None, variable_name=None, pff=False, multivalue=False)

categorical model input parameter

Parameters:
  • name (str) –
  • categories (collection of obj) –
  • variable_name (str, or list of str) –
  • multivalue (boolean) – if categories have a set of values, for each variable_name a different one.
cat_for_index(index)

return category given index

Parameters:index (int) –
Returns:
Return type:object
index_for_cat(category)

return index of category

Parameters:category (object) –
Returns:
Return type:int
invert(name)

invert a category to an integer

Parameters:name (obj) – category
Raises:ValueError – if category is not found
ema_workbench.em_framework.parameters.create_parameters(uncertainties, **kwargs)

Helper function for creating many Parameters based on a DataFrame or csv file

Parameters:
  • uncertainties (str, DataFrame) –
  • **kwargs (dict, arguments to pass to pandas.read_csv) –
Returns:

Return type:

list of Parameter instances

This helper function creates uncertainties. It assumes that the DataFrame or csv file has a column titled ‘name’, optionally a type column {int, real, cat}, can be included as well. the remainder of the columns are handled as values for the parameters. If type is not specified, the function will try to infer type from the values.

Note that this function does not support the resolution and default kwargs on parameters.

An example of a csv:

NAME,TYPE,,, a_real,real,0,1.1, an_int,int,1,9, a_categorical,cat,a,b,c

this CSV file would result in

[RealParameter(‘a_real’, 0, 1.1, resolution=[], default=None),
IntegerParameter(‘an_int’, 1, 9, resolution=[], default=None), CategoricalParameter(‘a_categorical’, [‘a’, ‘b’, ‘c’], default=None)]
ema_workbench.em_framework.parameters.experiment_generator(scenarios, model_structures, policies)

generator function which yields experiments

Parameters:
  • designs (iterable of dicts) –
  • model_structures (list) –
  • policies (list) –

Notes

this generator is essentially three nested loops: for each model structure, for each policy, for each scenario, return the experiment. This means that designs should not be a generator because this will be exhausted after the running the first policy on the first model.

class ema_workbench.em_framework.parameters.Policy(name=<ema_workbench.em_framework.util.Counter object>, **kwargs)

Helper class representing a policy

name
Type:str, int, or float
id
Type:int
all keyword arguments are wrapped into a dict.
to_list(parameters)

get list like representation of policy where the parameters are in the order of levers

class ema_workbench.em_framework.parameters.Scenario(name=<ema_workbench.em_framework.util.Counter object>, **kwargs)

Helper class representing a scenario

name
Type:str, int, or float
id
Type:int
all keyword arguments are wrapped into a dict.
class ema_workbench.em_framework.parameters.Experiment(scenario, policy, constants, replication=None)

helper class that combines scenario, policy, any constants, and replication information (seed etc) into a single dictionary.