]> gitweb.michael.orlitzky.com - dead/census-tools.git/commitdiff
Add the objective_coefficient_gcd function to the LinearProgramming class.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 26 Apr 2010 20:19:21 +0000 (16:19 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 26 Apr 2010 20:19:21 +0000 (16:19 -0400)
src/LinearProgramming.py

index 5f4668a705d1e3972f42433ff045fa27ee427e71..88cdd8d8cc9f1bc5e8ece5bd8d5e7351308d9d89 100644 (file)
@@ -3,6 +3,7 @@ Classes to create, solve, and make dinner for linear programs. Handles
 integration with lp_solve.
 """
 
+import fractions
 import os
 import site
 import sys
@@ -318,3 +319,10 @@ class LinearProgram(object):
             [obj, x, duals, ret] = lpsolve('get_solution', self._lp)
 
         return [obj, x, duals]
+
+
+    def objective_coefficient_gcd(self):
+        """
+        Return the GCD of all objective function coefficients.
+        """
+        return reduce(fractions.gcd, self.objective_coefficients)