X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fdunshire%2Ferrors.py;h=b63344a0311e9c843cdeb189c903902de4a2179b;hb=dd98bb15beba1e9eae310598e1b55a7dd9d4aa01;hp=020186475b2a920f8425ffe0be76b3a27625de85;hpb=fa8fa4d690c5f30f7d5fee1818a9b4c15f52c5ff;p=dunshire.git diff --git a/src/dunshire/errors.py b/src/dunshire/errors.py index 0201864..b63344a 100644 --- a/src/dunshire/errors.py +++ b/src/dunshire/errors.py @@ -55,6 +55,12 @@ class GameUnsolvableException(Exception): Examples -------- + >>> from dunshire import * + >>> K = IceCream(2) + >>> L = [[1,2],[3,4]] + >>> e1 = [1, 0.1] + >>> e2 = [3, 0.1] + >>> G = SymmetricLinearGame(L,K,e1,e2) >>> d = {'residual as dual infeasibility certificate': None, ... 'y': matrix([1,1]), ... 'dual slack': 8.779496368228267e-10, @@ -72,8 +78,16 @@ class GameUnsolvableException(Exception): ... 'gap': None, ... 'residual as primal infeasibility certificate': ... 3.986246886102996e-09} - >>> print(GameUnsolvableException(d)) + >>> print(GameUnsolvableException(G,d)) Solution failed with result "primal infeasible." + The linear game (L, K, e1, e2) where + L = [ 1 2] + [ 3 4], + K = Lorentz "ice cream" cone in the real 2-space, + e1 = [1.0000000] + [0.1000000], + e2 = [3.0000000] + [0.1000000]. CVXOPT returned: dual infeasibility: None dual objective: 1.0 @@ -98,11 +112,12 @@ class GameUnsolvableException(Exception): [ 0] [ 0] """ - def __init__(self, solution_dict): + def __init__(self, game, solution_dict): """ Create a new GameUnsolvableException object. """ super().__init__() + self._game = game self._solution_dict = solution_dict @@ -112,14 +127,13 @@ class GameUnsolvableException(Exception): The returned representation highlights the "status" field of the CVXOPT dictionary, since that should explain what went - wrong. The full CVXOPT solution dictionary is included after the - status. + wrong. The game details and full CVXOPT solution dictionary is + included after the status. """ tpl = 'Solution failed with result "{:s}."\n' \ + '{!s}\n' \ 'CVXOPT returned:\n {!s}' cvx_lines = _pretty_format_dict(self._solution_dict).splitlines() - # Indent the whole dict by two spaces. cvx_str = '\n '.join(cvx_lines) - - return tpl.format(self._solution_dict['status'], cvx_str) + return tpl.format(self._solution_dict['status'], self._game, cvx_str)