scml.cliadv

The SCML universal command line tool

Attributes

DEFAULT_NEGOTIATOR

anac2020_world_generator

anac_config_generator_std_old

n_completed

n_total

Classes

FactoryManager

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

DefaultGreedyManager

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

SCML2019World

The SCML2020World class running a simulation of supply chain management.

Functions

anac2019_assigner(, params, Any]] =, ...)

anac2019_config_generator(, consumption_horizon, ...)

anac2019_sabotage_assigner(, params, Any]] =, ...)

anac2019_sabotage_config_generator(, ...)

anac2019_world_generator(**kwargs)

balance_calculator(→ negmas.tournaments.WorldRunResults)

A scoring function that scores factory managers' performance by the final balance only ignoring whatever still

sabotage_effectiveness(...)

A scoring function that scores factory managers' performance by the final balance only ignoring whatever still

anac_assigner_std(, params, Any]] | None =, ...)

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

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

cli()

tournament(ctx, ignore_warnings)

create(ctx, name, steps, ttype, timeout, log, ...)

run(ctx, name, verbosity, parallel, distributed, ip, ...)

display_results(results, metric)

_path(→ pathlib.Path)

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

run2019(steps, levels, neg_speedup, negotiator, ...)

run2020(force_signing, batch_signing, steps, ...)

version()

Module Contents

scml.cliadv.DEFAULT_NEGOTIATOR = 'negmas.sao.AspirationNegotiator'[source]
class scml.cliadv.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.cliadv.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.cliadv.anac2019_assigner(config: List[Dict[str, Any]], max_n_worlds: int, n_agents_per_competitor: int = 1, fair: bool = True, competitors: Sequence[Type[negmas.Agent]] = (), params: Sequence[Dict[str, Any]] = (), 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) List[List[Dict[str, Any]]][source]
scml.cliadv.anac2019_config_generator(n_competitors: int, n_agents_per_competitor: int, agent_names_reveal_type: bool = False, non_competitors: Tuple[str | scml.scml2019.factory_managers.builtins.FactoryManager] | None = None, non_competitor_params: Tuple[Dict[str, Any]] | None = None, compact: bool = True, *, consumption_schedule: Tuple[int, int] = (0, 5), consumption_horizon: Tuple[int, int] = (10, 15), n_retrials: int | Tuple[int, int] = 2, negotiator_type: str = DEFAULT_NEGOTIATOR, n_steps: int | Tuple[int, int] = (50, 100), n_miners: int | Tuple[int, int] = 5, n_consumers: int | Tuple[int, int] = 5, profile_cost: Tuple[float, float] = (1, 4), profile_time: int | Tuple[int, int] = 1, n_intermediate: Tuple[int, int] = (1, 4), min_factories_per_level: int = 5, max_factories_per_level: int = 8, n_default_managers: Tuple[int, int] = (1, 4), n_lines: int = 10, **kwargs) List[Dict[str, Any]][source]
scml.cliadv.anac2019_sabotage_assigner(config: List[Dict[str, Any]], max_n_worlds: int, n_agents_per_competitor: int = 1, fair: bool = True, competitors: Sequence[Type[negmas.Agent]] = (), params: Sequence[Dict[str, Any]] = (), 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) List[List[Dict[str, Any]]][source]
scml.cliadv.anac2019_sabotage_config_generator(n_competitors: int, n_agents_per_competitor: int, agent_names_reveal_type: bool = False, non_competitors: Tuple[str | scml.scml2019.factory_managers.builtins.FactoryManager] | None = None, non_competitor_params: Tuple[Dict[str, Any]] | None = None, compact: bool = True, *, consumption_schedule: Tuple[int, int] = (0, 5), consumption_horizon: Tuple[int, int] = (10, 15), n_retrials: int | Tuple[int, int] = 2, negotiator_type: str = DEFAULT_NEGOTIATOR, n_steps: int | Tuple[int, int] = (50, 100), n_miners: int | Tuple[int, int] = 5, n_consumers: int | Tuple[int, int] = 5, profile_cost: Tuple[float, float] = (1, 4), profile_time: int | Tuple[int, int] = 1, n_intermediate: Tuple[int, int] = (1, 4), min_factories_per_level: int = 5, n_default_managers: Tuple[int, int] = (1, 4), n_lines: int = 10, **kwargs) List[Dict[str, Any]][source]
scml.cliadv.anac2019_world_generator(**kwargs)[source]
scml.cliadv.balance_calculator(worlds: List[scml.scml2019.world.SCML2019World], scoring_context: Dict[str, Any], dry_run: bool, ignore_default=True) negmas.tournaments.WorldRunResults[source]

A scoring function that scores factory managers’ performance by the final balance only ignoring whatever still in their inventory.

Parameters:
  • worlds – The world which is assumed to be run up to the point at which the scores are to be calculated.

  • scoring_context – A dict of context parameters passed by the world generator or assigner.

  • dry_run – A boolean specifying whether this is a dry_run. For dry runs, only names and types are expected in the returned WorldRunResults

Returns:

WorldRunResults giving the names, scores, and types of factory managers.

scml.cliadv.sabotage_effectiveness(worlds: List[scml.scml2019.world.SCML2019World], scoring_context: Dict[str, Any], dry_run: bool) negmas.tournaments.WorldRunResults[source]

A scoring function that scores factory managers’ performance by the final balance only ignoring whatever still in their inventory.

Parameters:
  • worlds – The world which is assumed to be run up to the point at which the scores are to be calculated.

  • scoring_context – A dict of context parameters passed by the world generator or assigner.

  • dry_run – A boolean specifying whether this is a dry_run. For dry runs, only names and types are expected in the returned WorldRunResults

Returns:

WorldRunResults giving the names, scores, and types of factory managers.

class scml.cliadv.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:

scml.cliadv.anac2020_world_generator[source]
scml.cliadv.anac_assigner_std(config: list[dict[str, Any]], max_n_worlds: int, n_agents_per_competitor: int = 1, fair: bool = True, competitors: Sequence[str | type[scml.oneshot.agent.OneShotAgent] | type[negmas.Agent]] = (), params: Sequence[dict[str, Any]] | None = (), dynamic_non_competitors: Sequence[str | type[negmas.Agent]] | None = None, dynamic_non_competitor_params: list[dict[str, Any]] | None = None, exclude_competitors_from_reassignment: bool = True) list[list[dict[str, Any]]][source]
scml.cliadv.anac_config_generator_std_old[source]
scml.cliadv.gui_option(x)[source]
scml.cliadv.n_completed = 0[source]
scml.cliadv.n_total = 0[source]
scml.cliadv.get_range(x, x_min, x_max)[source]

Gets a range with possibly overriding it with a single value

scml.cliadv.default_log_path()[source]

Default location for all logs

scml.cliadv.default_tournament_path()[source]

The default path to store tournament run info

scml.cliadv.default_world_path()[source]

The default path to store world run info

scml.cliadv.print_progress(_, i, n) None[source]

Prints the progress of a tournament

scml.cliadv.print_world_progress(world) None[source]

Prints the progress of a world

scml.cliadv.cli()[source]
scml.cliadv.tournament(ctx, ignore_warnings)[source]
scml.cliadv.create(ctx, name, steps, ttype, timeout, log, verbosity, reveal_names, runs, configs, max_runs, competitors, world_config, non_competitors, compact, factories, agents, log_ufuns, log_negs, raise_exceptions, steps_min, steps_max, path, cw, inputs, inputs_min, inputs_max, outputs, outputs_min, outputs_max, costs, costs_min, costs_max, increasing_costs, equal_exogenous_supplies, equal_exogenous_sales, profit_mean, profit_std, productivity, productivity_min, productivity_max, cash_availability, cash_availability_min, cash_availability_max, buy_missing, borrow, bankruptcy_limit, penalty, reports, interest, force_exogenous, borrow_to_produce, balance, processes, factories_min, factories_max, horizon)[source]
scml.cliadv.run(ctx, name, verbosity, parallel, distributed, ip, port, compact, path, log, metric)[source]
scml.cliadv.display_results(results, metric)[source]
scml.cliadv._path(path) pathlib.Path[source]

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

scml.cliadv.run2019(steps, levels, neg_speedup, negotiator, agents, horizon, min_consumption, max_consumption, transport, time, neg_time, neg_steps, sign, guaranteed, lines, retrials, use_consumer, max_insurance, riskiness, competitors, log, compact, log_ufuns, log_negs, reserved_value, balance, shared_profile, raise_exceptions, path, world_config)[source]
scml.cliadv.run2020(force_signing, batch_signing, steps, processes, neg_speedup, factories, factories_min, factories_max, horizon, time, neg_time, neg_steps, lines, competitors, log, compact, log_ufuns, log_negs, balance, raise_exceptions, path, world_config, inputs, inputs_min, inputs_max, outputs, outputs_min, outputs_max, costs, costs_min, costs_max, increasing_costs, equal_exogenous_supplies, equal_exogenous_sales, profit_mean, profit_std, productivity, productivity_min, productivity_max, cash_availability, cash_availability_min, cash_availability_max, buy_missing, borrow, bankruptcy_limit, penalty, reports, interest, force_exogenous, borrow_to_produce, show_contracts)[source]
scml.cliadv.version()[source]