def test_adjust_probs_all_zero(): """Test adjust_probs method when all elements in input vector sum to zero.""" dists = [(0, 1, 3), (0, 2, 5), (0, 3, 1), (0, 4, 7), (1, 3, 6), (4, 1, 9), (2, 3, 8), (2, 4, 2), (3, 2, 8), (3, 4, 4)] problem = TSPOpt(5, distances=dists) probs = np.zeros(5) assert np.array_equal(problem.adjust_probs(probs), np.zeros(5))
def test_adjust_probs_non_zero(): """Test adjust_probs method when all elements in input vector sum to some value other than zero.""" dists = [(0, 1, 3), (0, 2, 5), (0, 3, 1), (0, 4, 7), (1, 3, 6), (4, 1, 9), (2, 3, 8), (2, 4, 2), (3, 2, 8), (3, 4, 4)] problem = TSPOpt(5, distances=dists) probs = np.array([0.1, 0.2, 0, 0, 0.5]) x = np.array([0.125, 0.25, 0, 0, 0.625]) assert np.array_equal(problem.adjust_probs(probs), x)