@@ -1647,9 +1647,9 @@ void HighsPrimalHeuristics::flushStatistics() {
16471647 lp_iterations = 0 ;
16481648}
16491649
1650- double knapsackRecurrence (const std::vector< HighsInt>& weight ,
1650+ double knapsackRecurrence (const HighsInt num_item ,
16511651 const std::vector<double >& value,
1652- const HighsInt num_item ,
1652+ const std::vector< HighsInt>& weight ,
16531653 const double capacity,
16541654 std::vector<std::vector<double >> &dp_result,
16551655 std::vector<std::vector<bool >> &use_item) {
@@ -1659,12 +1659,12 @@ double knapsackRecurrence(const std::vector<HighsInt>& weight,
16591659 if (dp_result[num_item][capacity] != -1 ) return dp_result[num_item][capacity]; // Check if result is already computed
16601660
16611661 // Exclude the item
1662- double exclude = knapsackRecurrence (weight , value, num_item- 1 , capacity, dp_result, use_item);
1662+ double exclude = knapsackRecurrence (num_item- 1 , value, weight , capacity, dp_result, use_item);
16631663
16641664 // Include the item (if it fits in the knapsack)
16651665 double include = 0 ;
16661666 if (weight[num_item-1 ] <= capacity)
1667- include = value[num_item-1 ] + knapsackRecurrence (weight , value, num_item- 1 , capacity - weight[num_item-1 ], dp_result, use_item);
1667+ include = value[num_item-1 ] + knapsackRecurrence (num_item- 1 , value, weight , capacity - weight[num_item-1 ], dp_result, use_item);
16681668
16691669 // Store whether the item is used with this capacity
16701670 use_item[num_item][capacity] = include > exclude;
@@ -1690,7 +1690,7 @@ HighsModelStatus solveKnapsack(const HighsLogOptions& log_options,
16901690 // Set up the item use array, indicating that items are not used
16911691 std::vector<std::vector<bool >> use_item (num_item + 1 , std::vector<bool >(capacity + 1 , false ));
16921692
1693- solution_objective = knapsackRecurrence (weight , value, num_item , capacity, dp_result, use_item);
1693+ solution_objective = knapsackRecurrence (num_item , value, weight , capacity, dp_result, use_item);
16941694
16951695 // Deduce the solution
16961696 std::vector<HighsInt> knapsack_solution (num_item, 0 );
0 commit comments