Dynamic travelling salesman problem

Dynamic travelling salesman problem

osama_a6
Not applicable
1,056 Views
11 Replies
Message 1 of 12

Dynamic travelling salesman problem

osama_a6
Not applicable

[ FlexSim 21.2.3 ]

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.


0 Likes
Accepted solutions (1)
1,057 Views
11 Replies
Replies (11)
Message 2 of 12

jason_lightfoot_adsk
Autodesk
Autodesk
Accepted solution

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.

0 Likes
Message 3 of 12

osama_a6
Not applicable
Is there a way to do it by script?
0 Likes
Message 4 of 12

joerg_vogel_HsH
Mentor
Mentor

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
Message 5 of 12

osama_a6
Not applicable
Can you please demonstrate it?
0 Likes
Message 6 of 12

FelixMoehlmann
Collaborator
Collaborator

Here's a simple example. In the load trigger of the operators a new row is added to the table and the "From" column is filled in using the station parameter of the trigger. Also, the row number and the start time of the travel are noted.

In the unload trigger the "To" information is added to the row and the travel time is calculate as the difference between the current time and the start time of the travel.

TravelLog.fsm

Message 7 of 12

osama_a6
Not applicable
Thank you so much
0 Likes
Message 8 of 12

osama_a6
Not applicable
Can you please demonstrate how did you do it? I want to use the same logic for trucks, forklifts, any transporter.
0 Likes
Message 9 of 12

jason_lightfoot_adsk
Autodesk
Autodesk
It says in Felix's post the code is in the load and unload triggers of the operators - you would need to do the same for all your transporters to use this method.
Message 10 of 12

joerg_vogel_HsH
Mentor
Mentor

get number of rows in a table

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

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#Me...

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#Pr...

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

compute difference of involved columns in row.

0 Likes
Message 11 of 12

osama_a6
Not applicable
Does the table show automatically or do I need to build a new thing?
0 Likes
Message 12 of 12

jason_lightfoot_adsk
Autodesk
Autodesk
Felix has created a Global Table called "Travels".
0 Likes