From 4234aa4e2437deca77a7635eb0e12e3ebd197a77 Mon Sep 17 00:00:00 2001 From: Evgeniy L Date: Mon, 11 Jan 2016 16:16:39 +0300 Subject: [PATCH] Fix coefficients for objective function --- bareon_dynamic_allocator/allocators.py | 6 ++---- bareon_dynamic_allocator/sequences.py | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bareon_dynamic_allocator/allocators.py b/bareon_dynamic_allocator/allocators.py index 7096de9..6624c72 100644 --- a/bareon_dynamic_allocator/allocators.py +++ b/bareon_dynamic_allocator/allocators.py @@ -27,7 +27,6 @@ from bareon_dynamic_allocator.parser import Parser from bareon_dynamic_allocator.sequences import CrossSumInequalitySequence - LOG = log.getLogger(__name__) @@ -475,10 +474,9 @@ class DynamicAllocationLinearProgram(object): coefficients[c_i] = NONE_ORDER_COEFF continue - coeff = SET_COEFF * (i_set + 1) if space.best_with_disks: if d_i in space.best_with_disks: - coefficients[c_i] += coeff + coefficients[c_i] += SET_COEFF else: # If current disk is not in the set, set it to 0 # TODO isn't it better to leave there order coefficient? @@ -488,7 +486,7 @@ class DynamicAllocationLinearProgram(object): # Don't allcoate coefficient for the spaces # which have no best_with_disks, on best_with_disks if d_i in not_best_disks: - coefficients[c_i] += coeff + coefficients[c_i] += SET_COEFF # By default the algorithm tries to minimize the solution # we should invert sign, in order to make it a maximization diff --git a/bareon_dynamic_allocator/sequences.py b/bareon_dynamic_allocator/sequences.py index a3d180d..663fd57 100644 --- a/bareon_dynamic_allocator/sequences.py +++ b/bareon_dynamic_allocator/sequences.py @@ -35,6 +35,7 @@ class BaseSequence(object): class CrossSumInequalitySequence(BaseSequence): """An implementaion of a sequence from 1 to n + https://oeis.org/A002620 http://math.stackexchange.com/a/1596812/301008 """ @@ -43,7 +44,7 @@ class CrossSumInequalitySequence(BaseSequence): raise StopIteration else: self.previous = int(math.floor((self.current + 1) / 2.0) * - math.floor((self.current + 2) / 2.0)) + math.floor((self.current + 2) / 2.0)) self.n_current += 1 self.current += 1