From: Michael Orlitzky Date: Sat, 12 Nov 2016 12:35:12 +0000 (-0500) Subject: Add an epsilon_scale() method for games. X-Git-Tag: 0.1.0~32 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dunshire.git;a=commitdiff_plain;h=cd77ba5250ed98ece623730c26af845366847487 Add an epsilon_scale() method for games. When testing, we often need to know how lenient to be when making comparisons. Trying to figure out just how lenient has been a huge source of problems, and ultimately, the scaling factor (applied to ABS_TOL) probably depends on properties of the solution. This commit adds a new method, epsilon_scale(), that returns a safe (very lenient) scaling factor. If things are within epsilon_scale() times ABS_TOL, we consider then equal, or optimal, or whatever. --- diff --git a/dunshire/games.py b/dunshire/games.py index a1ac0f5..ae1426a 100644 --- a/dunshire/games.py +++ b/dunshire/games.py @@ -853,6 +853,15 @@ class SymmetricLinearGame: self._L_specnorm_value = specnorm(self.L()) return self._L_specnorm_value + def epsilon_scale(self, solution): + # Don't return anything smaller than 1... we can't go below + # out "minimum tolerance." + norm_p1_opt = norm(solution.player1_optimal()) + norm_p2_opt = norm(solution.player2_optimal()) + scale = self._L_specnorm()*(norm_p1_opt + norm_p2_opt) + return max(1, scale) + + def solution(self): """ Solve this linear game and return a :class:`Solution`.