From 72e0a1e1729a2c5693c94d7a835b0735f84d13ed Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 26 Apr 2010 16:19:21 -0400 Subject: [PATCH] Add the objective_coefficient_gcd function to the LinearProgramming class. --- src/LinearProgramming.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/LinearProgramming.py b/src/LinearProgramming.py index 5f4668a..88cdd8d 100644 --- a/src/LinearProgramming.py +++ b/src/LinearProgramming.py @@ -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) -- 2.44.2