To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 95e62d2a authored by sfritschi's avatar sfritschi
Browse files

Accurate number of unrealized throats

parent cf93b48a
......@@ -179,11 +179,10 @@ class CellList:
print(f"progress {((i+1) / n)*100.:.1f}%", end="\r", flush=True)
candidates = self.find_candidates(pore)
# TODO: Handle case where there are no candidates left for
# some remaining throat(s)
# Find best candidate for each throat of pore
for idx, throatIdx in enumerate(pore.throats):
lt = Network.throatL[throatIdx]
if (len(candidates) == 0):
self.set_throat(pore.index, -1, idx)
break # no possible candidates left
......@@ -764,12 +763,9 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
# throats, connect pores
if (not mute): print("\nconnecting")
throats = []
k = 0 # count of unrealised throats
avg_throat_diff = 0.
count = 0
total = 0
n_already_taken = 0
# Copy throats of pores to keep track of the ones already realized
ttbrs = [pore.throats.copy() for pore in pores[:n]]
......@@ -777,12 +773,13 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
if (not mute): print("Total throats: %d" % totalThroats)
# Maximum number of iterations until we give up
maxIters = 6
maxIters = 6
throatTolerance = 0.002 # Max. 0.2% may not be realized
iterCount = 0
throatsLeft = totalThroats
throatThreshold = int(0.002 * totalThroats)
throatThreshold = int(throatTolerance * totalThroats)
# Pores that are not fully-connected yet
# Pores in interior that are not fully-connected yet
reduced_pores = pores[:n]
while (iterCount < maxIters and throatsLeft > throatThreshold):
......@@ -819,6 +816,7 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
if throatIdx not in poreTtbr:
continue # Throat already realized
# TODO: Remaining throats not properly tracked
if match == -1: # give up
poreTtbr.clear()
break
......@@ -835,9 +833,7 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
nborTtbr = ttbrs[nbor.index]
total += 1
if (len(nborTtbr) == 0 or nbor.index in conporesInd):
n_already_taken += 1
continue
conporesInd.add(nbor.index)
......@@ -880,16 +876,17 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
throatCount = 0
# Copy throats back to original pores and update #throats left
# and compute remaining (reduced) pores
reduced_pores = []
for i, pore in enumerate(pores[:n]):
poreTtbr = ttbrs[i]
next_pores = []
for pore in reduced_pores:
poreTtbr = ttbrs[pore.index]
throatCount += len(poreTtbr)
pore.throats = poreTtbr.copy()
if len(poreTtbr) > 0:
# Insert in random order for improved load balancing
reduced_pores.insert(randint(0,len(reduced_pores)), pore)
next_pores.insert(randint(0,len(next_pores)), pore)
reduced_pores = next_pores
# Recompute loads and displacements for all threads
n_reduced = len(reduced_pores)
remainder = n_reduced % nthreads
......@@ -904,7 +901,8 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
throatsLeft = throatCount // 2
iterCount += 1
k = throatsLeft
# Unrealized throats
n_unrealized = totalThroats - len(throats)
# Free memory associated with cellList (not needed anymore)
del cellList
......@@ -912,13 +910,12 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
# DEBUG
if (iterCount == maxIters):
print("Maximum iteration count reached!")
percent = k / totalThroats * 100.
percent = n_unrealized / totalThroats * 100.
print("\b"*24 + "{0:d} throats in total, {1:d} unrealised ({2:.3f}%)".\
format(len(throats), k, percent))
format(len(throats), n_unrealized, percent))
avg_throat_diff /= count
print("Avg. throat length difference: %e" % avg_throat_diff)
print("Relative to Lmax: %.1f%%" % (avg_throat_diff / basenet.Lmax * 100.))
print("Percentage where match was fully-connected: %.1f%%" % (n_already_taken / total * 100.))
# assemble and return network
network = Network(lb=[0.0 for k in range(d)],
......
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