scml.oneshot.awi ================ .. py:module:: scml.oneshot.awi .. autoapi-nested-parse:: Implements the one shot version of the Agent-World Interface. Classes ------- .. autoapisummary:: scml.oneshot.awi.OneShotAWI Module Contents --------------- .. py:class:: OneShotAWI(world: scml.oneshot.world.SCMLBaseWorld, agent: scml.oneshot.agent.OneShotAgent) Bases: :py:obj:`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: A. 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) B. 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. A. 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? B. 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. C. 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. D. 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 E. 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. .. py:attribute:: _world .. py:attribute:: agent .. py:attribute:: _future_sales :type: dict[int, dict[str, int]] .. py:attribute:: _future_supplies :type: dict[int, dict[str, int]] .. py:attribute:: _future_sales_cost :type: dict[int, dict[str, int]] .. py:attribute:: _future_supplies_cost :type: dict[int, dict[str, int]] .. py:property:: max_n_lines :type: int Maximum number of lines in the whole system .. py:property:: quantity_range :type: int The maximum cardinality of the quantity issue in all negotiations .. py:property:: price_range :type: int The maximum cardinality of the quantity issue in all negotiations .. py:property:: n_products :type: int Returns the number of products in the system .. py:property:: n_competitors :type: int Returns the number of factories/agents in the same production level .. py:property:: n_processes :type: int Returns the number of processes in the system .. py:property:: all_suppliers :type: list[list[str]] Returns a list of agent IDs for all suppliers for every product .. py:property:: production_capacities :type: list[int] Returns the total production capacity in the market for each process .. py:property:: all_consumers :type: list[list[str]] Returns a list of agent IDs for all consumers for every product .. py:method:: is_system(aid: str) -> bool Checks whether an agent is a system agent or not :param aid: Agent ID .. py:method:: is_bankrupt(aid: str | None = None) -> bool Checks whether an agent is a system agent or not :param aid: Agent ID .. py:property:: horizon :type: int Horizon for negotiations .. py:property:: catalog_prices :type: numpy.ndarray Returns the catalog prices of all products .. py:property:: price_multiplier :type: float 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. .. py:property:: is_exogenous_forced :type: bool Are exogenous contracts forced in the sense that the agent cannot decide not to sign them? .. py:property:: allow_zero_quantity :type: bool Does negotiations allow zero quantity? .. py:property:: profile :type: scml.oneshot.common.OneShotProfile Gets the profile (static private information) associated with the agent .. py:property:: n_lines :type: int The number of lines in the corresponding factory. You can read `state` to get this among other information .. py:property:: n_input_negotiations :type: int Number of negotiations with suppliers at every step .. py:property:: n_output_negotiations :type: int Number of negotiations with consumers at every step .. py:property:: is_first_level Whether this agent is in the first production level .. py:property:: is_last_level Whether this agent is in the last production level .. py:property:: level The production level which is the index of the process for this factory (or the index of its input product) .. py:property:: is_middle_level Whether this agent is in neither in the first nor in the last level .. py:property:: my_input_product :type: int the product I need to buy .. py:property:: my_output_product :type: int the product I need to sell .. py:property:: my_competitors :type: list[str] Returns the names of all factories in the same level as me .. py:property:: my_suppliers :type: list[str] Returns a list of IDs for all of the agent's suppliers (agents that can supply the product I need). .. py:property:: my_consumers :type: list[str] Returns a list of IDs for all the agent's consumers (agents that can consume at least one product it may produce). .. py:property:: my_partners :type: list[str] Returns a list of IDs for all of the agent's partners starting with suppliers .. py:property:: penalties_scale :type: Literal['trading', 'catalog', 'unit', 'none'] .. py:property:: state :type: scml.oneshot.common.OneShotState Returns the private state of the agent in that world .. py:property:: current_balance .. py:property:: current_score :type: float Returns the current score (profit) of the agent .. py:property:: current_inventory :type: tuple[int, int] Current input and output inventory quantity .. py:property:: current_inventory_input :type: int Current input inventory quantity .. py:property:: current_inventory_output :type: int Current output inventory quantity .. py:property:: current_exogenous_input_quantity :type: int The exogenous contracts for the input (this step) .. py:property:: current_exogenous_input_price :type: int The exogenous contracts for the input (this step) .. py:property:: current_exogenous_output_quantity :type: int The exogenous contracts for the input (this step) .. py:property:: current_exogenous_output_price :type: int The exogenous contracts for the input (this step) .. py:method:: penalty_multiplier(is_input: bool, unit_price: float | None) -> float 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. .. py:property:: is_perishable :type: bool Are all products perishable (original design of OneShot) .. py:property:: current_disposal_cost :type: float Cost of storing one unit (penalizes buying too much/ selling too little) .. py:property:: current_storage_cost :type: float Cost of storing one unit (penalizes buying too much/ selling too little) .. py:property:: current_shortfall_penalty :type: float Cost of failure to deliver one unit (penalizes buying too little / selling too much) .. py:property:: trading_prices :type: numpy.ndarray Returns the current trading prices of all products .. py:property:: exogenous_contract_summary :type: list[tuple[int, int]] 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" .. py:method:: reports_of_agent(aid: str) -> dict[int, scml.oneshot.common.FinancialReport] Returns a dictionary mapping time-steps to financial reports of the given agent .. py:method:: reports_at_step(step: int) -> dict[str, scml.oneshot.common.FinancialReport] Returns a dictionary mapping agent ID to its financial report for the given time-step .. py:property:: current_input_issues :type: list[negmas.ContiguousIssue] .. py:property:: current_output_issues :type: list[negmas.ContiguousIssue] .. py:property:: current_input_outcome_space :type: negmas.outcomes.DiscreteCartesianOutcomeSpace .. py:property:: current_output_outcome_space :type: negmas.outcomes.DiscreteCartesianOutcomeSpace .. py:property:: current_negotiation_details :type: dict[str, dict[str, scml.oneshot.common.NegotiationDetails]] 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 .. py:property:: current_buy_states :type: dict[str, negmas.sao.SAOState] All running buy negotiations as a mapping from partner ID to current negotiation state .. py:property:: current_sell_states :type: dict[str, negmas.sao.SAOState] All running sell negotiations as a mapping from partner ID to current negotiation state .. py:property:: current_states :type: dict[str, negmas.sao.SAOState] All running negotiations as a mapping from partner ID to current negotiation state .. py:property:: current_buy_nmis :type: dict[str, negmas.sao.SAONMI] All running buy negotiations as a mapping from partner ID to current negotiation nmi .. py:property:: current_sell_nmis :type: dict[str, negmas.sao.SAONMI] All running negotiations as a mapping from partner ID to current negotiation state .. py:property:: current_nmis :type: dict[str, negmas.sao.SAONMI] All running negotiations as a mapping from partner ID to current negotiation nmi .. py:property:: current_buy_offers :type: dict[str, negmas.outcomes.Outcome] All current buy negotiations as a mapping from partner ID to current offer .. py:property:: current_sell_offers :type: dict[str, negmas.outcomes.Outcome] All current sell negotiations as a mapping from partner ID to current offer .. py:property:: current_offers :type: dict[str, negmas.outcomes.Outcome] All current negotiations as a mapping from partner ID to current offer .. py:property:: running_buy_states :type: dict[str, negmas.sao.SAOState] All running buy negotiations as a mapping from partner ID to current negotiation state .. py:property:: running_sell_states :type: dict[str, negmas.sao.SAOState] All running sell negotiations as a mapping from partner ID to current negotiation state .. py:property:: running_states :type: dict[str, negmas.sao.SAOState] All running negotiations as a mapping from partner ID to current negotiation state .. py:property:: running_sell_nmis :type: dict[str, negmas.sao.SAONMI] All running sell negotiations as a mapping from partner ID to current negotiation nmi .. py:property:: running_buy_nmis :type: dict[str, negmas.sao.SAONMI] All running buy negotiations as a mapping from partner ID to current negotiation nmi .. py:property:: running_nmis :type: dict[str, negmas.sao.SAONMI] All running negotiations as a mapping from partner ID to current negotiation nmi .. py:property:: sales :type: dict[str, int] Sales (quantity) per customer so far (this day) .. py:property:: supplies :type: dict[str, int] Supplies (quantity) per supplier so far (this day) .. py:property:: sales_cost :type: dict[str, int] Sales (total price) per customer so far (this day) .. py:property:: supplies_cost :type: dict[str, int] Supplies (total price) per supplier so far (this day) .. py:property:: future_sales :type: dict[int, dict[str, int]] Future sales (quantity) per customer so far (excluding this day) .. py:property:: future_supplies :type: dict[int, dict[str, int]] Future supplies (quantity) per supplier so far (excluding this day) .. py:property:: future_sales_cost :type: dict[int, dict[str, int]] Future sales (total price) per customer so far (excluding this day) .. py:property:: future_supplies_cost :type: dict[int, dict[str, int]] Future supplies (total price) per supplier so far (excluding this day) .. py:property:: total_sales :type: int Total sales so far (this day) .. py:property:: total_supplies :type: int Total supplies so far (this day) .. py:property:: total_future_sales :type: int Total sales so far (this day) .. py:method:: total_sales_from(start: int) -> int Total sales starting at start and ending at end (inclusive). Past days are ignored .. py:method:: total_supplies_from(start: int) -> int Total supplies starting at start and ending at end (inclusive). Past days are ignored .. py:method:: total_sales_between(start: int, end: int) -> int Total sales starting at start and ending at end (inclusive). Past days are ignored .. py:method:: total_supplies_between(start: int, end: int) -> int Total supplies starting at start and ending at end (inclusive). Past days are ignored .. py:method:: total_supplies_until(step: int) -> int Total supplies starting today until the given step (inclusive). Past days are ignored .. py:method:: total_sales_until(step: int) -> int Total sales starting today until the given step (inclusive). Past days are ignored .. py:method:: total_sales_at(step: int) -> int Total sales already signed at a future step .. py:method:: total_supplies_at(step: int) -> int Total supplies already signed at a future step .. py:property:: total_future_supplies :type: int Total supplies so far (this day) .. py:property:: needed_sales :type: int Sales that need to be secured (exogenous input + total supplies - exogenous output - total sales so far) .. py:property:: needed_supplies :type: int Supplies that need to be secured (exogenous output + total sales - exogenous input - total supplies so far) .. py:method:: _register_sale(customer: str, quantity: int, unit_price: int, step: int) -> None .. py:method:: _register_supply(supplier: str, quantity: int, unit_price: int, step: int) -> None .. py:method:: _reset_sales_and_supplies() -> None