public abstract class BimatrixEquilibriumSolver
extends java.lang.Object
solve(double[][], double[][])
method takes as input the payoff matrice for the row and column players of the Bimatrix game.
If the Bimatrix is identical the to Bimatrix requested in the previous call to the solve method (if it was previously called), then
nothing is done as the previous results are cached and can be retrieved. If the bimatrix is different, then the strategy
for the row player and column player are computed using the abstract computeRowStrategy(double[][], double[][])
and computeColStrategy(double[][], double[][])
methods and then cached. The cahced results
can be retreived using the getLastComputedRowStrategy()
and getLastComputedColStrategy()
methods.
Note that the bimatrix is compared to the last cached version for equality with an epislon difference comparions
of the individual double values. That is, if the difference absolute difference |a - b| < doubleEpislon
,
then the a and b are treated as equal. By default, doubleEpislon
is set to 1e-8; but this is a public
static member that can be changed.
Modifier and Type | Field and Description |
---|---|
static double |
doubleEpislon
The epislon difference used to test for double equality.
|
protected double[][] |
lastColPlayerPayoff
The last cached column player payoff matrix
|
protected double[] |
lastColsStrategy
The last cached column player strategy
|
protected double[][] |
lastRowPlayerPayoff
The last cached row player payoff matrix
|
protected double[] |
lastRowStrategy
The last cached row player strategy
|
Constructor and Description |
---|
BimatrixEquilibriumSolver() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
bimatrixEqualsLast(double[][] rowPayoff,
double[][] colPayoff)
Tests whether the inputed bimatrix is equal to the last bimatrix cached by the
solve(double[][], double[][]) method. |
abstract double[] |
computeColStrategy(double[][] rowPayoff,
double[][] colPayoff)
Computes and returns the column player strategy for the given bimatrix game.
|
abstract double[] |
computeRowStrategy(double[][] rowPayoff,
double[][] colPayoff)
Computes and returns the row player strategy for the given bimatrix game.
|
protected static boolean |
doubleEquality(double a,
double b)
Returns true if |a - b| <
doubleEpislon ; false otherwise. |
double[] |
getLastComputedColStrategy()
Returns the last column player strategy computed by the
solve(double[][], double[][]) method. |
double[] |
getLastComputedRowStrategy()
Returns the last row player strategy computed by the
solve(double[][], double[][]) method. |
void |
solve(double[][] rowPayoff,
double[][] colPayoff)
Solves and caches the solution for the given bimatrix.
|
public static final double doubleEpislon
protected double[] lastRowStrategy
protected double[] lastColsStrategy
protected double[][] lastRowPlayerPayoff
protected double[][] lastColPlayerPayoff
public void solve(double[][] rowPayoff, double[][] colPayoff)
rowPayoff
- the row player payoff matrixcolPayoff
- the column player payoff matrixpublic double[] getLastComputedRowStrategy()
solve(double[][], double[][])
method.
The strategy is represented as a double array where a[i] is the probability of action i being selected.public double[] getLastComputedColStrategy()
solve(double[][], double[][])
method.
The strategy is represented as a double array where a[i] is the probability of action i being selected.public abstract double[] computeRowStrategy(double[][] rowPayoff, double[][] colPayoff)
rowPayoff
- the row player payoffs.colPayoff
- the column player payoffs.public abstract double[] computeColStrategy(double[][] rowPayoff, double[][] colPayoff)
rowPayoff
- the row player payoffs.colPayoff
- the column player payoffs.protected boolean bimatrixEqualsLast(double[][] rowPayoff, double[][] colPayoff)
solve(double[][], double[][])
method.
If there have been no previous calls to the solve(double[][], double[][])
method and therefore no cached bimatrix,
then this method returns false. If the input bimatrix as a different dimensionality that the cached matrix, this method returns false.
If any row or column player payoffs for the input bimatrix are different than cached bimatrix this method returns false. Otherwise
this method returns true.
Equality
between two double values is tested with an epsilon difference where value a and b are evaluated as equal if
|a - b| < doubleEpislon
.rowPayoff
- the row player payoffs.colPayoff
- the column player payoffs.protected static boolean doubleEquality(double a, double b)
doubleEpislon
; false otherwise.a
- first inputb
- second inputdoubleEpislon
; false otherwise.