Question: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that
Given a set of items, each with a weight and a value, determine the number of each item to include in a
collection so that the total weight is less than or equal to a given limit and the total value is as large as
possible,
maximize X
i in I
cixi
subject to X
i in I
xiwi W xi in
Create an abstract base class which represents the above problem with solve as the pure
virtual function.
The abstract base class should contain the necessary members such as wi
ci and xi
forall i in I, with generic type T
Write functions in the abstract base class to add items to the problem, and set the value W
Write a function in the abstract base class to print the expanded problem in a linear
programming format, egxxx
Write a function in the abstract base class to obtain and print the solution.
Question Vraag
Create heuristic solver class that inherits the abstract base class created in Question
Override the solve function and implement a greedy heuristic with priority queues for
the problem described in Question
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
