scml.cli

The SCML universal command line tool

Attributes

DefaultAgents

DefaultAgents2022

n_completed

n_total

DEFAULT_STD_OLD

DEFAULT_STD_2021

DEFAULT_ONESHOT

DEFAULT_STD

DEFAULT_2021_NONCOMPETITORS

DEFAULT_STD_NONCOMPETITORS_OLD

DEFAULT_ONESHOT_NONCOMPETITORS

DEFAULT_STD_NONCOMPETITORS

DB_FOLDER

DB_NAME

Classes

SCML2021OneShotWorld

Oneshot simulation as used in SCML 2021 competition

SCML2022OneShotWorld

Oneshot simulation as used in SCML 2022 competition

SCML2023OneShotWorld

Oneshot simulation as used in SCML 2023 competition

SCML2024OneShotWorld

Oneshot simulation as used in SCML 2024 competition

FactoryManager

Base factory manager class that will be inherited by participant negmas in ANAC 2019.

SCML2019World

The SCML2020World class running a simulation of supply chain management.

DefaultGreedyManager

The default factory manager that will be implemented by the committee of ANAC-SCML 2019

SCML2020Agent

Base class for all SCML2020 agents (factory managers)

SCML2020World

A Supply Chain SCML2020World simulation as described for the SCML league of ANAC @ IJCAI 2020.

SCML2021World

A Supply Chain SCML2020World simulation as described for the SCML league of ANAC @ IJCAI 2020.

SCML2023World

A Supply Chain SCML2020World simulation as described for the SCML league of ANAC @ IJCAI 2020.

SCML2022World

A Supply Chain SCML2020World simulation as described for the SCML league of ANAC @ IJCAI 2020.

SCML2024StdWorld

The SCML-standard simulation as used in [SCML 2024](https://scml.cs.brown.edu)

Functions

anac2019_collusion(...)

The function used to run ANAC 2019 SCML tournament (collusion track).

anac2019_sabotage(...)

The function used to run ANAC 2019 SCML tournament (collusion track).

anac2019_std(...)

The function used to run ANAC 2019 SCML tournament (standard track).

is_system_agent(→ bool)

Checks whether an agent is a system agent or not

anac2020_collusion(...)

The function used to run ANAC 2020 SCML tournament (collusion track).

anac2020_std(...)

The function used to run ANAC 2020 SCML tournament (standard track).

anac2021_collusion(...)

The function used to run ANAC 2021 SCML tournament (collusion track).

anac2021_oneshot(...)

The function used to run ANAC 2021 SCML tournament (oneshot track).

anac2021_std(...)

The function used to run ANAC 2021 SCML tournament (standard track).

anac2022_collusion(...)

The function used to run ANAC 2022 SCML tournament (collusion track).

anac2022_oneshot(...)

The function used to run ANAC 2022 SCML tournament (oneshot track).

anac2022_std(...)

The function used to run ANAC 2022 SCML tournament (standard track).

anac2023_collusion(...)

The function used to run ANAC 2023 SCML tournament (collusion track).

anac2023_oneshot(...)

The function used to run ANAC 2023 SCML tournament (oneshot track).

anac2023_std(...)

The function used to run ANAC 2023 SCML tournament (standard track).

anac2024_oneshot(...)

The function used to run ANAC 2024 SCML tournament (oneshot track).

anac2024_std(...)

The function used to run ANAC 2024 SCML tournament (std track).

gui_option(x)

get_range(x, x_min, x_max)

Gets a range with possibly overriding it with a single value

default_log_path()

Default location for all logs

save_run_info(name, log_path[, type_, path])

default_tournament_path()

The default path to store tournament run info

default_world_path()

The default path to store world run info

print_progress(→ None)

Prints the progress of a tournament

print_world_progress(→ None)

Prints the progress of a world

shortest_unique_names(strs[, sep])

Finds the shortest unique strings starting from the end of each input

nCr(n, r)

main()

display_results(results, metric[, file_name])

_path(→ pathlib.Path)

Creates an absolute path from given path which can be a string

run2019(steps, levels, competitors, log, compact, ...)

run2020(steps, time, competitors, log, compact, ...)

run2021(steps, time, competitors, log, compact, ...)

run2022(steps, time, competitors, log, compact, ...)

run2023(steps, time, competitors, log, compact, ...)

run2024(steps, time, competitors, log, compact, ...)

tournament2019(output, parallel, name, steps, ttype, ...)

tournament2020(name, steps, timeout, ttype, log, ...)

tournament2021(name, steps, timeout, ttype, log, ...)

tournament2022(name, steps, timeout, ttype, log, ...)

tournament2023(name, steps, timeout, ttype, log, ...)

tournament2024(name, steps, timeout, total_timeout, ...)

version()

Module Contents

scml.cli.DefaultAgents: tuple[type[scml.scml2020.world.SCML2020Agent], Ellipsis][source]
scml.cli.DefaultAgents2022[source]
class scml.cli.SCML2021OneShotWorld(*args, **kwargs)[source]

Bases: SCML2020OneShotWorld

Oneshot simulation as used in SCML 2021 competition

class scml.cli.SCML2022OneShotWorld(*args, **kwargs)[source]

Bases: SCML2021OneShotWorld

Oneshot simulation as used in SCML 2022 competition

class scml.cli.SCML2023OneShotWorld(*args, **kwargs)[source]

Bases: SCML2020OneShotWorld

Oneshot simulation as used in SCML 2023 competition

class scml.cli.SCML2024OneShotWorld(*args, **kwargs)[source]

Bases: SCML2023OneShotWorld

Oneshot simulation as used in SCML 2024 competition

class scml.cli.FactoryManager(name=None, simulator_type: str | Type[scml.scml2019.simulators.FactorySimulator] = FastFactorySimulator)[source]

Bases: scml.scml2019.agent.SCML2019Agent, abc.ABC

Base factory manager class that will be inherited by participant negmas in ANAC 2019.

The agent can access the world simulation in one of two ways:

  1. Attributes and methods available in the Agent-SCML2020World-Interface (See SCMLAWI documentation for those).

  2. Attributes and methods in the FactoryManager object itself. All factory managers will have the following attributes and methods that simplify the interaction with the world simulation. Some of these attributes/methods are convenient ways to access functionality already available in the agent’s internal SCMLAWI.

Attributes

Agent information

  • id : The unique ID assigned to this agent. This is unique system-wide and is what is used in contracts, CFPs, etc.

  • name: A name of the agent used for display purposes only. The simulator never accesses or uses this name except in printing and logging.

  • uuid : Another name of the id .

  • type_name : A string giving the type of the agent (as a fully qualified python class name).

Capabilities/Profiles

  • line_profiles : A mapping specifying for each line index, all the profiles that can be run on it

  • process_profiles : A mapping specifying for each Process index, all the profiles used to run it in the factory

  • producing : Mapping from a product index to all manufacturing processes that can generate it

  • consuming : Mapping from a product index to all manufacturing processes that can consume it

  • compiled_profiles : All the profiles to be used by the factory belonging to this agent compiled to use process indices

  • max_storage : Maximum storage available to the agent. Zero, None or float(‘inf’) all indicate unlimited storage.

Production Graph (also accessible through awi)

  • products : List of products in the system

  • processes : List of processes in the system

Helper Objects

  • awi : The SCMLAWI instance assigned to this agent. It can be used to interact with the simulation (See SCMLAWI documentation).

  • simulator : A FactorySimulator object that can be used to simulate what happens in the Factory assigned to this agent when given operations are conducted (e.g. production, paying money, etc).

Negotiations/Contracts

  • requested_negotiations : A dynamic list of negotiations currently requested by the agent but not started. Correct management of this list is only possible if the agent **always* uses request_negotiation method of this class (see methods later) rather than directly calling request_method on the SCMLAWI ( awi ) member.

  • running_negotiations : A dynamic list of negotiations currently running involving this agent. Correct management of this list is only possible if the agent **always* uses request_negotiation method of this class (see methods later) rather than directly calling request_method on the SCMLAWI ( awi ) member.

  • unsigned_contracts : A dynamic list of negotiations contracts concluded involving this agent but not yet signed. Correct management of this list is only possible if the agent **always* uses request_negotiation method of this class (see methods later) rather than directly calling request_method on the SCMLAWI ( awi ) member.

Simulation attributes (also accessible through awi)

Methods (Callable by the agent)

Actions on the world

Scheduling and simulation helpers

  • can_expect_agreement : Checks if it is possible in principle to get an agreement on this CFP by the time it becomes executable.

Callbacks (Callable by the simulation)

Decision callbacks (Called to make decisions)

  • Negotiation and Contracts

    • respond_to_negotiation_request : Decide whether or not to engage in a negotiation on a CFP that was published earlier by this factory manager. If accepted, the agent should return a SAONegotiator object.

    • sign_contract : Decide whether or not to sign the contract. If accepted, the agent should return its own ID.

    • confirm_contract_execution : Decide whether or not to go on with executing a contract that the agent already signed. If rejected (by returning False ), a refusal-to-execute breach will be recorded.

  • Breach related

    • confirm_partial_execution : Decide whether the agent agrees to partial execution. Called only when the the partner of this agent commits a partial breach (of level < 1) and this agent commits no breaches.

    • set_renegotiation_agenda : Decide what are the issues and ranges of acceptable values to re-negotiate about. Called only in case of breaches.

    • respond_to_renegotiation_request : Decide whether or not to engage in a re-negotiation.

  • Financial

    • confirm_loan : Decide whether or not to accept an offered loan. *In ANAC 2019 league, loans are not allowed and this callback will never be called by the simulator.

Time-dependent callbacks (Information callback called at predefined times)

  • init : Called once before any production or negotiations to initiate the agent.

  • step : Called at every production step.

Information callbacks (Called to inform the agent about events)

  • CFP related

    • on_new_cfp : Called whenever a CFP on a Product for which the agent has already registered interest (using register_interest method of its awi) is published. By default all agents register interest in the products they can consume or produce according to their profiles.

    • on_remove_cfp : Called whenever a CFP on a Product for which the agent has already registered interest (using register_interest method of its awi) is removed from the bulletin-board.

  • Negotiation related

  • Contract related

    • on_contract_cancelled : Called whenever a Contract of which the agent is a party is cancelled because the other party refused to sign it.

    • on_contract_signed : Called whenever a Contract of which the agent is a party is signed by both patners.

    • on_contract_nullified : Called whenever a Contract of which the agent is a party is nullified by the simulator as a part of bankruptcy processing.

    • on_contract_executed : Called when a contract executes completely and successfully.

    • on_contract_breached : Called when a contract is breached after complete contract processing.

  • Production and factory related

    • on_production_failure : Called whenever a scheduled production (see SCMLAWI for production commands) fails

    • on_inventory_change : Called whenever there is a change in the inventory (something is moved in or out or out of storage due to an event other than production (e.g. contract execution).

    • on_cash_transfer : Called whenever cash is transferred to or from the factory’s wallet.

  • About other agents

transportation_delay = 0

Transportation delay in the world

simulator: scml.scml2019.simulators.FactorySimulator | None = None

The simulator used by this agent

simulator_type: Type[scml.scml2019.simulators.FactorySimulator]

Simulator type (as a class)

current_step = 0

Current simulation step

max_storage: int = 0

Maximum storage available to the agent

init_()[source]

The initialization function called by the world directly.

It does the following actions by default:

  1. copies some of the static world settings to the agent to make them available without calling the AWI.

  2. prepares production related properties like producing, consuming, line_profiles, compiled_profiles, etc.

  3. registers interest in all products that the agent can produce or consume in its factory.

  4. finally it calls any custom initialization logic implemented in `init`()

See also

init, step

step_()[source]

Called at every time-step. This function is called directly by the world.

abstract on_production_failure(failures: List[scml.scml2019.common.ProductionFailure]) None[source]

Called with a list of ProductionFailure records on production failure.

abstract on_production_success(reports: List[scml.scml2019.common.ProductionReport]) None[source]

Called with a list of ProductionReport records on production success

class scml.cli.SCML2019World(products: Collection[scml.scml2019.common.Product], processes: Collection[scml.scml2019.common.Process], factories: List[scml.scml2019.common.Factory], consumers: List[scml.scml2019.consumers.Consumer], miners: List[scml.scml2019.miners.Miner], factory_managers: List[scml.scml2019.factory_managers.builtins.FactoryManager] | None = None, n_steps=100, time_limit=60 * 90, mechanisms: Dict[str, Dict[str, Any]] | None = None, neg_n_steps=20, neg_time_limit=2 * 60, neg_step_time_limit=60, negotiation_speed=21, no_bank=False, minimum_balance=0, interest_rate=0.1, interest_max=0.3, installment_interest=0.2, interest_time_increment=0.02, balance_at_max_interest=None, loan_installments=1, no_insurance=False, premium=0.03, premium_time_increment=0.03, premium_breach_increment=0.001, max_allowed_breach_level=None, breach_processing=BreachProcessing.VICTIM_THEN_PERPETRATOR, breach_penalty_society=0.1, breach_penalty_society_min=0.0, breach_penalty_victim=0.0, breach_move_max_product=True, initial_wallet_balances: int | None = None, money_resolution=0.5, default_signing_delay=0, transportation_delay: int = 0, transfer_delay: int = 0, start_negotiations_immediately=False, catalog_profit=0.15, avg_process_cost_is_public=True, catalog_prices_are_public=True, strip_annotations=True, financial_reports_period=10, ignore_negotiated_penalties=False, prevent_cfp_tampering=False, default_price_for_products_without_one=1, compensation_fraction=0.5, compact=False, log_folder=None, log_to_file: bool = False, log_to_screen: bool = False, log_file_level=logging.DEBUG, log_screen_level=logging.ERROR, log_file_name: str = 'log.txt', log_ufuns: bool = False, log_negotiations: bool = False, save_mechanism_state_in_contract=False, save_signed_contracts: bool = True, save_cancelled_contracts: bool = True, save_negotiations: bool = True, save_resolved_breaches: bool = True, save_unresolved_breaches: bool = True, ignore_agent_exceptions: bool = False, ignore_contract_execution_exceptions: bool = False, name: str | None = None, **kwargs)[source]

Bases: negmas.situated.TimeInAgreementMixin, negmas.situated.World

The SCML2020World class running a simulation of supply chain management.

join(x: negmas.situated.Agent, simulation_priority: int = 0)[source]

Add an agent to the world.

Parameters:
  • x – The agent to be registered

  • simulation_priority – The simulation priority. Entities with lower priorities will be stepped first during

Returns:

save_config(file_name: str) None[source]

Saves the config of the world as a yaml file

Parameters:

file_name – Name of file to save the config to

Returns:

assign_managers(factory_managers=Iterable[Union[str, Type[FactoryManager], FactoryManager]], params: Iterable[Dict[str, Any]] | None = None) None[source]

Assigns existing factories to new factory managers created from the given types and parameters or manager objects.

Parameters:
  • factory_managers – An iterable of FactoryManager objects type names or FactoryManager types to assign to

  • params – parameters of the newly created managers

Remarks:

  • factories are assigned in the same order they exist in the local factories attribute cycling through the input managers or types/params

  • If a FactoryManager object is given instead of a type or a string in the factory_managers collection, and the number of factory_managers is less than the number of factories in the world causing this object to cycle for more than one factory, it is assigned to the first such factory but then deep copies of it with new ids and names are assigned to the rest of the factories. That ensures that each manager has exactly one factory and that all factories are assigned exactly one unique manager.

classmethod random_small(n_production_levels: int = 1, n_factories: int = 10, factory_kwargs: Dict[str, Any] = None, miner_kwargs: Dict[str, Any] = None, consumer_kwargs: Dict[str, Any] = None, **kwargs)[source]
classmethod chain_world(n_intermediate_levels=0, n_miners=5, n_factories_per_level=5, n_consumers: int | Tuple[int, int] | List[int] = 5, n_steps=100, n_lines_per_factory=10, n_max_assignable_factories=None, log_file_name: str = None, agent_names_reveal_type: bool = False, negotiator_type: str = DEFAULT_NEGOTIATOR, miner_type: str | Type[scml.scml2019.miners.Miner] = ReactiveMiner, consumer_type: str | Type[scml.scml2019.consumers.Consumer] = JustInTimeConsumer, max_storage: int = sys.maxsize, default_manager_params: Dict[str, Any] = None, miner_kwargs: Dict[str, Any] = None, consumption: int | Tuple[int, int] = (0, 5), consumer_kwargs: Dict[str, Any] = None, negotiation_speed: int | None = 21, manager_types: Sequence[Type[scml.scml2019.factory_managers.builtins.FactoryManager]] = (GreedyFactoryManager,), manager_params: Sequence[Dict[str, Any]] | None = None, n_default_per_level: int = 0, default_factory_manager_type: Type[scml.scml2019.factory_managers.builtins.FactoryManager] = GreedyFactoryManager, randomize: bool = True, initial_wallet_balances=1000, process_cost: float | Tuple[float, float] = (1.0, 5.0), process_time: int | Tuple[int, int] = 1, interest_rate=float('inf'), interest_max=float('inf'), shared_profile_per_factory=False, **kwargs)[source]

Creates a very small world in which only one raw material and one final product. The production graph is a series with n_intermediate_levels intermediate levels between the single raw material and single final product

Parameters:
  • n_max_assignable_factories – The maximum number of factories assigned to managers other than the default

  • randomize – If true, the factory assignment is randomized

  • n_default_per_level – The number of GreedyFactoryManager objects guaranteed at every level

  • default_factory_manager_type – The FactoryManager type to use as the base for default_factory_managers. You can specify how many of this type exist at every level by specifying n_default_per_level. If n_default_per_level is zero, this parameter has no effect.

  • manager_types – A sequence of factory manager types to control the factories.

  • manager_params – An optional sequence of dictionaries giving the parameters to pass to manager_types.

  • consumer_type – Consumer type to use for all consumers

  • miner_type – Miner type to use for all miners

  • consumption – Consumption schedule

  • n_intermediate_levels – The number of intermediate products

  • n_miners – number of miners of the single raw material

  • n_factories_per_level – number of factories at every production level

  • n_consumers – number of consumers of the final product

  • n_steps – number of simulation steps

  • n_lines_per_factory – number of lines in each factory

  • process_cost – The range of process costs. A uniform distribution will be used

  • process_time – The range of process times. A uniform distribution will be used

  • log_file_name – File name to store the logs

  • agent_names_reveal_type – If true, agent names will start with a snake_case version of their type name

  • negotiator_type – The negotiation factory used to create all negotiators

  • max_storage – maximum storage capacity for all factory managers If None then it is unlimited

  • default_manager_params – keyword arguments to be used for constructing factory managers

  • consumer_kwargs – keyword arguments to be used for constructing consumers

  • miner_kwargs – keyword arguments to be used for constructing miners

  • negotiation_speed – The number of negotiation steps per simulation step. None means infinite

  • interest_max – Maximum interest rate

  • interest_rate – Minimum interest rate

  • initial_wallet_balances – initial wallet balances for all factories

  • shared_profile_per_factory – If true, all lines in the same factory will have the same profile costs

  • kwargs – Any other parameters are just passed to the world constructor

Returns:

SCML2019World ready to run

Remarks:

  • Every production level n has one process only that takes n steps to complete

classmethod random(n_raw_materials: int | Tuple[int, int] = (5, 10), raw_material_price: float | Tuple[float, float] = (1.0, 30.0), n_final_products: int | Tuple[int, int] = (3, 5), n_production_levels: int | Tuple[int, int] = (3, 5), n_products_per_level: int | Tuple[int, int] = (3, 5), n_processes_per_level: int | Tuple[int, int] = (6, 10), n_inputs_per_process: int | Tuple[int, int] = (2, 5), bias_toward_last_level_products: float = 0.0, quantity_per_input: int | Tuple[int, int] = (1, 10), input_step: float | Tuple[float, float] = 0.0, quantity_per_output: int | Tuple[int, int] = (1, 1), output_step: float | Tuple[float, float] = 1.0, process_relative_cost: float | Tuple[float, float] = (0.05, 0.4), n_outputs_per_process: int | Tuple[int, int] = (1, 1), n_lines: int | Tuple[int, int] = (3, 5), lines_are_similar: bool = False, n_processes_per_line: int | Tuple[int, int] = None, cost_for_line: float | Tuple[float, float] = (5.0, 50.0), n_production_steps: int | Tuple[int, int] = (2, 10), max_storage: int | Tuple[int, int] = 2000, n_factories: int | Tuple[int, int] = 20, n_consumers: int | Tuple[int, int] = 5, n_products_per_consumer: int | Tuple[int, int] = None, n_miners: int | Tuple[int, int] = 5, n_products_per_miner: int | Tuple[int, int] | None = None, factory_manager_types: Type[scml.scml2019.factory_managers.builtins.FactoryManager] | List[Type[scml.scml2019.factory_managers.builtins.FactoryManager]] = GreedyFactoryManager, consumer_types: Type[scml.scml2019.consumers.Consumer] | List[Type[scml.scml2019.consumers.Consumer]] = JustInTimeConsumer, miner_types: Type[scml.scml2019.miners.Miner] | List[Type[scml.scml2019.miners.Miner]] = ReactiveMiner, negotiator_type=DEFAULT_NEGOTIATOR, initial_wallet_balance: float | Tuple[float, float] = 1000, factory_kwargs: Dict[str, Any] = None, miner_kwargs: Dict[str, Any] = None, consumer_kwargs: Dict[str, Any] = None, **kwargs)[source]

Creates a random SCML scenario with adjustable parameters.

Parameters:
  • n_raw_materials – Number of raw materials. Can be a value or a range.

  • raw_material_price – Catalog prices for raw materials. Can be a value or a range.

  • n_final_products – Number of final products. Can be a value or a range.

  • n_production_levels – How deep is the production graph (number of intermediate products). Can be a value or

  • range. (miner. Can be a value or a)

  • n_products_per_level – How many intermediate products per intermediate level. Can be a value or a range.

  • n_processes_per_level – Number of processes in intermediate levels. Can be a value or a range.

  • n_inputs_per_process – Number of inputs per process. Can be a value or a range.

  • bias_toward_last_level_products – How biased are production processes toward using products from the last

  • them (level below)

  • quantity_per_input – How many items are needed for each input to a process. Can be a value or a range.

  • input_step – When are inputs consumed during the production process. Can be a value or a range. Default 0

  • quantity_per_output – How many items are produced per output. Can be a value or a range.

  • output_step – When are outputs created during the production process. Can be a value or a range. Default 1

  • process_relative_cost – Intrinsic relative cost of processes [Outputs will be produced

  • sum (at a cost of)

  • n_outputs_per_process – Number of outputs per process. Can be a value or a range.

  • n_lines – Number of lines per factory. Can be a value or a range.

  • lines_are_similar – If true then all lins of the same factory will have the same production processes.

  • n_processes_per_line – Number of processes that can be run on each line per factory. Can be a value or a

  • range.

  • cost_for_line – Cost for running a process on a line. Can be a value or a range.

  • n_production_steps – Number of production steps per line. Can be a value or a range.

  • max_storage – Maximum storage per factory. Can be a value or a range.

  • n_factories – Number of factories. Can be a value or a range.

  • n_consumers – Number of consumers. Can be a value or a range.

  • n_products_per_consumer – Number of products per miner. If None then all final products will be assigned to

  • range.

  • n_miners – Number of miners. Can be a value or a range.

  • n_products_per_miner – Number of products per miner. If None then all raw materials will be assigned to every

  • range.

  • factory_manager_types – A callable for creating factory managers for the factories

  • consumer_types – A callable for creating Consumer objects

  • miner_types – A callable for creating Miner objects

  • negotiator_type – A string that can be `eval`uated to a negotiator.

  • initial_wallet_balance – The initial balance of all wallets

  • factory_kwargs – keyword arguments to be used for constructing factory managers

  • consumer_kwargs – keyword arguments to be used for constructing consumers

  • miner_kwargs – keyword arguments to be used for constructing miners

  • **kwargs

Returns:

SCML2019World The random world generated

Remarks:

  • Most parameters accept either a single value or a 2-valued tuple. In the later case, it will sample a value within the range specified by the tuple (low, high) inclusive. For example the number of lines (n_lines) follows this pattern

_update_dynamic_product_process_info()[source]

Updates the catalog prices of all products based on the prices of their inputs

set_consumers(consumers: List[scml.scml2019.consumers.Consumer])[source]
set_miners(miners: List[scml.scml2019.miners.Miner])[source]
set_factory_managers(factory_managers: List[scml.scml2019.factory_managers.builtins.FactoryManager] | None)[source]
set_processes(processes: Collection[scml.scml2019.common.Process])[source]
set_products(products: Collection[scml.scml2019.common.Product])[source]
order_contracts_for_execution(contracts: Collection[negmas.situated.Contract])[source]

Orders the contracts in a specific time-step that are about to be executed

execute_action(action: negmas.situated.Action, agent: negmas.situated.Agent, callback: Callable[[negmas.situated.Action, bool], Any] = None) bool[source]

Executes the given action by the given agent

get_private_state(agent: negmas.situated.Agent) scml.scml2019.common.FactoryState[source]

Reads the private state of the given agent

receive_financial_reports(agent: scml.scml2019.agent.SCML2019Agent, receive: bool, agents: List[str] | None)[source]

Registers interest/disinterest in receiving financial reports

simulation_step(stage)[source]

A step of SCML simulation

pre_step_stats()[source]

Called at the beginning of the simulation step to prepare stats or update them

Kept for backward compatibility and will be dropped. Override update_stats instead

post_step_stats()[source]

Saves relevant stats

start_contract_execution(contract: negmas.situated.Contract) Set[negmas.situated.Breach][source]

Tries to execute the contract

Parameters:

contract

Returns:

The set of breaches committed if any. If there are no breaches return an empty set

Return type:

Set[Breach]

Remarks:

  • You must call super() implementation of this method before doing anything

  • It is possible to return None which indicates that the contract was nullified (i.e. not executed due to a reason other than an execution exeception).

_move_product(buyer: scml.scml2019.agent.SCML2019Agent, seller: scml.scml2019.agent.SCML2019Agent, product_id: int, quantity: int, money: float)[source]

Moves as much product and money between the buyer and seller

complete_contract_execution(contract: negmas.situated.Contract, breaches: List[negmas.situated.Breach], resolution: negmas.situated.Contract | None)[source]

The resolution can either be None or a contract with the following items:

The issues can be any or all of the following:

immediate_quantity: int immediate_unit_price: float later_quantity: int later_unit_price: int later_penalty: float later_time: int

_move_product_force(buyer: scml.scml2019.agent.SCML2019Agent, seller: scml.scml2019.agent.SCML2019Agent, product_id: int, quantity: int, money: float)[source]

Moves as much product and money between the buyer and seller

register_interest(agent: scml.scml2019.agent.SCML2019Agent, products: List[int]) None[source]
unregister_interest(agent: scml.scml2019.agent.SCML2019Agent, products: List[int]) None[source]
make_bankrupt(agent: scml.scml2019.agent.SCML2019Agent, amount: float, beneficiary: negmas.situated.Agent, contract: negmas.situated.Contract | None) None[source]

Marks the agent as bankrupt

nullify_contract(contract: negmas.situated.Contract)[source]
evaluate_insurance(contract: negmas.situated.Contract, agent: scml.scml2019.agent.SCML2019Agent, t: int = None) float | None[source]

Can be called to evaluate the premium for insuring the given contract against breachs committed by others

Parameters:
  • agent – The agent buying the contract

  • contract – hypothetical contract

  • t – time at which the policy is to be bought. If None, it means current step

buy_insurance(contract: negmas.situated.Contract, agent: scml.scml2019.agent.SCML2019Agent) bool[source]

Buys insurance for the contract by the premium calculated by the insurance company.

Remarks:

The agent can call evaluate_insurance to find the premium that will be used.

_process_annotation(annotation: Dict[str, Any] | None) Dict[str, Any] | None[source]

Processes an annotation stripping any extra information not allowed if necessary. Will return None if the annotation is suspecious

run_negotiation(caller: negmas.situated.Agent, issues: Collection[negmas.outcomes.Issue], partners: Collection[negmas.situated.Agent], negotiator: negmas.Negotiator, ufun: negmas.UtilityFunction = None, caller_role: str = None, roles: Collection[str] = None, annotation: Dict[str, Any] | None = None, mechanism_name: str = None, mechanism_params: Dict[str, Any] = None) Tuple[negmas.situated.Contract, negmas.NegotiatorMechanismInterface] | None[source]

Runs a negotiation until completion

Parameters:
  • caller – The agent requesting the negotiation

  • partners – A list of partners to participate in the negotiation. Note that the caller itself may not be in this list which makes it possible for an agent to request a negotaition that it does not participate in. If that is not to be allowed in some world, override this method and explicitly check for these kinds of negotiations and return False. If partners is passed as a single string/Agent or as a list containing a single string/Agent, then he caller will be added at the beginning of the list. This will only be done if roles was passed as None.

  • negotiator – The negotiator to be used in the negotiation

  • preferences – The utility function. Only needed if the negotiator does not already know it

  • caller_role – The role of the caller in the negotiation

  • issues – Negotiation issues

  • annotation – Extra information to be passed to the partners when asking them to join the negotiation

  • partners – A list of partners to participate in the negotiation

  • roles – The roles of different partners. If None then each role for each partner will be None

  • mechanism_name – Name of the mechanism to use. It must be one of the mechanism_names that are supported by the

  • None (must also be)

  • my_role (then roles and)

  • None

  • mechanism_params – A dict of parameters used to initialize the mechanism object

Returns:

A Tuple of a contract and the nmi of the mechanism used to get it in case of success. None otherwise

run_negotiations(caller: negmas.situated.Agent, issues: List[negmas.outcomes.Issue] | List[List[negmas.outcomes.Issue]], partners: List[List[negmas.situated.Agent]], negotiators: List[negmas.Negotiator], ufuns: List[negmas.UtilityFunction] = None, caller_roles: List[str] = None, roles: List[List[str] | None] | None = None, annotations: List[Dict[str, Any] | None] | None = None, mechanism_names: str | List[str] | None = None, mechanism_params: Dict[str, Any] | List[Dict[str, Any]] | None = None, all_or_none: bool = False) List[Tuple[negmas.situated.Contract, negmas.NegotiatorMechanismInterface]][source]

Requests to run a set of negotiations simultaneously. Returns after all negotiations are run to completion

Parameters:
  • caller – The agent requesting the negotiation

  • partners – A list of list of partners to participate in the negotiation. Note that the caller itself may not be in this list which makes it possible for an agent to request a negotaition that it does not participate in. If that is not to be allowed in some world, override this method and explicitly check for these kinds of negotiations and return False. If partners[i] is passed as a single string/Agent or as a list containing a single string/Agent, then he caller will be added at the beginning of the list. This will only be done if roles was passed as None.

  • issues – Negotiation issues

  • negotiators – The negotiator to be used in the negotiation

  • ufuns – The utility function. Only needed if the negotiator does not already know it

  • caller_roles – The role of the caller in the negotiation

  • annotations – Extra information to be passed to the partners when asking them to join the negotiation

  • partners – A list of partners to participate in the negotiation

  • roles – The roles of different partners. If None then each role for each partner will be None

  • mechanism_names – Name of the mechanism to use. It must be one of the mechanism_names that are supported by the

  • None (must also be)

  • my_role (then roles and)

  • None

  • mechanism_params – A dict of parameters used to initialize the mechanism object

  • all_of_none – If True, ALL partners must agree to negotiate to go through.

Returns:

contract (None for failure) and nmi (The mechanism info [None if the partner refused the negotiation])

Return type:

A list of tuples each with two values

request_negotiation_about(req_id: str, caller: negmas.situated.Agent, issues: List[negmas.outcomes.Issue], partners: List[negmas.situated.Agent], roles: List[str] = None, annotation: Dict[str, Any] | None = None, mechanism_name: str = None, mechanism_params: Dict[str, Any] = None, group=None)[source]

Requests to start a negotiation with some other agents

Parameters:
  • req_id – An ID For the request that is unique to the caller

  • caller – The agent requesting the negotiation

  • partners – A list of partners to participate in the negotiation. Note that the caller itself may not be in this list which makes it possible for an agent to request a negotaition that it does not participate in. If that is not to be allowed in some world, override this method and explicitly check for these kinds of negotiations and return False. If partners is passed as a single string/Agent or as a list containing a single string/Agent, then he caller will be added at the beginning of the list. This will only be done if roles was passed as None.

  • issues – Negotiation issues

  • annotation – Extra information to be passed to the partners when asking them to join the negotiation

  • partners – A list of partners to participate in the negotiation

  • roles – The roles of different partners. If None then each role for each partner will be None

  • mechanism_name – Name of the mechanism to use. It must be one of the mechanism_names that are supported by the

  • None (must also be)

  • my_role (then roles and)

  • None

  • mechanism_params – A dict of parameters used to initialize the mechanism object

  • group – An identifier for the group to which the negotiation belongs. This is not not used by the system.

Returns:

None. The caller will be informed by a callback function on_neg_request_accepted or on_neg_request_rejected about the status of the negotiation.

property winners
The winners of this world (factory managers with maximum wallet balance
on_event(event: negmas.events.Event, sender: negmas.events.EventSource) None[source]

Called whenever an event is raised for which the SCML2020World is registered asa listener

Parameters:
  • event – The event

  • sender – The sender

Returns:

None

contract_record(contract: negmas.situated.Contract) Dict[str, Any][source]

Converts a contract to a record suitable for permanent storage

breach_record(breach: negmas.situated.Breach) Dict[str, Any][source]

Converts a breach to a record suitable for storage during the simulation

contract_size(contract: negmas.situated.Contract) float[source]

Returns an estimation of the activity level associated with this contract. Higher is better :param contract:

Returns:

class scml.cli.DefaultGreedyManager(*args, reserved_value=0.0, negotiator_params=None, optimism=0.0, negotiator_type=DEFAULT_NEGOTIATOR, n_retrials=5, use_consumer=True, reactive=True, sign_only_guaranteed_contracts=False, riskiness=0.0, max_insurance_premium: float = float('inf'), **kwargs)[source]

Bases: scml.scml2019.factory_managers.builtins.GreedyFactoryManager

The default factory manager that will be implemented by the committee of ANAC-SCML 2019

scml.cli.anac2019_collusion(competitors: Sequence[str | Type[scml.scml2019.factory_managers.builtins.FactoryManager]], competitor_params: Sequence[Dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = 1000, n_runs_per_world: int = 5, n_agents_per_competitor: int = 5, min_factories_per_level: int = 5, tournament_path: str = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.scml2019.world.SCML2019World | None], None] | None = None, non_competitors: Sequence[str | Type[scml.scml2019.factory_managers.builtins.FactoryManager]] | None = None, non_competitor_params: Sequence[Dict[str, Any]] | None = None, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2019 SCML tournament (collusion track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • n_agents_per_competitor – Number of agents per competitor

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2019_sabotage(competitors: Sequence[str | Type[scml.scml2019.factory_managers.builtins.FactoryManager]], competitor_params: Sequence[Dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = 1000, n_runs_per_world: int = 5, n_agents_per_competitor: int = 5, min_factories_per_level: int = 5, tournament_path: str | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] = None, world_progress_callback: Callable[[scml.scml2019.world.SCML2019World | None], None] = None, non_competitors: Sequence[str | Type[scml.scml2019.factory_managers.builtins.FactoryManager]] | None = None, non_competitor_params: Sequence[str | Type[scml.scml2019.factory_managers.builtins.FactoryManager]] | None = None, name: str = None, verbose: bool = False, configs_only=False, compact=False, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2019 SCML tournament (collusion track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • n_agents_per_competitor – Number of agents per competitor

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after every step of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2019_std(competitors: Sequence[str | Type[scml.scml2019.factory_managers.builtins.FactoryManager]], competitor_params: Sequence[Dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = 1000, n_runs_per_world: int = 5, min_factories_per_level: int = 5, tournament_path: str = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] = None, world_progress_callback: Callable[[scml.scml2019.world.SCML2019World | None], None] = None, non_competitors: Sequence[str | Type[scml.scml2019.factory_managers.builtins.FactoryManager]] | None = None, non_competitor_params: Sequence[str | Type[scml.scml2019.factory_managers.builtins.FactoryManager]] | None = None, name: str = None, verbose: bool = False, configs_only=False, compact=False, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2019 SCML tournament (standard track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

class scml.cli.SCML2020Agent(name: str | None = None, type_postfix: str = '', preferences: negmas.preferences.Preferences | None = None, ufun: negmas.preferences.UtilityFunction | None = None)[source]

Bases: negmas.Agent

Base class for all SCML2020 agents (factory managers)

reset()[source]
is_clean() bool[source]
init()[source]

Called to initialize the agent after the world is initialized. the AWI is accessible at this point.

before_step()[source]
step_()[source]

Called at every time-step. This function is called directly by the world.

step()[source]

Called by the simulator at every simulation step

to_dict()[source]
_respond_to_negotiation_request(initiator: str, partners: List[str], issues: List[negmas.Issue], annotation: Dict[str, Any], mechanism: negmas.NegotiatorMechanismInterface, role: str | None, req_id: str | None) negmas.Negotiator | None[source]

Called by the mechanism to ask for joining a negotiation. The agent can refuse by returning a None

Parameters:
  • initiator – The ID of the agent that initiated the negotiation request

  • partners – The partner list (will include this agent)

  • issues – The list of issues

  • annotation – Any annotation specific to this negotiation.

  • mechanism – The mechanism that started the negotiation

  • role – The role of this agent in the negotiation

  • req_id – The req_id passed to the AWI when starting the negotiation (only to the initiator).

Returns:

None to refuse the negotiation or a Negotiator object appropriate to the given mechanism to accept it.

Remarks:

  • It is expected that world designers will introduce a better way to respond and override this function to call it

on_contract_breached(contract: negmas.Contract, breaches: List[negmas.Breach], resolution: negmas.Contract | None) None[source]

Called after complete processing of a contract that involved a breach.

Parameters:
  • contract – The contract

  • breaches – All breaches committed (even if they were resolved)

  • resolution – The resolution contract if re-negotiation was successful. None if not.

on_contract_executed(contract: negmas.Contract) None[source]

Called after successful contract execution for which the agent is one of the partners.

set_renegotiation_agenda(contract: negmas.Contract, breaches: List[negmas.Breach]) negmas.RenegotiationRequest | None[source]

Received by partners in ascending order of their total breach levels in order to set the renegotiation agenda when contract execution fails

Parameters:
  • contract – The contract being breached

  • breaches – All breaches on contract

Returns:

Renegotiation agenda (issues to negotiate about to avoid reporting the breaches).

respond_to_renegotiation_request(contract: negmas.Contract, breaches: List[negmas.Breach], agenda: negmas.RenegotiationRequest) negmas.Negotiator | None[source]

Called to respond to a renegotiation request

Parameters:
  • agenda

  • contract

  • breaches

Returns:

on_neg_request_rejected(req_id: str, by: List[str] | None)[source]

Called when a requested negotiation is rejected

Parameters:
  • req_id – The request ID passed to _request_negotiation

  • by – A list of agents that refused to participate or None if the failure was for another reason

on_neg_request_accepted(req_id: str, mechanism: negmas.NegotiatorMechanismInterface)[source]

Called when a requested negotiation is accepted

property internal_state: Dict[str, Any]

Returns the internal state of the agent for debugging purposes

on_negotiation_failure(partners: List[str], annotation: Dict[str, Any], mechanism: negmas.NegotiatorMechanismInterface, state: negmas.MechanismState) None[source]

Called whenever a negotiation ends without agreement

on_negotiation_success(contract: negmas.Contract, mechanism: negmas.NegotiatorMechanismInterface) None[source]

Called whenever a negotiation ends with agreement

on_agent_bankrupt(agent: str, contracts: List[negmas.Contract], quantities: List[int], compensation_money: int) None[source]

Called whenever a contract is nullified (because the partner is bankrupt)

Parameters:
  • agent – The ID of the agent that went bankrupt.

  • contracts – All future contracts between this agent and the bankrupt agent.

  • quantities – The actual quantities that these contracts will be executed at.

  • compensation_money – The compensation money that is already added to the agent’s wallet (if ANY).

Remarks:

  • compensation_money will be nonzero iff immediate_compensation is enabled for this world

on_failures(failures: List[scml.scml2020.common.Failure]) None[source]

Called whenever there are failures either in production or in execution of guaranteed transactions

Parameters:

failures – A list of Failure s.

respond_to_negotiation_request(initiator: str, issues: List[negmas.Issue], annotation: Dict[str, Any], mechanism: negmas.NegotiatorMechanismInterface) negmas.Negotiator | None[source]

Called whenever another agent requests a negotiation with this agent.

Parameters:
  • initiator – The ID of the agent that requested this negotiation

  • issues – Negotiation issues

  • annotation – Annotation attached with this negotiation

  • mechanism – The NegotiatorMechanismInterface interface to the mechanism to be used for this negotiation.

Returns:

None to reject the negotiation, otherwise a negotiator

confirm_production(commands: numpy.ndarray, balance: int, inventory) numpy.ndarray[source]

Called just before production starts at every time-step allowing the agent to change what is to be produced in its factory

Parameters:
  • commands – an n_lines vector giving the process to be run at every line (NO_COMMAND indicates nothing to be processed

  • balance – The current balance of the factory

  • inventory – an n_products vector giving the number of items available in the inventory of every product type.

Returns:

an n_lines vector giving the process to be run at every line (NO_COMMAND indicates nothing to be processed

Remarks:

  • Not called in SCML2020 competition.

  • The inventory will contain zero items of all products that the factory does not buy or sell

  • The default behavior is to just retrun commands confirming production of everything.

sign_all_contracts(contracts: List[negmas.Contract]) List[str | None][source]

Signs all contracts

scml.cli.is_system_agent(aid: str) bool[source]

Checks whether an agent is a system agent or not

Parameters:

aid – Agent ID

Returns:

True if the ID is for a system agent.

class scml.cli.SCML2020World(process_inputs: numpy.ndarray, process_outputs: numpy.ndarray, catalog_prices: numpy.ndarray, profiles: list[scml.scml2020.common.FactoryProfile], agent_types: list[type[scml.scml2020.agent.SCML2020Agent]], agent_params: list[dict[str, Any]] | None = None, exogenous_contracts: Collection[scml.scml2020.common.ExogenousContract] = (), initial_balance: numpy.ndarray | tuple[int, int] | int = 1000, allow_buying_output=False, allow_selling_input=False, catalog_quantities: int | numpy.ndarray = 50, buy_missing_products=True, borrow_on_breach=True, bankruptcy_limit=0.0, liquidation_rate=1.0, spot_market_global_loss=0.3, interest_rate=0.05, financial_report_period: int = 5, compensation_fraction: float = 1.0, compensate_immediately=False, compensate_before_past_debt=True, exogenous_horizon: int | None = None, exogenous_force_max: bool = False, production_confirm=False, production_buy_missing=False, production_no_borrow=True, production_no_bankruptcy=False, production_penalty=0.15, compact=False, no_logs=False, n_steps=1000, time_limit=60 * 90, neg_n_steps=20, neg_time_limit=2 * 60, neg_step_time_limit=60, negotiation_speed=21, negotiation_quota_per_step=None, negotiation_quota_per_simulation=float('inf'), n_concurrent_negs_between_partners=float('inf'), shuffle_negotiations=False, end_negotiation_on_refusal_to_propose=True, trading_price_discount=0.9, spot_discount=0.9, spot_multiplier=0.05, signing_delay=0, force_signing=False, batch_signing=True, name: str = None, publish_exogenous_summary=True, publish_trading_prices=True, agent_name_reveals_position: bool = True, agent_name_reveals_type: bool = True, inventory_valuation_trading: float = 0.5, inventory_valuation_catalog: float = 0.0, **kwargs)[source]

Bases: negmas.situated.TimeInAgreementMixin, negmas.situated.World

A Supply Chain SCML2020World simulation as described for the SCML league of ANAC @ IJCAI 2020.

Parameters:
  • process_inputs – An n_processes vector specifying the number of inputs from each product needed to execute each process.

  • process_outputs – An n_processes vector specifying the number of inputs from each product generated by executing each process.

  • catalog_prices – An n_products vector (i.e. n_processes+1 vector) giving the catalog price of all products

  • profiles – An n_agents list of FactoryProfile objects specifying the private profile of the factory associated with each agent.

  • agent_types – An n_agents list of strings/ SCML2020Agent classes specifying the type of each agent

  • agent_params – An n_agents dictionaries giving the parameters of each agent

  • initial_balance – The initial balance in each agent’s wallet. All agents will start with this same value.

  • allow_selling_input – Allows agents to sell their input product(s) through negotiation

  • allow_buying_output – Allows agents to buy their output product(s) through negotiation

  • catalog_quantities – The quantities in the past for which catalog_prices are the average unit prices. This is used when updating the trading prices. If set to zero then the trading price will follow the market price and will not use the catalog_price (except for products that are never sold in the market for which the trading price will take the default value of the catalog price). If set to a large value (e.g. 10000), the price at which a product is sold will not affect the trading price

  • spot_market_global_loss – Buying from the spot market will cost trading-price * (1+`spot_market_global_loss) and selling to it will cost trading-price / (1+ spot_market_global_loss) for agents with unit spot-market-loss-multiplier

  • financial_report_period – The number of steps between financial reports. If < 1, it is a fraction of n_steps

  • borrow_on_breach – If true, agents will be forced to borrow money on breach as much as possible to honor the contract

  • interest_rate – The interest at which loans grow over time (it only affect a factory when its balance is negative)

  • bankruptcy_limit – The maximum amount that be be borrowed (including interest). The balance of any factory cannot go lower than - borrow_limit or the agent will go bankrupt immediately

  • liquidation_rate – The rate at which future contracts get liquidated when an agent gets bankrupt. It should be between zero and one.

  • compensation_fraction – Fraction of a contract to be compensated (at most) if a partner goes bankrupt. Notice that this fraction is not guaranteed because the bankrupt agent may not have enough assets to pay all of its standing contracts to this level of compensation. In such cases, a smaller fraction will be used.

  • compensate_immediately – If true, compensation will happen immediately when an agent goes bankrupt and in in money. This means that agents with contracts involving the bankrupt agent will just have these contracts be nullified and receive monetary compensation immediately . If false, compensation will not happen immediately but at the contract execution time. In this case, agents with contracts involving the bankrupt agent will be informed of the compensation fraction (instead of the compensation money) at the time of bankruptcy and will receive the compensation in kind (money if they are sellers and products if they are buyers) at the normal execution time of the contract. In the special case of no-compensation (i.e. compensation_fraction is zero or the bankrupt agent has no assets), the two options will behave similarity.

  • compensate_before_past_debt – If true, then compensations will be paid before past debt is considered, otherwise, the money from liquidating bankrupt agents will first be used to pay past debt then whatever remains will be used for compensation. Notice that in all cases, the trigger of bankruptcy will be paid before compensation and past debts.

  • exogenous_horizon – The horizon for revealing external contracts

  • exogenous_force_max – If true, exogenous contracts are forced to be signed independent of the setting of force_signing

  • production_no_borrow – If true, agents will not borrow if they fail to satisfy its production need to execute a scheduled production command

  • production_no_bankruptcy – If true, agents will not go bankrupt because of an production related transaction.

  • production_penalty – The penalty paid when buying from spot-market to satisfy production needs

  • production_confirm – If true, the factory will confirm running processes at every time-step just before running them by calling confirm_production on the agent controlling it.

  • compact – If True, no logs will be kept and the whole simulation will use a smaller memory footprint

  • n_steps – Number of simulation steps (can be considered as days).

  • time_limit – Total time allowed for the complete simulation in seconds.

  • neg_n_steps – Number of negotiation steps allowed for all negotiations.

  • neg_time_limit – Total time allowed for a complete negotiation in seconds.

  • neg_step_time_limit – Total time allowed for a single step of a negotiation. in seconds.

  • negotiation_speed – The number of negotiation steps that pass in every simulation step. If 0, negotiations will be guaranteed to finish within a single simulation step

  • signing_delay – The number of simulation steps to pass between a contract is concluded and signed

  • name – The name of the simulations

  • **kwargs – Other parameters that are passed directly to SCML2020World constructor.

classmethod generate(agent_types: list[type[scml.scml2020.agent.SCML2020Agent] | str], agent_params: list[dict[str, Any]] | None = None, agent_processes: list[int] | None = None, n_steps: tuple[int, int] | int = (50, 200), n_processes: tuple[int, int] | int = (2, 4), n_lines: numpy.ndarray | tuple[int, int] | int = 10, n_agents_per_process: numpy.ndarray | tuple[int, int] | int = (2, 4), process_inputs: numpy.ndarray | tuple[int, int] | int = 1, process_outputs: numpy.ndarray | tuple[int, int] | int = 1, production_costs: numpy.ndarray | tuple[int, int] | int = (1, 4), profit_means: numpy.ndarray | tuple[float, float] | float = (0.15, 0.2), profit_stddevs: numpy.ndarray | tuple[float, float] | float = 0.001, max_productivity: numpy.ndarray | tuple[float, float] | float = 1.0, initial_balance: numpy.ndarray | tuple[int, int] | int | None = None, cost_increases_with_level=True, equal_exogenous_supply=False, equal_exogenous_sales=False, exogenous_supply_predictability: tuple[float, float] | float = (0.6, 0.9), exogenous_sales_predictability: tuple[float, float] | float = (0.6, 0.9), exogenous_control: tuple[float, float] | float = (0.2, 0.8), cash_availability: tuple[float, float] | float = (1.5, 2.5), force_signing=False, profit_basis=np.max, horizon: tuple[float, float] | float = (0.2, 0.5), inventory_valuation_trading: numpy.ndarray | tuple[float, float] | float = 0.5, inventory_valuation_catalog: numpy.ndarray | tuple[float, float] | float = 0.0, random_agent_types: bool = False, cost_relativity: float = 1.0, exogenous_generation_method='profitable', exogenous_supply_surplus: tuple[float, float] | float = 0.0, exogenous_sales_surplus: tuple[float, float] | float = 0.0, run_extra_checks: bool = True, **kwargs) dict[str, Any][source]

Generates the configuration for a world

Parameters:
  • agent_types – All agent types

  • agent_params – Agent parameters used to initialize them

  • n_steps – Number of simulation steps

  • n_processes – Number of processes in the production chain

  • n_lines – Number of lines per factory

  • process_inputs – Number of input units per process

  • process_outputs – Number of output units per process

  • production_costs – Production cost per factory

  • profit_means – Mean profitability per production level (i.e. process).

  • profit_stddevs – Std. Dev. of the profitability of every level (i.e. process).

  • inventory_valuation_catalog – The fraction of catalog price to value items at the end.

  • inventory_valuation_trading – The fraction of trading price to value items at the end.

  • max_productivity – Maximum possible productivity per level (i.e. process).

  • initial_balance – The initial balance of all agents

  • n_agents_per_process – Number of agents per process

  • agent_processes – The process for each agent. If not None , it will override n_agents_per_process and must be a list/tuple of the same length as agent_types . Morevoer, random_agent_types must be False in this case

  • cost_increases_with_level – If true, production cost will be higher for processes nearer to the final product.

  • profit_basis – The statistic used when controlling catalog prices by profit arguments. It can be np.mean, np.median, np.min, np.max or any Callable[[list[float]], float] and is used to summarize production costs at every level.

  • horizon – The horizon used for revealing external supply/sales as a fraction of n_steps

  • equal_exogenous_supply – If true, external supply will be distributed equally among all agents in the first layer

  • equal_exogenous_sales – If true, external sales will be distributed equally among all agents in the last layer

  • exogenous_supply_predictability – How predictable are exogenous supplies of each agent over time. 1.0 means that every agent will have the same quantity for all of its contracts over time. 0.0 means quantities per agent are completely random

  • exogenous_sales_predictability – How predictable are exogenous supplies of each agent over time. 1.0 means that every agent will have the same quantity for all of its contracts over time. 0.0 means quantities per agent are completely random

  • cash_availability – The fraction of the total money needs of the agent to work at maximum capacity that is available as initial_balance . This is only effective if initial_balance is set to None .

  • force_signing – Whether to force contract signatures (exogenous contracts are treated in the same way).

  • exogenous_control – How much control does the agent have over exogenous contract signing. Only effective if force_signing is False and use_exogenous_contracts is True

  • random_agent_types – If True, the final agent types used by the generato wil always be sampled from the given types. If False, this random sampling will only happin if len(agent_types) != n_agents.

  • cost_relativity – The exponent of production cost used to distribute contracts during generation

  • method – The method used for world generation. Available methods are “profitable” and “guaranteed_profit”

  • exogenous_supply_surplus – The surpolus exogenous supply contract quantity to add to the system as a fraction of the a fraction of the contracts generated by the given method.

  • exogenous_sales_surplus – The surpolus exogenous sales contract quantity to add to the system as a fraction of the a fraction of the contracts generated by the given method.

  • run_extra_checks – If given, the world generation method will check whether the genrated world “makes sense” given its internal criteria. May slow down world generation

  • **kwargs

Returns:

world configuration as a dict[str, Any]. A world can be generated from this dict by calling SCML2020World(**d)

Remarks:

  • There are two general ways to use this generator:
    1. Pass random_agent_types = True, and pass agent_types, agent_processes to control placement of each agent in each level of the production graph.

    2. Pass random_agent_types = False and pass agent_types, n_agents_per_process to make the system randomly place the specified number of agents in each production level

  • Most parameters (i.e. process_inputs , process_outputs , n_agents_per_process , costs ) can take a single value, a tuple of two values, or a list of values. If it has a single value, it is repeated for all processes/factories as appropriate. If it is a tuple of two numbers $(i, j)$, each process will take a number sampled from a uniform distribution supported on $[i, j]$ inclusive. If it is a list of values, of the length n_processes , it is used as it is otherwise, it is used to sample values for each process.

classmethod generate_guaranteed_profit(n_steps: int, n_lines: int, n_agents_per_process: int, process_of_agent: list[int], first_agent: list[int], last_agent: list[int], production_costs: list[int], exogenous_control: float, cash_availability: float, force_signing: bool, horizon: int, exogenous_supplies: list[int], max_productivity_process: list[float], max_productivity_agent: list[float], equal_exogenous_sales: bool, process_inputs: list[int], process_outputs: list[int], exogenous_sales_predictability: float, costs: numpy.ndarray, profit_stddevs_agent=list[float], profit_means_agent=list[float], initial_balance: numpy.ndarray | tuple[int, int] | int | None = None, cost_relativity: float = 1.0, profit_basis=np.max, inventory_valuation_trading: float = 0.5, inventory_valuation_catalog: float = 0.0, run_extra_checks=True) tuple[list[scml.scml2020.common.ExogenousContract], list[int], list[scml.scml2020.common.FactoryProfile], list[float], dict[str, Any]][source]

Generates prices, contracts and profiles ensuring that all agents can profit and returning a set of explict contracts that can achieve this profit

classmethod generate_profitable(n_steps: int, n_lines: int, n_agents_per_process: int, process_of_agent: list[int], first_agent: list[int], last_agent: list[int], production_costs: list[int], exogenous_control: float, cash_availability: float, force_signing: bool, horizon: int, exogenous_supplies: list[int], max_productivity_process: list[float], max_productivity_agent: list[float], equal_exogenous_sales: bool, process_inputs: list[int], process_outputs: list[int], exogenous_sales_predictability: float, costs: numpy.ndarray, profit_stddevs_agent=list[float], profit_means_agent=list[float], initial_balance: numpy.ndarray | tuple[int, int] | int | None = None, cost_relativity: float = 1.0, profit_basis=np.max, inventory_valuation_trading: float = 0.5, inventory_valuation_catalog: float = 0.0, run_extra_checks: bool = True) tuple[list[scml.scml2020.common.ExogenousContract], list[int], list[scml.scml2020.common.FactoryProfile], list[float], dict[str, Any]][source]

Generates the prices, contracts and profiles ensuring there is some possibility of profit in the market

get_private_state(agent: scml.scml2020.agent.SCML2020Agent) dict[source]

Reads the private state of the given agent

add_financial_report(agent: scml.scml2020.agent.SCML2020Agent, factory: scml.scml2020.factory.Factory, reports_agent, reports_time) None[source]

Records a financial report for the given agent in the agent indexed reports and time indexed reports

Parameters:
  • agent – The agent

  • factory – Its factory

  • reports_agent – A dictionary of financial reports indexed by agent id

  • reports_time – A dictionary of financial reports indexed by time

Returns:

negs_between(a1, a2)[source]
current_balance(agent_id: str)[source]
can_negotiate(a1, a2)[source]
simulation_step(stage)[source]

A single step of the simulation.

Parameters:

stage – How many times so far was this method called within the current simulation step

Remarks:

  • Using the stage parameter, it is possible to have Operations . SimulationStep several times with the list of operations while differentiating between these calls.

contract_size(contract: negmas.Contract) float[source]

Returns an estimation of the activity level associated with this contract. Higher is better :param contract:

Returns:

contract_record(contract: negmas.Contract) dict[str, Any][source]

Converts a contract to a record suitable for permanent storage

breach_record(breach: negmas.Breach) dict[str, Any][source]

Converts a breach to a record suitable for storage during the simulation

execute_action(action: negmas.Action, agent: scml.scml2020.agent.SCML2020Agent, callback: Callable = None) bool[source]

Executes the given action by the given agent

post_step_stats()[source]

Called at the end of the simulation step to update all stats

Kept for backward compatibility and will be dropped. Override update_stats ins

pre_step_stats()[source]

Called at the beginning of the simulation step to prepare stats or update them

Kept for backward compatibility and will be dropped. Override update_stats instead

property productivity: float

Fraction of production lines occupied during the simulation

welfare(include_bankrupt: bool = False) float[source]

Total welfare of all agents

relative_welfare(include_bankrupt: bool = False) float | None[source]

Total welfare relative to expected value. Returns None if no expectation is found in self.info

property relative_productivity: float | None

Productivity relative to the expected value. Will return None if self.info does not have the expected productivity

property bankruptcy_rate: float

The fraction of factories that went bankrupt

property num_bankrupt: float

The fraction of factories that went bankrupt

order_contracts_for_execution(contracts: Collection[negmas.Contract]) Collection[negmas.Contract][source]

Orders the contracts in a specific time-step that are about to be executed

_execute(product: int, q: int, p: int, u: int, buyer_factory: scml.scml2020.factory.Factory, seller_factory: scml.scml2020.factory.Factory, has_breaches: bool)[source]

Executes the contract

__register_contract(agent_id: str, level: float) None[source]

Registers execution of the contract in the agent’s stats

record_bankrupt(factory: scml.scml2020.factory.Factory) None[source]

Records agent bankruptcy

on_contract_concluded(contract: negmas.Contract, to_be_signed_at: int) None[source]

Called to add a contract to the existing set of unsigned contract after it is concluded

Parameters:
  • contract – The contract to add

  • to_be_signed_at – The timestep at which the contract is to be signed

Remarks:

  • By default this function just adds the contract to the set of contracts maintaned by the world.

  • You should ALWAYS call this function when overriding it.

is_valid_contact(contract: negmas.Contract) bool[source]

Checks whether a signed contract is valid

on_contract_signed(contract: negmas.Contract) bool[source]

Called to add a contract to the existing set of contract after it is signed

Parameters:

contract – The contract to add

Returns:

True if everything went OK and False otherwise

Remarks:

  • By default this function just adds the contract to the set of contracts maintaned by the world.

  • You should ALWAYS call this function when overriding it.

nullify_contract(contract: negmas.Contract, new_quantity: int)[source]
__register_breach(agent_id: str, level: float, contract_total: float, factory: scml.scml2020.factory.Factory) int[source]

Registers a breach of the given level on the given agent. Assume that the contract is already added to the agent_contracts

Parameters:
  • agent_id – The perpetrator of the breach

  • level – The breach level

  • contract_total – The total of the contract breached (quantity * unit_price)

  • factory – The factory corresponding to the perpetrator

Returns:

If nonzero, the agent should go bankrupt and this amount taken from them

_spot_loss(aid: str) float[source]
start_contract_execution(contract: negmas.Contract) set[negmas.Breach] | None[source]

Tries to execute the contract

Parameters:

contract

Returns:

The set of breaches committed if any. If there are no breaches return an empty set

Return type:

Set[Breach]

Remarks:

  • You must call super() implementation of this method before doing anything

  • It is possible to return None which indicates that the contract was nullified (i.e. not executed due to a reason other than an execution exeception).

complete_contract_execution(contract: negmas.Contract, breaches: list[negmas.Breach], resolution: negmas.Contract) None[source]

Called after breach resolution is completed for contracts for which some potential breaches occurred.

Parameters:
  • contract – The contract considered.

  • breaches – The list of potential breaches that was generated by _execute_contract.

  • resolution – The agreed upon resolution

Returns:

compensate(available: int, factory: scml.scml2020.factory.Factory) dict[str, list[tuple[negmas.Contract, int, int]]][source]

Called by a factory when it is going bankrupt after liquidation

Parameters:
  • available – The amount available from liquidation

  • factory – The factory being bankrupted

Returns:

A mapping from agent ID to nullified contracts, the new quantity for them and compensation_money

scores(assets_multiplier_trading: float | None = None, assets_multiplier_catalog: float | None = None, assets_multiplier: float | None = None) dict[str, float][source]

scores of all agents given the asset multiplier.

Parameters:

assets_multiplier – a multiplier to multiply the assets with.

property winners
The winners of this world (factory managers with maximum wallet balance
trading_prices_for(discount: float = 1.0, condition='executed') numpy.ndarray[source]

Calculates the prices at which all products traded using an optional discount factor

Parameters:
  • discount – A discount factor to treat older prices less importantly (exponential discounting).

  • condition – The condition for contracts to consider. Possible values are executed, signed, concluded, nullified

Returns:

an n_products vector of trading prices

property trading_prices
property stats_df: pandas.DataFrame

Returns a pandas data frame with the stats

property contracts_df: pandas.DataFrame

Returns a pandas data frame with the contracts

property system_agents: list[scml.scml2020.agent.SCML2020Agent]

Returns the two system agents

property system_agent_names: list[str]

Returns the names two system agents

property non_system_agents: list[scml.scml2020.agent.SCML2020Agent]

Returns all agents except system agents

property non_system_agent_names: list[str]

Returns names of all agents except system agents

property agreement_fraction: float

Fraction of negotiations ending in agreement and leading to signed contracts

system_agent_ids
non_system_agent_ids
draw(steps: tuple[int, int] | int | None = None, what: Collection[str] = DEFAULT_EDGE_TYPES, who: Callable[[negmas.Agent], bool] = None, where: Callable[[negmas.Agent], int | tuple[float, float]] = None, together: bool = True, axs: Collection[matplotlib.axis.Axis] = None, ncols: int = 4, figsize: tuple[int, int] = (15, 15), **kwargs) tuple[matplotlib.axis.Axis, networkx.Graph] | tuple[list[matplotlib.axis.Axis], list[networkx.Graph]][source]
class scml.cli.SCML2021World(*args, **kwargs)[source]

Bases: SCML2020World

A Supply Chain SCML2020World simulation as described for the SCML league of ANAC @ IJCAI 2020.

Parameters:
  • process_inputs – An n_processes vector specifying the number of inputs from each product needed to execute each process.

  • process_outputs – An n_processes vector specifying the number of inputs from each product generated by executing each process.

  • catalog_prices – An n_products vector (i.e. n_processes+1 vector) giving the catalog price of all products

  • profiles – An n_agents list of FactoryProfile objects specifying the private profile of the factory associated with each agent.

  • agent_types – An n_agents list of strings/ SCML2020Agent classes specifying the type of each agent

  • agent_params – An n_agents dictionaries giving the parameters of each agent

  • initial_balance – The initial balance in each agent’s wallet. All agents will start with this same value.

  • allow_selling_input – Allows agents to sell their input product(s) through negotiation

  • allow_buying_output – Allows agents to buy their output product(s) through negotiation

  • catalog_quantities – The quantities in the past for which catalog_prices are the average unit prices. This is used when updating the trading prices. If set to zero then the trading price will follow the market price and will not use the catalog_price (except for products that are never sold in the market for which the trading price will take the default value of the catalog price). If set to a large value (e.g. 10000), the price at which a product is sold will not affect the trading price

  • spot_market_global_loss – Buying from the spot market will cost trading-price * (1+`spot_market_global_loss) and selling to it will cost trading-price / (1+ spot_market_global_loss) for agents with unit spot-market-loss-multiplier

  • financial_report_period – The number of steps between financial reports. If < 1, it is a fraction of n_steps

  • borrow_on_breach – If true, agents will be forced to borrow money on breach as much as possible to honor the contract

  • interest_rate – The interest at which loans grow over time (it only affect a factory when its balance is negative)

  • bankruptcy_limit – The maximum amount that be be borrowed (including interest). The balance of any factory cannot go lower than - borrow_limit or the agent will go bankrupt immediately

  • liquidation_rate – The rate at which future contracts get liquidated when an agent gets bankrupt. It should be between zero and one.

  • compensation_fraction – Fraction of a contract to be compensated (at most) if a partner goes bankrupt. Notice that this fraction is not guaranteed because the bankrupt agent may not have enough assets to pay all of its standing contracts to this level of compensation. In such cases, a smaller fraction will be used.

  • compensate_immediately – If true, compensation will happen immediately when an agent goes bankrupt and in in money. This means that agents with contracts involving the bankrupt agent will just have these contracts be nullified and receive monetary compensation immediately . If false, compensation will not happen immediately but at the contract execution time. In this case, agents with contracts involving the bankrupt agent will be informed of the compensation fraction (instead of the compensation money) at the time of bankruptcy and will receive the compensation in kind (money if they are sellers and products if they are buyers) at the normal execution time of the contract. In the special case of no-compensation (i.e. compensation_fraction is zero or the bankrupt agent has no assets), the two options will behave similarity.

  • compensate_before_past_debt – If true, then compensations will be paid before past debt is considered, otherwise, the money from liquidating bankrupt agents will first be used to pay past debt then whatever remains will be used for compensation. Notice that in all cases, the trigger of bankruptcy will be paid before compensation and past debts.

  • exogenous_horizon – The horizon for revealing external contracts

  • exogenous_force_max – If true, exogenous contracts are forced to be signed independent of the setting of force_signing

  • production_no_borrow – If true, agents will not borrow if they fail to satisfy its production need to execute a scheduled production command

  • production_no_bankruptcy – If true, agents will not go bankrupt because of an production related transaction.

  • production_penalty – The penalty paid when buying from spot-market to satisfy production needs

  • production_confirm – If true, the factory will confirm running processes at every time-step just before running them by calling confirm_production on the agent controlling it.

  • compact – If True, no logs will be kept and the whole simulation will use a smaller memory footprint

  • n_steps – Number of simulation steps (can be considered as days).

  • time_limit – Total time allowed for the complete simulation in seconds.

  • neg_n_steps – Number of negotiation steps allowed for all negotiations.

  • neg_time_limit – Total time allowed for a complete negotiation in seconds.

  • neg_step_time_limit – Total time allowed for a single step of a negotiation. in seconds.

  • negotiation_speed – The number of negotiation steps that pass in every simulation step. If 0, negotiations will be guaranteed to finish within a single simulation step

  • signing_delay – The number of simulation steps to pass between a contract is concluded and signed

  • name – The name of the simulations

  • **kwargs – Other parameters that are passed directly to SCML2020World constructor.

classmethod generate(*args, inventory_valuation_trading: numpy.ndarray | tuple[float, float] | float = (0.0, 0.5), horizon: tuple[float, float] | float = (0.2, 0.5), **kwargs) dict[str, Any][source]

Generates the configuration for a world

Parameters:
  • agent_types – All agent types

  • agent_params – Agent parameters used to initialize them

  • n_steps – Number of simulation steps

  • n_processes – Number of processes in the production chain

  • n_lines – Number of lines per factory

  • process_inputs – Number of input units per process

  • process_outputs – Number of output units per process

  • production_costs – Production cost per factory

  • profit_means – Mean profitability per production level (i.e. process).

  • profit_stddevs – Std. Dev. of the profitability of every level (i.e. process).

  • inventory_valuation_catalog – The fraction of catalog price to value items at the end.

  • inventory_valuation_trading – The fraction of trading price to value items at the end.

  • max_productivity – Maximum possible productivity per level (i.e. process).

  • initial_balance – The initial balance of all agents

  • n_agents_per_process – Number of agents per process

  • agent_processes – The process for each agent. If not None , it will override n_agents_per_process and must be a list/tuple of the same length as agent_types . Morevoer, random_agent_types must be False in this case

  • cost_increases_with_level – If true, production cost will be higher for processes nearer to the final product.

  • profit_basis – The statistic used when controlling catalog prices by profit arguments. It can be np.mean, np.median, np.min, np.max or any Callable[[list[float]], float] and is used to summarize production costs at every level.

  • horizon – The horizon used for revealing external supply/sales as a fraction of n_steps

  • equal_exogenous_supply – If true, external supply will be distributed equally among all agents in the first layer

  • equal_exogenous_sales – If true, external sales will be distributed equally among all agents in the last layer

  • exogenous_supply_predictability – How predictable are exogenous supplies of each agent over time. 1.0 means that every agent will have the same quantity for all of its contracts over time. 0.0 means quantities per agent are completely random

  • exogenous_sales_predictability – How predictable are exogenous supplies of each agent over time. 1.0 means that every agent will have the same quantity for all of its contracts over time. 0.0 means quantities per agent are completely random

  • cash_availability – The fraction of the total money needs of the agent to work at maximum capacity that is available as initial_balance . This is only effective if initial_balance is set to None .

  • force_signing – Whether to force contract signatures (exogenous contracts are treated in the same way).

  • exogenous_control – How much control does the agent have over exogenous contract signing. Only effective if force_signing is False and use_exogenous_contracts is True

  • random_agent_types – If True, the final agent types used by the generato wil always be sampled from the given types. If False, this random sampling will only happin if len(agent_types) != n_agents.

  • cost_relativity – The exponent of production cost used to distribute contracts during generation

  • method – The method used for world generation. Available methods are “profitable” and “guaranteed_profit”

  • exogenous_supply_surplus – The surpolus exogenous supply contract quantity to add to the system as a fraction of the a fraction of the contracts generated by the given method.

  • exogenous_sales_surplus – The surpolus exogenous sales contract quantity to add to the system as a fraction of the a fraction of the contracts generated by the given method.

  • run_extra_checks – If given, the world generation method will check whether the genrated world “makes sense” given its internal criteria. May slow down world generation

  • **kwargs

Returns:

world configuration as a dict[str, Any]. A world can be generated from this dict by calling SCML2020World(**d)

Remarks:

  • There are two general ways to use this generator:
    1. Pass random_agent_types = True, and pass agent_types, agent_processes to control placement of each agent in each level of the production graph.

    2. Pass random_agent_types = False and pass agent_types, n_agents_per_process to make the system randomly place the specified number of agents in each production level

  • Most parameters (i.e. process_inputs , process_outputs , n_agents_per_process , costs ) can take a single value, a tuple of two values, or a list of values. If it has a single value, it is repeated for all processes/factories as appropriate. If it is a tuple of two numbers $(i, j)$, each process will take a number sampled from a uniform distribution supported on $[i, j]$ inclusive. If it is a list of values, of the length n_processes , it is used as it is otherwise, it is used to sample values for each process.

class scml.cli.SCML2023World(*args, **kwargs)[source]

Bases: SCML2022World

A Supply Chain SCML2020World simulation as described for the SCML league of ANAC @ IJCAI 2020.

Parameters:
  • process_inputs – An n_processes vector specifying the number of inputs from each product needed to execute each process.

  • process_outputs – An n_processes vector specifying the number of inputs from each product generated by executing each process.

  • catalog_prices – An n_products vector (i.e. n_processes+1 vector) giving the catalog price of all products

  • profiles – An n_agents list of FactoryProfile objects specifying the private profile of the factory associated with each agent.

  • agent_types – An n_agents list of strings/ SCML2020Agent classes specifying the type of each agent

  • agent_params – An n_agents dictionaries giving the parameters of each agent

  • initial_balance – The initial balance in each agent’s wallet. All agents will start with this same value.

  • allow_selling_input – Allows agents to sell their input product(s) through negotiation

  • allow_buying_output – Allows agents to buy their output product(s) through negotiation

  • catalog_quantities – The quantities in the past for which catalog_prices are the average unit prices. This is used when updating the trading prices. If set to zero then the trading price will follow the market price and will not use the catalog_price (except for products that are never sold in the market for which the trading price will take the default value of the catalog price). If set to a large value (e.g. 10000), the price at which a product is sold will not affect the trading price

  • spot_market_global_loss – Buying from the spot market will cost trading-price * (1+`spot_market_global_loss) and selling to it will cost trading-price / (1+ spot_market_global_loss) for agents with unit spot-market-loss-multiplier

  • financial_report_period – The number of steps between financial reports. If < 1, it is a fraction of n_steps

  • borrow_on_breach – If true, agents will be forced to borrow money on breach as much as possible to honor the contract

  • interest_rate – The interest at which loans grow over time (it only affect a factory when its balance is negative)

  • bankruptcy_limit – The maximum amount that be be borrowed (including interest). The balance of any factory cannot go lower than - borrow_limit or the agent will go bankrupt immediately

  • liquidation_rate – The rate at which future contracts get liquidated when an agent gets bankrupt. It should be between zero and one.

  • compensation_fraction – Fraction of a contract to be compensated (at most) if a partner goes bankrupt. Notice that this fraction is not guaranteed because the bankrupt agent may not have enough assets to pay all of its standing contracts to this level of compensation. In such cases, a smaller fraction will be used.

  • compensate_immediately – If true, compensation will happen immediately when an agent goes bankrupt and in in money. This means that agents with contracts involving the bankrupt agent will just have these contracts be nullified and receive monetary compensation immediately . If false, compensation will not happen immediately but at the contract execution time. In this case, agents with contracts involving the bankrupt agent will be informed of the compensation fraction (instead of the compensation money) at the time of bankruptcy and will receive the compensation in kind (money if they are sellers and products if they are buyers) at the normal execution time of the contract. In the special case of no-compensation (i.e. compensation_fraction is zero or the bankrupt agent has no assets), the two options will behave similarity.

  • compensate_before_past_debt – If true, then compensations will be paid before past debt is considered, otherwise, the money from liquidating bankrupt agents will first be used to pay past debt then whatever remains will be used for compensation. Notice that in all cases, the trigger of bankruptcy will be paid before compensation and past debts.

  • exogenous_horizon – The horizon for revealing external contracts

  • exogenous_force_max – If true, exogenous contracts are forced to be signed independent of the setting of force_signing

  • production_no_borrow – If true, agents will not borrow if they fail to satisfy its production need to execute a scheduled production command

  • production_no_bankruptcy – If true, agents will not go bankrupt because of an production related transaction.

  • production_penalty – The penalty paid when buying from spot-market to satisfy production needs

  • production_confirm – If true, the factory will confirm running processes at every time-step just before running them by calling confirm_production on the agent controlling it.

  • compact – If True, no logs will be kept and the whole simulation will use a smaller memory footprint

  • n_steps – Number of simulation steps (can be considered as days).

  • time_limit – Total time allowed for the complete simulation in seconds.

  • neg_n_steps – Number of negotiation steps allowed for all negotiations.

  • neg_time_limit – Total time allowed for a complete negotiation in seconds.

  • neg_step_time_limit – Total time allowed for a single step of a negotiation. in seconds.

  • negotiation_speed – The number of negotiation steps that pass in every simulation step. If 0, negotiations will be guaranteed to finish within a single simulation step

  • signing_delay – The number of simulation steps to pass between a contract is concluded and signed

  • name – The name of the simulations

  • **kwargs – Other parameters that are passed directly to SCML2020World constructor.

class scml.cli.SCML2022World(*args, **kwargs)[source]

Bases: SCML2021World

A Supply Chain SCML2020World simulation as described for the SCML league of ANAC @ IJCAI 2020.

Parameters:
  • process_inputs – An n_processes vector specifying the number of inputs from each product needed to execute each process.

  • process_outputs – An n_processes vector specifying the number of inputs from each product generated by executing each process.

  • catalog_prices – An n_products vector (i.e. n_processes+1 vector) giving the catalog price of all products

  • profiles – An n_agents list of FactoryProfile objects specifying the private profile of the factory associated with each agent.

  • agent_types – An n_agents list of strings/ SCML2020Agent classes specifying the type of each agent

  • agent_params – An n_agents dictionaries giving the parameters of each agent

  • initial_balance – The initial balance in each agent’s wallet. All agents will start with this same value.

  • allow_selling_input – Allows agents to sell their input product(s) through negotiation

  • allow_buying_output – Allows agents to buy their output product(s) through negotiation

  • catalog_quantities – The quantities in the past for which catalog_prices are the average unit prices. This is used when updating the trading prices. If set to zero then the trading price will follow the market price and will not use the catalog_price (except for products that are never sold in the market for which the trading price will take the default value of the catalog price). If set to a large value (e.g. 10000), the price at which a product is sold will not affect the trading price

  • spot_market_global_loss – Buying from the spot market will cost trading-price * (1+`spot_market_global_loss) and selling to it will cost trading-price / (1+ spot_market_global_loss) for agents with unit spot-market-loss-multiplier

  • financial_report_period – The number of steps between financial reports. If < 1, it is a fraction of n_steps

  • borrow_on_breach – If true, agents will be forced to borrow money on breach as much as possible to honor the contract

  • interest_rate – The interest at which loans grow over time (it only affect a factory when its balance is negative)

  • bankruptcy_limit – The maximum amount that be be borrowed (including interest). The balance of any factory cannot go lower than - borrow_limit or the agent will go bankrupt immediately

  • liquidation_rate – The rate at which future contracts get liquidated when an agent gets bankrupt. It should be between zero and one.

  • compensation_fraction – Fraction of a contract to be compensated (at most) if a partner goes bankrupt. Notice that this fraction is not guaranteed because the bankrupt agent may not have enough assets to pay all of its standing contracts to this level of compensation. In such cases, a smaller fraction will be used.

  • compensate_immediately – If true, compensation will happen immediately when an agent goes bankrupt and in in money. This means that agents with contracts involving the bankrupt agent will just have these contracts be nullified and receive monetary compensation immediately . If false, compensation will not happen immediately but at the contract execution time. In this case, agents with contracts involving the bankrupt agent will be informed of the compensation fraction (instead of the compensation money) at the time of bankruptcy and will receive the compensation in kind (money if they are sellers and products if they are buyers) at the normal execution time of the contract. In the special case of no-compensation (i.e. compensation_fraction is zero or the bankrupt agent has no assets), the two options will behave similarity.

  • compensate_before_past_debt – If true, then compensations will be paid before past debt is considered, otherwise, the money from liquidating bankrupt agents will first be used to pay past debt then whatever remains will be used for compensation. Notice that in all cases, the trigger of bankruptcy will be paid before compensation and past debts.

  • exogenous_horizon – The horizon for revealing external contracts

  • exogenous_force_max – If true, exogenous contracts are forced to be signed independent of the setting of force_signing

  • production_no_borrow – If true, agents will not borrow if they fail to satisfy its production need to execute a scheduled production command

  • production_no_bankruptcy – If true, agents will not go bankrupt because of an production related transaction.

  • production_penalty – The penalty paid when buying from spot-market to satisfy production needs

  • production_confirm – If true, the factory will confirm running processes at every time-step just before running them by calling confirm_production on the agent controlling it.

  • compact – If True, no logs will be kept and the whole simulation will use a smaller memory footprint

  • n_steps – Number of simulation steps (can be considered as days).

  • time_limit – Total time allowed for the complete simulation in seconds.

  • neg_n_steps – Number of negotiation steps allowed for all negotiations.

  • neg_time_limit – Total time allowed for a complete negotiation in seconds.

  • neg_step_time_limit – Total time allowed for a single step of a negotiation. in seconds.

  • negotiation_speed – The number of negotiation steps that pass in every simulation step. If 0, negotiations will be guaranteed to finish within a single simulation step

  • signing_delay – The number of simulation steps to pass between a contract is concluded and signed

  • name – The name of the simulations

  • **kwargs – Other parameters that are passed directly to SCML2020World constructor.

class scml.cli.SCML2024StdWorld(*args, horizon=STD_DEFAULT_PARAMS['horizon'], price_range_fraction=STD_DEFAULT_PARAMS['price_range_fraction'], price_multiplier=STD_DEFAULT_PARAMS['price_multiplier'], wide_price_range=STD_DEFAULT_PARAMS['wide_price_range'], one_time_per_negotiation=STD_DEFAULT_PARAMS['one_time_per_negotiation'], perishable=STD_DEFAULT_PARAMS['perishable'], quantity_multiplier=STD_DEFAULT_PARAMS['quantity_multiplier'], **kwargs)[source]

Bases: StdWorld

The SCML-standard simulation as used in [SCML 2024](https://scml.cs.brown.edu)

scml.cli.anac2020_collusion(competitors: Sequence[str | type], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, n_agents_per_competitor: int = 3, min_factories_per_level: int = 2, tournament_path: str | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.scml2020.world.SCML2020World | None], None] | None = None, non_competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = True, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=None, forced_logs_fraction: float = FORCED_LOGS_FRACTION, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2020 SCML tournament (collusion track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • n_agents_per_competitor – Number of agents per competitor

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created

  • dynamic_non_competitor_params – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment – If true, competitors are excluded from the dynamic non-competitors

  • n_competitors_per_world – Number of competitors in every simulation. If not given it will be a random number between 2 and min(2, n), where n is the number of competitors

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • forced_logs_fraction – Fraction of simulations for which logs are always saved (including negotiations)

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2020_std(competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, min_factories_per_level: int = 2, tournament_path: str | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.scml2020.world.SCML2020World | None], None] | None = None, non_competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = True, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=None, forced_logs_fraction: float = FORCED_LOGS_FRACTION, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2020 SCML tournament (standard track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created

  • dynamic_non_competitor_params – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment – If true, competitors are excluded from the dynamic non-competitors

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • n_competitors_per_world – Number of competitors in every simulation. If not given it will be a random number between 2 and min(2, n), where n is the number of competitors

  • forced_logs_fraction – Fraction of simulations for which logs are always saved (including negotiations)

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2021_collusion(competitors: Sequence[str | type], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, n_agents_per_competitor: int = 3, min_factories_per_level: int = 2, tournament_path: str | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.scml2020.world.SCML2020World | None], None] | None = None, non_competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = False, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=1, forced_logs_fraction: float = FORCED_LOGS_FRACTION, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2021 SCML tournament (collusion track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • n_agents_per_competitor – Number of agents per competitor

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created

  • dynamic_non_competitor_params – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment – If true, competitors are excluded from the dynamic non-competitors

  • n_competitors_per_world – Number of competitors in every simulation. If not given it will be a random number between 2 and min(2, n), where n is the number of competitors. This value will always be set to 1 in SCML2021

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • forced_logs_fraction – Fraction of simulations for which logs are always saved (including negotiations)

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2021_oneshot(competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, min_factories_per_level: int = 4, tournament_path: str | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.scml2020.world.SCML2020World | None], None] | None = None, non_competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = False, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=None, forced_logs_fraction: float = FORCED_LOGS_FRACTION, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2021 SCML tournament (oneshot track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created

  • dynamic_non_competitor_params – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment – If true, competitors are excluded from the dynamic non-competitors

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • n_competitors_per_world – Number of competitors in every simulation. If not given it will be a random number between 2 and min(2, n), where n is the number of competitors

  • forced_logs_fraction – Fraction of simulations for which logs are always saved (including negotiations)

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2021_std(competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, min_factories_per_level: int = 2, tournament_path: str | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.scml2020.world.SCML2020World | None], None] | None = None, non_competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = True, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=None, forced_logs_fraction: float = FORCED_LOGS_FRACTION, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2021 SCML tournament (standard track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created

  • dynamic_non_competitor_params – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment – If true, competitors are excluded from the dynamic non-competitors

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • n_competitors_per_world – Number of competitors in every simulation. If not given it will be a random number between 2 and min(2, n), where n is the number of competitors

  • forced_logs_fraction – Fraction of simulations for which logs are always saved (including negotiations)

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2022_collusion(competitors: Sequence[str | type], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, n_agents_per_competitor: int = 3, min_factories_per_level: int = 2, tournament_path: str | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.scml2020.world.SCML2020World | None], None] | None = None, non_competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = False, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=1, forced_logs_fraction: float = FORCED_LOGS_FRACTION, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2022 SCML tournament (collusion track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • n_agents_per_competitor – Number of agents per competitor

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created

  • dynamic_non_competitor_params – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment – If true, competitors are excluded from the dynamic non-competitors

  • n_competitors_per_world – Number of competitors in every simulation. If not given it will be a random number between 2 and min(2, n), where n is the number of competitors. This value will always be set to 1 in SCML2022

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • forced_logs_fraction – Fraction of simulations for which logs are always saved (including negotiations)

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2022_oneshot(competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, min_factories_per_level: int = 4, tournament_path: str | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.scml2020.world.SCML2020World | None], None] | None = None, non_competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = False, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=None, forced_logs_fraction: float = FORCED_LOGS_FRACTION, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2022 SCML tournament (oneshot track).

Args: :returns: TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2022_std(competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, min_factories_per_level: int = 2, tournament_path: str | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.scml2020.world.SCML2020World | None], None] | None = None, non_competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = True, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=None, forced_logs_fraction: float = FORCED_LOGS_FRACTION, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2022 SCML tournament (standard track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created

  • dynamic_non_competitor_params – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment – If true, competitors are excluded from the dynamic non-competitors

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • n_competitors_per_world – Number of competitors in every simulation. If not given it will be a random number between 2 and min(2, n), where n is the number of competitors

  • forced_logs_fraction – Fraction of simulations for which logs are always saved (including negotiations)

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2023_collusion(competitors: Sequence[str | type], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, n_agents_per_competitor: int = 3, min_factories_per_level: int = 2, tournament_path: str | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.scml2020.world.SCML2020World | None], None] | None = None, non_competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = False, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=1, forced_logs_fraction: float = FORCED_LOGS_FRACTION, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2023 SCML tournament (collusion track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • n_agents_per_competitor – Number of agents per competitor

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created

  • dynamic_non_competitor_params – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment – If true, competitors are excluded from the dynamic non-competitors

  • n_competitors_per_world – Number of competitors in every simulation. If not given it will be a random number between 2 and min(2, n), where n is the number of competitors. This value will always be set to 1 in SCML2022

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • forced_logs_fraction – Fraction of simulations for which logs are always saved (including negotiations)

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2023_oneshot(competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, min_factories_per_level: int = 4, tournament_path: str | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.scml2020.world.SCML2020World | None], None] | None = None, non_competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = False, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=None, forced_logs_fraction: float = FORCED_LOGS_FRACTION, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2023 SCML tournament (oneshot track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created

  • dynamic_non_competitor_params – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment – If true, competitors are excluded from the dynamic non-competitors

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • n_competitors_per_world – Number of competitors in every simulation. If not given it will be a random number between 2 and min(2, n), where n is the number of competitors

  • forced_logs_fraction – Fraction of simulations for which logs are always saved (including negotiations)

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2023_std(competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, min_factories_per_level: int = 2, tournament_path: str | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.scml2020.world.SCML2020World | None], None] | None = None, non_competitors: Sequence[str | type[scml.scml2020.world.SCML2020Agent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = True, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=None, forced_logs_fraction: float = FORCED_LOGS_FRACTION, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2023 SCML tournament (standard track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created

  • dynamic_non_competitor_params – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment – If true, competitors are excluded from the dynamic non-competitors

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • n_competitors_per_world – Number of competitors in every simulation. If not given it will be a random number between 2 and min(2, n), where n is the number of competitors

  • forced_logs_fraction – Fraction of simulations for which logs are always saved (including negotiations)

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2024_oneshot(competitors: Sequence[str | type[scml.oneshot.agent.OneShotAgent]], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, min_factories_per_level: int = 4, tournament_path: str | pathlib.Path | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.oneshot.world.SCML2024OneShotWorld | None], None] | None = None, non_competitors: Sequence[str | type[scml.oneshot.agent.OneShotAgent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[scml.oneshot.agent.OneShotAgent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = False, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=None, forced_logs_fraction: float = FORCED_LOGS_FRACTION, context=None, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2024 SCML tournament (oneshot track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created

  • dynamic_non_competitor_params – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment – If true, competitors are excluded from the dynamic non-competitors

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • n_competitors_per_world – Number of competitors in every simulation. If not given it will be a random number between 2 and min(2, n), where n is the number of competitors

  • forced_logs_fraction – Fraction of simulations for which logs are always saved (including negotiations)

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.anac2024_std(competitors: Sequence[str | type[scml.std.agent.StdAgent]], competitor_params: Sequence[dict[str, Any]] | None = None, agent_names_reveal_type=False, n_configs: int = 5, max_worlds_per_config: int | None = None, n_runs_per_world: int = 1, min_factories_per_level: int = 4, tournament_path: str | pathlib.Path | pathlib.Path | None = None, total_timeout: int | None = None, parallelism='parallel', scheduler_ip: str | None = None, scheduler_port: str | None = None, tournament_progress_callback: Callable[[negmas.tournaments.WorldRunResults | None], None] | None = None, world_progress_callback: Callable[[scml.oneshot.world.SCML2024OneShotWorld | None], None] | None = None, non_competitors: Sequence[str | type[scml.oneshot.agent.OneShotAgent]] | None = None, non_competitor_params: Sequence[dict[str, Any]] | None = None, dynamic_non_competitors: list[type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = False, name: str | None = None, verbose: bool = False, configs_only=False, compact=False, n_competitors_per_world=None, forced_logs_fraction: float = FORCED_LOGS_FRACTION, context=None, **kwargs) negmas.tournaments.TournamentResults | os.PathLike[source]

The function used to run ANAC 2024 SCML tournament (std track).

Parameters:
  • name – Tournament name

  • competitors – A list of class names for the competitors

  • competitor_params – A list of competitor parameters (used to initialize the competitors).

  • agent_names_reveal_type – If true then the type of an agent should be readable in its name (most likely at its beginning).

  • n_configs – The number of different world configs (up to competitor assignment) to be generated.

  • max_worlds_per_config – The maximum number of worlds to run per config. If None, then all possible assignments of competitors within each config will be tried (all permutations).

  • n_runs_per_world – Number of runs per world. All of these world runs will have identical competitor assignment and identical world configuration.

  • min_factories_per_level – Minimum number of factories for each production level

  • total_timeout – Total timeout for the complete process

  • tournament_path – Path at which to store all results. A scores.csv file will keep the scores and logs folder will keep detailed logs

  • parallelism – Type of parallelism. Can be ‘serial’ for serial, ‘parallel’ for parallel and ‘distributed’ for distributed

  • scheduler_port – Port of the dask scheduler if parallelism is dask, dist, or distributed

  • scheduler_ip – IP Address of the dask scheduler if parallelism is dask, dist, or distributed

  • world_progress_callback – A function to be called after everystep of every world run (only allowed for serial evaluation and should be used with cautious).

  • tournament_progress_callback – A function to be called with WorldRunResults after each world finished processing

  • non_competitors – A list of agent types that will not be competing in the sabotage competition but will exist in the world

  • non_competitor_params – parameters of non competitor agents

  • dynamic_non_competitors – A list of non-competing agents that are assigned to the simulation dynamically during the creation of the final assignment instead when the configuration is created

  • dynamic_non_competitor_params – paramters of dynamic non competitor agents

  • exclude_competitors_from_reassignment – If true, competitors are excluded from the dynamic non-competitors

  • verbose – Verbosity

  • configs_only – If true, a config file for each

  • compact – If true, compact logs will be created and effort will be made to reduce the memory footprint

  • n_competitors_per_world – Number of competitors in every simulation. If not given it will be a random number between 2 and min(2, n), where n is the number of competitors

  • forced_logs_fraction – Fraction of simulations for which logs are always saved (including negotiations)

  • kwargs – Arguments to pass to the world_generator function

Returns:

TournamentResults The results of the tournament or a PathLike giving the location where configs were saved

Remarks:

Default parameters will be used in the league with the exception of parallelism which may use distributed processing

scml.cli.gui_option(x)[source]
scml.cli.n_completed = 0[source]
scml.cli.n_total = 0[source]
scml.cli.DEFAULT_STD_OLD = 'RandomAgent;BuyCheapSellExpensiveAgent;SatisficerAgent;DecentralizingAgent;DoNothingAgent'[source]
scml.cli.DEFAULT_STD_2021 = 'MarketAwareDecentralizingAgent;RandomAgent;SatisficerAgent;DecentralizingAgent'[source]
scml.cli.DEFAULT_ONESHOT = 'GreedySyncAgent;SyncRandomOneShotAgent'[source]
scml.cli.DEFAULT_STD = 'GreedySyncAgent;SyncRandomStdAgent;SyncRandomOneShotAgent'[source]
scml.cli.DEFAULT_2021_NONCOMPETITORS = ['scml.scml2020.agents.DecentralizingAgent', 'scml.scml2020.agents.BuyCheapSellExpensiveAgent'][source]
scml.cli.DEFAULT_STD_NONCOMPETITORS_OLD = ['scml.scml2020.agents.DecentralizingAgent', 'scml.scml2020.agents.BuyCheapSellExpensiveAgent'][source]
scml.cli.DEFAULT_ONESHOT_NONCOMPETITORS = ['scml.oneshot.agents.RandDistOneShotAgent', 'scml.oneshot.agents.EqualDistOneShotAgent'][source]
scml.cli.DEFAULT_STD_NONCOMPETITORS = ['scml.std.agents.GreedyStdAgent', 'scml.std.agents.RandomStdAgent',...[source]
scml.cli.get_range(x, x_min, x_max)[source]

Gets a range with possibly overriding it with a single value

scml.cli.default_log_path()[source]

Default location for all logs

scml.cli.DB_FOLDER[source]
scml.cli.DB_NAME = 'rundb.csv'[source]
scml.cli.save_run_info(name: str, log_path: pathlib.Path | str | None, type_: str = 'world', path: pathlib.Path = DB_FOLDER)[source]
scml.cli.default_tournament_path()[source]

The default path to store tournament run info

scml.cli.default_world_path()[source]

The default path to store world run info

scml.cli.print_progress(_, i, n) None[source]

Prints the progress of a tournament

scml.cli.print_world_progress(world) None[source]

Prints the progress of a world

scml.cli.shortest_unique_names(strs: List[str], sep='.')[source]

Finds the shortest unique strings starting from the end of each input string based on the separator.

The final strings will only be unique if the inputs are unique.

Example

given [“a.b.c”, “d.e.f”, “a.d.c”] it will generate [“b.c”, “f”, “d.c”]

scml.cli.nCr(n, r)[source]
scml.cli.main()[source]
scml.cli.display_results(results, metric, file_name=None)[source]
scml.cli._path(path) pathlib.Path[source]

Creates an absolute path from given path which can be a string

scml.cli.run2019(steps, levels, competitors, log, compact, log_ufuns, log_negs, raise_exceptions, path, world_config)[source]
scml.cli.run2020(steps, time, competitors, log, compact, log_ufuns, log_negs, raise_exceptions, path, world_config, show_contracts)[source]
scml.cli.run2021(steps, time, competitors, log, compact, log_ufuns, log_negs, raise_exceptions, path, world_config, show_contracts, oneshot, name, method)[source]
scml.cli.run2022(steps, time, competitors, log, compact, log_ufuns, log_negs, raise_exceptions, path, world_config, show_contracts, oneshot, name, method)[source]
scml.cli.run2023(steps, time, competitors, log, compact, log_ufuns, log_negs, raise_exceptions, path, world_config, show_contracts, oneshot, name, method)[source]
scml.cli.run2024(steps, time, competitors, log, compact, log_ufuns, log_negs, raise_exceptions, path, world_config, show_contracts, oneshot, name, method)[source]
scml.cli.tournament2019(output, parallel, name, steps, ttype, timeout, configs, runs, max_runs, competitors, non_competitors, log, world_config, verbosity, log_ufuns, log_negs, compact, raise_exceptions, path, cw)[source]
scml.cli.tournament2020(name, steps, timeout, ttype, log, verbosity, runs, configs, max_runs, competitors, world_config, non_competitors, compact, log_ufuns, log_negs, raise_exceptions, path, cw, parallel, output)[source]
scml.cli.tournament2021(name, steps, timeout, ttype, log, verbosity, runs, configs, max_runs, competitors, world_config, non_competitors, compact, log_ufuns, log_negs, raise_exceptions, path, cw, parallel, output)[source]
scml.cli.tournament2022(name, steps, timeout, ttype, log, verbosity, runs, configs, max_runs, competitors, world_config, non_competitors, compact, log_ufuns, log_negs, raise_exceptions, path, cw, parallel, output)[source]
scml.cli.tournament2023(name, steps, timeout, ttype, log, verbosity, runs, configs, max_runs, competitors, world_config, non_competitors, compact, log_ufuns, log_negs, raise_exceptions, path, cw, parallel, output)[source]
scml.cli.tournament2024(name, steps, timeout, total_timeout, ttype, log, verbosity, runs, configs, max_runs, competitors, world_config, non_competitors, compact, log_ufuns, log_negs, raise_exceptions, path, cw, parallel, output)[source]
scml.cli.version()[source]