public class CorrelatedEquilibriumSolver
extends java.lang.Object
4 different correlated equilibrium problems can be solved:
utilitarian, egalitarian, libertarian, and republican, as defined by Greenwald and Hall [1]. The utilitarian
objective maximizes the sum payoff of the found joint strategy. Egalitarian maximizes the minimum player payoff.
Republican maximizes the maximum player payoff. Liberatarian maximizes the payoff for a specific player.
These different objectives can be specified with the CorrelatedEquilibriumSolver.CorrelatedEquilibriumObjective
enumeration.
The primary method
to use to get the equilibrium is the getCorrelatedEQJointStrategy(CorrelatedEquilibriumObjective, double[][], double[][])
method.
This class depends on the SCPSolver library.
1. Greenwald, Amy, Keith Hall, and Roberto Serrano. "Correlated Q-learning." ICML. Vol. 3. 2003.
Modifier and Type | Class and Description |
---|---|
static class |
CorrelatedEquilibriumSolver.CorrelatedEquilibriumObjective
The four different equilibrium objectives that can be used:
UTILITARIAN, EGALITARIAN, REPUBLICAN, and LIBERTARIAN.
|
Modifier and Type | Method and Description |
---|---|
protected static int |
addCorrelatedEquilibriumMainConstraints(scpsolver.problems.LinearProgram lp,
double[][] payoffRow,
double[][] payoffCol,
int n,
int cCount)
Adds the common LP constraints for the correlated equilribum problem: rationalaity constraits (no agent has a motivation to diverge
from a joint policy selection), the probability of all joint action variables must sum to 1, and all joint action variables are lower
bound at 0.0.
|
static double[][] |
getCorrelatedEQJointStrategy(CorrelatedEquilibriumSolver.CorrelatedEquilibriumObjective objectiveType,
double[][] payoffRow,
double[][] payoffCol)
Returns the correlated equilibrium joint strategy in a 2D double matrix, which represents the probability of each joint actino (where rows
are player 1s actions and columns are player 2's actions).
|
static double[][] |
getCorrelatedEQJointStrategyEgalitarian(double[][] payoffRow,
double[][] payoffCol)
Returns the correlated equilibrium joint strategy in a 2D double matrix for the Egalitarian objective.
|
static double[][] |
getCorrelatedEQJointStrategyLibertarianForCol(double[][] payoffRow,
double[][] payoffCol)
Returns the correlated equilibrium joint strategy in a 2D double matrix for the Libertarian objective.
|
static double[][] |
getCorrelatedEQJointStrategyLibertarianForRow(double[][] payoffRow,
double[][] payoffCol)
Returns the correlated equilibrium joint strategy in a 2D double matrix for the Libertarian objective.
|
static double[][] |
getCorrelatedEQJointStrategyRepublican(double[][] payoffRow,
double[][] payoffCol)
Returns the correlated equilibrium joint strategy in a 2D double matrix for the Republican objective.
|
static double[][] |
getCorrelatedEQJointStrategyUtilitarian(double[][] payoffRow,
double[][] payoffCol)
Returns the correlated equilibrium joint strategy in a 2D double matrix for the Utilitarian objective.
|
static double[] |
getEgalitarianObjective(double[][] payoffRow,
double[][] payoffCol)
Returns the egalitarian objective for the given payoffs for the row and column player.
|
static double[] |
getRepublicanObjective(double[][] payoffForQueryPlayer)
Returns the republican/libertarian objective for the given player's payoffs that are to be maximized.
|
static double[] |
getUtilitarianObjective(double[][] payoffRow,
double[][] payoffCol)
Returns the utilitarian objective for the given payoffs for the row and column player.
|
protected static boolean |
isZeroArray(double[] a)
Returns true if a if the input array is all zeros.
|
protected static int |
jointIndex(int r,
int c,
int nCols)
Returns the 1D array index for a given row and column of a matrix with the given number of columns.
|
static void |
main(java.lang.String[] args) |
protected static double[][] |
removeZeroRows(double[][] m)
Takes an input 2D double matrix and returns a new matrix will all the all zero rows removed.
|
static double[] |
roundNegativesToZero(double[] a)
Creates a new 1D double array with all negative values rounded to 0.
|
protected static int[] |
rowCol(int i,
int nCols)
Returns the 2D row column index in a matrix of a given number of columns for a given 1D array index.
|
protected static double[][] |
runLPAndGetJointActionProbs(scpsolver.problems.LinearProgram lp,
int nRows,
int nCols)
Helper method for running the linear program optimization (after its constraints have already been set) and returning
the result in the form of the 2D double matrix joint strategy.
|
public static void main(java.lang.String[] args)
public static double[][] getCorrelatedEQJointStrategy(CorrelatedEquilibriumSolver.CorrelatedEquilibriumObjective objectiveType, double[][] payoffRow, double[][] payoffCol)
CorrelatedEquilibriumSolver.CorrelatedEquilibriumObjective.LIBERTARIAN
objective
is selected, it will maximize with respect to the row player's payoffs and return the strategy from their perspecitve. Therefore
for a combined joint strategy for each player in libertrain, this method should then be called for each player
and then combined as necessary to get a final joint strategy that will be followed by the players.objectiveType
- the maximizing objective for the correlated equilibrium being solved.payoffRow
- the payoff for the player whose actions correspond to the rows of the matrixpayoffCol
- the payoff for the player whose actions correspond to the columns of the matrixpublic static double[][] getCorrelatedEQJointStrategyUtilitarian(double[][] payoffRow, double[][] payoffCol)
payoffRow
- the payoff for the player whose actions correspond to the rows of the matrixpayoffCol
- the payoff for the player whose actions correspond to the columns of the matrixpublic static double[][] getCorrelatedEQJointStrategyEgalitarian(double[][] payoffRow, double[][] payoffCol)
payoffRow
- the payoff for the player whose actions correspond to the rows of the matrixpayoffCol
- the payoff for the player whose actions correspond to the columns of the matrixpublic static double[][] getCorrelatedEQJointStrategyRepublican(double[][] payoffRow, double[][] payoffCol)
payoffRow
- the payoff for the player whose actions correspond to the rows of the matrixpayoffCol
- the payoff for the player whose actions correspond to the columns of the matrixpublic static double[][] getCorrelatedEQJointStrategyLibertarianForRow(double[][] payoffRow, double[][] payoffCol)
payoffRow
- the payoff for the player whose actions correspond to the rows of the matrixpayoffCol
- the payoff for the player whose actions correspond to the columns of the matrixpublic static double[][] getCorrelatedEQJointStrategyLibertarianForCol(double[][] payoffRow, double[][] payoffCol)
payoffRow
- the payoff for the player whose actions correspond to the rows of the matrixpayoffCol
- the payoff for the player whose actions correspond to the columns of the matrixprotected static double[][] runLPAndGetJointActionProbs(scpsolver.problems.LinearProgram lp, int nRows, int nCols)
lp
- the linear program to be optimizednRows
- the number of rows in the bimatrix (number of player 1 actions)nCols
- the number of columns in the bimatrix (number of player 2 actions)protected static int addCorrelatedEquilibriumMainConstraints(scpsolver.problems.LinearProgram lp, double[][] payoffRow, double[][] payoffCol, int n, int cCount)
lp
- the lineary program to which the constraints will be addedpayoffRow
- the payoffs for the row playerpayoffCol
- the payoffs for the col playern
- the total number of lp variablescCount
- the number of constraints that have been added to the lp so farpublic static double[] getUtilitarianObjective(double[][] payoffRow, double[][] payoffCol)
payoffRow
- the row player's payoffspayoffCol
- the column player's payoffspublic static double[] getEgalitarianObjective(double[][] payoffRow, double[][] payoffCol)
payoffRow
- the row player's payoffspayoffCol
- the column player's payoffspublic static double[] getRepublicanObjective(double[][] payoffForQueryPlayer)
payoffForQueryPlayer
- the given player's player's payoffs that are to be maximizedprotected static int jointIndex(int r, int c, int nCols)
r
- the row indexc
- the column indexnCols
- the number of columns in the matrixprotected static int[] rowCol(int i, int nCols)
i
- the 1D array indexnCols
- the number of columns in the matrixprotected static double[][] removeZeroRows(double[][] m)
m
- input 2D double matrixprotected static boolean isZeroArray(double[] a)
a
- the input arraypublic static double[] roundNegativesToZero(double[] a)
a
- and input array