]>
gitweb.michael.orlitzky.com - dunshire.git/blob - errors.py
2 Errors that can occur when solving a linear game.
5 from cvxopt
import matrix
8 class GameUnsolvableException(Exception):
10 Every linear game has a solution (this follows from a general
11 min-max theorem). If we can't solve the conic program associated
12 with a linear game, then something is wrong with either the model of
16 tpl
= 'Solution failed with result "{:s}."\n' \
17 'CVXOPT returned:\n{!s}'
18 return tpl
.format(self
._solution
_dict
['status'],
19 self
._pretty
_print
_dict
(self
._solution
_dict
))
22 def __init__(self
, solution_dict
):
24 Create a new GameUnsolvableException object.
28 - ``solution_dict`` -- the solution dictionary returned from the
32 self
._solution
_dict
= solution_dict
35 def _pretty_print_dict(self
, solution_dict
):
37 Return a pretty-printed string representation of a CVXOPT
41 for (k
,v
) in solution_dict
.items():
42 if isinstance(v
, matrix
):
43 # Display matrices on their own lines, indented.
44 result
+= ' {:s}:'.format(k
)
45 colvec
= '\n{!s}'.format(v
)
46 result
+= '\n '.join(colvec
.splitlines())
49 result
+= ' {:s}: {!s}\n'.format(k
,v
)