X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FLinearProgramming.py;h=4211058df56d904f2d5bae46c22b8e58848b0f35;hb=b49d0e70000050fa22fc74e8cf94f33cb4b6238d;hp=ceb2e5fca184f5825720406ef3db6c7a30c6cad4;hpb=9e873928a42a91b468e56bf95217f8504c12dad2;p=dead%2Fcensus-tools.git diff --git a/src/LinearProgramming.py b/src/LinearProgramming.py index ceb2e5f..4211058 100644 --- a/src/LinearProgramming.py +++ b/src/LinearProgramming.py @@ -382,6 +382,15 @@ class SimplexIteration(object): self._solution_vector = array(value) + @property + def variables(self): + vars = [] + for idx in range(1, len(self.solution_vector)+1): + vars.append("x" + str(idx)) + + return vars + + @property def basic_variables(self): # The current set of basic variables. Constructed from the @@ -461,6 +470,13 @@ class SimplexIteration(object): bm = delete(bm, idxs, axis=1) return bm.tolist() + + def objective_function_value(self): + c = array(self.objective_coefficients) + sv = array(self.solution_vector) + return dot(sv, c) + + def reduced_cost(self, idx): # Find the reduced cost ofthe variable whose column has index # idx.