nhra_gt.solvers_jax¶
JAX-Accelerated Game Theory Solvers.
This module provides high-performance solvers for various equilibrium concepts,
including Quantal Response Equilibrium (QRE), Regret Minimization,
Stackelberg (Leader-Follower), and Rubinstein bargaining. All solvers are
designed to be compatible with JAX transformations (jit, vmap, grad).
Functions¶
qre_solver_jax(u_row, u_col, lam=5.0, max_iter=100, tol=1e-06)
¶
Solves for the Quantal Response Equilibrium (Logit-equilibrium). Uses fixed-point iteration: p = logit(u_row @ q), q = logit(p @ u_col).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u_row
|
Any
|
Payoff matrix for the row player. |
required |
u_col
|
Any
|
Payoff matrix for the column player. |
required |
lam
|
float
|
Rationality parameter (lambda). Higher = closer to Nash. |
5.0
|
max_iter
|
int
|
Maximum number of iterations. |
100
|
tol
|
float
|
Convergence tolerance. |
1e-06
|
Returns:
| Type | Description |
|---|---|
tuple[Any, Any, Any]
|
A tuple of (row_strategy, col_strategy, residual). |
Source code in src/nhra_gt/solvers_jax.py
regret_min_solver_jax(u_row, u_col, max_iter=500, learning_rate=0.05)
¶
Finds approximate Nash equilibrium by minimizing total regret using gradient descent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u_row
|
Any
|
Payoff matrix for the row player. |
required |
u_col
|
Any
|
Payoff matrix for the column player. |
required |
max_iter
|
int
|
Number of optimization iterations. |
500
|
learning_rate
|
float
|
Step size for gradient descent. |
0.05
|
Returns:
| Type | Description |
|---|---|
tuple[Any, Any, Any]
|
A tuple of (row_strategy, col_strategy, final_regret). |
Source code in src/nhra_gt/solvers_jax.py
discrete_nash_jax(u_row, u_col)
¶
JAX-friendly wrapper for finding a pure Nash equilibrium in a discrete game.
Since pure Nash is non-differentiable, this is used as an Oracle or for comparison. If multiple exist, it returns the payoff-dominant one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u_row
|
Any
|
Payoff matrix for the row player. |
required |
u_col
|
Any
|
Payoff matrix for the column player. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Any, Any]
|
A tuple of (row_strategy, col_strategy) as one-hot vectors if a pure NE is found. |
Source code in src/nhra_gt/solvers_jax.py
solve_hierarchical_game_jax(macro_row_matrix, macro_col_matrix, micro_game_factory, lam=5.0)
¶
Solves a nested hierarchical game using backward induction.
The macro game payoffs are augmented by the equilibrium utilities of the resulting micro games for each macro strategy profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
macro_row_matrix
|
Any
|
Baseline payoffs for the macro row player. |
required |
macro_col_matrix
|
Any
|
Baseline payoffs for the macro column player. |
required |
micro_game_factory
|
Any
|
A function (i, j) -> (u_micro_row, u_micro_col). |
required |
lam
|
float
|
QRE rationality parameter. |
5.0
|
Returns:
| Type | Description |
|---|---|
tuple[Any, Any, Any]
|
A tuple of (macro_row_strat, macro_col_strat, micro_utilities_matrix). |
Source code in src/nhra_gt/solvers_jax.py
qre_3player_jax(u1, u2, u3, lam=5.0, max_iter=100, tol=1e-06)
¶
Solves for QRE in a 3-player normal form game using tensor contractions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u1, u2, u3
|
3D payoff tensors for each player. |
required | |
lam
|
float
|
QRE rationality parameter. |
5.0
|
max_iter
|
int
|
Max fixed-point iterations. |
100
|
tol
|
float
|
Convergence tolerance. |
1e-06
|
Returns:
| Type | Description |
|---|---|
tuple[Any, Any, Any, Any]
|
A tuple of (strat1, strat2, strat3, residual). |
Source code in src/nhra_gt/solvers_jax.py
rubinstein_jax(pie_size, delta_1, delta_2)
¶
JAX implementation of Rubinstein bargaining share for Player 1 (First Mover). Share = (1 - delta_2) / (1 - delta_1 * delta_2).
Source code in src/nhra_gt/solvers_jax.py
stackelberg_jax(u_leader, u_follower)
¶
JAX implementation of Stackelberg Equilibrium (Row=Leader). Returns one-hot strategies.