tags:

views:

80

answers:

3

Assume that a task exists with two attributes: priority and due date.

Priority p is a numeric value. The priority importance increases to infinity, meaning that 5 is a priority higher than 4. Priority 0 is normal priority.

Due date d is a date in the past or in the future, when compared with the current date. A d date before now is more important than a date in the future.

The idea is to combine these two attributes, priority and due date, according to the rules above, in order to produce a numeric output that can be used to order a list of tasks.

This should be possible to model as a math function but I am rusty, to say the least, in that field. I am even not convinced if it should be a 2D function or a 3D function.

I started by a 2D graph where x-axis is for priority and y-axis is for the difference between the current date and the due date.

  • The upper left quadrant A1 has due dates in the past and high priorities.
  • The upper right quadrant A2 has due dates in the future and high priorities.
  • The lower left quadrant A3 has due dates in the past and low priorities.
  • The lower right quadrant A4 has due dates in the future and low priorities.

Any guys with math knowledge that can throw a fee pointers?

A: 

Well, one approach would be to follow the idea you've already outlined. Plot all the points on the 2D graph, transform to 1D by measuring the distance from (0,0) to the point. So the function would be:

fun(x,y) = sqrt(x^2+y^2)

Or, since your data is sort of categorical, you could simply divide the plane of your graph into little boxes, one for each date/priority pair, and use, say, the manhattan distance from the origin of that box. If you are not familiar with manhattan distances, go Google.

I leave it up to you to decide if either of these approaches fits your requirements.

High Performance Mark
This seems to be an odd use of distance since it looses the direction i.e. fun(x,y) = fun(y,x), then how do we decide if x should be done before or after y? Furhtermore, this approach requires computing the function for all pairs of tasks, and even when we have this matrix, we cannot easily tell, say given 3 tasks, what is their relative combined priority.
mjv
@mjv -- OP states 'The idea is to combine these two attributes, priority and due date, according to the rules above, in order to produce a numeric output that can be used to order a list of tasks.' and I think that a distance function does this rather well. It does not require computing the function for all pairs of tasks -- the 'distance' of a task from the origin establishes it's priority relative to all the other tasks. I think you're right that it's not strictly a distance function, you'd want to supply the 'coordinates' in the same order every time so f(x,y) != f(y,x).
High Performance Mark
@HP Mark: my bad, apologies! I misread your answer and assumed this was a distance between two task points, rather than between a task and some origin. In that sense, your suggestion does provide a scalar usable for the sorting of the tasks. The difficulty is with calibrating the scale of each dimension and the relative importance of these dimensions, but this problem is common to any formula which combines d and p in any fashion.
mjv
A: 

You could just add the two together to come up with a total. I believe you would want to negate the due date though to make items past due a higher priority.
Examples:
Priority 0 Due yesterday (-1) would have a total of 1 (0 + 1)
Priority 20 Due 3 days from now would have a total of 17 (20 + -3)

As the first commenter pointed out - you could then weight each variable, if one is more important, by multiplying it by a factor.
Examples (due date is twice is important so multiply priority by .5):
Priority 0 Due yesterday (-1) would have a total of 1 (0 + 1)
Priority 20 Due 3 days from now would have a total of 7 (.5 * 20 + -3)

ktharsis
+2  A: 

A simple linear function should do. Something based on 3 variables and one constant; something like

CombinedPriority = k * (cd - d) + p

Where k is a coefficient expressing the relative importance of the date vs. the priority value, and cd is the current date.

How/why does this work?

  • (cd - d), expressed is day units, indicates how late (if positive) we are, or how many days we have left (if negative), relative to d. The bigger the value the more "blown" the delivery date; the smaller the value, the more time we have before it comes due.
  • k is used to "convert" this days-late-or-early value, in whatever rank units of the variable p.
  • take the sum of the two, and you have a rating value for a given task (i.e. a d and p value pair), relative to other tasks, for today (this will of course change tomorrow, as when we move in time, d matters more).

Another, similar but less intuitively tractable approach is to increase the degree of the equation, to express the fact that, say, when we are two days late is the importance of the date should have a bigger impact on the CombinedPriority than when we are just one day late.
The function would the look something like

 CombinedPriority = kd2 * ((cd - d) ^ 2)
                  + kd1 * (cd - d) 
                  + kp2 * (p^2)
                  + kp1 * p

Where kd1, kd2, kp1, kp2 are constants, expressing the relative importance of the four elements of the addition. some of these constants may even be zero; in that sense, the first function is a particular case of the second function, one where
kd2 = 0, kp2 = 0, kp1 = 1 and kd1 = k

To summarize: the difficulty is not so much with the math per-se, but with defining a good set of constants which expresses the relative importance of d and p, and possibly the scale on which d and p are measured.
The first function assumes that each of these two factor is on a linear scale (a job with p = 6 is twice as urgent as a job with p = 3, and/or a job 3 days late is three times as urgent as a job due yesterday etc.), whereby the second function allows the d and/or p factors to be on a quadratic scale.

A tentative plan to help define the coefficient(s) is to:

  • first consider the p factor individually (as if the d factor didn't exist). Only considering the p factor, how urgent is a job with p = 3 relative to a job with p = 6 (or p = 9) etc. ?.
  • second consider the d factor individually. (Similar to above: how urgent is a job which is due 5 days from now, relative to a job due tomorrow? Or a job due two days ago?
  • these two steps help define if any of the scales is not linear, and orient us toward a function or the another
  • then we're just left defining the relative importance of the "normalized" p and d factors; this is done by tweaking the k (or kpn, kdn) constant(s).
mjv
Will this approach work with priority ranging from -inf to +inf? For the same day the function result will be a mirror for the negative priorities with the positive priorities. Given day 02-03-2010 (with today with 04-03-2010) then for priorities:-2 -> 5-1 -> 30 -> 31 -> 52 -> 9The ideal would be to weight the priority in that day. Or perhaps the priorities have to be shifted towards 0? Meaning that I have only from 0 to +inf? Although that can be a hard deal as I do not known the minimum value for the priority so I can shift the values.
smink
@smink : I'm sorry, I don't understand. The formulas I suggest are general enough that they can be parametrized (with the constants) to support any linear (or quadratic) combination of the p and d factors. If somehow the rules to use for determining the relative priority of the tasks in the list require a two step process (such as to first consider all tasks assigned to a given day), a two or three variables algebraric formula will not help, since the ranking is essentially a function of all the tasks (at least all the ones for a given day...) You should try and define the rules...
mjv
... which should be used to produce this ranking, and maybe this can be converted to a simple formula. Also, you shouldn't worry too much about infinity, because one of your variables (d, the date) isn't on an infinite scale, consequently you should eithe bound p to some practical range (near the asymptote, but this is a bit circular of course, since asymptote depends on the constants...), or otherwise have an exponential scale for d, since otherwise, you might as well never really consider d (which would always be overpowered by the p factor).
mjv
What I am saying is that if we ran the simple function `CombinedPriority = k * (cd - d) + p` for p ranging from [-2, 2] in increments of 1, so for the set {-2, -1, 0, 1, 2}, for the same date, say 02-03-2010 (with today with 04-03-2010), so (cd - d) will be always the same, then the `CombinedPriority` will be 5 (p = -2), 3 (p = -1), 3 (p = 0), 5 (p = 1), 9 (p = 2).
smink
@smink: not at all! Within a given (cd - d) value, the k * (cd - d) part of the function becomes constant, and hence the whole function simply returns an offseted value of p, which seems to be a desirable property: since the due-date (cd) is the same for all tasks, they rank, relatively, as per their priority factor (p). Things become more interesting between items where cd and p differ, that's where the constant coefficient(s) such as k matter.
mjv