Emptying a reservoir from any level

269 views
Skip to first unread message

Sbrad

unread,
Feb 2, 2022, 4:14:48 AM2/2/22
to or-tools-discuss
Hi all,

First time writing in the forums, but i've taken a look a lots of the other threads and its super helpful! 

Im coding a job scheduling problem where tasks are scheduled on machines to manufacture products. We have a rule that 
1. we can only manufacture a specific number of the same product before we have to stop to clean the machine before continuing to make the same product. 
2. if the product changes from product A to product B, the machine must be cleaned in-between. 
The aim is to minimize the amount of cleaning performed on the machines.

Ive made some progress by modelling these constraints as a reservoir with the maximum capacity equal to the max number of products that can be manufactured at once before cleaning, and each time a product is manufactured on the line the level rises. When the capacity of the reservoir is reached cleaning is initiated and the reservoir is emptied since the level of the reservoir is known when it is at full capacity. However, how can I completely empty the reservoir when it is not at full capacity? i.e. when the product changes from type A to type B the machine will be cleaned due to the second rule, and the capacity must again start from 0 and begin counting for the new product. Is there a way to empty the reservoir from any level? or another way to solve this problem?

Thanks

Rushabh Doshi

unread,
Feb 2, 2022, 4:32:27 AM2/2/22
to or-tools...@googlegroups.com
Hi Sbrad,

A good way of modelling the change-overs in a scheduling problem is to use circuit constraints. Look at the way the job shop with distance is modelled (https://github.com/google/or-tools/blob/master/examples/python/jobshop_ft06_distance_sat.py).
In the example minimum distance is added between any two jobs being scheduled on the same machine. To model your constraints you can add the conditions inside the second for loop and swap out minimum distance for a function of your constraints.

--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/709e92cf-725b-40c4-a520-794036f0b4a8n%40googlegroups.com.

Sbrad

unread,
Feb 2, 2022, 8:03:45 AM2/2/22
to or-tools-discuss
Hi Rushab,

Thanks for the advice. Ive taken a look at the code example you sent but don't see how this would work? If I was to implement the constraint using arcs i would need some kind of variable which is able to count how many consecutive products have been manufactured so that when in reaches the limit cleaning is initiated, or when a new product is manufactured the count is reset.

I already have logic to add cleaning and it enforces from the type of product changes, but how can I count the number of product types?

Sbrad

unread,
Feb 2, 2022, 8:04:32 AM2/2/22
to or-tools-discuss
From my original question, do you know if it is possible to empty a reservoir without knowing the current level?

Rushabh Doshi

unread,
Feb 4, 2022, 6:12:17 AM2/4/22
to or-tools-discuss
Hi Sam,

I don't know how to use reservoir levels to implement the changeover constraints. 
I have attached a jupyter notebook where changeover constraints have been implemented. We need the product family of every job to be scheduled. The way it is setup is that if the solver schedules jobs of the same product family then the transition time between jobs is 0 else some time is added. Let me know what you think.

Changeover_constraints_OR_Tools.ipynb

Laurent Perron

unread,
Feb 4, 2022, 6:50:02 AM2/4/22
to or-tools-discuss
Hi Rushabh, 

This is a good approach. 

Nice job.
Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



TheAbesis

unread,
Apr 19, 2022, 7:43:21 AM4/19/22
to or-tools-discuss
Hi everybody,

I have a similar problem to Sbrad's.

We have a machine that needs to be cleaned after several units have been processed.
The products come in batches of 10-30 units so we are scheduling batches of various demands, not single units.
After processing 200 units (demand), the machine must be cleaned.

We have tried using reservoir constraints for that.
The idea was to set the bounds of the reservoir to 0-200 and empty it using virtual batches of lets say demand -200.
But then, in most cases, the solver will not manage to fit product batches with total demand of exactly 200, before emptying the reservoir, so it will not be able to schedule the virtual batch of -200.

So, following the original question of Sbrad, is there a way to reset the reservoir, whatever its level is?

Btw, I have also tried to follow Rushab's example with circular constraints instead, but it does not seem to fit.
Rushab adds void time for cleaning every count_jobs_processed_before_cleaning jobs, but adds it between specific pairs of jobs at the time of building the problem.
This does not let the solver decide where to put those cleaning tasks. I'm not an experienced user though, so please let me know if I am missing something.

Thanks!

mangka123 Right

unread,
Dec 27, 2023, 8:54:50 PM12/27/23
to or-tools-discuss
Hi Rushabh, your code helped me a lot. I have similar problem to solve, but my changeover constraints are  more complicated. Except for machines, I have tools shared by machines or product family. So there will be a situation that a shared tool switch from one machine to another machine,  the worked machine has to stop, then it will start work again after the tool switch back. the transition_time needed be considered here . Do you have any coding suggestion for the kind of scenario. Thanks!
Reply all
Reply to author
Forward
0 new messages