def test_allocator_quad_sets(self): indexSets = [set([4]), set([3, 2]), set([1, 2]), set([1, 2, 3, 4])] allocator = Allocator(indexSets) assert len(allocator.slots) == 5 allocation = allocator.allocate() print(allocator.report()) self.validate_allocation(indexSets, allocation)
def test_allocator_triple_sets(self): indexSets = [set([3, 1, 4]), set([3, 2, 1]), set([1]), set([0, 1])] allocator = Allocator(indexSets) assert len(allocator.slots) == 5 allocation = allocator.allocate() print(allocator.report()) self.validate_allocation(indexSets, allocation)
def test_allocator_single_sets(self): indexSets = [set([3]), set([2]), set([1]), set([0])] allocator = Allocator(indexSets) assert len(allocator.slots) == 4 allocation = allocator.allocate() print(allocator.report()) self.validate_allocation(indexSets, allocation)
def test_allocator_single_confilicting_sets(): """ Test allocation with matching sets """ indexSets = [set([1]), set([1])] allocator = Allocator(indexSets) assert len(allocator.slots) == 2 allocation = allocator.allocate() assert not allocation
def test_allocator_quad_sets(): """ Test allocation with quadruple sets """ indexSets = [set([4]), set([3, 2]), set([1, 2]), set([1, 2, 3, 4])] allocator = Allocator(indexSets) assert len(allocator.slots) == 5 allocation = allocator.allocate() LOGGER.info(allocator.report()) validate_allocation(indexSets, allocation)
def test_allocator_triple_sets(): """ Test allocation with triple sets """ indexSets = [set([3, 1, 4]), set([3, 2, 1]), set([1]), set([0, 1])] allocator = Allocator(indexSets) assert len(allocator.slots) == 5 allocation = allocator.allocate() LOGGER.info(allocator.report()) validate_allocation(indexSets, allocation)
def test_allocator_single_sets(): """ Test allocation with single sets """ indexSets = [set([3]), set([2]), set([1]), set([0])] allocator = Allocator(indexSets) assert len(allocator.slots) == 4 allocation = allocator.allocate() LOGGER.info(allocator.report()) validate_allocation(indexSets, allocation)
def test_allocator_octa_sets(self): indexSets = [ set([0, 1, 2, 3]), set([0, 1, 2, 3]), set([0, 1, 2, 3]), set([0, 1, 2, 3, 4, 5, 6, 7]) ] allocator = Allocator(indexSets) assert len(allocator.slots) == 8 allocation = allocator.allocate() print(allocator.report()) self.validate_allocation(indexSets, allocation)
def test_allocator_octa_sets(): """ Test allocation with sets of 8 """ indexSets = [ set([0, 1, 2, 3]), set([0, 1, 2, 3]), set([0, 1, 2, 3]), set([0, 1, 2, 3, 4, 5, 6, 7]) ] allocator = Allocator(indexSets) assert len(allocator.slots) == 8 allocation = allocator.allocate() LOGGER.info(allocator.report()) validate_allocation(indexSets, allocation)
def sort(requests): """ Sorts a list of requests based on constraints :param requests: A list of requests to be sorted """ if RequestSorter.isSorted(requests): return requests indexSets = [req.event.validPmc for req in requests] allocator = Allocator(indexSets) if allocator.slotCount() == len(indexSets): allocation = allocator.allocate() if allocation: sortedRequests = [None] * len(requests) for i, req in enumerate(requests): sortedRequests[allocation[i]] = req return sortedRequests return None
def test_allocator_single_confilicting_sets(self): indexSets = [set([1]), set([1])] allocator = Allocator(indexSets) assert len(allocator.slots) == 2 allocation = allocator.allocate() assert not allocation