Fix coefficients for objective function
This commit is contained in:
parent
3aa3ef23dd
commit
4234aa4e24
@ -27,7 +27,6 @@ from bareon_dynamic_allocator.parser import Parser
|
|||||||
from bareon_dynamic_allocator.sequences import CrossSumInequalitySequence
|
from bareon_dynamic_allocator.sequences import CrossSumInequalitySequence
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -475,10 +474,9 @@ class DynamicAllocationLinearProgram(object):
|
|||||||
coefficients[c_i] = NONE_ORDER_COEFF
|
coefficients[c_i] = NONE_ORDER_COEFF
|
||||||
continue
|
continue
|
||||||
|
|
||||||
coeff = SET_COEFF * (i_set + 1)
|
|
||||||
if space.best_with_disks:
|
if space.best_with_disks:
|
||||||
if d_i in space.best_with_disks:
|
if d_i in space.best_with_disks:
|
||||||
coefficients[c_i] += coeff
|
coefficients[c_i] += SET_COEFF
|
||||||
else:
|
else:
|
||||||
# If current disk is not in the set, set it to 0
|
# If current disk is not in the set, set it to 0
|
||||||
# TODO isn't it better to leave there order coefficient?
|
# TODO isn't it better to leave there order coefficient?
|
||||||
@ -488,7 +486,7 @@ class DynamicAllocationLinearProgram(object):
|
|||||||
# Don't allcoate coefficient for the spaces
|
# Don't allcoate coefficient for the spaces
|
||||||
# which have no best_with_disks, on best_with_disks
|
# which have no best_with_disks, on best_with_disks
|
||||||
if d_i in not_best_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
|
# By default the algorithm tries to minimize the solution
|
||||||
# we should invert sign, in order to make it a maximization
|
# we should invert sign, in order to make it a maximization
|
||||||
|
@ -35,6 +35,7 @@ class BaseSequence(object):
|
|||||||
class CrossSumInequalitySequence(BaseSequence):
|
class CrossSumInequalitySequence(BaseSequence):
|
||||||
"""An implementaion of a sequence from 1 to n
|
"""An implementaion of a sequence from 1 to n
|
||||||
|
|
||||||
|
https://oeis.org/A002620
|
||||||
http://math.stackexchange.com/a/1596812/301008
|
http://math.stackexchange.com/a/1596812/301008
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ class CrossSumInequalitySequence(BaseSequence):
|
|||||||
raise StopIteration
|
raise StopIteration
|
||||||
else:
|
else:
|
||||||
self.previous = int(math.floor((self.current + 1) / 2.0) *
|
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.n_current += 1
|
||||||
self.current += 1
|
self.current += 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user