scml.oneshot.context

Module Contents

Classes

ContextParams

Basic Parameters you can assume about a context. Returned by extract_context_params

Context

A context used for generating worlds satisfying predefined conditions and testing for them

GeneralContext

A context that generates oneshot worlds with agents of a given types with predetermined structure and settings

LimitedPartnerNumbersContext

Generates a world limiting the range of the agent level, production capacity

FixedPartnerNumbersContext

Generates a world limiting the range of the agent level, production capacity

MonopolicContext

An agent that has no competitors in the same level as themselves

SingleAgentPerLevelSupplierContext

A world in which every level has exactly one factory and the agent is a supplier

EutopiaContext

An unrealistic context in which the agent is the only one in its level and all other agents are nice.

EutopiaSupplierContext

An unrealistic context in which the agent is the only supplier and all consumers are nice.

EutopiaConsumerContext

An unrealistic context in which the agent is the only consumer and all suppliers are nice.

FixedPartnerNumbersOneShotContext

Generates a world limiting the range of the agent level, production capacity

ANACContext

Generates a oneshot world with no constraints except compatibility with a specific ANAC competition year.

LimitedPartnerNumbersOneShotContext

Generates a oneshot world limiting the range of the agent level, production capacity

ANACOneShotContext

Generates a oneshot world with no constraints except compatibility with a specific ANAC competition year.

SupplierContext

A world context that can generate any world compatible with the observation manager

StrongSupplierContext

A supplier with almost many consumers relative to competitors

BalancedSupplierContext

A supplier with almost same number of consumers as competitors

WeakSupplierContext

A supplier with few consumers relative to competitors

ConsumerContext

A world context that can generate any world compatible with the observation manager

StrongConsumerContext

A consumer with almost many suppliers relative to competitors

BalancedConsumerContext

A consumer with almost same number of suppliers as competitors

WeakConsumerContext

A consumer with few suppliers relative to competitors

RepeatingContext

Encapsulates one or more configs and switches between them when asked to generate or make something.

class scml.oneshot.context.ContextParams[source]

Basic Parameters you can assume about a context. Returned by extract_context_params

perishable: bool[source]
nlines: int[source]
nsuppliers: int[source]
nconsumers: int[source]
class scml.oneshot.context.Context[source]

Bases: abc.ABC

A context used for generating worlds satisfying predefined conditions and testing for them

__call__(*args, **kwargs)[source]
abstract generate(types: tuple[type[scml.oneshot.agent.OneShotAgent], Ellipsis] | None = None, params: tuple[dict[str, Any], Ellipsis] | None = None, name: str | None = None) tuple[scml.oneshot.world.SCMLBaseWorld, tuple[scml.oneshot.agent.OneShotAgent]][source]

Generates a world with one or more agents to be controlled externally and returns both

Parameters:
  • agent_types – The types of a list of agents to be guaranteed to exist in the world

  • agent_params – The parameters to pass to the constructors of these agents. None means no parameters for any agents

  • name – The name of the worlds to generate. Uses a random name if not given

Returns:

The constructed world and a tuple of the agents created corresponding (in order) to the given agent types/params

abstract is_valid_world(world: scml.oneshot.world.SCMLBaseWorld) bool[source]

Checks that the given world could have been generated from this context

abstract is_valid_awi(awi: scml.oneshot.awi.OneShotAWI) bool[source]

Checks that the given AWI is connected to a world that could have been generated from this context

abstract contains_context(context: Context) bool[source]

Checks that the any world generated from the given context could have been generated from this context

__contains__(other: SCMLBaseWorld | OneShotAWI | Context) bool[source]
class scml.oneshot.context.GeneralContext[source]

Bases: BaseContext

A context that generates oneshot worlds with agents of a given types with predetermined structure and settings

perishable: bool = True[source]
price_multiplier: numpy.ndarray | tuple[float, float] | float = (1.5, 2.0)[source]
force_signing = True[source]
n_steps: tuple[int, int] | int = (20, 200)[source]
n_processes: tuple[int, int] | int = 2[source]
n_lines: tuple[int, int] | int = 10[source]
n_agents_per_process: numpy.ndarray | list[int] | tuple[int, int] | int = ()[source]
production_costs: numpy.ndarray | tuple[int, int] | int = (1, 4)[source]
cash_availability: tuple[float, float] | float = (1.5, 2.5)[source]
shortfall_penalty: tuple[float, float] | float = (0.2, 1.0)[source]
shortfall_penalty_dev: tuple[float, float] | float = (0.0, 0.1)[source]
disposal_cost: tuple[float, float] | float = (0.0, 0.2)[source]
disposal_cost_dev: tuple[float, float] | float = (0.0, 0.02)[source]
storage_cost: tuple[float, float] | float = (0.0, 0.02)[source]
storage_cost_dev: tuple[float, float] | float = 0[source]
cost_increases_with_level = True[source]
penalties_scale: str | list[str] = 'trading'[source]
process_inputs: tuple[int, int] | int = 1[source]
process_outputs: numpy.ndarray | tuple[int, int] | int = 1[source]
exogenous_generation_method = 'profitable'[source]
profit_means: numpy.ndarray | tuple[float, float] | float = (0.1, 0.2)[source]
profit_stddevs: numpy.ndarray | tuple[float, float] | float = 0.05[source]
max_productivity: numpy.ndarray | tuple[float, float] | float = (0.8, 1.0)[source]
initial_balance: numpy.ndarray | tuple[int, int] | int | None[source]
exogenous_supply_predictability: tuple[float, float] | float = (0.6, 0.9)[source]
exogenous_sales_predictability: tuple[float, float] | float = (0.6, 0.9)[source]
exogenous_control: tuple[float, float] | float[source]
exogenous_price_dev: tuple[float, float] | float = (0.1, 0.2)[source]
equal_exogenous_supply = False[source]
equal_exogenous_sales = False[source]
cap_exogenous_quantities: bool = True[source]
__attrs_post_init__()[source]
extract_context_params(min_values: bool, level: int | None = None) ContextParams[source]
make_predefined_config(agent_types: list[type[scml.oneshot.agent.OneShotAgent]], agent_processes: list[int], agent_params: list[dict[str, Any]], n_agents_per_process: list[int]) dict[str, Any][source]

Generates a config for a world

contains_context(context: Context, raise_on_failure: bool = False, warn_on_failure: bool = False, n_tests: int = NTESTS) bool[source]

Checks that the any world generated from the given context could have been generated from this context

_assign_types(n_processes, types, params, levels, n_agents_per_process)[source]
_distribute_agents(n_types)[source]
make_config() dict[str, Any][source]

Generates a config for a world

is_valid_world(world: scml.oneshot.world.SCMLBaseWorld, raise_on_failure: bool = False, warn_on_failure: bool = False, types: tuple[str | type[scml.oneshot.agent.OneShotAgent], Ellipsis] | None = None) bool[source]

Checks that the given world could have been generated from this context

contains_general_context(context: GeneralContext) bool[source]

Checks that the any world generated from the given context could have been generated from this context

class scml.oneshot.context.LimitedPartnerNumbersContext[source]

Bases: GeneralContext

Generates a world limiting the range of the agent level, production capacity and the number of suppliers, consumers, and optionally same-level competitors.

level: int = 0[source]
n_consumers: tuple[int, int][source]
n_suppliers: tuple[int, int] = (0, 0)[source]
n_competitors: tuple[int, int] = ()[source]
buying_strength: Strength | None[source]
selling_strength: Strength | None[source]
__attrs_post_init__()[source]
extract_context_params(min_values: bool, level: int | None = None) ContextParams[source]
make_config() dict[str, Any][source]

Generates a config

find_test_agents(world: scml.oneshot.world.SCMLBaseWorld, types: tuple[type[scml.oneshot.agent.OneShotAgent], Ellipsis] | None = None) list[str][source]
is_valid_world(world: scml.oneshot.world.SCMLBaseWorld, types: tuple[type[scml.oneshot.agent.OneShotAgent], Ellipsis] | None = None, raise_on_failure: bool = False, warn_on_failure: bool = False) bool[source]

Checks that the given world could have been generated from this context

contains_limited_partner_context(context: LimitedPartnerNumbersContext, raise_on_failure: bool = False, warn_on_failure: bool = False) bool[source]
contains_context(context: Context, raise_on_failure: bool = False, warn_on_failure: bool = False, n_tests: int = NTESTS) bool[source]

Checks that the any world generated from the given context could have been generated from this context

class scml.oneshot.context.FixedPartnerNumbersContext[source]

Bases: LimitedPartnerNumbersContext

Generates a world limiting the range of the agent level, production capacity and the number of suppliers, consumers, and optionally same-level competitors.

level: int = 0[source]
n_consumers: int = 4[source]
n_suppliers: int = 0[source]
n_competitors: int = 3[source]
__attrs_post_init__()[source]
extract_context_params(min_values: bool, level: int | None = None) ContextParams[source]
class scml.oneshot.context.MonopolicContext[source]

Bases: LimitedPartnerNumbersContext

An agent that has no competitors in the same level as themselves

n_competitors: tuple[int, int] = (0, 0)[source]
n_agents_per_process: numpy.ndarray | list[int] | tuple[int, int] | int[source]
__attrs_post_init__()[source]
class scml.oneshot.context.SingleAgentPerLevelSupplierContext[source]

Bases: MonopolicContext

A world in which every level has exactly one factory and the agent is a supplier

level: int = 0[source]
n_consumers: tuple[int, int] = (1, 1)[source]
n_suppliers: tuple[int, int] = (0, 0)[source]
n_agents_per_process: numpy.ndarray | list[int] | tuple[int, int] | int[source]
class scml.oneshot.context.EutopiaContext[source]

Bases: MonopolicContext

An unrealistic context in which the agent is the only one in its level and all other agents are nice.

non_competitors: tuple[str | type[scml.oneshot.agent.OneShotAgent], Ellipsis][source]
class scml.oneshot.context.EutopiaSupplierContext[source]

Bases: EutopiaContext

An unrealistic context in which the agent is the only supplier and all consumers are nice.

level: int[source]
n_consumers: tuple[int, int][source]
n_suppliers: tuple[int, int] = (0, 0)[source]
class scml.oneshot.context.EutopiaConsumerContext[source]

Bases: EutopiaContext

An unrealistic context in which the agent is the only consumer and all suppliers are nice.

level: int[source]
n_consumers: tuple[int, int] = (0, 0)[source]
n_suppliers: tuple[int, int][source]
class scml.oneshot.context.FixedPartnerNumbersOneShotContext[source]

Bases: FixedPartnerNumbersContext

Generates a world limiting the range of the agent level, production capacity and the number of suppliers, consumers, and optionally same-level competitors.

class scml.oneshot.context.ANACContext[source]

Bases: GeneralContext

Generates a oneshot world with no constraints except compatibility with a specific ANAC competition year.

year: int = 2024[source]
__attrs_post_init__()[source]
class scml.oneshot.context.LimitedPartnerNumbersOneShotContext[source]

Bases: LimitedPartnerNumbersContext

Generates a oneshot world limiting the range of the agent level, production capacity and the number of suppliers, consumers, and optionally same-level competitors.

year: int = 2024[source]
__attrs_post_init__()[source]
class scml.oneshot.context.ANACOneShotContext[source]

Bases: ANACContext

Generates a oneshot world with no constraints except compatibility with a specific ANAC competition year.

__attrs_post_init__()[source]
class scml.oneshot.context.SupplierContext(*args, **kwargs)[source]

Bases: LimitedPartnerNumbersOneShotContext

A world context that can generate any world compatible with the observation manager

class scml.oneshot.context.StrongSupplierContext(*args, **kwargs)[source]

Bases: SupplierContext

A supplier with almost many consumers relative to competitors

class scml.oneshot.context.BalancedSupplierContext(*args, **kwargs)[source]

Bases: SupplierContext

A supplier with almost same number of consumers as competitors

class scml.oneshot.context.WeakSupplierContext(*args, **kwargs)[source]

Bases: SupplierContext

A supplier with few consumers relative to competitors

class scml.oneshot.context.ConsumerContext(*args, **kwargs)[source]

Bases: LimitedPartnerNumbersOneShotContext

A world context that can generate any world compatible with the observation manager

class scml.oneshot.context.StrongConsumerContext(*args, **kwargs)[source]

Bases: ConsumerContext

A consumer with almost many suppliers relative to competitors

class scml.oneshot.context.BalancedConsumerContext(*args, **kwargs)[source]

Bases: ConsumerContext

A consumer with almost same number of suppliers as competitors

class scml.oneshot.context.WeakConsumerContext(*args, **kwargs)[source]

Bases: ConsumerContext

A consumer with few suppliers relative to competitors

class scml.oneshot.context.RepeatingContext[source]

Bases: BaseContext

Encapsulates one or more configs and switches between them when asked to generate or make something.

configs: tuple[dict[str, Any], Ellipsis][source]
randomize: bool = True[source]
rename: bool = True[source]
_next: int[source]
__attrs_post_init__()[source]
extract_context_params(min_values: bool, level: int | None = None) ContextParams[source]
make_config(types: tuple[type[scml.oneshot.agent.OneShotAgent], Ellipsis] = DEFAULT_PLACEHOLDER_AGENT_TYPES, params: tuple[dict[str, Any], Ellipsis] | None = None) dict[str, Any][source]

Generates a config for a world

classmethod from_context(context: BaseContext, n: int = 1, types: tuple[type[scml.oneshot.agent.OneShotAgent]] = DEFAULT_PLACEHOLDER_AGENT_TYPES, rename: bool = False, randomize: bool = False)[source]
contains_repeating_context(context: RepeatingContext, raise_on_failure: bool = False, warn_on_failure: bool = False)[source]
is_valid_world(world: scml.oneshot.world.SCMLBaseWorld, raise_on_failure=RAISE_ON_FAILURE, warn_on_failure=WARN_ON_FAILURE, types: tuple[str | type[scml.oneshot.agent.OneShotAgent], Ellipsis] | None = None) bool[source]

Checks that the given world could have been generated from this context

contains_context(context: Context, raise_on_failure: bool = False, warn_on_failure: bool = False, n_tests: int = NTESTS) bool[source]

Checks that the any world generated from the given context could have been generated from this context