CS 600 Test 2



November 6, 2000



1. For each of the problems below, if it is solvable in polynomial time in the worst case, then prove it. You do not have to solve it. If it is NP-Complete, then prove it. You may assume they are in class NP. Also you can use any of Bin Packing, Maximum Cliques, Graph Coloring, Knapsack, CNF SAT, Vertex Cover, Set Cover and 3 Dimensional Matching as a known NP-Complete problem for your proof.



Problem A: There are m groups of people and they are to attend meetings held in n rooms. No group is allowed to send more than one of its members to any single meeting. For each i there are p(i) people in group i and room j can hold q(j) people. Find an assignment of the people to the rooms. [33 points]



This can be solved as a max flow problem.
First construct a network as follows: Add one source and one sink vertices. Add one vertex for each group and add one vertex for each room. Then connect the source to group i with an arc with weight p(i) for each i, connect each group to each room with an arc with weight 1 and connect room j to the sink with an arc with weight q(j).

Then find a maximum flow from the source to the sink. The flows through the arcs from the groups to the rooms give the assignment.
If the maximum flow saturates all the arcs from the source, then everyone is assined to some room. Otherwise there isn't enough room and there are some people who can not be assigned to any room.
Note that the flows through all the arcs are integers. Hence no fraction of a person is assigned to a room.

On the other hand, if there is an assignment of people to rooms, then that can be represented by (saturated) arcs from the vertices for the groups to those for the rooms. Hence there is a flow from the source to the sink. Furthermore the arcs from the source are all saturated because every member is assigned to a room.



Problem B: There are m groups of people and they are to attend meetings held in n rooms. No group is allowed to send more than one of its members to any single meeting. In addition, certain pairs of people can not be assigned to any room together. For each i there are p(i) ($\geq 1$) people in group i and all rooms can hold as many people as necessary. Find an assignment of the people to the rooms if p(i) $\leq$ q for each i. [33 points]

This is an NP-Complete problem. The graph coloring problem can be transformed to this problem.
Given an instance of graph color problem: A graph and a positive integer k. Form groups by putting the vertices in them one per a group. So there are n groups if there are n vertices. Also provide k rooms. Then if vertices i and j are connected by an edge in the given graph, then the people coresponding to i and j must be put in separate rooms. If a room assignment is found, then the vertices corresponding to the groups assigned to the same room can be given the same color. Conversely if the given graph is colorable with k colors, then the groups corresponding to the vertices of the same color can be put in the same room. For there are no edges between them. Hence any pair of them can be put in the same room. Since only k colors are used, k rooms are sufficient. Thus the answer to the graph color problem is "yes" if and only if the answer to the assignment problem is "yes"


2. Formulate the following problem as a LP problem and solve it by the simplex method:

Any food is good for your health if appropriate amount is taken. But any excess is usually harmful. Consider two types of food for simplicity: type A and type B. Type A produces 3 kcal of energy per serving per day. Type B produces 4 kcal of energy per serving if two or less servings are taken per day. If more than two servings are taken, you lose energy at the rate of 1 kcal per serving. Due to the balance required between foods, the total servings of type A can not exceed that of type B plus 1 serving per day. Type A costs $3.00 per serving and type B $2.00. Find the amount of servings to maximize the total energy without spending more than $7.00 a day. [34 points]

Let $x_{1}$ be the amount of type A food to be taken, let $x_{21}$ be that for type B up to 2 servings per day and let $x_{22}$ be that for type B in excess of 2 servings per day. Then the problem is formulated as a linear programming problem as follows:

Max $3x_{1} + 4x_{21} - x_{22}$
subject to $x_{1} - x_{21} - x_{22} \leq 1$
              $3x_{1} + 2x_{21} + 2x_{22} \leq 7$
              $x_{21} \leq 2$
              $x_{1}. x_{21}, x_{22} \geq 0$

To solve this by simplex method, first add two slack variables $x_{3}$, $x_{4}$ and $x_{5}$.
Then the first dictionary is:

$x_{3} = 1 - x_{1} + x_{21} + x_{22}$
$x_{4} = 7 - 3x_{1} - 2x_{21} - 2x_{22}$
$x_{5} = 2 - x_{21}$
$z = 3x_{1} + 4x_{21} - x_{22}$

Selecting $x_{21}$ for the new basic variable, we get
$x_{21} = 2 - x_{5}$
$x_{3} = 3 - x_{1} - x_{5} + x_{22}$
$x_{4} = 3 - 3x_{1} + 2x_{5} - 2x_{22}$
$z = 8 + 3x_{1} - 4x_{5} - x_{22}$

Selecting $x_{1}$ for the new basic variable, we get
$x_{21} = 2 - x_{5}$
$x_{3} = 2 - (5/3)x_{5} + (5/3)x_{22} + (1/3)x_{4}$
$x_{1} = 1 + (2/3)x_{5} - (2/3)x_{22} - (1/3)x_{4}$
$z = 11 - 2x_{5} - 3x_{22} - x_{4}$

Since all the coefficients in $z$ are negative, a maximum has been reached.
Thus the maximum calorie is 11 kcal and that is attained by taking 1 serving of type A and 2 servings of Type B