コード例 #1
0
def test_knapsack_bottomup_on_big_list():
    from knapsack_test_data import weights, profits

    capacity = 1000
    t1 = datetime.now()
    res = maximum_sum_bottomup(weights, profits, capacity)
    t2 = datetime.now()

    print(t2 - t1)

    assert res > 0
コード例 #2
0
def test_knapsack_bottomup_first_bigger(costs):
    weights = [8, 1, 6, 3]
    # [3, 1, 6, 8]
    res = maximum_sum_bottomup(weights, costs, capacity=7)
    assert res == 9
コード例 #3
0
def test_knapsack_bottomup_empty_selection():
    res = maximum_sum_bottomup([], [], capacity=7)
    assert res == 0
コード例 #4
0
def test_knapsack_bottomup_non_equal_lengths(weights, costs):
    res = maximum_sum_bottomup(weights, costs[:-2], capacity=7)
    assert res == 0
コード例 #5
0
def test_knapsack_bottomup_positive(weights, costs, capacity, expected):
    res = maximum_sum_bottomup(weights, costs, capacity=capacity)
    assert res == expected