question

Felipe Capalbo avatar image
0 Likes"
Felipe Capalbo asked Jason Lightfoot edited

Amount of items by type in a Rack

I'm building a Reinforcement Learning model that has its observations based on the content of the available racks.

So far I found the following script to reference the number of items in the rack:

Model.find("Rack1").subnodes.length

That command provides me only the overall quantity of items. I want to have this informations separated by its Type, an Item Label, in a command. Is that a way to do that?

1706112124478.png

Parameter Table with the Parameters that references the rack content.

FlexSim 24.0.0
rackcontent
1706112124478.png (2.4 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.

José Antonio MD avatar image
1 Like"
José Antonio MD answered Felipe Capalbo commented

Hello @Felipe Capalbo ,

If you want to count filtering by object and type I would use the StorageSystem. Using this system, you could use more filters, grouping...

Variant itemsWH = Storage.system.queryItems("WHERE Type = $1 AND item.slot.storageObject=$2",0,2/*Type*/,Model.find("Rack2")/*Rack*/);
return itemsWH.length;

You have more options such as looping and counting, filtering by tree... but I think this one will work well for you.

I hope I have been helpful.


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

Felipe Capalbo avatar image Felipe Capalbo commented ·
Thank you!
0 Likes 0 ·
Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Jason Lightfoot edited

Here's a one shot query to list all the types and quantities by storage object and place that information in a global table.

Storage.system.queryItems("SELECT item.slot.storageObject AS Rack, item.Type AS Type, count(*) AS Count  GROUP BY Type,Rack").as(Array).as(Table).cloneTo(Table("GlobalTable1"))
· 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.

Felipe Capalbo avatar image Felipe Capalbo commented ·
Is there a way to fix the Rows position as the GlobalTable updates its values?
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Felipe Capalbo commented ·

You can try adding the clause to "ORDER BY Rack ASC, Type ASC" after the GROUP BY clause

1 Like 1 ·