def test_find_coupled_resource_sets_c(): """ Test the _find_coupled_resource_sets method of the wrapped RL environment directly. The method takes in a binary matrix denoting which resources are affected by which constraints and returns a list of sets of resources the actions of which are made dependent by the constraints. This is essentially noticing and interpreting the chaining effect of multiple constraints on activities. """ # This test case tests the chaining effect. The first constraint links resources 0 and 1 then # the second links resources 2 and 3 and the third links 1 and 2 which creates a chain such that # resources 0, 1, 2 and 3 form one large dependent resource set overlapping_resource_constraints_matrix = np.array([ [1, 0, 0], [1, 0, 1], [0, 1, 1], [0, 1, 0] ]) # => Resource set is {0, 1, 2, 3} # Run the method for the test case defined above overlapping_resource_sets = RLControlledRandomWalk._find_coupled_resource_sets( overlapping_resource_constraints_matrix ) # Assert that the responses are as expected. assert overlapping_resource_sets == [{0, 1, 2, 3}]
def test_find_coupled_resource_sets_a(): """ Test the _find_coupled_resource_sets method of the wrapped RL environment directly. The method takes in a binary matrix denoting which resources are affected by which constraints and returns a list of sets of resources the actions of which are made dependent by the constraints. This is essentially noticing and interpreting the chaining effect of multiple constraints on activities. """ # Each resource has one activity and all are independent. independent_resource_constraints_matrix = np.eye(4) # => resource sets are [{0}, {1}, {2}, {3}] # Run the method for the test case defined above independent_resource_sets = RLControlledRandomWalk._find_coupled_resource_sets( independent_resource_constraints_matrix) # Assert that the responses are as expected. assert independent_resource_sets == [{0}, {1}, {2}, {3}]
def test_find_coupled_resource_sets_b(): """ Test the _find_coupled_resource_sets method of the wrapped RL environment directly. The method takes in a binary matrix denoting which resources are affected by which constraints and returns a list of sets of resources the actions of which are made dependent by the constraints. This is essentially noticing and interpreting the chaining effect of multiple constraints on activities. """ # The constraints lead to resources 0 and 2, and 1 and 3 being coupled into two dependent sets. simple_resource_constraints_matrix = np.array([ [1, 0], [0, 1], [1, 0], [0, 1] ]) # => Resource sets are [{0, 2}, {1, 3}] # Run the method for the test case defined above simple_resource_sets = RLControlledRandomWalk._find_coupled_resource_sets( simple_resource_constraints_matrix ) # Assert that the responses are as expected. assert simple_resource_sets == [{0, 2}, {1, 3}]