pyschedule
pyschedule copied to clipboard
Setup time
How can I add setup time to jobs when using flowshop? It is very usual to setup a machine before put an another kind of job.
Sometimes accordingly setup times of each job it can be a bad ideia to schedule these jobs in a specific order because that order will have a extra coust of time in reason of setup time between jobs of different kind.
@moacirbrg One way to limit switches between setup groups is to set some parameter and limit the number of times this parameter changes, like:
T.my_setup_group = 1 #task T belongs to my_setup_group
T += R #needs resource R
R['my_setup_group'].diff <= 3 #switch at most 3 times between tasks in mygroup and others on resource R
The ensure that a setuptime is incorporated, one could add specific optional setup tasks wirh some reward, which makes them optional, like:
T_setup = S.Task(length=setup_time, reward=0,my_setup_group=1)
T.my_setup_group = 2 #set the running state for my_setup_group to 2
for t in range(horizon):
S += R['my_setup_group'][t:t+1].diff_inc <= 1
# the last line ensures, that before running task T, there needs to be a task T_setup with setup state 1 to ramp up to the running state 2
So there are many options to penalize switching between setup groups. If you provide some more specific example, i give more advice how to model appropriatley. Finally, there is also the option of conditional precendence constraints, but this is very computationally expensive, so i would try using the example given above
Follows a simple example of what I'm trying to do.
There are 3 machines (resources): M1, M2 and M3 There are 5 jobs (tasks) and two job families (group): A1, A2, A3, B1, B2. All jobs need to pass trough all machines. Example: A1 must pass trough M1 first and then trough M2 and finally trough M3.
M1 has a setup time for each family exchange. Example: SETUP + A1 + A2 + A3 + SETUP + B1 + B2 M2 and M3 always has a fixed family-independent setup time for each job. Example: SETUP + A1 + SETUP + A2 + SETUP + A3 + SETUP + B1 + SETUP + B2
Thank you very much.
i added an example with your requirements to the examples notebook folder: https://github.com/timnon/pyschedule/blob/master/example-notebooks/flowshop-setup-scheduling.ipynb Please check and test, this is a nice use case. The concept of a "setup state" that increases and decreases might be a little confusing. Also note that i partitioned your jobs into "groups", that is a special feature of pyschedule
Noe that the setup on Machines 2 and 3 can simply be solved by increasing the lengths of the tasks by one, so no need to implement this with specific setup tasks.
Also, please install the newest version:
pip uninstall pyschedule
pip install pyschedule
Thank you for your help. I have some points to consider.
- I didn't understand the real reason for block 7 that starts with "#each setup state is only".
- At block 6, why you have created and hide FA_M1_x? SA_ and SB_ are ok, but FA is confusing for me.
- Have you tried to put just one task from B family with high priority, all task from A family will disappear.
- About setup time on M2 and M3, it is really important to check setup time because something planned could be fail just because setup is wrong and not the entire task. Historicaly it is really important do separate setup and task to figure out what process need to be improved. It is really easy to configure in your lib, so... there is no problem here, it is just an information.
-
when the setup state ("setup_state_A") of a machine is 2, then it can run tasks of type A. However, the normal state is 0, and so the state needs to be increased by 2 to get to state 2. However, we limit the increase by 1 on in every step, and so its not directly possible. Therefore, one needs to first go to state 1 and then to state 2, each time increasing the state 1. The only tasks with state 1 are the setup tasks, and so its necessary to first schedule one of them to climb this ladder.
-
The fill tasks are there to fill gaps with setup state 2. More specifically, if we are in setup state 2, we continously have to run tasks in this state to keep it. However, we might not have enough "official" tasks, so we simply create some fill tasks which are optional to schedule and which we finally hide when plotting.
-
what do you mean with high priority?
-
This is indeed a nice use case
There is an update of your notebook: https://github.com/timnon/pyschedule/blob/master/example-notebooks/flowshop-setup-scheduling.ipynb
I added a feature to add all tasks belonging to the same group at once using S.Tasks
. This greatly reduces the number of lines needed. The parameter n_tasks
defines how many tasks are in the respective group.