scml.oneshot.awi
Implements the one shot version of the Agent-World Interface.
Module Contents
Classes
The agent world interface for the one-shot game. |
- 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:
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)
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.
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?
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.
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.
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
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 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_competitors: int[source]
Returns the number of factories/agents in the same production level
- 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
- 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 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 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_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 state: scml.oneshot.common.OneShotState[source]
Returns the private state of the agent in that world
- 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)
- 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”
- 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 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 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)
- 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
- 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.
- 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
- 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