Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Alternative routes over a simple network

Alternative routes over a simple network

In this notebook, we set up a basic simulation where two vessels move over a 1D network path. The network is setup as a square where each edge is 100 km long. All edges are bi-directional except one. We show how each each vessel follows a different route, because of the presence of a uni-directional edge.

0. Import libraries

This notebook is executed with OpenTNSim version 1.3.7

1. Define object classes

2. Create graph

Next we create a network (a graph) along which the vessel can move. For this case we create a square network with four nodes and four edges, each 100 km long, one of which is uni-directional.

Loading...
Loading...

3. Run simulation

4. Inspect output

We can now inspect the simulation output by inspecting the vessel.logbook. Note that the Log mix-in was included when we added Movable. The vessel.logbook keeps track of the moving activities of the vessel. For each discrete event OpenTNSim logs an event message, the start/stop time and the location. The vessel.logbook is of type dict. For convenient inspection it can be loaded into a Pandas dataframe.

'Vessel_on_Path_0' logbook data:

Loading...
'Vessel_on_Path_0' travelled a distance of 100000.0 meters
'Vessel_on_Path_0' took 100000.0 seconds to arrive at its destination
'Vessel_on_Path_0' travelled at an average speed of 1.0 meters per second


'Vessel_on_Path_1' logbook data:

Loading...
'Vessel_on_Path_1' travelled a distance of 299987.6 meters
'Vessel_on_Path_1' took 301347.6 seconds to arrive at its destination
'Vessel_on_Path_1' travelled at an average speed of 1.0 meters per second


The inspection of the logbook data shows that the first vessel moved from its origin (Node 0) directly to its destination (Node 3). The second vessel moved from its origin (Node 3) to its destination (Node 0), but while doing so was passing Node 2 and Node 1 in the process. This show that indeed the edge between Node 0 and Node 3 is uni-directional.

The print statements show that the length of the route from Node 3 to Node 3 is not exactly 300 km. This is primarily due to the fact that Edge ‘0 - 1’ and Edge ‘2 - 3’ are not exactly 100 km (see also the graph plot above). This is one of the issues that can occur when using coordinate projections.

Loading...
Loading...
Loading...