scml.experiment

Module Contents

Functions

bankruptcy_level(world)

relative_productivity(world)

n_bankrupt(world)

relative_welfare_all(world)

relative_welfare_non_bankrupt(world)

welfare_all(world)

welfare_non_bankrupt(world)

productivity(world)

bankruptcy_rate(world)

contract_execution(world)

breach_rate(world)

jobs(→ int)

get_var_vals(→ dict[str, Any])

Extracts variable name and value allowing for multiple names separated by semicolon

run_config(world_config, funcs)

Runs a single configuration and returns values of all functions for that configuration

satisfied(→ bool)

Tests whether the constraints are all satisfied in the config or not

generate_configs_factorial() → list[dict[str, Any]])

Generates all configs for an experiment with a factorial design

generate_configs_single(→ list[dict[str, Any]])

Generates all configs for an experiment with a factorial design

run_configs(→ pandas.DataFrame)

run(, n_jobs)

Runs an experiment

main(worlds, factorial, variables, name, steps, ...)

Attributes

N_STEPS

N_WORLDS

COMPACT

NOLOGS

Constraint

dep_vars

fixed_vars

scml.experiment.N_STEPS = 10[source]
scml.experiment.N_WORLDS = 2[source]
scml.experiment.COMPACT = True[source]
scml.experiment.NOLOGS = True[source]
scml.experiment.Constraint[source]
scml.experiment.bankruptcy_level(world: scml.SCML2020World)[source]
scml.experiment.relative_productivity(world: scml.SCML2020World)[source]
scml.experiment.n_bankrupt(world: scml.SCML2020World)[source]
scml.experiment.relative_welfare_all(world: scml.SCML2020World)[source]
scml.experiment.relative_welfare_non_bankrupt(world: scml.SCML2020World)[source]
scml.experiment.welfare_all(world: scml.SCML2020World)[source]
scml.experiment.welfare_non_bankrupt(world: scml.SCML2020World)[source]
scml.experiment.productivity(world: scml.SCML2020World)[source]
scml.experiment.bankruptcy_rate(world: scml.SCML2020World)[source]
scml.experiment.contract_execution(world: scml.SCML2020World)[source]
scml.experiment.breach_rate(world: scml.SCML2020World)[source]
scml.experiment.dep_vars[source]
scml.experiment.fixed_vars[source]
scml.experiment.jobs(n_jobs: float | int) int[source]
scml.experiment.get_var_vals(var: str, val: Any) dict[str, Any][source]

Extracts variable name and value allowing for multiple names separated by semicolon

scml.experiment.run_config(world_config: dict[str, Any], funcs: list[str])[source]

Runs a single configuration and returns values of all functions for that configuration

scml.experiment.satisfied(config: dict[str, Any], constraints: Iterable[Constraint]) bool[source]

Tests whether the constraints are all satisfied in the config or not

Parameters:
  • config

  • constraints

Returns:

scml.experiment.generate_configs_factorial(ind_vars: dict[str, list], fixed_vars: dict[str, Any], n_worlds_per_condition=5, constraints: tuple[Constraint, Ellipsis] = tuple()) list[dict[str, Any]][source]

Generates all configs for an experiment with a factorial design

Parameters:
  • ind_vars – Independent variables and their list of values

  • fixed_vars – Fixed variables to be passed directly to the world generator

  • n_worlds_per_condition – Number of simulations for each config

  • constraints – list of constraints that must be satisfied by all configs tested

Returns:

list of configs

scml.experiment.generate_configs_single(ind_var: str, ind_values: list[Any], fixed_vars: dict[str, Any], n_worlds_per_condition=5) list[dict[str, Any]][source]

Generates all configs for an experiment with a factorial design

Parameters:
  • ind_var – The independent variable. Note that multiple variables can be passed by separating them with semicolons

  • ind_values – The values to try for that independent variable. Note that multiple values can be passed in a tuple

  • fixed_vars – Fixed variables to be passed directly to the world generator

  • n_worlds_per_condition – Number of simulations for each config

Returns:

list of configs

scml.experiment.run_configs(configs: Iterable[dict[str, Any]], n_jobs: int) pandas.DataFrame[source]
scml.experiment.run(ind_vars: dict[str, list], fixed_vars: dict[str, Any], n_worlds_per_condition=5, factorial: bool = True, constraints: tuple[Constraint, Ellipsis] = tuple(), n_jobs: float | int = 0) pandas.DataFrame[source]

Runs an experiment :param ind_vars: The independent variables :param fixed_vars: Variables not tested but passed to the world generator :param n_worlds_per_condition: Number of simulations to run for each condition :param factorial: If true run all possibilities, otherwise test each ind_var in an experiment (much faster) :param constraints: list of constraints for world generation each specifying the feasible values of an independent

variable given that a condition is met

Parameters:

n_jobs – Number of jobs to use. If 1, processing will be serial. If zero all processes will be used. If a a fraction between zero and one, this fraction of CPU count will be used

Returns:

A dataframe with the results

scml.experiment.main(worlds, factorial, variables, name, steps, compact, log, jobs)[source]