OneShotAWI

class scml.oneshot.OneShotAWI(world, agent)[source]

Bases: negmas.situated.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.

  • 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 ).

  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.

  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_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.

  • 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.

  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

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.

Attributes Summary

all_consumers

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

all_suppliers

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

catalog_prices

Returns the catalog prices of all products

current_balance

current_disposal_cost

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

current_exogenous_input_price

The exogenous contracts for the input (this step)

current_exogenous_input_quantity

The exogenous contracts for the input (this step)

current_exogenous_output_price

The exogenous contracts for the input (this step)

current_exogenous_output_quantity

The exogenous contracts for the input (this step)

current_input_issues

rtype

List[Issue]

current_inventory

current_output_issues

rtype

List[Issue]

current_shortfall_penalty

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

exogenous_contract_summary

The exogenous contracts in the current step for all products

is_exogenous_forced

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

is_first_level

Whether this agent is in the first production level

is_last_level

Whether this agent is in the last production level

is_middle_level

Whether this agent is in neither in the first nor in the last level

level

The production level of the agent

my_consumers

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

my_input_product

the product I need to buy

my_output_product

the product I need to sell

my_suppliers

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

n_competitors

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

n_input_negotiations

Number of negotiations with suppliers at every step

n_lines

The number of lines in the corresponding factory.

n_output_negotiations

Number of negotiations with consumers at every step

n_processes

Returns the number of processes in the system

n_products

Returns the number of products in the system

penalties_scale

rtype

str

price_multiplier

Controls the minimum and maximum prices in the negotiation agendas

profile

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

trading_prices

Returns the current trading prices of all products

Methods Summary

is_bankrupt([aid])

Checks whether an agent is a system agent or not

is_system(aid)

Checks whether an agent is a system agent or not

penalty_multiplier(is_input, unit_price)

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

reports_at_step(step)

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

reports_of_agent(aid)

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

state()

Returns the private state of the agent in that world

Attributes Documentation

all_consumers

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

Return type

List[List[str]]

all_suppliers

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

Return type

List[List[str]]

catalog_prices

Returns the catalog prices of all products

Return type

ndarray

current_balance
current_disposal_cost

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

Return type

float

current_exogenous_input_price

The exogenous contracts for the input (this step)

Return type

int

current_exogenous_input_quantity

The exogenous contracts for the input (this step)

Return type

int

current_exogenous_output_price

The exogenous contracts for the input (this step)

Return type

int

current_exogenous_output_quantity

The exogenous contracts for the input (this step)

Return type

int

current_input_issues
Return type

List[Issue]

current_inventory
current_output_issues
Return type

List[Issue]

current_shortfall_penalty

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

Return type

float

exogenous_contract_summary

The exogenous contracts in the current step for all products

Return type

List[Tuple[int, int]]

Returns

A list of tuples giving the total quantity and total price of all revealed exogenous contracts of all products at the current step.

is_exogenous_forced

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

is_first_level

Whether this agent is in the first production level

is_last_level

Whether this agent is in the last production level

is_middle_level

Whether this agent is in neither in the first nor in the last level

level

The production level of the agent

Return type

int

my_consumers

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

Return type

List[str]

my_input_product

the product I need to buy

Return type

int

my_output_product

the product I need to sell

Return type

int

my_suppliers

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

Return type

List[str]

n_competitors

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

Return type

int

n_input_negotiations

Number of negotiations with suppliers at every step

Return type

int

n_lines

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

Return type

int

n_output_negotiations

Number of negotiations with consumers at every step

Return type

int

n_processes

Returns the number of processes in the system

Return type

int

n_products

Returns the number of products in the system

Return type

int

penalties_scale
Return type

str

price_multiplier

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.

profile

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

Return type

OneShotProfile

trading_prices

Returns the current trading prices of all products

Return type

ndarray

Methods Documentation

is_bankrupt(aid=None)[source]

Checks whether an agent is a system agent or not

Parameters

aid (Optional[str]) – Agent ID

Return type

bool

is_system(aid)[source]

Checks whether an agent is a system agent or not

Parameters

aid (str) – Agent ID

Return type

bool

penalty_multiplier(is_input, unit_price)[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.

Return type

float

reports_at_step(step)[source]

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

Return type

Dict[str, FinancialReport]

reports_of_agent(aid)[source]

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

Return type

Dict[int, FinancialReport]

state()[source]

Returns the private state of the agent in that world

Return type

Any