pub trait MetaSolver {
// Required methods
fn solve(&self, payoffs: &[Vec<f32>]) -> Vec<f32>;
fn name(&self) -> &'static str;
// Provided method
fn solve_n_player(
&self,
_payoffs: &[Vec<f32>],
num_agents: usize,
_per_role_k: usize,
) -> Vec<f32> { ... }
}Expand description
Meta-solver over a symmetric 2-player zero-sum empirical game.
Given an n × n row-player payoff matrix payoffs[i][j]
representing the expected return of row-player strategy i versus
column-player strategy j, returns the row-player’s mixed-Nash
distribution as a length-n probability vector summing to 1.0.
For symmetric zero-sum games (matching pennies, the homogeneous-policy version of bucket brigade) the column-player’s equilibrium is the same distribution by symmetry — callers can use the row distribution for both agents. For non-symmetric games, this trait is invoked twice (once per agent role) with appropriately transposed payoff matrices.
Required Methods§
Sourcefn solve(&self, payoffs: &[Vec<f32>]) -> Vec<f32>
fn solve(&self, payoffs: &[Vec<f32>]) -> Vec<f32>
Solve for the row-player mixed-Nash on a symmetric n × n
empirical payoff matrix.
§Contract
- Input is assumed to be
n × nand square; non-square inputs produce undefined behaviour (impl is free to panic). - Return vector has length
nwith non-negative entries summing to1.0(within1e-6tolerance).
Provided Methods§
Sourcefn solve_n_player(
&self,
_payoffs: &[Vec<f32>],
num_agents: usize,
_per_role_k: usize,
) -> Vec<f32>
fn solve_n_player( &self, _payoffs: &[Vec<f32>], num_agents: usize, _per_role_k: usize, ) -> Vec<f32>
N-player solve over an explicit per-agent payoff tensor.
payoffs is shape (k^num_agents, num_agents) where
payoffs[s][a] is agent a’s payoff at joint pure strategy
s. The flat joint-strategy index decomposes into per-agent
indices via little-endian mixed-radix (agent 0 = fastest):
s = Σ_i s_i · k^i.
Returns a probability vector of length k^num_agents summing
to 1.0 ± 1e-6.
§Default
The default implementation only supports num_agents == 2 and
delegates to solve via the row-marginal projection. For
num_agents > 2 it panics with a message naming the solver.
Only AlphaRankMetaSolver overrides this method with a true
N-player path; the other in-tree solvers (UniformMetaSolver,
FictitiousPlayMetaSolver, ReplicatorDynamicsMetaSolver)
have no N>2 generalization with the same convergence
guarantees and intentionally panic.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".