3P Routing Problems

Ver. 1.0.1 (2024-01-28)

This module provides a 3-player game of routing problems, where each player has to move simultaneously from the starting node to the target node. We also set up this game as a congestion game, which means that if multiple players select the same path, then the travelling time for both players are increased.

Node S represents the starting node, while node T denotes the target node. Here are the information of the routing network: Note -> [initial node to next node] : [x/y/z]

-> x = the travelling time, if only one player chooses this path -> y = the travelling time, if two players choose this path simulateneously -> z = the travelling time, if three players choose this path simulateneously

  1. Node S to Node 1 : [4/6/10]

  2. Node S to Node 2 : [3/4/5]

  3. Node 1 to Node 2 : [1/2/5]

  4. Node 1 to Node 3 : [3/5/6]

  5. Node 2 to Node 3 : [4/5/6]

  6. Node 2 to Node 4 : [3/6/9]

  7. Node 3 to Node T : [2/4/6]

8. Node 4 to Node 3 : [1/2/7] 8. Node 4 to Node T : [2/8/10]

The main objective of each player is to reach the target points as fast as possible, while trying to avoid taking same actions with other players. This game represents a common scenario in industries, e.g. AGV routing plan, mobile robots, logistics, and many more.

7 potential pathways can be selected by each player, such as:
  1. S -> 1 -> 2 -> 3 -> T

  2. S -> 1 -> 3 -> T

  3. S -> 1 -> 2 -> 4 -> 3 -> T

  4. S -> 1 -> 2 -> 4 -> T

  5. S -> 2 -> 4 -> T

  6. S -> 2 -> 4 -> 3 -> T

  7. S -> 2 -> 3 -> T

In this example, we are going to apply different solvers for each player, where Player 1 utilizes a min greedy policy, Player 2 utilizes a combination of a min greedy policy and a random policy, and Player 3 utilizes a random policy. 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.routingproblems_3p.TransferFunction_Routing3P(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.routingproblems_3p.PayoffFunction_Routing3P(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.routingproblems_3p.PayoffMatrix_Routing3P(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.routingproblems_3p.MinGreedyPolicy_Routing3P(p_strategy_space: MSpace, p_id=None, p_visualize: bool = False, p_logging=True, **p_param)

Bases: MinGreedyPolicy

_call_compute_strategy(p_payoff: GTPayoffMatrix) GTStrategy
class mlpro.gt.pool.native.games.routingproblems_3p.Routing_3P(p_mode=0, p_ada=False, p_cycle_limit=1, p_visualize: bool = False, p_logging=True)

Bases: GTGame

C_NAME = 'Routing_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:

GTPlayer