Fix coefficients for objective function

This commit is contained in:
Evgeniy L 2016-01-11 16:16:39 +03:00
parent 3aa3ef23dd
commit 4234aa4e24
2 changed files with 4 additions and 5 deletions

View File

@ -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

View File

@ -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