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,
... '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
[ 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
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)
# worst, since they indicate that CVXOPT is convinced the
# problem is infeasible (and that cannot happen).
if soln_dict['status'] in ['primal infeasible', 'dual infeasible']:
- raise GameUnsolvableException(soln_dict)
+ raise GameUnsolvableException(self, soln_dict)
elif soln_dict['status'] == 'unknown':
# When we get a status of "unknown", we may still be able
# to salvage a solution out of the returned
# primal/dual optimal solutions are within the cone (to a
# tolerance as well).
if abs(p1_value - p2_value) > options.ABS_TOL:
- raise GameUnsolvableException(soln_dict)
+ raise GameUnsolvableException(self, soln_dict)
if (p1_optimal not in self._K) or (p2_optimal not in self._K):
- raise GameUnsolvableException(soln_dict)
+ raise GameUnsolvableException(self, soln_dict)
return Solution(p1_value, p1_optimal, p2_optimal)