question

Melissa F2 avatar image
0 Likes"
Melissa F2 asked Melissa F2 commented

vehicle Routing Problem

Hello @Jordan Johnson

I'm having trouble moving forward on a project that I want to simulate on flexim. (I have 5 cities and a warehouse and two 10-ton trucks. Each of the cities has different demands. I would like to simulate this vehicle routing problem in order to optimize transport time and costs). Could you please help me.

capture-decran-2022-03-26-133850.png

FlexSim 22.1.0
minimize cost and time transport
· 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.

Melissa F2 avatar image Melissa F2 commented ·

Thanks a lot @Jordan Johnson

0 Likes 0 ·

1 Answer

Jordan Johnson avatar image
3 Likes"
Jordan Johnson answered Jordan Johnson commented

Here's a demo model I made:

RouteOptimizationDemo.fsm

The key to solving a routing problem is to use a Sequence parameter. A Sequence parameter is an array of values that represent a sequence. Your example has 4 destination cities, so we might consider a sequence with four values: [1, 2, 3, 4]. Other possible sequence values might include [3, 1, 2, 4] or [4, 3, 2, 1]. So a sequence parameter of length n contains all values [1, n] exactly once, but they can be in any order.

So now we just have to map the sequence array to a route for a truck. The way I did it was to add a Global Table with each of the destinations, and how many tons were to go to each destination. Then, in the Scheduled Source in Process Flow, I created one token per row in the table. This is where I used the sequence parameter. The first token uses the first element in the sequence parameter as a row number. Then it reads the name and demand for that city. The second token uses the second element in the sequence parameter, and so on. So the tokens read the table in the order specified by the sequence parameter.

So now, I know the order that I want to visit the cities in. But how to make sure each truck only carries 10 tons? I did that by adding a Zone. The Zone uses a Subset, and only allows 10 tons of demand into the zone at a time. The Zone also enforces the queue order, so that "smaller" tokens can't sneak past "larger" ones (in terms of demand).

Then I use a Batch activity. The batch collects as many tokens as it can (in zero time), and then release the batch. When the batch is released, I used an Event Triggered Source to create a token for the batch as a whole. The batch token reads the list of tokens in that batch, and builds a task sequence to visit each destination. But also, since the batch is release, all those tokens leave the Zone, allowing the next few tokens in.

I also made two performance measures: the time it takes to make all deliveries, and the total distance the trucks travelled.

With the sequence parameter and these performance measures, I added an optimization job. It quickly tries all combinations of routes.

Note: this seems like a good place to use GIS, to get better time estimates between destinations. I didn't do that, but the same approach would work. It would just use the GIS navigator instead of the AStar navigator. Also note that the position and size of barriers affects the final answer. And finally, note that I made a whole bunch of assumptions about how to go from a sequence to routes for multiple trucks.


· 6
5 |100000

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

Melissa F2 avatar image Melissa F2 commented ·

Bonjour, @Jordan Johnson

Je tiens à vous remercier pour ce démon. Cela va m'aider à faire ce projet. Merci beaucoup

0 Likes 0 ·
Melissa F2 avatar image Melissa F2 commented ·

Hi @Jordan Johnson


I would like to add a global table of transportation costs according to distances. How will I be able to calculate the transportation cost while minimizing it? Will I have to use sequences or Integer for this problem?


And also to be able to use NetworkNode to plot the trucks path do I have to delete the A* travel to be able to do this?


Sincerely

capture-decran-2022-03-31-103408.png


0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Melissa F2 commented ·

I will answer your questions in reverse, because the second question is much easier.

To use Network Nodes, you are correct. Just delete the AStar navigator. Then create your network with paths and nodes. Then just be sure to attach your destinations and travelers to the correct nodes.

The next question is how to use a cost table. I would start by adding a Tracked Variable called Cost. You can add Tracked Variables from the Toolbox window. Be sure its type is set to Level. You can set up the model, so that every time a truck visits a destination, you can increase that Tracked Variable by the correct amount.

I did it by adding a Location label to the Truck, which is set to start at the Warehouse. Then, whenever the truck finishes unloading, I use the names of the Location and Destination to look up a Cost in the route table. Then I increment the Cost Tracked Variable, and then I update the Truck's Location label.

Then, you can add the Cost Tracked Variable as a Performance Measure.

Once the Tracked Variable is a Performance Measure, you can add an Objective to the Optimizer that minimizes that value.

RouteOptimizationDemo_1.fsm

0 Likes 0 ·
Melissa F2 avatar image Melissa F2 commented ·

Thank you @Jordan Johnson for your answer.

0 Likes 0 ·
Melissa F2 avatar image Melissa F2 commented ·

Salut @Jordan Johnson

Thanks for your answer first.

J'ai essayé de simuler le modèle mais il ne prend pas en compte mon camion 1. Je pense que l'erreur vient du flux de processus au niveau de l'étiquette ou je me trompe.

Voici le message que je vois lorsque je simule :

"

heure : 23.326238 exception : exception FlexScript : Truck1 n'est pas un nom de ligne valide pour la table globale "RouteCost" dans MODEL:/Tools/ProcessFlow/ProcessFlow/Get Cost>labels/1/2"




0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Melissa F2 commented ·

Oh, sorry for the mistake. Click on Truck1, and point its Location label at the Warehouse queue, and then click the little "save" button on the Truck's labels panel.

0 Likes 0 ·