question

Osama A6 avatar image
0 Likes"
Osama A6 asked Jason Lightfoot commented

Dynamic travelling salesman problem

Let's assume that I have a truck going to different cities. For instant, let's assume I have only 2 cities (which are A and B). I want to make a table, that is linked to the truck. The table has 3 columns and dynamic rows. The column is: From, to, and time. The rows are created only when I visit the city. So, the first row is created when I went from origin A and sunk at depot B. The table will be filled as follows:

From I To I Time

1 : 2 : 3:00

I don't care about how the table looks, it is just only an example. Then; if I went back to point A from B the table will be as follows:

From I To I Time

1 : 2 : 3:00

2 : 1 : 2:30

let's say I have added another city later, which is C: then if I dispatched as follows: A, C, B (where city rank are A:1, B:2, C:3) the new table will be as followed:

From I To I Time

1 : 2: 3:00

2 : 1 : 2:30

1 : 3: 1:00

3 : 2 : 1:20

If I return the truck from B to C then to A, the table will again be shown as follows:

From I To I Time

1 : 2: 3:00

2 : 1 : 2:30

1 : 3: 1:00

3 : 2 : 1:20

2 : 3: 0:50

3: 1: 0:45

I prefer to have a transcript to make the table if it is possible.


FlexSim 21.2.3
tablestime tabletravelling salesman problem
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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot commented

Use a statistics collector. You can listen to taskexecuter events and try to interpret the task sequence to find the routes, or you can use process flow to generate the task sequence and listen to tokens at activities for which you know the lables refer to the route start and end points.

· 10
5 |100000

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

Osama A6 avatar image Osama A6 commented ·
Is there a way to do it by script?
0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Osama A6 commented ·

sure, you find for most events triggers in objects. Then you can fill and add values in a global table. If you store at your truck your currently active table row, you can add new values in a columns in your table.

0 Likes 0 ·
Osama A6 avatar image Osama A6 Joerg Vogel commented ·
Can you please demonstrate it?
0 Likes 0 ·
Show more comments
Joerg Vogel avatar image Joerg Vogel commented ·

get number of rows in a table

https://docs.flexsim.com/en/22.0/Reference/CodingInFlexSim/FlexScriptAPIReference/Data/Table.html#Property-numRows

add a new row to a table, you need a row number for this

https://docs.flexsim.com/en/22.0/Reference/CodingInFlexSim/FlexScriptAPIReference/Data/Table.html#Method-addRow

store row number in a label at Taskexecuter (operator)

write model time into a table cell

https://docs.flexsim.com/en/22.0/Reference/CodingInFlexSim/FlexScriptAPIReference/Data/Model.html#Property-time

travel finish: write time into another column of same row.

compute difference of involved columns in row.

0 Likes 0 ·