Project Scheduling and Copresheaves
Posted by Simon Willerton
Obsessed as I am with finding examples of enriched categories, I was struck by the unfamiliar notion of ‘activity network’ when checking a colleague’s course on graph theory. What struck me was how scheduling actives seemed to be like finding a certain kind of copresheaf. Activity networks are also known as PERT charts to people in project management: an activity network or PERT chart records all the dependencies between the activities need to be completed during a project, and also records the times the activities will take to complete. Once you have this information you can try to schedule each of the activities in so that the project is completed as quickly as possible, and you can identify which activities are critical in the sense that any delay in that activity will cause a delay to the whole project.
I noticed that there was some enriched category theory going on with these PERT charts. Patrons of the Café are probably familiar with the idea that metric spaces can be thought of as categories enriched over the category of extended non-negative numbers. The triangle inequality for metric spaces then corresponds to the composition for enriched categories. The category that is enriched over for PERT charts is so the main difference is that the morphisms go the other way, this means that you get a reversed triangle inequality! However, that makes sense in the scheduling context. I will explain how this gives categorical interpretations of terms like earliest start time, latest start time, float and critical path.
I have stressed the project management aspects here, but these ideas are also important, it seems, in scheduling processor jobs in parallel computing.
PERT graphs and project management
In project management, a project, for example renovating a house, will consist of various activities which need scheduling subject to various interdependencies between them. For instance, in the house example, you can’t get a decorator to paper the walls until you’ve had a plasterer plaster them and it takes, say, ten day to plaster the walls. There are standard methods to approach the scheduling of jobs. According to Wikipedia, the method of Program Evaluation and Review Technique (PERT) – closely associated to the critical path method –was introduced by the US Navy in the mid-twentieth century during the Polaris missile development and had precursors in the management of the Manhattan Project.
The PERT method begins with you writing down every activity you need to complete, how long each activity will take and which activities need which others to be finished. So, ignorant of anything to do with house renovation, let’s make up an example.
Label Activity Duration Requires a Fix electrics 7 days b Plaster walls 10 days a c Lay carpets 3 days a d Paper walls 12 days b e Re-tile roof 15 days
Note that we’ve only put in the explicit dependencies, so that although papering the walls (activity d) also requires the fixing of electrics (activity a) to be finished we don’t put that in.
We add specific start and finish activities, which we will label S and F. Activity F has no duration and is explicitly dependent on everything which didn’t have anything dependent on it – you can’t finish before everything is completed. Activity S has no duration, is not dependent on anything and any activity which is not already dependent on something is made dependent on S – nothing can begin before the start.
Label Activity Duration Requires S Start 0 days - a Fix electrics 7 days S b Plaster walls 10 days a c Lay carpets 3 days a d Paper walls 12 days b e Re-tile roof 15 days S F Finish 0 days d, c, e
We can now draw a graph of this data. We draw a node for each activity and and arrow for each explicit dependency. Each arrow is labelled by the amount of time after the first activity has started that the second activity can start – here we are measuring time in days. This is the basis of what is called a PERT chart.
Those of you who have filled in grant applications may have been asked to provide a PERT chart. Now you know, more-or-less, what one is. Often they are also labelled with things such as ‘earliest start time’, ‘latest start time’ and ‘float’, but we’ll come to those below.
Scheduling and copresheaves?
The goal of drawing up a PERT chart is to schedule the work, for instance book the contractors, so that the project finishes as quickly as possible. This means we wish to assign a start time to each activity so that whenever we have activity with an explicit dependency on we have the scheduling constraint.
where is the label on the arrow in the above PERT chart, so is how long after starts that can start.
Actually we can give ourselves such scheduling constraints (1) on the start times and for every pair and , not just those with those with arrows between them, by setting if there is no arrow from to in the graph, i.e. if there is no explicit dependency of on . If we take to be our set of activities (including the start and finish activities) and to be the set , then we have encoded the dependencies and times as a -graph , on the set , this just means that we have a function
I’ve obviously been thinking too much about enriched categories of late as the scheduling constraint (1) looks to me like a copresheaf condition. Remember that a copresheaf on an ordinary category is functor , so that means, of course, that to each object in we associate a set and to each pair of elements and we have a function between sets , or to put it another way, we have a morphism in the category of sets
where . Compare this with the scheduling constraint (1).
Closed monoidal structure
To make this similarity into something more formal we can make into a category by using as a poset structure, so there is a unique morphism if and only if and using as a monoidal structure. Note that this is the opposite to the category structure used on to define metric spaces as enriched categories – there we use . This means we can write the scheduling constraint (1) as the morphism
which now looks more like the set copresheaf situation (2).
If we are enriching over a monoidal category and want to talk about -functors into then we will need to give a -category structure, thiat is to say we will need that is a closed monoidal category. This means we need a functor such for each the functor is left adjoint to . I’m using double brackets here not to confuse the internal hom with the closed interval .
In our case this means we need
In order to do this we will have to add a plus infinity, so we will define the category to be with giving the morphisms and being the monoidal structure. It is easy to say what the closed structure is on finite numbers, so for we define
I will often write instead of with the understanding that it means if you get a negative answer.
Exercise: How do the monoidal and closed structures extend to include infinite numbers? Fill in the following tables, where and are finite. (I can give a hint if people need help getting started.)
If I’d put negative numbers in as well (which I don’t think are necessary here) then I would have used ordinary subtraction between finite numbers. This is what Lawvere does when he puts this closed monoidal structure on , the whole of the extended real numbers, in his entropy paper:
State Categories, Closed Categories, and the Existence of Semi-Continuous Entropy Functions, (10 MB file!) IMA reprint 86 (1984).
He calls categories enriched over ‘entropic categories’. I haven’t fully digested what use he makes of them in this paper.
Enriching over
We can now consider categories enriched over the closed monoidal category . Let’s just remind ourselves what such a thing is. It consists of a set and a function such that
- for all we have ,
- for all we have .
This last condition looks bizarre as it is the triangle inequality the wrong way round! However, we will make sense of it in if we look at our scheduling example. Our PERT chart, illustrating the explicit dependencies between events, can be thought of as an -graph on the set , this just means it corresponds a function
We can form the free -category on by defining
where the maximum is taken over all the tuples and over all . (Here max is the coproduct in .) This -category is now recording the implicit dependencies. So for instance in the example above we didn’t record any explicit dependency between fixing the electrics (activity a) and finishing the project (activity ), so but it is a consequence of the other dependencies that you need to fix the electrics at least twenty nine days before finishing the project, i.e. .
I hope that if we interpret as the time lag between starting activity and starting activity , you can now make sense of the reversed triangle inequality
The minimum time lag after starting to starting is at least as big as the minimum time lag from starting to starting plus the minimum time lag from to starting .
So we can think of the hom-objects in an -category as being like minimum possible time lags rather than minimum possible distances.
Scheduling and copresheaves
We can now return to the scheduling question. We want to schedule the activities in our project subject to the dependencies between them. Here by scheduling an activity we will mean setting a time relative to the start of the project, so that , subject to the explicit constraints, so for all activities
This means that is precisely an -graph function from out PERT chart to the underlying -graph of . This is corresponds exactly to an -functor from the free -category to . This is just expressing the free-forgetful functor between -graphs and -categories:
In other words, scheduling the jobs means finding a copresheaf on the -category of implicit dependencies.
We can give some categorical interpretations of standard ideas in critical path analysis now.
What we really want to do is to finish the project as quickly as possible. The shortest amount of time the project will take to finish is the minimum time lag between the start and the finish, this is just . Given that length of time, we want to know how much freedom we have in scheduling individual activities and whether delaying a specific activity will cause the whole project to be delayed – will it matter if the plasterer doesn’t turn up on time or the walls take longer to dry out than expected. There are three basic things then to know about each activity: the earliest start time, the latest start time, and the float.
The earliest start time of an activity is hopefully self-explanatory. It is the minimum time lag between the start of the project and the start of the activity. In categorical terms it is just – the evaluation of the representable copresheaf. As functions we have that the earliest start time is a copresheaf
The latest start time of an activity is the latest that an activity can start without delaying the whole project. The minimum time lag between the activity and the finish is , and if the project is not delayed then the finish time is , thus the latest start time is or in internal hom terms . So the latest start time is the copresheaf
The float of an activity is the difference between its earliest start time and its latest start time, and so reflects how much leeway you have in scheduling the activity. If the float is zero then the activity is said to be critical. In our notation the float of activity is or in the internal hom notation To put it another way, the float is measuring how much the reverse triangle equality is violated for between and .
A viable schedule will be one which finishes the project as soon as possible and satisfies the constraints so will be a copresheaf which satisfies
I don’t know if that is a condition which crops up elsewhere in category theory.
A further important notion is that of critical path: this is a path in the PERT graph from the start to the finish which consists of activities with float zero, so a delay of any activity on the path will lead to a delay in the project. The path is critical in our example above. Everywhere on a critical path the triangle inequality from to is actually an equality, so critical paths are the analogues of geodesics in metric spaces.
Further questions
All of this came out of me looking at a colleague’s course and thinking randomly “Hmm. That looks categorical.” Here are some random further questions.
Do other categorical notions have useful interpretations in this context? Is the notion of -functor between projects meaningful? How about the notion of -profunctor?
Is it useful to think of these things are ‘generalized metric spaces with negative distances’?
Do these ideas extend to other networks such as Petri nets or networks of resistors?
Does it help to think in terms of entropy as in Lawvere’s paper?
Re: Project Scheduling and Copresheaves
[Note: Tim emailed me this straight after a skim reading of the post and before drinking his morning coffee, so I take responsibility for posting this here. Simon.]
I liked the post. I used to teach critical path analysis, and then go on to discrete dynamical systems and (times) Petri nets. These both have strong categorical flavour.
Have you looked at the paper:
(I think that is the right one of Pratt’s work. He has written a lot that is discursive so it is difficult to find which bit it is in.)
There are links between discrete dynamical systems approaches to scheduling and tropical algebra. I used to get students doing projects on using the Max+ / tropical algebra and linear algebra to attack fairly real life scheduling problems. That was good fun both for the students and for me! I learnt a lot!
The Petri nets aspect was explored by Meseguer, as a Petri net looks like a presentation of an symmetric monoidal category. Your post suggests that there may be an enriched version of his result for times Petri nets. (I had meant to explore that with students but the occasion never came, and the Bangor department was closed which made things impossible.) Meseguer’s papers include
and another one on Petri nets and Linear Logic from about the same time. See Meseguer’s papers at dblp.