Risk-Averse Quantal Equilibrium (RQE)
rqequilibrium.rqe
Player
dataclass
Concept of a player in the RQE game.
Attributes:
Name | Type | Description |
---|---|---|
tau |
float
|
Risk aversion parameter. |
epsilon |
float
|
Bounded Rational parameter. |
game_matrix |
ndarray
|
The payoff matrix for the player. |
Source code in src/rqequilibrium/rqe.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
RQE
RQE (Risk Quantal Response Equilibrium) solver for multi-player games.
This class implements the RQE solution concept, which combines risk aversion and bounded rationality in a multi-player setting. It uses projected gradient descent to optimize the policies of players.
Attributes:
Name | Type | Description |
---|---|---|
players |
list[Player]
|
List of Player objects representing the players in the game. |
lr |
float
|
Learning rate for the optimization. |
max_iter |
int
|
Maximum number of iterations for the optimization. |
quantal_function |
Callable
|
Function to compute the quantal response. |
risk_function |
Callable
|
Function to compute the risk term. |
projection |
Callable
|
Function to project policies onto a simplex. |
Methods:
Name | Description |
---|---|
risk_term |
Computes the risk term for a player given the game matrix, policy, and other player's policy. |
quantal_term |
Computes the quantal response term for a player given the game matrix, policy, and epsilon parameter. |
optimize |
Optimizes the policies for all players using projected gradient descent. |
print_game |
Prints the game matrices for two player games. |
Source code in src/rqequilibrium/rqe.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
optimize
optimize() -> np.ndarray
Optimize the policies for both players using projected gradient descent.
Returns:
Type | Description |
---|---|
ndarray
|
The optimal policy using RQE |
Source code in src/rqequilibrium/rqe.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
print_game
staticmethod
print_game(R1: ndarray, R2: ndarray)
Print the game matrices for both players.
Source code in src/rqequilibrium/rqe.py
184 185 186 187 188 189 190 191 192 193 |
|
quantal_term
quantal_term(game: ndarray, x: ndarray, p: ndarray, epsilon: float) -> np.array
Compute the quantal response term for a player given the game matrix, policy and epsilon parameter. Parameters: game: The game matrix for the player. x: The current policy of the player. p: The risk aversion term. epsilon: The epsilon parameter for bounded rationality. Returns: The gradient of the quantal term
Source code in src/rqequilibrium/rqe.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
risk_term
risk_term(game: ndarray, x: ndarray, p: ndarray, y: ndarray, tau: float) -> np.array
Compute the risk term for a player given the game matrix, policy, and other player's policy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
game
|
ndarray
|
The game matrix for the player. |
required |
x
|
ndarray
|
The current policy of the player. |
required |
p
|
ndarray
|
The last risk aversion term. |
required |
y
|
ndarray
|
The policy of all the other players. |
required |
Returns: The gradient of the risk term
Source code in src/rqequilibrium/rqe.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|