Part 2: Adding Road Network
In Part 1 of the Supply Chain tutorial we created a simulation model of a cargo delivery: trucks fulfill transportation requests coming at some rate, each request has a source and a destination asset picked randomly, delivery distance between assets is explicitly defined.
In this part, two major updates will be done: using a road graph, and scenario file loading.
1. Road graph
We will place all assets inside a road network. Each road connects two road nodes and is bidirectional: trucks may move from node 1 to node 2 and back. There will always be at least one route between two nodes. This route may include several roads.
Geographical locations of all nodes are taken as input data. Each road is a polyline, so its length can be calculated from the locations of its endpoint nodes and intermediate points.
To make that change, we will employ the Amalgama Platform’s Graph Agent Library.
2. Keep Scenario in an external file
In Part 1, all scenario data was created on-the-fly by the Java code. Each Scenario modification required this code to be changed, so it was not very reusable.
In this part, Scenarios will be loaded from external JSON files. The application will read scenario data from a file, so you will be able to change the input data without recompiling the application.