Commit 7112634b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e5aef07a
......@@ -84,6 +84,9 @@ import itertools
import re
inf = float('inf')
import numpy as np
import scipy.optimize
# Tree represents a tree node.
class Tree(object):
......@@ -241,18 +244,18 @@ def Restructure(ztree, newStructure):
assert isinstance(rzn.node, (ztreeType, zbucketType))
for rn in RNv:
assert isinstance(rn, _NodeInRange)
assert isinstance(rn.node, (Tree|Bucket))
assert isinstance(rn.node, (Tree,Bucket))
assert not hasattr(rn.node, 'Z')
rn.node.Z = None
# prepare cost matrix
C = np.zeros((len(RNv), len(RZv)))
for j in range(RNv): # "workers"
for i in range(RZv): # "jobs"
C[j,i] = D(A[i], B[j])
C[j,i] = D(RZv[i], RNv[j])
# find the assignments.
# TODO try to avoid scipy dependency; we could also probably make
# assignments more efficiently taking that Av and Bv are key↑ and the
# property of D function so that if B2 > B1 (all keys in B2 > all keys
......@@ -275,10 +278,12 @@ def Restructure(ztree, newStructure):
zn = zbucketType()
n.Z = zn
if len(Av) == len(Bv):
# XXX assert the result is 1-1 mapping
if len(RZv) == len(RNv):
# assert the result is 1-1 mapping
for j in range(len(RNv)):
assert RNv[j].node.Z is RZv[j].node
# XXX assert assignments are in key↑ order
# XXX assert assignments are in key↑ order ?
zrlevelv = list(__zwalkBFS(ztree)) # [] of _NodeInRange
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment