A
A
Agiot2018-06-26 11:31:14
Algorithms
Agiot, 2018-06-26 11:31:14

A task on a set of items with a condition. What is the solution algorithm?

Given: N (100) items. Each has its own value and weight. Cost and weight are independent of each other. There is a limited budget. It is necessary to choose exactly n (5) items from these items so that their total cost does not go beyond the budget and their total weight is maximum. You can solve the problem by enumeration, but this method is time consuming, so it is not suitable. Help, please, to solve the problem.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lander, 2018-06-26
@usdglander

The classic backpacking problem , which can be solved in polynomial time only if the cost grows exponentially at least twice. In other cases, only by enumeration.
The enumeration can be optimized by referring to the branch and bound method or using genetic algorithms (not bad, by the way, they work). But in both cases there is no guarantee that the solution found will be optimal, most likely it will be close to optimal.
upd: I'm sorry. The branch and bound method is still an exact solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question