scml.oneshot.awi

Implements the one shot version of the Agent-World Interface.

Classes

OneShotAWI

The agent world interface for the one-shot game.

Module Contents

class scml.oneshot.awi.OneShotAWI(world: scml.oneshot.world.SCMLBaseWorld, agent: scml.oneshot.agent.OneShotAgent)[source]

Bases: negmas.situated.AgentWorldInterface

The agent world interface for the one-shot game.

This class contains all the methods needed to access the simulation to extract information which are divided into 4 groups:

Static World Information:

Information about the world and the agent that does not change over time. These include:

  1. Market Information:

  • n_products: Number of products in the production chain.

  • n_processes: Number of processes in the production chain.

  • n_competitors: Number of other factories on the same production level.

  • all_suppliers: A list of all suppliers by product.

  • all_consumers: A list of all consumers by product.

  • proudction_capacities: The total production capacity (i.e. number of lines)

    for each production level (i.e. manufacturing process).

  • is_system: Is the given system ID corresponding to a system agent?

  • is_bankrupt: Is the given agent bankrupt? None asks about self

  • catalog_prices: A list of the catalog prices (by product).

  • price_multiplier: The multiplier multiplied by the trading/catalog price when the negotiation agendas are created to decide the maximum and lower quantities.

  • is_exogenous_forced: Are exogenous contracts always forced or can the agent decide not to sign them.

  • current_step: Current simulation step (inherited from negmas.situated.AgentWorldInterface ).

  • n_steps: Number of simulation steps (inherited from negmas.situated.AgentWorldInterface ).

  • relative_time: fraction of the simulation completed (inherited from negmas.situated.AgentWorldInterface).

  • state: The full state of the agent ( OneShotState ).

  • **settings* The system settings (inherited from negmas.situated.AgentWorldInterface ).

  • **quantity_range* The maximum quantity in all negotiation agendas (new in 0.6.1)

  • **price_range* The maximum number of different prices in any negotiation agenda (new in 0.6.1)

  1. Agent Information:

  • profile: Gives the agent profile including its production cost, number of production lines, input product index, mean of its delivery penalties, mean of its disposal costs, standard deviation of its shortfall penalties and standard deviation of its disposal costs. See OneShotProfile for full description. This information is private information and no other agent knows it.

  • n_lines: the number of production lines in the factory (private information).

  • is_first_level: Is the agent in the first production level (i.e. it is an input agent that buys the raw material).

  • is_last_level: Is the agent in the last production level (i.e. it is an output agent that sells the final product).

  • is_middle_level: Is the agent neither a first level nor a last level agent

  • my_input_product: The input product to the factory controlled by the agent.

  • my_output_product: The output product from the factory controlled by the agent.

  • level: The production level which is numerically the same as the input product.

  • my_suppliers: A list of IDs for all suppliers to the agent (i.e. agents that can sell the input product of the agent).

  • my_consumers: A list of IDs for all consumers to the agent (i.e. agents that can buy the output product of the agent).

  • penalties_scale: The scale at which to calculate disposal cost/delivery penalties. “trading” and “catalog” mean trading and catalog prices. “unit” means the contract’s unit price while “none” means that disposal cost/shortfall penalty are absolute.

  • n_input_negotiations: Number of negotiations with suppliers.

  • n_output_negotiations: Number of negotiations with consumers.

Dynamic World Information:

Information about the world and the agent that changes over time.

  1. Market Information:

  • trading_prices: The trading prices of all products. This information is only available if publish_trading_prices is set in the world.

  • exogenous_contract_summary: A list of n_products tuples each giving the total quantity and average price of exogenous contracts for a product. This information is only available if publish_exogenous_summary is set in the world.

  • is_perishable: Are all products perishable?

  1. Other Agents’ Information:

  • reports_of_agent: Gives all past financial reports of a given agent. See FinancialReport for details.

  • reports_at_step: Gives all reports of all agents at a given step. See FinancialReport for details.

  1. Current Negotiations Information:

  • current_input_outcome_space: The current outcome-space for all negotiations to buy the input product of the agent. If the agent is at level zero, this will have no issues.

  • current_output_outcome_space: The current outcome-space for all negotiations to buy the output product of the agent. If the agent is at level n_products - 1, this will have no issues.

  • current_negotiation_details: Details on all current negotiations separated into “buy” and “sell” dictionaries.

Useful helpers about current negotiations:

  • current_input_issues: The current issues for all negotiations to buy the input product of the agent. If the agent is at level zero, this will be empty. This is exactly the same as current_input_outcome_space.issues

  • current_output_issues: The current issues for all negotiations to buy the output product of the agent. If the agent is at level n_products - 1, this will be empty. This is exactly the same as current_output_outcome_space.issues

  • current_buy_nmis: All NMIs for current buy negotiations.

  • current_sell_nmis: All NMIs for current sell negotiations.

  • current_nmis: All states for current negotiations.

  • current_buy_states: All states for current buy negotiations.

  • current_sell_states: All states for current sell negotiations.

  • current_states: All states for current negotiations.

  • current_buy_offers: All offers for current buy negotiations.

  • current_sell_offers: All offers for current sell negotiations.

  • current_offers: All offers for current negotiations.

  • running_buy_nmis: All NMIs for running buy negotiations.

  • running_sell_nmis: All NMIs for running sell negotiations.

  • running_nmis: All states for running negotiations.

  • running_buy_states: All states for running buy negotiations.

  • running_sell_states: All states for running sell negotiations.

  • running_states: All states for running negotiations.

  1. Agent Information:

  • current_exogenous_input_quantity: The total quantity the agent have in its input exogenous contract.

  • current_exogenous_input_price: The total price of the agent’s input exogenous contract.

  • current_exogenous_output_quantity: The total quantity the agent have in its output exogenous contract.

  • current_exogenous_output_price: The total price of the agent’s output exogenous contract

  • current_disposal_cost: The disposal cost per unit item in the current step.

  • current_shortfall_penalty: The shortfall penalty per unit item in the current step.

  • current_balance: The current balance of the agent

  • current_score: The current score (balance / initial balance) of the agent

  • current_inventory_input: The total quantity remaining in the inventory of the input product

  • current_inventory_output: The total quantity remaining in the inventory of the output product

  • current_inventory: The total quantity remaining in the inventory of the input and output product

  1. Sales and Supplies (quantities) for today:

  • sales: Today’s sales per customer so far.

  • supplies: Today’s supplies per supplier so far.

  • total_sales: Today’s total sales so far.

  • total_supplies: Today’s total supplies so far.

  • needed_sales: Today’s needed sales as of now (exogenous input + total supplies - exogenous output - total sales so far).

  • needed_supplies: Today’s needed supplies as of now (exogenous output + total sales - exogenous input - total supplies so far).

Services (All inherited from negmas.situated.AgentWorldInterface):
  • logdebug/loginfo/logwarning/logerror: Logs to the world log at the given log level.

  • logdebug_agent/loginf_agnet/…: Logs to the agent specific log at the given log level.

  • bb_query: Queries the bulletin-board.

  • bb_read: Read a section of the bulletin-board.

property max_n_lines: int[source]

Maximum number of lines in the whole system

property quantity_range: int[source]

The maximum cardinality of the quantity issue in all negotiations

property price_range: int[source]

The maximum cardinality of the quantity issue in all negotiations

property n_products: int[source]

Returns the number of products in the system

property n_competitors: int[source]

Returns the number of factories/agents in the same production level

property n_processes: int[source]

Returns the number of processes in the system

property all_suppliers: list[list[str]][source]

Returns a list of agent IDs for all suppliers for every product

property production_capacities: list[int][source]

Returns the total production capacity in the market for each process

property all_consumers: list[list[str]][source]

Returns a list of agent IDs for all consumers for every product

is_system(aid: str) bool[source]

Checks whether an agent is a system agent or not

Parameters:

aid – Agent ID

is_bankrupt(aid: str | None = None) bool[source]

Checks whether an agent is a system agent or not

Parameters:

aid – Agent ID

property horizon: int[source]

Horizon for negotiations

property catalog_prices: numpy.ndarray[source]

Returns the catalog prices of all products

property price_multiplier: float[source]

Controls the minimum and maximum prices in the negotiation agendas

Remarks:
  • The base price is either the catalog price if trading price information is not public or the trading price.

  • The minimum unit price in any negotiation agenda is the base price of the previous product in the chain **divided by the multiplier. If that is less than 1, the minimum unit price becomes 1.

  • The maximum unit price in any negotiation agenda is the base price of the previous product in the chain **multiplied by the multiplier. If that is less than 1, the minimum unit price becomes 1.

property is_exogenous_forced: bool[source]

Are exogenous contracts forced in the sense that the agent cannot decide not to sign them?

property allow_zero_quantity: bool[source]

Does negotiations allow zero quantity?

property profile: scml.oneshot.common.OneShotProfile[source]

Gets the profile (static private information) associated with the agent

property n_lines: int[source]

The number of lines in the corresponding factory. You can read state to get this among other information

property n_input_negotiations: int[source]

Number of negotiations with suppliers at every step

property n_output_negotiations: int[source]

Number of negotiations with consumers at every step

property is_first_level[source]
Whether this agent is in the first production level
property is_last_level[source]
Whether this agent is in the last production level
property level[source]
The production level which is the index of the process for
this factory (or the index of its input product)
property is_middle_level[source]
Whether this agent is in neither in the first nor in the last level
property my_input_product: int[source]

the product I need to buy

property my_output_product: int[source]

the product I need to sell

property my_competitors: list[str][source]

Returns the names of all factories in the same level as me

property my_suppliers: list[str][source]

Returns a list of IDs for all of the agent’s suppliers (agents that can supply the product I need).

property my_consumers: list[str][source]

Returns a list of IDs for all the agent’s consumers (agents that can consume at least one product it may produce).

property my_partners: list[str][source]

Returns a list of IDs for all of the agent’s partners starting with suppliers

property penalties_scale: Literal['trading', 'catalog', 'unit', 'none'][source]
property state: scml.oneshot.common.OneShotState[source]

Returns the private state of the agent in that world

property current_balance[source]
property current_score: float[source]

Returns the current score (profit) of the agent

property current_inventory: tuple[int, int][source]

Current input and output inventory quantity

property current_inventory_input: int[source]

Current input inventory quantity

property current_inventory_output: int[source]

Current output inventory quantity

property current_exogenous_input_quantity: int[source]

The exogenous contracts for the input (this step)

property current_exogenous_input_price: int[source]

The exogenous contracts for the input (this step)

property current_exogenous_output_quantity: int[source]

The exogenous contracts for the input (this step)

property current_exogenous_output_price: int[source]

The exogenous contracts for the input (this step)

penalty_multiplier(is_input: bool, unit_price: float | None) float[source]

Returns the penalty multiplier for a contract with the give unit price.

Remarks:
  • The unit price is only needed if the penalties_scale is unit. For all other options (trading, catalog, none), the penalty scale does not depend on the unit price.

property is_perishable: bool[source]

Are all products perishable (original design of OneShot)

property current_disposal_cost: float[source]

Cost of storing one unit (penalizes buying too much/ selling too little)

property current_storage_cost: float[source]

Cost of storing one unit (penalizes buying too much/ selling too little)

property current_shortfall_penalty: float[source]

Cost of failure to deliver one unit (penalizes buying too little / selling too much)

property trading_prices: numpy.ndarray[source]

Returns the current trading prices of all products

property exogenous_contract_summary: list[tuple[int, int]][source]

The exogenous contracts in the current step for all products

Returns:

A list of tuples giving the total quantity and total price of all revealed exogenous contracts of all products at the current step. Will be empty if the world has “publish_exogenous_summary==False”

reports_of_agent(aid: str) dict[int, scml.oneshot.common.FinancialReport][source]

Returns a dictionary mapping time-steps to financial reports of the given agent

reports_at_step(step: int) dict[str, scml.oneshot.common.FinancialReport][source]

Returns a dictionary mapping agent ID to its financial report for the given time-step

property current_input_issues: list[negmas.ContiguousIssue][source]
property current_output_issues: list[negmas.ContiguousIssue][source]
property current_input_outcome_space: negmas.outcomes.DiscreteCartesianOutcomeSpace[source]
property current_output_outcome_space: negmas.outcomes.DiscreteCartesianOutcomeSpace[source]
property current_negotiation_details: dict[str, dict[str, scml.oneshot.common.NegotiationDetails]][source]

Details of current negotiations separated as two dicts for buying and selling.

Remarks:
  • current_negotiation_details[“buy”] gives details on all negotiations for buying

  • current_negotiation_details[“sell”] gives details on all negotiations for selling

property current_buy_states: dict[str, negmas.sao.SAOState][source]

All running buy negotiations as a mapping from partner ID to current negotiation state

property current_sell_states: dict[str, negmas.sao.SAOState][source]

All running sell negotiations as a mapping from partner ID to current negotiation state

property current_states: dict[str, negmas.sao.SAOState][source]

All running negotiations as a mapping from partner ID to current negotiation state

property current_buy_nmis: dict[str, negmas.sao.SAONMI][source]

All running buy negotiations as a mapping from partner ID to current negotiation nmi

property current_sell_nmis: dict[str, negmas.sao.SAONMI][source]

All running negotiations as a mapping from partner ID to current negotiation state

property current_nmis: dict[str, negmas.sao.SAONMI][source]

All running negotiations as a mapping from partner ID to current negotiation nmi

property current_buy_offers: dict[str, negmas.outcomes.Outcome][source]

All current buy negotiations as a mapping from partner ID to current offer

property current_sell_offers: dict[str, negmas.outcomes.Outcome][source]

All current sell negotiations as a mapping from partner ID to current offer

property current_offers: dict[str, negmas.outcomes.Outcome][source]

All current negotiations as a mapping from partner ID to current offer

property running_buy_states: dict[str, negmas.sao.SAOState][source]

All running buy negotiations as a mapping from partner ID to current negotiation state

property running_sell_states: dict[str, negmas.sao.SAOState][source]

All running sell negotiations as a mapping from partner ID to current negotiation state

property running_states: dict[str, negmas.sao.SAOState][source]

All running negotiations as a mapping from partner ID to current negotiation state

property running_sell_nmis: dict[str, negmas.sao.SAONMI][source]

All running sell negotiations as a mapping from partner ID to current negotiation nmi

property running_buy_nmis: dict[str, negmas.sao.SAONMI][source]

All running buy negotiations as a mapping from partner ID to current negotiation nmi

property running_nmis: dict[str, negmas.sao.SAONMI][source]

All running negotiations as a mapping from partner ID to current negotiation nmi

property sales: dict[str, int][source]

Sales (quantity) per customer so far (this day)

property supplies: dict[str, int][source]

Supplies (quantity) per supplier so far (this day)

property sales_cost: dict[str, int][source]

Sales (total price) per customer so far (this day)

property supplies_cost: dict[str, int][source]

Supplies (total price) per supplier so far (this day)

property future_sales: dict[int, dict[str, int]][source]

Future sales (quantity) per customer so far (excluding this day)

property future_supplies: dict[int, dict[str, int]][source]

Future supplies (quantity) per supplier so far (excluding this day)

property future_sales_cost: dict[int, dict[str, int]][source]

Future sales (total price) per customer so far (excluding this day)

property future_supplies_cost: dict[int, dict[str, int]][source]

Future supplies (total price) per supplier so far (excluding this day)

property total_sales: int[source]

Total sales so far (this day)

property total_supplies: int[source]

Total supplies so far (this day)

property total_future_sales: int[source]

Total sales so far (this day)

total_sales_from(start: int) int[source]

Total sales starting at start and ending at end (inclusive). Past days are ignored

total_supplies_from(start: int) int[source]

Total supplies starting at start and ending at end (inclusive). Past days are ignored

total_sales_between(start: int, end: int) int[source]

Total sales starting at start and ending at end (inclusive). Past days are ignored

total_supplies_between(start: int, end: int) int[source]

Total supplies starting at start and ending at end (inclusive). Past days are ignored

total_supplies_until(step: int) int[source]

Total supplies starting today until the given step (inclusive). Past days are ignored

total_sales_until(step: int) int[source]

Total sales starting today until the given step (inclusive). Past days are ignored

total_sales_at(step: int) int[source]

Total sales already signed at a future step

total_supplies_at(step: int) int[source]

Total supplies already signed at a future step

property total_future_supplies: int[source]

Total supplies so far (this day)

property needed_sales: int[source]

Sales that need to be secured (exogenous input + total supplies - exogenous output - total sales so far)

property needed_supplies: int[source]

Supplies that need to be secured (exogenous output + total sales - exogenous input - total supplies so far)

_register_sale(customer: str, quantity: int, unit_price: int, step: int) None[source]
_register_supply(supplier: str, quantity: int, unit_price: int, step: int) None[source]
_reset_sales_and_supplies() None[source]