I want to develop an algorithm to serve the queue of children queueing to a basket full of balls of different colour, where each ball can be painted within a known time any colour (of several colours offered) requested by the child, and any child would eventually return a ball back to the basket after he/she finished playing with it. Painting of several different balls can happen in parallel.
To me this looks like a scheduling algorithm to serve a queue of requests to access one resource within a shared fixed-size resource pool, where each resource takes some time to prepare. Here are the requirements it should satisfy:
- resources can belong to one of several classes (number of classes is low and fixed), each class takes a different (known and fixed) time to prepare;
- each customer only requests one resource of a specified class;
- we have visibility to the customers' requests for the entire queue, not just its head, i.e. we can see all requested classes before the customer starts being served;
- resource preparation can happen on demand, when customers arrive to the queue, as well as in advance, when we see the growing queue and want to "guess" what kind of resource future customers would want;
- the maximum number of resource preparation activities we can run in parallel is the same as the pool size;
- we want to maximise the queue throughput.
On the first glance, this looks like something we can address using the queuing theory for queues with multiple servers (due to our capacity to prepare several resources in parallel) and work-independent service times. The difference I see here is that each customer eventually returns resource it has obtained from the pool back to the pool. Returned resource can either:
- be immediately served to a waiting customer, if the class of resource is what a waiting customer wants; or
- be placed back to the pool (hoping we would soon get a customer that would want that resource class), therefore reducing pool's capacity for resources of other classes; or
- be converted into another class: this is possible and takes same time it would take to prepare resource of that other class.
If we would know the distribution of time it takes each customer to return its resource back to the pool, can we still model this as a queue with multiple servers? How would this affect the distribution of the serving time? Or maybe there's another model describing what I want? Any help or pointers would be appreciated.