def test_knapsack_problem_initial(): problem = KnapsackProblem(20, [(0, 0), (0, 0)]) assert problem.initial.capacity == 20 assert problem.value(problem.initial) == 0 assert problem.initial.weight == 0
def test_knapsack_value(): problem = KnapsackProblem(20, [(25, 30), (5, 9), (20, 200)]) state = KnapsackState(20, 20, 20, [False]) assert problem.value(state) == state.value