Skip to content

Commit

Permalink
Adds option to take absolute difference
Browse files Browse the repository at this point in the history
  • Loading branch information
sjstreicher committed Mar 16, 2018
1 parent ebaadfa commit 8c7f76a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ranking/noderank.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,8 @@ def gainmatrix_preprocessing(gainmatrix):
return modgainmatrix, currentmean


def dif_gainmatrix_preprocessing(gainmatrix):
"""Only keeps positive elements of the difference gain matrix.
def dif_gainmatrix_preprocessing(gainmatrix, method='floor'):
"""
WIP
Expand All @@ -473,7 +473,13 @@ def dif_gainmatrix_preprocessing(gainmatrix):

for col, row in itertools.izip(gainmatrix.nonzero()[0],
gainmatrix.nonzero()[1]):
modgainmatrix[col, row] = max(0, gainmatrix[col, row])
if method == 'floor':
# Only keeps positive elements of the difference gain matrix
modgainmatrix[col, row] = max(0, gainmatrix[col, row])
elif method == 'abs':
# Alternative: Take absolute of change
modgainmatrix[col, row] = abs(gainmatrix[col, row])


return modgainmatrix

Expand Down Expand Up @@ -618,7 +624,7 @@ def dorankcalc(noderankdata, scenario, datadir, typename, rank_method,
dif_gainmatrix = dif_gainmatrices[index]
# Take only positive values for now due to convergence issues
# TODO: Investigate proper handling of negative edge changes
mod_dif_gainmatrix = dif_gainmatrix_preprocessing(dif_gainmatrix)
mod_dif_gainmatrix = dif_gainmatrix_preprocessing(dif_gainmatrix, method='floor')

delays = delaymatrices[index]

Expand Down

0 comments on commit 8c7f76a

Please sign in to comment.