Commit 37a49cf8 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6e5b283b
......@@ -274,9 +274,13 @@ def Restructure(ztree, newStructure):
rn.node.Z = None
def D(a, b):
def fin(v): # TeX hack: inf = 10000
if v == +inf: return +1E4
if v == -inf: return -1E4
assert abs(v) < 1E3
return v
def d(x,y):
if x == y: return 0 # prevents inf-inf -> nan
return abs(x-y)
return abs(fin(x)-fin(y))
return d(a.range.klo, b.range.klo) + \
d(a.range.khi, b.range.khi)
......@@ -292,6 +296,7 @@ def Restructure(ztree, newStructure):
# property of D function so that if B2 > B1 (all keys in B2 > all keys
# in B1) and A < B1.hi, then D(B2, A) > D(B1, A).
print()
print('COST:')
print(C)
jv, iv = scipy.optimize.linear_sum_assignment(C)
print(jv, iv)
......
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