burlap.behavior.stochasticgames.solvers

## Class GeneralBimatrixSolverTools

• java.lang.Object
• burlap.behavior.stochasticgames.solvers.GeneralBimatrixSolverTools

• ```public class GeneralBimatrixSolverTools
extends java.lang.Object```
A class holding static methods for performing common operations on bimatrix games.
Author:
James MacGlashan
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double[]` ```constantDoubleArray(double constant, int dimension)```
Returns a double array of a given dimension filled with the same value.
`static double` ```dot(double[] a, double[] b)```
Returns the dot product of two vectors
`static double[]` ```expectedPayoffs(double[][] payoffRowPlayer, double[][] payoffColPlayer, double[][] jointActionProbabilities)```
`static double[]` ```expectedPayoffs(double[][] payoffRowPlayer, double[][] payoffColPlayer, double[] rowPlayerStrategy, double[] colPlayerStrategy)```
Computes the expected payoff for each player in a bimatrix game according to their strategies.
`static double[]` `getNegatedArray(double[] a)`
Returns a negated version of the input array in a new array object.
`static double[][]` `getNegatedMatrix(double[][] m)`
Returns a negated version of the input matrix in a new matrix object.
`static double[][]` `getPositiveMatrix(double[][] m)`
Creates a new matrix (m2) whose values are the values of m shifted by a constant amount c such that all the values in m2 are positive.
`static double[][]` ```jointActionProbabilities(double[] rowPlayerStrategy, double[] colPlayerStrategy)```
Computes the joint action probabilities accroding to each player's strategy and returns it as a matrix.
`static double[]` `marginalizeColPlayerStrategy(double[][] jointActionProbabilities)`
Returns the column player's strategy by marginalizing it out from a joint action probability distribution represented as a matrix
`static double[]` `marginalizeRowPlayerStrategy(double[][] jointActionProbabilities)`
Returns the row player's strategy by marginalizing it out from a joint action probability distribution represented as a matrix
`static double[][]` `transposeMatrix(double[][] m)`
Creates and returns a new matrix that is a transpose of m.
`static double[]` ```zero1Array(int index, int dim)```
Creates an array that is all zeros except one index which has a value of 1.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Method Detail

• #### expectedPayoffs

```public static double[] expectedPayoffs(double[][] payoffRowPlayer,
double[][] payoffColPlayer,
double[] rowPlayerStrategy,
double[] colPlayerStrategy)```
Computes the expected payoff for each player in a bimatrix game according to their strategies.
Parameters:
`payoffRowPlayer` - the payoff for player 1. Rows are player 1's actions; columns player 2's.
`payoffColPlayer` - the payoff for player 2. Rows are player 1's actions; columns player 2's.
`rowPlayerStrategy` - the strategy for player 1. Should be array with dimension equal to the number of player 1's actions.
`colPlayerStrategy` - the stratgy for player 2. Should be array with dimension equal to the number of player 2's actions.
Returns:
a double array of dimension two. Index 0 holds the first player's expected payoff; index 1 holds the second player's expected payoff.
• #### expectedPayoffs

```public static double[] expectedPayoffs(double[][] payoffRowPlayer,
double[][] payoffColPlayer,
double[][] jointActionProbabilities)```
• #### jointActionProbabilities

```public static double[][] jointActionProbabilities(double[] rowPlayerStrategy,
double[] colPlayerStrategy)```
Computes the joint action probabilities accroding to each player's strategy and returns it as a matrix.
Parameters:
`rowPlayerStrategy` - the strategy of the player whose actions will be represented by the rows of the returned matrix.
`colPlayerStrategy` - the strategy of the player whose actions will represented by the columns of the returned matrix.
Returns:
the joint action probabilities in a matrix. m[i][j] represents the probability of the row player selecting action i and the column player selecting action j.
• #### marginalizeRowPlayerStrategy

`public static double[] marginalizeRowPlayerStrategy(double[][] jointActionProbabilities)`
Returns the row player's strategy by marginalizing it out from a joint action probability distribution represented as a matrix
Parameters:
`jointActionProbabilities` - a matrix of 2-player joint aciton probability distribution
Returns:
the row player's strategy
• #### marginalizeColPlayerStrategy

`public static double[] marginalizeColPlayerStrategy(double[][] jointActionProbabilities)`
Returns the column player's strategy by marginalizing it out from a joint action probability distribution represented as a matrix
Parameters:
`jointActionProbabilities` - a matrix of 2-player joint aciton probability distribution
Returns:
the column player's strategy
• #### constantDoubleArray

```public static double[] constantDoubleArray(double constant,
int dimension)```
Returns a double array of a given dimension filled with the same value.
Parameters:
`constant` - the constant value with which the double array is filled.
`dimension` - the dimension of the double array.
Returns:
a double array of size dimension filled with the value constant.
• #### getNegatedMatrix

`public static double[][] getNegatedMatrix(double[][] m)`
Returns a negated version of the input matrix in a new matrix object. That is, a new 2D double array (m2) is created with the m2[i][j] value set to -1 * m[i][j].
Parameters:
`m` - the input matrix.
Returns:
the negated matrix.
• #### getNegatedArray

`public static double[] getNegatedArray(double[] a)`
Returns a negated version of the input array in a new array object. That is, a new double array (b) is created with b[i] value set to -1 * a[i].
Parameters:
`a` - the input double array
Returns:
a negated version of the input array
• #### getPositiveMatrix

`public static double[][] getPositiveMatrix(double[][] m)`
Creates a new matrix (m2) whose values are the values of m shifted by a constant amount c such that all the values in m2 are positive. If all entries in m are already postive, then c = 0 (no shift). Otherwise, c = 1 - min(m).
Parameters:
`m` - the input matrix.
Returns:
a constant shifted version of m that is positive.
• #### transposeMatrix

`public static double[][] transposeMatrix(double[][] m)`
Creates and returns a new matrix that is a transpose of m.
Parameters:
`m` - the input matrix.
Returns:
the transposed version of m.
• #### dot

```public static double dot(double[] a,
double[] b)```
Returns the dot product of two vectors
Parameters:
`a` - first vector
`b` - second vector
Returns:
the dot product
• #### zero1Array

```public static double[] zero1Array(int index,
int dim)```
Creates an array that is all zeros except one index which has a value of 1. For example zero1Array(2, 4) will return {0., 0., 1., 0.}.
Parameters:
`index` - the index which will have a valu of 1
`dim` - the dimension of the array to create
Returns:
an array that is all zeros except one index which has a value of 1.