question

Sonia A avatar image
0 Likes"
Sonia A asked Sonia A commented

How to organize and pull single items from a list

Hello everybody!

I am trying to build a model focused on warehouse systems. In my warehouse, I have some drive-in racks with corridors, levels and bays. At every level, bay and corridor there is a control point on an AGV network. I would like some pallets (sku=1) to be stored as close as possible to a specific control point (called CP1). I have thought to put all the Control points of the rack (which are indications of the address of slots in the racks) in a list and to calculate for every control point the distance to CP1. I have filled the list as you can see in the code below.

I have then calculated the distance in another custom code and this is the result. As you can see the CPs in the list are ordered based on the way they have been pushed in the list. I would like to have the CPs in the list ordered by increasing distance (from lowest to highest). How do I put the CPs with the lowest distance in the first position? If I can do that, how can I pull the first CP from the list?

Maybe I am approaching the problem in a weird way but my end goal is to pull from that list, one CP at a time, the CPs with the lowest distance (and of course have them removed from the list after I have pulled them). Does anyone have ideas on the right commands to use to achieve that?

To be extra clear, if we look at the list above, I would like to pull CP11011, save this address in a variable, do some other things and then remove CP11011 from the list. I would then pull CP11021, save the address and remove CP11021 from the list. I would then like to pull CP12011 save this address and remove it from the list, and so on following the distance values from lowest to highest.

I have tried to pull items in this way but it does not work, I am doing something wrong:

Variant ind_CP = List("CP list").pull("ORDER BY distance ASC");

Thank you so much for your help!


FlexSim 21.0.0
flexscriptwarehouseflexsim 21.0.0pulling from listscostum code
1615191484448.png (37.2 KiB)
1615192225109.png (58.8 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.

Ben Wilson avatar image Ben Wilson ♦♦ commented ·

Hi @Sonia A, was Sonia A's or Jörg Vogel's answer helpful? If so, please click the red "Accept" button at the bottom of one of their answers. 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 ·

1 Answer

·
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Sonia A commented

FlexScript Class Reference in Manual:

List.pull

List.PullResult

List - functional concepts

· 4
5 |100000

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

Sonia A avatar image Sonia A commented ·

Thank you, I have managed to pull items from the list in this way:

Variant ind_CP = List("CP list").pull("ORDER BY distance ASC",1,1);

Is there a way to copy the item value with the lowest distance from the list into a variable? When using List.pull() the item is deleted from the list but I don't want to lose that information since I need to compare the item value with something else before removing it from the list.

Thank you for your help!

0 Likes 0 ·
Fiorenzo A avatar image Fiorenzo A Sonia A commented ·

Hi,

as you write is good. Flexsim save in the local variable (in your case ind_CP) the information of what item you are pulled. If you want to access this variable all the time, you can save it on a GlobalVariable as in the picture below

0 Likes 0 ·
1615203803223.png (44.6 KiB)
Joerg Vogel avatar image Joerg Vogel Sonia A commented ·

A list pull method does not store any field values. If you need the field values then you can query the list as a table. You do a table.query and then you pull the value from the list.

0 Likes 0 ·
Sonia A avatar image Sonia A Joerg Vogel commented ·

Thank you for your help!

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.