예제 #1
0
 def test_knapsack_holds_all_items_except_last(self):
     assert fractional_knapsack.get_optimal_value(50, [20, 20, 20],
                                                  [10, 10, 10]) == 25.0
예제 #2
0
 def test_items_without_value(self):
     assert fractional_knapsack.get_optimal_value(100, [30, 30, 30],
                                                  [0, 0, 0]) == 0.0
예제 #3
0
 def test_knapsack_holds_all_items(self):
     assert fractional_knapsack.get_optimal_value(100, [30, 30, 30],
                                                  [10, 10, 10]) == 30.0
예제 #4
0
 def test_sample2(self):
     assert fractional_knapsack.get_optimal_value(10, [30], [500]) == (
     500 / 3)
예제 #5
0
 def test_empty_knapsack(self):
     assert fractional_knapsack.get_optimal_value(0, [30], [500]) == 0.0
예제 #6
0
 def test_knapsack_holds_all_items_except_last(self):
     assert fractional_knapsack.get_optimal_value(50, [20, 20, 20],
                                                  [10, 10, 10]) == 25.0
예제 #7
0
 def test_sample1(self):
     assert fractional_knapsack.get_optimal_value(50, [20, 50, 30],
                                                  [60, 100, 120]) == 180.0000
예제 #8
0
 def test_knapsack_holds_all_items(self):
     assert fractional_knapsack.get_optimal_value(100, [30, 30, 30],
                                                  [10, 10, 10]) == 30.0
예제 #9
0
 def test_items_without_value(self):
     assert fractional_knapsack.get_optimal_value(100, [30, 30, 30],
                                                  [0, 0, 0]) == 0.0
예제 #10
0
 def test_empty_knapsack(self):
     assert fractional_knapsack.get_optimal_value(0, [30], [500]) == 0.0
예제 #11
0
 def test_sample2(self):
     assert fractional_knapsack.get_optimal_value(10, [30],
                                                  [500]) == (500 / 3)
예제 #12
0
 def test_sample1(self):
     assert fractional_knapsack.get_optimal_value(
         50, [20, 50, 30], [60, 100, 120]) == 180.0000