How to set number of operator for each shift by Global Table?

How to set number of operator for each shift by Global Table?

yunjukuo
Not applicable
22 Views
17 Replies
Message 1 of 18

How to set number of operator for each shift by Global Table?

yunjukuo
Not applicable

[ FlexSim 16.1.2 ]

In this case, the operators are divided into day shifts and night shifts. The maximum number of operator in each shift is 5, so there should be a total of 10 operators in day and night shifts. But for the convenience of generating charts, I set 5 operators working for 24 hours in the model.

Day shift working hours: 7:00~19:00

Night shift work hours: 19:00~next day7:00

Each person has a rest time following the TimeTable setting.

I want to use GlobalTable to set the number of operator working in day shift and night shift. How can I do this in FlexSim?

In the table below, each row represents the day of the month, and each column represents which person is on the day shift or night shift. 1 means working, 0 means not working

For example, row "Day 5" column "Day OP_B" is 1 means operatorB must work on the 5th day of this month.

1660407402106.png

https://drive.google.com/file/d/1Mg577vHXRjEMAoagDcksjB-zONzXFCwA/view?usp=sharing

0 Likes
Accepted solutions (1)
23 Views
17 Replies
Replies (17)
Message 2 of 18

joerg_vogel_HsH
Mentor
Mentor
There exists already a timetable tool wherein you can choose down and uptime. And you can select members connected to this timetable.

PLEASE use this tool! It is always better to follow methods than inventing new one. If you want to replace timetables, then you setup for example a repeating user event, which loops through your table to stop or resume involved operators.

0 Likes
Message 3 of 18

yunjukuo
Not applicable

Can you please demonstrate how to use TimeTable to achieve the function of the above situation? The daily rest time of each operator is fixed. The users of this model hope to have a function such as a table that can easily set staff shifts without changing member of TimeTable each time.

Or is there a code function/command to change the members of the TimeTable, so that I can put operator into the TimeTable that Shedule_Down all day according to the GlobalTable setting every shift.

0 Likes
Message 4 of 18

moehlmann_fe
Observer
Observer
Accepted solution

What you could do is create a time table for each shift, with each operator being a member of both time tables. In the down/resume-function you can then add a condition based on the Shift table that controls if the operator is actually stopped or not.

Because this controls if the down time happens or not, the marked times in the time table are inverted: In the night shift table, the night hours are marked as inactive and vice versa.

The code below determines the correct row by reading the current date and converting the day into a number. To get the column it's probably easiest to just write those onto labels of the operators and read them from there.

1660549108270.png

Only if the shift is marked with a "0" in the table, will the condition evaluate to true and the operator will be stopped. Otherwise nothing happens and the operator remains active.

1660548986237.png

(In the screenshot I use the default "Stop Object" logic. You can also use other logic such as the "Travel To Object, Delay Until Down Time Complete". Just change the option before you edit the code and then enclose everything after the variable definitions (up to line 6) in the condition as seen above)

0 Likes
Message 5 of 18

andrew_o2
Not applicable

Hi @Yunjukuo, was Felix Möhlmann's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes
Message 6 of 18

fengjun0113
Not applicable

Hi @Felix MöhlmannI tried to take reference of your code. But, According to the situation of this case, I chose "Travel To Delay Until Down Time Complete" instead of "Stop Object". However, I observed two unormal things. First, these two operators will go to "Rest" directly. Some of them should NOT go to "Rest" based on the setting in "Global Table-Shift". Second, for this case I think we should consider operators should work or not ("Global Table-Shift") then dicide these operators going to "Rest"(Time Table). But, your logic just consider operators going to "Rest" when they are in both "Down Time" and not work. Belows is the link of the model.

1661006866519.png

https://drive.google.com/file/d/1DKwubrQbJnRgqT4pSH7VATbpiNEhV1AW/view?usp=sharing

0 Likes
Message 7 of 18

moehlmann_fe
Observer
Observer

When reading the value from the the global table you set the name of the table as "shift" instead of "Shift". Because of this the command always returns 0 since no table with the given name exists. This then causes the down function to execute.

I don't quite understand what you mean by your second point. What you describe is functionally the same as what the time table is doing: At given points in time (when the down time starts) it checks if the operator works or not and sends them to "Rest" in the latter case.

In newer versions of FlexSim you could also do this with only a single time table that contains both shifts. But since in 16.1 the time table only supports increments of 5min, two down shifts that follow directly after each other would be merged into one.

You will always need a timed trigger to check whether the operator should start its down time or not. I believe using the down time of the time tables for this is convenient since all you need to do is to not run the default code depending on the value in the table. For example the time table automatically handles the case of the model starting during a shift, which you would have to account for separately in a custom logic.

If you think handling this logic from the time tables would be better, then you can of course set up a timer in a process flow that checks the value of the respective columns every 12 hours and runs the same code as the down function would, if the operator is supposed to be off shift.

0 Likes
Message 8 of 18

fengjun0113
Not applicable

Thanks for your reply


For the first point, I edited "shift" to "Shift", but these operators still go to "Rest".


For seconf point, what I mean is I want operators go to "Rest" in two conditions. There are marked 0 in "Shift" and Down Time in Time Table. consider operators should work or not ("Global Table-Shift") then dicide these operators going to "Rest"(Time Table). But your logic makes operaors go to "Rest" go to "Rest" in only one condition which is marked 0 in "Shift" and Down Time in Time Table happened at the same time.

https://drive.google.com/file/d/1DKwubrQbJnRgqT4pSH7VATbpiNEhV1AW/view?usp=sharing


0 Likes
Message 9 of 18

moehlmann_fe
Observer
Observer

When I run your model the only operator that goes to "Rest" is C2, which has zeros in the "Shift" table up to row 18, so this seems correct.

1661020121687.png

Without linking the "Shift" table to a time table it would be meaningless, since there wouldn't be any definition of which model time those values belong to.

So you could consider the time tables that are currently in your model as a necessary part of the "Shift" table to make it work.

If you want to add break times to the "active" shifts, then you can add more time tables. These should then be set up in reverse to the current ones, so that the down times only happen if the value in "Shift" is 1.

So either the value is 0 and the current time tables will make the operator inactive or the value is 1 and the added time tables can set them as inactive.

0 Likes
Message 10 of 18

fengjun0113
Not applicable

I tried to use Time Table "Shift_Night" and "Shift_Day" to make operators inactive based on the setting in Global Table "Shfit".Then, I used the other Time Table to determine whether operators should work or break. However, when I run model, all operator don't work.

https://drive.google.com/file/d/1DKwubrQbJnRgqT4pSH7VATbpiNEhV1AW/view?usp=sharing

0 Likes
Message 11 of 18

moehlmann_fe
Observer
Observer

You removed the condition from the "AB/C Day/Night" time tables, meaning they are always active and will always set the operators inactive for their respective 12h periods.

The two new "Shift" time tables don't have any time marked as operational, so they will set the operators as inactive for the whole day if the condition is fulfilled. And "Shift Day" doesn't have any members assigned to it.

I adjusted the model so that the two "Shift" time tables control whether the operators are active during a shift. If not they are send to a new "OffShift" object.

The other two "Breaks" time tables control when operators rest during an active shift. The entered times are of course only example values. Again, it's important here that the "Breaks" time tables only trigger their down function if the operators are actually active. Otherwise you will end up with duplicate task sequences that delay the operators for longer than they should. That is why they also need to check the values in the "Shift" table.

I changed the time format in the model to use the 24h clock, so that you don't need separate day/night time tables for the breaks, since the code can use the 24h time to determine which shift is currently active and adjust the column it reads from.

https://drive.google.com/file/d/1FZZgrArLN5uUxPZ25NBfuYl6oCQm1igA/view?usp=sharing

0 Likes
Message 12 of 18

fengjun0113
Not applicable
When I run your model, five operators go to "OffShift". Is it correct?
0 Likes
Message 13 of 18

moehlmann_fe
Observer
Observer

No, only C2 should go to "OffShift".

1661077660293.png

Could you run the following commands (separately) in the script window (Top bar, next to the "Dashboards" button) and post the results?

convert(time(), MODEL_TIME, DATE_STR)
convert(time(), MODEL_TIME, TIME_STR)

1661077866656.png

Maybe the language setting of your operating system is influencing the date format, so the code that reads the day would have to be adjusted.

0 Likes
Message 14 of 18

fengjun0113
Not applicable

It seems like something went wrong. How can I fix it?

1661083746260.png

0 Likes
Message 15 of 18

moehlmann_fe
Observer
Observer
Only put in one command at a time. That's what I meant by "separately".
0 Likes
Message 16 of 18

fengjun0113
Not applicable

Ok, I think it's because some of the characters are Chinese. How can I adjust?

1661087212138.png

1661087231997.png

0 Likes
Message 17 of 18

moehlmann_fe
Observer
Observer

It could be that the chinese character takes up more memory, so the index at which the number starts is higher in your case.

Open the code of down function of "Shift_Day" and put a break point at line 19. Run the model and the code will pause when reaching that line. Then step through the code line by line and look at what is assigned to the "dayDate" variable.

If it is different to "1 " (1 plus one space) then increase the start index parameter in the "stringcopy" command (marked green) until the output matches.

1661088362742.pngUsing this method you can also check if the code is working correctly in other areas.

0 Likes
Message 18 of 18

fengjun0113
Not applicable
it works. Thank you !
0 Likes