Combined average for priority and due date
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 thes开发者_运维百科e 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 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).
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.
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)
精彩评论