Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started