Answered step by step
Verified Expert Solution
Link Copied!

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 {0,1}
1. Create an abstract base class which represents the above problem with solve as the pure
virtual function.
(5)
2. The abstract base class should contain the necessary members such as wi
, ci and xi
forall i in I, with generic type T.
(6)
3. Write functions in the abstract base class to add items to the problem, and set the value W.(2)
4. Write a function in the abstract base class to print the expanded problem in a linear
programming format, e.g.2x1+3x2+4x3<=40.
(3)
5. Write a function in the abstract base class to obtain and print the solution. (3)
Question 2/ Vraag 2
1. Create heuristic solver class that inherits the abstract base class created in Question 1.(3)
2. Override the solve() function and implement a greedy heuristic with priority queues for
the problem described in Question 1.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

=+(5.42) E[n \N2] = a, Var[n 'N.] - B - x2 +H-P n

Answered: 1 week ago