X-Git-Url: https://gitweb.michael.orlitzky.com/?p=dunshire.git;a=blobdiff_plain;f=dunshire%2Fgames.py;h=08a6d6f342b59f93d26fbdeae320034f95004321;hp=1f3a15a0b261c723f7f5c65d66d255fd2b9fdc99;hb=eb940c4312540b7db2f43a8c4067aff6e94928de;hpb=528182f894a8329a2d3d36c4a58aa4a17cf29f71 diff --git a/dunshire/games.py b/dunshire/games.py index 1f3a15a..08a6d6f 100644 --- a/dunshire/games.py +++ b/dunshire/games.py @@ -667,24 +667,48 @@ class SymmetricLinearGame: >>> norm(s1.player2_optimal() - s2.player2_optimal()) < ABS_TOL True + This game cannot be solved with the default tolerance, but it + can be solved with a weaker one:: + + >>> from dunshire import * + >>> from dunshire.options import ABS_TOL + >>> L = [[ 0.58538005706658102767, 1.53764301129883040886], + ... [-1.34901059721452210027, 1.50121179114155500756]] + >>> K = NonnegativeOrthant(2) + >>> e1 = [1.04537193228494995623, 1.39699624965841895374] + >>> e2 = [0.35326554172108337593, 0.11795703527854853321] + >>> SLG = SymmetricLinearGame(L,K,e1,e2) + >>> print(SLG._try_solution(ABS_TOL / 10)) + Traceback (most recent call last): + ... + dunshire.errors.GameUnsolvableException: Solution failed... + >>> print(SLG._try_solution(ABS_TOL)) + Game value: 9.1100945 + Player 1 optimal: + [-0.0000000] + [ 8.4776631] + Player 2 optimal: + [0.0000000] + [0.7158216] + """ try: - solvers.options['show_progress'] = options.VERBOSE - solvers.options['abs_tol'] = tolerance + opts = {'show_progress': options.VERBOSE, 'abstol': tolerance} soln_dict = solvers.conelp(self._c(), self._G(), self._h(), self._C().cvxopt_dims(), self._A(), - self._b()) - except ValueError as e: - if str(e) == 'math domain error': + self._b(), + options=opts) + except ValueError as error: + if str(error) == 'math domain error': # Oops, CVXOPT tried to take the square root of a # negative number. Report some details about the game # rather than just the underlying CVXOPT crash. raise PoorScalingException(self) else: - raise e + raise error # The optimal strategies are named ``p`` and ``q`` in the # background documentation, and we need to extract them from