question

Ankur A3 avatar image
0 Likes"
Ankur A3 asked Jeanette F 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

FlexSim 21.0.10
random slotselection
· 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.

Jeanette F avatar image Jeanette F ♦ commented ·

Hi @Ankur A3, was one of Kavika F's or Jonah K's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. 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 0 ·
Kavika F avatar image
0 Likes"
Kavika F answered Kavika F 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)
· 2
5 |100000

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

Ankur A3 avatar image Ankur A3 commented ·
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 ·
Kavika F avatar image Kavika F ♦ Ankur A3 commented ·
Did you want scalability? If so, please mention that in your original post next time. It will help us a lot in the future to answer your questions if you include all the details you have so we can accurately solve your problem instead of solving small portions at a time and jig-sawing them together.
0 Likes 0 ·
Jonah K avatar image
0 Likes"
Jonah K answered Jonah K 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


· 2
5 |100000

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

Ankur A3 avatar image Ankur A3 commented ·
I couldn't open the model since I am using version 21.1.5.
0 Likes 0 ·
Jonah K avatar image Jonah K ♦ Ankur A3 commented ·

Sorry about that. Here is some of the data I used in my example.

The Assign Labels Activity:

1652715467135.png

The DelayTime Custom Code:

/**Custom Code*/

Object current = param(1);

treenode activity = param(2);

Token token = param(3);

Variant assignTo = param(4);

string labelName = param(5);

treenode processFlow = ownerobject(activity);

DateTime dt = DateTime(token.ArrDateTime);

DateTime sdt = DateTime.compose(

Model.startDateTime.year,

Model.startDateTime.month,

Model.startDateTime.day

);

DateTime dt2 = dt - (Model.startDateTime - sdt);

return dt2;


The Model Layout:

1652715708195.png

And the Global Table:

1652715739963.png


Hope this helps.

0 Likes 0 ·
1652715467135.png (318.6 KiB)
1652715708195.png (56.8 KiB)
1652715739963.png (134.4 KiB)

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.