Statistics/Probability Question

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
It's been awhile since I've done stats so don't laugh :p

I am writing a tool, and part of the functionality is scheduling tasks. Each task has a priority level, and the scheduler has different queues for each priority. To schedule the next task, I have two independent "heuristics":

1.) The priority level of the queue
2.) The ratio of tasks in that queue to the total number of tasks overall

So say there are 4 queues, each with a different priority. A logical, but arbitrary weight to assign to each one:

.4 (highest priority queue)
.3
.2
.1 (lowest) +
________________
1

On the flip side, I have a weight for the number of tasks in a queue. Once again 4 queues with a total of 50 tasks:

12 - 12/50 = .24 (highest priority queue)
24 - 24/50 = .48
6 - 6/50 = .12
8 - 8/50 = .16 (lowest) +
________________
1

Is there a probability formula to combine these two weights to get a standard score (value between 0 and 1, scores for all 4 queues equals 1) for each queue?
 

mugs

Lifer
Apr 29, 2003
48,920
46
91
So you essentially want a queue's priority to increase if it is longer than the other queues?

You could multiply the two values for each queue together and divide by the total, so you end up with:

.34
.51
.09
.05

The 2nd highest priority queue went up substantially because it was the longest, while the two lowest went down substantially because they were the shortest. (It's impractical to show the math - I just made a spreadsheet with your values in columns A and B, column C = A*B, C5=sum(C1:C4), column D = column C/C5

If my calculations are correct, your queues would hover at the following levels:
12% of total jobs (highest priority)
16%
24%
48% (lowest priority)

If that is unacceptable, you could adjust your first set of probabilities.
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
Originally posted by: mugs
So you essentially want a queue's priority to increase if it is longer than the other queues?

Exactly. If you only schedule based on priority, you can run into situations where the lower priority queues get starved. With this method, if a low priority queue has the majority of tasks, the probability that the scheduler will pick that queue next goes up.
 

mugs

Lifer
Apr 29, 2003
48,920
46
91
Originally posted by: tfinch2
Originally posted by: mugs
So you essentially want a queue's priority to increase if it is longer than the other queues?

Exactly. If you only schedule based on priority, you can run into situations where the lower priority queues get starved. With this method, if a low priority queue has the majority of tasks, the probability that the scheduler will pick that queue next goes up.

Edited my previous response with a suggestion.
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
Originally posted by: mugs
Originally posted by: tfinch2
Originally posted by: mugs
So you essentially want a queue's priority to increase if it is longer than the other queues?

Exactly. If you only schedule based on priority, you can run into situations where the lower priority queues get starved. With this method, if a low priority queue has the majority of tasks, the probability that the scheduler will pick that queue next goes up.

Edited my previous response with a suggestion.

I will give that a try. Thanks!