question

Yash Patel avatar image
0 Likes"
Yash Patel asked Felix Möhlmann commented

how to access and manipulating arrival table with process flow?

Is it possible for me to look up the value in the arrival table which have not yet triggered and swap them with the current trigger based on model condition. for example below is the original arrival table.


Time Name Quantity Label

1 Part 1 X

2 Part 1 Y

3 Part 1 Y

4 Part 1 Z

5 Part 1 X

6 Part 1 Y

7 Part 1 Z


lets say now at time 4 when part Z is supposed to be created, target batch size is 3 I want part Y which was to be generated at time 6 to be generated now and same will be swapped with part Z which will now be generated at time 6. and this swap should only happen if there is availably to of part in future like


Time Name Quantity Label

1 Part 1 X

2 Part 1 Y

3 Part 1 Y

4 Part 1 Y

5 Part 1 X

6 Part 1 Z

7 Part 1 Z


which function can I use to access the arrival table and change / swap

FlexSim 24.2.2
processs flowarrival table
5 |100000

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

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Felix Möhlmann commented

The schedule table is stored in the activity's attribute tree. Once you cast it as a table you can read and write to it just like a global table.

Table schedule = Model.find("Tools/ProcessFlow/ProcessFlow/Source>variables/arrivals");
schedule[2][4] = 8;

Though I would suggest to simply not have predetermined labels in the source at all. Keep a list of yet to be produced parts somewhere (for example in a global variable array). Then, whenever a token is generated it dynamically checks which part is "best" to be produced now. That way you don't need to worry about finding the next schedule row that has not triggered, swapping entries to a different row and resetting the table to its original state on model reset.

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

Yash Patel avatar image Yash Patel commented ·
I'd assume for looking up ill just have to iterate over whole table in a for loop? and since I want to match multiple columns in actual use case I'd have to iterate over all rows and columns? also could you guide me to documentation about global variable array please.
0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Yash Patel commented ·

Yes, using for-loops to iterate through the table is one option. You could also use the getRowByKey method to find the first row with a matching cell value.

Or you use a query which would allow you to filter/sort by multiple columns. For example, the following code would return the row number of the next row with a time larger than the current model time and a "label1" value of 4.

Table schedule = Model.find("Tools/ProcessFlow/ProcessFlow/Source>variables/arrivals");
Table result = Table.query("SELECT ROW_NUMBER FROM $1 WHERE Time > $2 AND Label1 == 4 ORDER BY Time ASC", schedule, Model.time)[1][1]; int nextRow = 0; if(result.numRows > 0) {     nextRow = result[1][1]; }

Here's the documentation for global variables. Global variables are mostly what you would expect given the name. Variables you can access from anywhere in the model.

https://docs.flexsim.com/en/24.2/Reference/Tools/GlobalVariables/GlobalVariables.html

0 Likes 0 ·