An activity-selection is the problem of scheduling a resource
among several competing activity.
Statement: Given a set S of n activities with and start time, Si
and fi, finish time of an ith activity. Find the maximum size set
of mutually compatible activities.
Compatible Activities
Activities i and j are compatible if the half-open internal [si,
fi) and [sj, fj) do not overlap, that is, i and j are compatible if
si ≥ fj and sj ≥ fi
Greedy Algorithm for Selection Problem
I. Sort the input activities by increasing finishing time.
f1 ≤ f2 ≤ . . . ≤ fn
II Call GREEDY-ACTIVITY-SELECTOR (Sif)
n = length [s]
A={i}
j = 1
FOR i = 2 to n
do if si ≥ fj
then A= AU{i}
j = i
Return A
Operation of the algorithm
Let 11 activities are given S = {p, q, r, s, t, u, v, w, x, y, z}
start and finished times for proposed activities are (1, 4), (3,
5), (0, 6), 5, 7), (3, 8), 5, 9), (6, 10), (8, 11), (8, 12), (2,
13) and (12, 14).
A = {p} Initialization at line 2
A = {p, s} line 6 - 1st iteration of FOR - loop
A = {p, s, w} line 6 -2nd iteration of FOR - loop
A = {p, s, w, z} line 6 - 3rd iteration of FOR-loop
Out of the FOR-loop and Return A = {p, s, w, z}
Analysis
Part I requires O(nlgn) time (use merge of heap sort).
Part II requires Theta(n) time assuming that activities were
already sorted in part I by their finish time.
CORRECTNESS
Note that Greedy algorithm do not always produce optimal solutions
but GREEDY-ACTIVITY-SELECTOR does.
Theorem: Algorithm GREED-ACTIVITY-SELECTOR produces solution of
maximum size for the activity-selection problem.
Proof Idea: Show the activity problem satisfied
I. Greedy choice property.
II. Optimal substructure property
Proof:
I. Let S = {1, 2, . . . , n} be the set of activities. Since
activities are in order by finish time. It implies that activity 1
has the earliest finish time.
Suppose, A is a subset of S is an optimal solution and let
activities in A are ordered by finish time. Suppose, the first
activity in A is k.
If k = 1, then A begins with greedy choice and we are done (or to
be very precise, there is nothing to proof here).
If k not=1, we want to show that there is another solution B that
begins with greedy choice, activity 1.
Let B = A - {k} U {1}. Because f1 =< fk, the activities in B are
disjoint and since B has same number of activities as A, i.e., |A|
= |B|, B is also optimal.
II. Once the greedy choice is made, the problem reduces to finding
an optimal solution for the problem. If A is an optimal solution to
the original problem S, then A` = A - {1} is an optimal solution to
the activity-selection problem S` = {i in S: Si >= fi}.
why?
If we could find a solution B` to S` with more activities then A`,
adding 1 to B` would yield a solution B to S with more activities
than A, there by contradicting the optimality.
Dynamic-Programming Algorithm for the Activity-Selection
Problem
Problem: Given a set of activities to among lecture halls. Schedule
all the activities using minimal lecture halls.
In order to determine which activity should use which lecture hall,
the algorithm uses the GREEDY-ACTIVITY-SELECTOR to calculate the
activities in the first lecture hall. If there are some activities
yet to be scheduled, a new lecture hall is selected and
GREEDY-ACTIVITY-SELECTOR is called again. This continues until all
activities have been scheduled.
LECTURE-HALL-ASSIGNMENT (s,f)
n = length [s)
FOR i = 1 to n
DO HALL [i] = NIL
k = 1
WHILE (Not empty (s))
Do HALL [k] = GREEDY-ACTIVITY-SELECTOR (s, t, n)
k = k + 1
RETURN HALL
Following changes can be made in the GREEDY-ACTIVITY-SELECTOR (s,
f) (CLR).
j = first (s)
A = i
FOR i = j + 1 to n
DO IF s(i) not= "-"
THEN IF
GREED-ACTIVITY-SELECTOR (s,f,n)
j = first (s)
A = i = j + 1 to n
IF s(i] not = "-" THEN
IF s[i] >= f[j]|
THEN A = A U {i}
s[i] = "-"
j = i
return A
CORRECTNESS:
The algorithm can be shown to be correct and optimal. As a
contradiction, assume the number of lecture halls are not optimal,
that is, the algorithm allocates more hall than necessary.
Therefore, there exists a set of activities B which have been
wrongly allocated. An activity b belonging to B which has been
allocated to hall H[i] should have optimally been allocated to
H[k]. This implies that the activities for lecture hall H[k] have
not been allocated optimally, as the GREED-ACTIVITY-SELECTOR
produces the optimal set of activities for a particular lecture
hall.
Analysis:
In the worst case, the number of lecture halls require is n.
GREED-ACTIVITY-SELECTOR runs in θ(n). The running time of this
algorithm is O(n2).
Observe that choosing the activity of least duration will not
always produce an optimal solution. For example, we have a set of
activities {(3, 5), (6, 8), (1, 4), (4, 7), (7, 10)}. Here, either
(3, 5) or (6, 8) will be picked first, which will be picked first,
which will prevent the optimal solution of {(1, 4), (4, 7), (7,
10)} from being found.
Also observe that choosing the activity with the least overlap will
not always produce solution. For example, we have a set of
activities {(0, 4), (4, 6), (6, 10), (0, 1), (1, 5), (5, 9), (9,
10), (0, 3), (0, 2), (7, 10), (8, 10)}. Here the one with the least
overlap with other activities is (4, 6), so it will be picked
first. But that would prevent the optimal solution of {(0, 1), (1,
5), (5, 9), (9, 10)} from being found.
example
Consider the following variation on the Activity Selection Problem.You have a resource that may be used for activities...
Full question from above:"Consider a modification to the activity-selection problem in which each activity ai has, in addition to a start and a finish time, a value vi. The objective is nolonger to maximize the number of activities scheduled, but instead to maximize the total value of the activities scheduled. That is, we wish to choose a set A ofcompatible activities such that [summation, sub k in A, of v sub k] is maximized. Give a polynomial-time algorithm for this...
Suppose that you are scheduling a room. You are given a group of activities each of which has a start and stop time. Two activities are compatible if they do not overlap (one activity finishes before another one starts). For example, in the following activities, activity A is compatible with activities B and D but not activity C: Activity Start Time Stop time A 1 2 B 2 5 C 1 3 D 5 6 The room has a start...
1. Consider the following project. Activity Duration (weeks)5 Immediate Predecessor(s) Cost (S) 1000 | 400 I 200 | 1200 | 500 | 700 | 1200 | 800 | 1800 | 1500 | 400 (a) Construct the activity-on-node (AoN) network for the relations among the activities in the (b) Using the activity-on-node (Ao) network developed in part (a), determine the critical path and the minimum time required to complete the project. Develop the earliest start and finish times, the latest finish...
QUESTION 9 Consider the following project; for which activities is it possible that the slack can be greater than zero? Activity Immediate Predecessors B, E a. Only activities B or E could have slack, but they could not both have slack. Ob. Only activities B or C could have slack, but they could not both have slack. Oc. It is possible for any or all activities in this project to have slack. Od. It is possible for either all three...
A manufacturer of personal computers has recently identified time estimates, activities and predecessors to design, manufacture and market a new laptop computer. Their estimates are listed below Immediate Activity Description Estimated completion time (days) 90 15 Predecessors Prototype design Purchase of materials Manufacture of prototype Revision of design Initial production run Staff training Staff input on prototype Sales training Preproduction advertising campaign Post production advertising campaign 20 21 25 14 28 30 C,F D,I Management has also provided you with...
Sub Hub-Retail Site Selection Read the overview below and complete the activities that follow. Sub Hub is a quick service submarine sandwich shop, with current operations in five states. Sub Hub operates franchise locations only. The company has announced their expansion plans for the next few years with a mix of new company owned and franchised stores in new markets. Sub Hub prides itself on the quality of its product, freshly made sandwiches and fast and friendly service. A normal...
PART I: Multiple Choice Write all answers to the following questions. No partial credit available. Consumption utility is composed of price and convenience. True or False? A firm reduces inefficiencies by making trade-offs. True or False? A firm can increase its profitability by: A. increasing costs and reducing price. B. moving away from the efficient frontier. C. increasing inefficiencies. D. reducing inefficiencies. Operations comes from the Latin word "opus," which means: A. activity. B. helping people. C. improvement. D. work....
Required information [The following information applies to the questions displayed below.] Consider the following narrative describing the process of going to class: Larry awoke to his alarm clock buzz. He got up and dressed for the day. Then, he ate a hearty breakfast of oatmeal, toast, orange juice, and coffee. He grabbed his books and prepared to leave for school. Before he left home, he checked the weather. If it looked like rain, he put on a jacket and took...
Question: The whole process before administering blood can be broken down into the following nine activities: A. Register B. Consult and take tests C. Sample blood D. Deliver blood sample to lab E. Deliver blood to bank (CBS) F. Deliver test blood to lab (CBS) G. Cross-match H. Retrieve blood from bank I. Deliver blood to the clinic (Note: Administering blood is a pure medical activity. This activity will be excluded since your the analysis will not help to reduce...
Match the type of schedule listed with the description following. Schedule types may be used more than once a. Activity on arrow (AOA) b. Activity on node (AON) C. Matrix d. Bar chart 40 Graphically the simplest Graphic style makes it adaptable to high-rise construction 42.Utilizes i-j notation 43 Could also be termed precedent notation Would be used for a summary report to the owner Questions 45-49 Match the terms listed with their description. Terms may be used only once...