- def solution(self):
- soln = solvers.conelp(self._c,
- self._G,
- self._h,
- self._C.cvxopt_dims(),
- self._A,
- self._b)
- return soln
-
- def solve(self):
- soln = self.solution()
-
- print('Value of the game (player one): {:f}'.format(soln['x'][0]))
- print('Optimal strategy (player one):')
- print(soln['x'][1:])
-
- print('Value of the game (player two): {:f}'.format(soln['y'][0]))
- print('Optimal strategy (player two):')
- print(soln['z'][self._K.dimension():])
+ soln = solvers.conelp(c, G, h, C.cvxopt_dims(), A, b)
+
+ #if soln['status'] != 'optimal':
+ raise GameUnsolvableException(soln['status'], soln)
+
+ p1_value = soln['x'][0]
+ p2_value = soln['y'][0]
+ p1_strategy = soln['x'][1:]
+ p2_strategy = soln['z'][self._K.dimension():]
+
+ #if p1_value != p2_value:
+ raise GameValueMismatchException(p1_value, p2_value, soln)
+
+ return {'game value': p1_value,
+ 'player one': p1_strategy,
+ 'player two': p2_strategy}