handle overlap for multiple validators per node correctly
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
5613996547
commit
c366c05616
|
@ -79,3 +79,9 @@ def sampleLine(line, limit):
|
|||
r[i] = 1
|
||||
limit -= 1
|
||||
return r
|
||||
|
||||
def unionOfSamples(population, sampleSize, times):
|
||||
selected = set()
|
||||
for t in range(times):
|
||||
selected |= set(random.sample(population, sampleSize))
|
||||
return selected
|
||||
|
|
|
@ -4,7 +4,7 @@ import random
|
|||
import collections
|
||||
import logging
|
||||
from DAS.block import *
|
||||
from DAS.tools import shuffled, shuffledDict
|
||||
from DAS.tools import shuffled, shuffledDict, unionOfSamples
|
||||
from bitarray.util import zeros
|
||||
from collections import deque
|
||||
from itertools import chain
|
||||
|
@ -60,12 +60,7 @@ class Validator:
|
|||
elif self.shape.chi > self.shape.blockSize:
|
||||
self.logger.error("Chi has to be smaller than %d" % self.shape.blockSize, extra=self.format)
|
||||
else:
|
||||
if self.amIproposer:
|
||||
self.chi = 1 # not used
|
||||
elif self.ID <= shape.numberNodes * shape.class1ratio:
|
||||
self.chi = shape.chi * shape.vpn1
|
||||
else:
|
||||
self.chi = shape.chi * shape.vpn2 # TODO: union of random subsets vpn2 times
|
||||
self.chi = shape.chi
|
||||
if amIproposer:
|
||||
self.rowIDs = range(shape.blockSize)
|
||||
self.columnIDs = range(shape.blockSize)
|
||||
|
@ -75,11 +70,11 @@ class Validator:
|
|||
if rows:
|
||||
self.rowIDs = rows
|
||||
else:
|
||||
self.rowIDs = random.sample(range(self.shape.blockSize), self.chi)
|
||||
self.rowIDs = unionOfSamples(range(self.shape.blockSize), self.chi, self.shape.vpn1)
|
||||
if columns:
|
||||
self.columnIDs = columns
|
||||
else:
|
||||
self.columnIDs = random.sample(range(self.shape.blockSize), self.chi)
|
||||
self.columnIDs = unionOfSamples(range(self.shape.blockSize), self.chi, self.shape.vpn1)
|
||||
self.rowNeighbors = collections.defaultdict(dict)
|
||||
self.columnNeighbors = collections.defaultdict(dict)
|
||||
|
||||
|
|
Loading…
Reference in New Issue