def test_ensure_jobs_conservation_with_multiple_demand_and_no_supply(): num_buffers = 5 num_activities = 5 mu1 = 1 mu2 = 2 mu3 = 3 mud1 = 4 mud2 = 5 buffer_processing_matrix = np.array([[-mu1, 0, 0, 0, 0], [mu1, -mu2, mu3, 0, -mud2], [0, 0, 0, 0, -mud2], [0, mu2, -mu3, -mud1, 0], [0, 0, 0, -mud1, 0]]) ind_surplus_buffers = [1, 3] s0 = stinit.DeterministicCRWStateInitialiser(np.zeros((num_buffers, 1))) job_generator = drjg(np.ones((num_buffers, 1)), buffer_processing_matrix, sim_time_interval=1) env = ControlledRandomWalk(np.ones((num_buffers, 1)), np.ones((num_buffers, 1)), np.zeros((num_buffers, num_activities)), job_generator, s0, model_type='pull', ind_surplus_buffers=ind_surplus_buffers) state = np.zeros((num_buffers, 1)) routing_jobs_matrix = env.ensure_jobs_conservation( buffer_processing_matrix, state) assert np.all(routing_jobs_matrix == np.zeros((num_buffers, num_activities)))
def test_ensure_jobs_conservation_with_not_enough_jobs(): num_buffers = 2 num_activities = 2 buffer_processing_matrix = np.array([[-2, 0], [2, -3]]) s0 = stinit.DeterministicCRWStateInitialiser(np.zeros((num_buffers, 1))) job_generator = drjg(np.ones((num_buffers, 1)), buffer_processing_matrix, sim_time_interval=1) env = ControlledRandomWalk(np.ones((num_buffers, 1)), np.ones((num_buffers, 1)), np.zeros((num_buffers, num_activities)), job_generator, s0) state = np.ones((num_buffers, 1)) routing_jobs_matrix = env.ensure_jobs_conservation( buffer_processing_matrix, state) assert np.all(routing_jobs_matrix == np.array([[-1, 0], [1, -1]]))