question

Ankur A3 avatar image
0 Likes"
Ankur A3 asked Ankur A3 commented

How to choose random slot out of available slots everyday?

Hi Team,

I have 10 arrival slots available as below:

1652439195272.png

How to choose 5 slots randomly daily basis?

Thank you!

RandomSlotSelection.fsm

random slotselection
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Kavika F avatar image
0 Likes"
Kavika F answered Ankur A3 commented

Here's another possibility with custom code. In the source activity, we set a label "keep". At the beginning of each cycle, we shuffle an array with possible paths and then assign them to each token based upon it's index. This code can be found in the Source activity under the Custom Code value.test1.fsm

1652475554865.png


1652475554865.png (165.1 KiB)
test1.fsm (30.1 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Hi @Kavika F,

Thanks for your answer!

Since we are defining the array manually with 10 elements, I don't feel it is having scalability if we are changing number of slots.

Thank you!

0 Likes 0 ·
Jonah K avatar image
0 Likes"
Jonah K answered Ankur A3 commented

The attached file uses a Global Table to evaluate Arrival and Departure times for each token. First, change the Source quantity to produce the total number of items to be delivered that day (5). The Assign Labels activity does 5 things:

1. Assigns a random Label to the token (1-10)

2. Looks at the Global table to find the Arrival/Departure times

3. Converts both Arrival and Departure times into seconds

4. Calculates correct arrival time in the model

5. Calculates Processing time (between arrival and departure)

The first delay activity waits for each arrival time to be reached (DelayTime for each). The second delay lasts for the Processing Duration.

Does this answer your question?

RandomSlotSelection_Solution2.fsm


· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

I couldn't open the model since I am using version 21.1.5.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.