[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

1596.0. "Resource allocation Algorithm ?" by SNOFS2::ROY () Sat Apr 18 1992 08:33

    Suppose we have a set {1,2,3...n} of n proposed activities that wish to
    use a resource that can be used only by one activity at a time. Each
    activity i starts at time s(i) and finishes at time f(i)  if the
    resource is allocated to it . Activities i and j are compatiable if
    they do not overlap (ie, s(i)>=f(j) or s(j)>f(i)) . The question is how
    to select a maximum-size set of mutually compatiable activities.
T.RTitleUserPersonal
Name
DateLines
1596.1See 1595.1VMSDEV::HALLYBFish have no concept of fire.Sat Apr 18 1992 10:481
    
1596.2Its in Algorithms alsoSNOFS2::ROYTue Apr 21 1992 01:353
    I have posted the same entry in Algorithms conference.
    
    Goutam
1596.3TRACE::GILBERTOwnership ObligatesTue Apr 21 1992 13:2044
Given the right approach, this is pretty straight-forward.

Consider a time T, and all the activities that are active at time T.
For each of these activities, maintain the 'maximum-size set of mutually
compatiable activities' in time that now has this activity active.  Ditto
for having no activities now active.

This works because at any point in time, the only things of interest are:
which activity is active, and how many activities have been activated.

for i in {0..N} do N[i] <- 0	! N[0] is a special counter for 'nothing active'
E <- {s(i),f(i)}, in sorted order
For each e in E do
    if e is a 's' endpoint s(i) then
	N[i] <- N[0] + 1	! Add i as another mutually compatible activity
				! (if nothing is now active)
    else {e is a 'f' endpoint f(i)}
	N[0] <- max(N[0], N[i])	! If i were active, nothing is active now

Now, N[0] = the maximum number of mutually compatible activities

For the 'sorted order' above, if some s(i) = f(i), the f(i) comes first
(so that that activity finishes before the next one starts at that time).


There are a few ways to reconstruct the set of activities.  One is to run
the above algorithm in reverse (after having run it forward).

M <- �				! Initialize to the empty set
For each e in E (in reverse order) do
    if e is a 's' endpoint s(i) then
	N[0] <- N[i] - 1	! Forward: N[i] <- N[0] + 1
    else {e is a 'f' endpoint f(i)}
	if N[0] = N[i]		! Forward: N[0] <- max(N[0], N[i])
	    M <- M & i		! Add i to the set of activities
	    N[0] <- -1		! Set to an unknown/bogus value

C'est tout!


Note: the definition in .0 says that if s(i)>=f(j) or s(j)> f(i), the activities
don't overlap.  Switching variables: if s(i)> f(j) or s(j)>=f(i), the activities
don't overlap.  Thus, it should say that the activities don't overlap if
(and only if) s(i)>=f(j) or s(j)>=f(i).