From 23a78f1c16aa4654b74a1908a091661fc6d551a2 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 6 Oct 2016 12:48:48 -0400 Subject: [PATCH] Fix lint warnings and a few variable errors in symmetric_linear_game.py. --- symmetric_linear_game.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/symmetric_linear_game.py b/symmetric_linear_game.py index 694e09f..e92e820 100644 --- a/symmetric_linear_game.py +++ b/symmetric_linear_game.py @@ -1,3 +1,10 @@ +""" +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 @@ -34,12 +41,12 @@ class Solution: '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): @@ -101,16 +108,15 @@ class SymmetricLinearGame: 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) -- 2.43.2