scml.experiment =============== .. py:module:: scml.experiment Attributes ---------- .. autoapisummary:: scml.experiment.N_STEPS scml.experiment.N_WORLDS scml.experiment.COMPACT scml.experiment.NOLOGS scml.experiment.dep_vars scml.experiment.fixed_vars Classes ------- .. autoapisummary:: scml.experiment.Constraint Functions --------- .. autoapisummary:: scml.experiment.bankruptcy_level scml.experiment.relative_productivity scml.experiment.n_bankrupt scml.experiment.relative_welfare_all scml.experiment.relative_welfare_non_bankrupt scml.experiment.welfare_all scml.experiment.welfare_non_bankrupt scml.experiment.productivity scml.experiment.bankruptcy_rate scml.experiment.contract_execution scml.experiment.breach_rate scml.experiment.jobs scml.experiment.get_var_vals scml.experiment.run_config scml.experiment.satisfied scml.experiment.generate_configs_factorial scml.experiment.generate_configs_single scml.experiment.run_configs scml.experiment.run scml.experiment.main Module Contents --------------- .. py:data:: N_STEPS :value: 10 .. py:data:: N_WORLDS :value: 2 .. py:data:: COMPACT :value: True .. py:data:: NOLOGS :value: True .. py:class:: Constraint Bases: :py:obj:`tuple` .. py:attribute:: condition_vars .. py:attribute:: condition_values .. py:attribute:: conditioned_var .. py:attribute:: feasible_values .. py:function:: bankruptcy_level(world: scml.SCML2020World) .. py:function:: relative_productivity(world: scml.SCML2020World) .. py:function:: n_bankrupt(world: scml.SCML2020World) .. py:function:: relative_welfare_all(world: scml.SCML2020World) .. py:function:: relative_welfare_non_bankrupt(world: scml.SCML2020World) .. py:function:: welfare_all(world: scml.SCML2020World) .. py:function:: welfare_non_bankrupt(world: scml.SCML2020World) .. py:function:: productivity(world: scml.SCML2020World) .. py:function:: bankruptcy_rate(world: scml.SCML2020World) .. py:function:: contract_execution(world: scml.SCML2020World) .. py:function:: breach_rate(world: scml.SCML2020World) .. py:data:: dep_vars .. py:data:: fixed_vars .. py:function:: jobs(n_jobs: float | int) -> int .. py:function:: get_var_vals(var: str, val: Any) -> dict[str, Any] Extracts variable name and value allowing for multiple names separated by semicolon .. py:function:: run_config(world_config: dict[str, Any], funcs: list[str]) Runs a single configuration and returns values of all functions for that configuration .. py:function:: satisfied(config: dict[str, Any], constraints: Iterable[Constraint]) -> bool Tests whether the constraints are all satisfied in the config or not :param config: :param constraints: Returns: .. py:function:: 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]] Generates all configs for an experiment with a factorial design :param ind_vars: Independent variables and their list of values :param fixed_vars: Fixed variables to be passed directly to the world generator :param n_worlds_per_condition: Number of simulations for each config :param constraints: list of constraints that must be satisfied by all configs tested :returns: list of configs .. py:function:: generate_configs_single(ind_var: str, ind_values: list[Any], fixed_vars: dict[str, Any], n_worlds_per_condition=5) -> list[dict[str, Any]] Generates all configs for an experiment with a factorial design :param ind_var: The independent variable. Note that multiple variables can be passed by separating them with semicolons :param ind_values: The values to try for that independent variable. Note that multiple values can be passed in a tuple :param fixed_vars: Fixed variables to be passed directly to the world generator :param n_worlds_per_condition: Number of simulations for each config :returns: list of configs .. py:function:: run_configs(configs: Iterable[dict[str, Any]], n_jobs: int) -> pandas.DataFrame .. py:function:: 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 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 :param 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 .. py:function:: main(worlds, factorial, variables, name, steps, compact, log, jobs)