]> gitweb.michael.orlitzky.com - dunshire.git/commitdiff
Use "2" as a numerically-better factor in player[12]_start().
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 11 Nov 2016 14:47:48 +0000 (09:47 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 13 Nov 2016 20:19:27 +0000 (15:19 -0500)
dunshire/games.py

index 0a473915716de7f4be4ce7d99cbc64d87c960795..f9877b334cfa3bcf2d60c6269ecbf4340de24eb1 100644 (file)
@@ -4,8 +4,6 @@ Symmetric linear games and their solutions.
 This module contains the main :class:`SymmetricLinearGame` class that
 knows how to solve a linear game.
 """
 This module contains the main :class:`SymmetricLinearGame` class that
 knows how to solve a linear game.
 """
-from math import sqrt
-
 from cvxopt import matrix, printing, solvers
 from .cones import CartesianProduct, IceCream, NonnegativeOrthant
 from .errors import GameUnsolvableException, PoorScalingException
 from cvxopt import matrix, printing, solvers
 from .cones import CartesianProduct, IceCream, NonnegativeOrthant
 from .errors import GameUnsolvableException, PoorScalingException
@@ -833,9 +831,10 @@ class SymmetricLinearGame:
             # 45-45-90 triangle and the shortest distance to the
             # outside of the cone should be 1/sqrt(2) of that.
             # It works in R^2, so it works everywhere, right?
             # 45-45-90 triangle and the shortest distance to the
             # outside of the cone should be 1/sqrt(2) of that.
             # It works in R^2, so it works everywhere, right?
+            # We use "2" because it's better numerically than sqrt(2).
             height = self.e1()[0]
             radius = norm(self.e1()[1:])
             height = self.e1()[0]
             radius = norm(self.e1()[1:])
-            dist = (height - radius) / sqrt(2)
+            dist = (height - radius) / 2
         else:
             raise NotImplementedError
 
         else:
             raise NotImplementedError
 
@@ -862,9 +861,10 @@ class SymmetricLinearGame:
             # 45-45-90 triangle and the shortest distance to the
             # outside of the cone should be 1/sqrt(2) of that.
             # It works in R^2, so it works everywhere, right?
             # 45-45-90 triangle and the shortest distance to the
             # outside of the cone should be 1/sqrt(2) of that.
             # It works in R^2, so it works everywhere, right?
+            # We use "2" because it's better numerically than sqrt(2).
             height = self.e2()[0]
             radius = norm(self.e2()[1:])
             height = self.e2()[0]
             radius = norm(self.e2()[1:])
-            dist = (height - radius) / sqrt(2)
+            dist = (height - radius) / 2
         else:
             raise NotImplementedError
 
         else:
             raise NotImplementedError