question

Sander avatar image
0 Likes"
Sander asked Joerg Vogel commented

Find lowest value over multiple partitions in a list

Hellow,

I wanted to query over multiple partition in a list but that unfortunately not possible. Good idea for improvement imho.

Due to various reasons it still better for me to look in multiple partitions than it is to rewrite my model.

In the model I’ve build parcels arrive and are allocated to storage 1,2,3,4. They have a tonnage and a grade (1 or 2). I need to pull the earliest entry (FIFO) of a grade (for example grade 1). But I need to determine what partition has the earliest entry per grade in order to access the right partition.

All I can think of is make a query per partition in a custom code. Put those values in an array and then loop through it to find the lowest value.

Is there a better/easier way to do this?

FlexSim 24.0.8
pull from list partition
· 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.

Joerg Vogel avatar image Joerg Vogel commented ·

@Sander, a global list is a node structure in model tree. You can evaluate this structure to get references to all partitions. Knowing this you can query each partition by ORDER Clause. Then it is up to you if you order an array, a table or a list to get the lowest value.

https://answers.flexsim.com/answers/64417/view.html

0 Likes 0 ·
Sander avatar image Sander commented ·

Hi @Joerg Vogel ,


Ive tried to understand and implement your comment. unsuccesfull atm.
Ive added the test file. I dont understand how i would go from the partition id to query a partition and get a specific value (label) that i can compare. Could you elaborate please?

(Didnt know the evaluate part, that will be usefull in the future anyhow. thank you.)

Test_list_partition.fsm

0 Likes 0 ·

1 Answer

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Joerg Vogel commented

test-list-partition-jv.fsm

Here I get access to the treenodes of a global List object to get partition IDs and pushTime values of each first entry of a list partition. It is just the source code without any assignment to token labels of any kind.


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

Sander avatar image Sander commented ·

Thanks again @Joerg Vogel. very helpfull!

I kept getting errors from search in the list. I found out that my model creates a partition 0 with nothing in it. and query this partition will throw the code.

1743175462145.pngAfter some digging i found the culprit

Table("Storage_levels")[1][1] = Table.query("SELECT SUM(Tonnage) FROM List1.1")[1][1];test-list-partition-jv-S.fsm


So to say it does mess some stuff up in my model. Any ideas on how to elimite this partition 0?



0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Sander commented ·
@Sander, a partition of 0 is a list without any partition at all. You must have assigned somewhere this value as a partition value. I think that is something you must find out yourself.
0 Likes 0 ·
Sander avatar image Sander Joerg Vogel commented ·
Yeah my thoughts as well but I havnt assigned it anywhere.

check the file in my last post, i added the tabel.query code to the test model and it creates the 0 partition as well.

By your explaination on the treenodes i can rewrite some code to avoid the tabel.query but it looks like bug to me

0 Likes 0 ·
Show more comments