Optimization, Optimization Algorithms, Python, Programming, Algorithms.
knapsack_max_value :return: List of included items (1-based index) """ n = len(weights) W = len(dp[0]) - 1 included_items = [] i, w = n, W while i > 0 and w > 0: if dp[i][w] != dp[i - 1][w]: included_items.append(i) w -= weights[i - 1] i -= 1 included_items.reverse() return included_items # Test