+"""
+Symmetric linear games and their solutions.
+
+This module contains the main SymmetricLinearGame class that knows how
+to solve a linear game.
+"""
+
from cvxopt import matrix, printing, solvers
from cones import CartesianProduct
'Player 1 optimal:{:s}\n' \
'Player 2 optimal:{:s}\n'
- p1 = '\n{!s}'.format(self.player1_optimal())
- p1 = '\n '.join(p1.splitlines())
- p2 = '\n{!s}'.format(self.player2_optimal())
- p2 = '\n '.join(p2.splitlines())
+ p1_str = '\n{!s}'.format(self.player1_optimal())
+ p1_str = '\n '.join(p1_str.splitlines())
+ p2_str = '\n{!s}'.format(self.player2_optimal())
+ p2_str = '\n '.join(p2_str.splitlines())
- return tpl.format(self.game_value(), p1, p2)
+ return tpl.format(self.game_value(), p1_str, p2_str)
def game_value(self):
raise ValueError('the point e2 must lie in the interior of K')
def solution(self):
-
- C = CartesianProduct(K, K)
+ C = CartesianProduct(self._K, self._K)
b = matrix([1], tc='d')
# A column of zeros that fits K.
zero = matrix(0, (self._K.dimension(), 1), tc='d')
h = matrix([zero, zero])
c = matrix([-1, zero])
- G = append_row(append_col(zero, -identity(K.dimension())),
- append_col(self._e1, -self._L))
- A = matrix([0, self._e1], (1, K.dimension() + 1), 'd')
+ G = append_row(append_col(zero, -identity(self._K.dimension())),
+ append_col(self._e1, -self._L))
+ A = matrix([0, self._e1], (1, self._K.dimension() + 1), 'd')
soln_dict = solvers.conelp(c, G, h, C.cvxopt_dims(), A, b)