question

SudheerReddy avatar image
0 Likes"
SudheerReddy asked Regan Blackett commented

Query on Pull From List

As shown in below image, I need to Pull the tokens based on below mentioned logic

When token id:4 enters into list the cumulative sum of Value is 12 which is >=8. So I need to order first three token whose cumulative Value is <=8. i.e. first three tokens.

In similar way When id:5 enters into list the cumulative sum of Value is 10 which is >=8. So I need to order only id:4 token whose cumulative Value is <=8 i.e only one token.

So in Request number and Require Number in first situation it should be 3 and in second situation it should be 1 and so. How can I achieve this.

Is there any other way if the above mentioned is not possible or any other best way to do.

I'm attaching my model for reference.

pull.fsm

FlexSim 19.2.4
pull
pull.jpg (38.4 KiB)
pull1.jpg (49.5 KiB)
pull.fsm (27.8 KiB)
5 |100000

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

Regan Blackett avatar image
2 Likes"
Regan Blackett answered Regan Blackett commented

I hope I’m understanding your problem correctly. It sounds like the idea is that when puller comes to your list, it pulls ALL entries present, such that the cumulative value of entries is less than or equal to 8. So if 3 tokens with a cumulative value of 7 are present the puller takes them all.If there is a single entry with a value of 2 present, the puller takes it.If the puller becomes a back order, wait until an entry shows up then pull it.

See the attached model but I’ll explain a bit what it’s doing because there’s a couple of things here that are not common.For the pullers from the List, they need to know how “much” they have pulled so far so that our Query can check to see if there is an entry whose Value will keep the puller under the threshold (less than or equal to 8). I assigned the amount pulled so far to a label called PulledToDate, and this label is initialized at zero right after the source.

Then the Pull from list does two things that are interesting; the Query Says to pull Where the Value field/label of the entries, plus the value of the PulledToDate label on the puller is less than or equal to 8.

WHERE (Value + puller.PulledToDate) <= 8

But it only pulls one Entry.The puller will have to loop around and pull again if there are additional entries that could keep the puller below 8. So after pulling an entry, I update the PulledToDate label, and go to a decide that checks if there are entries on the list.If there aren’t, then the puller is done.If there are, it goes back to the Pull from List and pulls again.

Here is where it get a little tricky; if there are no entries on the list that can keep the puller below 8, I don’t want the puller to become a backorder, so I’m using the Max Idle Timer option to say if the puller has pulled at least 1 thing so far, then wait for zero amount of time and release from the Pull activity.This effectively means that the puller will give up waiting for an entry to pull as soon as it arrives if no entries satisfy the query.This will also allow a puller that arrives to the Pull with an empty list, it will properly become a back order and wait for an entry to arrive because it hasn't pulled at least one thing yet. Below is an image of the basic flow:


· 5
5 |100000

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

SudheerReddy avatar image SudheerReddy commented ·

@Regan Blackett Thanks for support it really helped. Following are few observations I made in the model.

1) I just changed Source:Pullers(Activated Arrival at Time 0) and then If there are no entries in the list the following error (exception: FlexScript exception: label pulled doesn't exist on token id: 1 at MODEL:/Tools/ProcessFlow/ProcessFlow/Pull from List>variables/startIdle) is thrown as shown in below Image.

So token.pulled.length>=1 is getting failed when puller arrived first and when List is empty.

I am attaching the model which is throwing error for your reference.

24180-pull-cumulative-value-1.fsm.

2) The next part is as you mentioned, if there are no entries on the list that can keep the puller below 8, then my puller has to wait i.e. want the puller to become a backorder, and pull the items until the below Query is failed. So the puller has to leave the loop only when the Query is failed.

WHERE (Value + puller.PulledToDate) <= 8

Could you please help me on the above two items.

0 Likes 0 ·
Regan Blackett avatar image Regan Blackett ♦ SudheerReddy commented ·

@Sudheer R

Here's an updated version. I just changed the Max Idle time Start Criteria a little. I thought I did this yesterday to account for when the puller shows up first but I guess I only thought about it. The condition now says if the the pulled label exists and the label has a length of 1 or more then the idle timer is in effect. So if a puller hasn't pulled anything (token.pulled doesn't exist) then the idle timer is off.

However I'm not clear on your second point. Under the current behavior if a puller comes to the list and there are no entries it becomes a back order. A single entry arrives with a value of 1, the puller pulls and considers itself finished because it's cumulative value is less than/equal to 8 and there are no more entries to consider. Are you saying that the puller should go back and wait for more entries to consider in order to get even closer to 8?

I'm starting to wonder what it is you are really trying to do? In the system you are modeling is there an actual searching mechanism one part of the system is doing on another or is the list mechanism just limiting the flow of the entries? If it's jsut a flow control mechanism this might be more easily handled with a Zone and it's subset contraints.

pull-cumulative-value-2.fsm

0 Likes 0 ·
SudheerReddy avatar image SudheerReddy commented ·

@Regan Blackett

token.pulled? && token.pulled.length >= 1<br>

Could you please explain token.pulled? . Here ? will search whether pulled label is Null or not. Is my understanding is correct.

What I am looking for is I am trying to fill a Truck with different dimensions parts. So Once the Truck is full only it can dispatch. Is my approach of sending the parts to List and once the required quantity is arrived pull from list is correct approach or could you please recommend if any better solution.

0 Likes 0 ·
Regan Blackett avatar image Regan Blackett ♦ SudheerReddy commented ·

@Sudheer R

Maybe a Batch activity with a Label quantifier would give you what you need with a lot less work? See the properties below.

With the quantifier set to your label Value, the Batch will try to collect the Batch Quantity. If it can't collect the full amount, it will let the the token that would have put the Batch over it's limit be part of the next Batch and the collected amount is released as a single token that could represent your truck.

IN the label aggregation section I just added those in so you can see the individual Values of the batch members as an Array, as well as the total value of the Batch.

1 Like 1 ·
batchversion.png (23.8 KiB)
Regan Blackett avatar image Regan Blackett ♦ SudheerReddy commented ·

Regarding the Start Criteria for the Max Idle time:

token.pulled?

Means to return a nullvar if the pulled label doesn't exist, which is treated as 'false' for the Start Criteria. So it can essentially be treated as saying "if the pulled label exists and it has a length of >= 1" then use the Idle timer. The previous Start Criteria threw an exception because it tried to access a label that didn't exist.

0 Likes 0 ·
Benjamin W2 avatar image
0 Likes"
Benjamin W2 answered SudheerReddy edited

Hi @Sudheer R,

This type of specific behavior will require some custom code.

  1. Add an event triggered source in your process flow that fires every time a token enters your "Push to List" activity.
  2. Add a "Pull from List" activity directly after that. Make sure to connect this activity to your "List" activity.
  3. In that "Pull from List" activity, add the following custom code to both the Request Number and Require Number field
  4. List itemList = List("ItemList1");
    int listLen = itemList.entries().length;
    int valueSum = 0;
    for (int i = 1; i <= listLen; i++)
    {
    	valueSum += List("ItemList1").entries()[i].value.labels["Value"].value;
    	if(valueSum >= 8)
    	{
    		return i - 1;
    	}
    }
    return 0;
    	

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

SudheerReddy avatar image SudheerReddy commented ·

@Benjamin W2 Thanks for the Custom Code it helped me.

I have few doubts in the way the custom code return statement is working

if(valueSum >= 8)
{  
return i - 1;
}
return 0;

If valueSum is>=8 then only return will return i-1 else it will return 0. But as shown in below image ...token id:4 has pulled id:1, id:3 even though return statement returned 0

Now in below image, token id:6 has pulled id:1, id:3 id:5 even though return statement returned 0.

So for id:6 it is showing as tokens are pulled but still pulled tokens are in the List(waiting to get pulled) as you can see in the below image. This looks bit confusing.

Now in the below image token id:8 has pulled the same tokens as above id:1 id:3 id:5. And now the tokens are finally pulled from the list and moved to next activity.

Here my question is why in the above two situations even though the Custom Code is returning 0 the tokens are getting pulled and still not moving out of the list. In this third situation tokens are pulled and moved out of list. How to understand this step.

I am attaching the model for your reference

24179-custompullfromlist.fsm

0 Likes 0 ·
1.jpg (477.2 KiB)
2.jpg (350.0 KiB)
3.jpg (351.8 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.