3P Supply and Demand
Ver. 1.0.1 (2024-01-12)
This module provides a 3-player game of supply and demand games, where each player represents a seller. Each seller has the capability to produce the same product with a quantity between 1-5 items everyday. The production cost of producing 1-5 items are constant, which is 5€. Therefore, the seller needs to sell an item with higher price, if they produce less amount.
- The tables below show the sales price based on the quantity produced by each seller:
Seller 1 Seller 2 Seller 3
- Price (€) Quantity Price (€) Quantity Price (€) Quantity
15 1 10 1 8 1 12 2 8 2 7 2 9 3 6 3 6 3 6 4 4 4 5 4 3 5 2 5 4 5
The market demand of the products is 10 products/day. The buyer will always firstly buy the products with less prices. Therefore, each player needs an individual strategy in the competitive manner to select the quantity of the produced products in a day in order to maximize their profit.
In this example, we are going to apply different solvers for each seller, where Seller 1 and 2 utilize max greedy policy. This means that they always select the best possible outcomes without caring what the other sellers are doing. Meanwhile, Seller 3 utilized random solver. In the near future, we are going to add more solvers and this game is going to be updated accordingly.
- class mlpro.gt.pool.native.games.supplydemand_3p.TransferFunction_SD3P(p_name: str, p_id: int = None, p_type: int = None, p_unit_in: str = None, p_unit_out: str = None, p_dt: float = 0.01, p_logging=True, **p_args)
Bases:
TransferFunction
- _set_function_parameters(p_args) bool
This method provides a functionality to set the parameters of the transfer function.
- Parameters:
p_args (dict) – set of parameters of the transfer function.
- Returns:
true means no parameters are missing.
- Return type:
bool
- _custom_function(p_input, p_range=None)
This function represents the template to create a custom function and must be redefined.
- Parameters:
p_input – input value.
p_range – range of the calculation. None means 0. Default: None.
- Returns:
output value.
- Return type:
float
- class mlpro.gt.pool.native.games.supplydemand_3p.PayoffFunction_SD3P(p_func_type: int, p_dim_elems: list = None, p_num_coalisions: int = None, p_logging=True)
Bases:
GTFunction
- _setup_transfer_functions()
A method to setup transfer functions. This is only applicable for C_FUNC_TRANSFER_FCTS. This method needs to be redefined based on the setup of the game.
- class mlpro.gt.pool.native.games.supplydemand_3p.PayoffMatrix_SD3P(p_function: GTFunction = None, p_player_ids: list = None, p_logging=True)
Bases:
GTPayoffMatrix
- _call_mapping(p_input: str, p_strategies: GTStrategy) float
If the payoff matrix does not use the standardized matrix by MLPro-GT. This method can be used by redefining it.
- Parameters:
p_input (str) – inputs of the payoff matrix.
p_strategies (GTStrategy) – Selected strategies by all players/coalitions.
- Returns:
Payoff of the player/coalition.
- Return type:
float
- _call_best_response(p_element_id: str) float
If the payoff matrix does not use the standardized matrix by MLPro-GT. This method can be used to get the best response value by redefining it.
- Parameters:
p_element_id (str) – Id of a specific player/coalition.
- Returns:
The highest possible payoff of a player/coalition.
- Return type:
float
- _call_zero_sum() bool
If the payoff matrix does not use the standardized matrix by MLPro-GT. This method can be used to get the detect zero sum games by redefining it.
- Returns:
True means it is a zero sum game, otherwise no.
- Return type:
bool
- class mlpro.gt.pool.native.games.supplydemand_3p.MaxGreedyPolicy_SD3P_P1(p_strategy_space: MSpace, p_id=None, p_visualize: bool = False, p_logging=True, **p_param)
Bases:
MaxGreedyPolicy
- _call_compute_strategy(p_payoff: GTPayoffMatrix) GTStrategy
- class mlpro.gt.pool.native.games.supplydemand_3p.MaxGreedyPolicy_SD3P_P2(p_strategy_space: MSpace, p_id=None, p_visualize: bool = False, p_logging=True, **p_param)
Bases:
MaxGreedyPolicy
- _call_compute_strategy(p_payoff: GTPayoffMatrix) GTStrategy
- class mlpro.gt.pool.native.games.supplydemand_3p.SupplyDemand_3P(p_mode=0, p_ada=False, p_cycle_limit=1, p_visualize: bool = False, p_logging=True)
Bases:
GTGame
- C_NAME = 'SupplyDemand_3P'
- _setup(p_mode, p_ada: bool, p_visualize: bool, p_logging) Model
Custom setup of GT Game. Payoff matrix has to be defined here as self._payoff.
- Parameters:
p_mode – Operation mode. See Mode.C_VALID_MODES for valid values. Default = Mode.C_MODE_SIM
p_ada (bool) – Boolean switch for adaptivity.
p_visualize (bool) – Boolean switch for visualisation.
p_logging – Log level (see constants of class Log).
- Returns:
player – GTPlayer model (object of type GTPlayer, GTCoalition or GTCompetition).
- Return type: