question

Jouky D avatar image
0 Likes"
Jouky D asked Ben Wilson commented

How to use the number of tokens with label X waiting to be pulled?

Hello everyone!

I am trying to optimize Stock using simulation. Until now, I have bought the optimal stock everytime the command point is reached. But now, I would like to buy the needed units to reach the optimal Stock depending on the actual units. For example:

If I have an optimal stock of 300 units of D, and I have 30 units in the warehouse of label D, and the command point is when the warehouse' stock is less than 40 units of D, then I have to send to the warehouse 300 units of D (optimal stock) - 30 units of D (actual Stock) =270 units of D.

I am doing it using a List in Process Flow. My question is: How can I get the value of tokens that are pushed into the list (waiting to be pulled) and take it to calculate the units of D to send to the warehouse? I have remarked the units of D, because I do not want the total tokens that are waiting to be pulled, I want for each label (30 tokens of A, 20 tokens of B, etc. are waiting to be pulled) and use them to the calculus.

Thank you!

FlexSim 20.0.5
processflowlabelslisttokensflexsim 20.0.5
· 3
5 |100000

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

tannerp avatar image
1 Like"
tannerp answered

@jouky.d,

I can offer some guidance as to how you can retrieve the entries on the list. However, I'm not sure how your stock re-filling works, so I'll leave that up to you. Here's how I would check to see the contents of the list, assuming that each item type has its own partition. You could alter the logic a little bit if they aren't sorted by partition. Let me know if you'd like to do that instead.

In my example model, I am pushing 10 items of three different types to a list. Then, the token in Process Flow is created at 10 seconds and grabs the items on the list in the Custom Code activity.

The "entries()" function allows you to get the entries on a list in Array form. You can then check the array's length to know how many items are currently on the list for each type. I've simply taken the length and assigned it to a token label for each item type, as seen in the example model. You don't even need to pull the entries to get this data. I hope I understood correctly and that this helps!

Here's the code used:

  1. List itemList = List("ItemList1");
  2. Array itemArray;
  3. int lengthArray;
  4. string labelName;
  5.  
  6. //Check each partition for Types 1-3
  7. for (int i = 1; i <= 3; i++)    {
  8.     itemArray = itemList.entries(i).toArray(); //Save entries from partition "i" to array
  9.     lengthArray = itemArray.length; //Calculate length (number) of items in array of Type "i" items
  10.     
  11.     labelName = "Type"+i+"Length"; //Create label for Type "i"
  12.     token.labels.assert(labelName, lengthArray); //Assert label to token
  13. }

pull length list entries.fsm


5 |100000

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

Benjamin W2 avatar image
0 Likes"
Benjamin W2 answered Jeff Nordgren edited

Hi @jouky.d,

I think all you need to do is check the "Leave Entries On List" box in your "Pull from List" activity. This will create a reference to the pulled tokens without actually pulling them off the list. Take a look at the attached example model:

LeaveEntriesOnList.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.