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.

Resource restriction on part of the network

Resource restriction on part of the network

In this notebook, we set up a basic simulation where two vessels move over a 1D network path consisting of four edges. We add a resrouce restriction on the two middle edges: only one vessel can use those edges at a time. The second vessel now has to wait until the first vessel has passed the middle 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 three edge network: a starting edge of 10 km long, a middle edge of 5 km long and an final edge of 10 km long.

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 1' logbook data:

Loading...
'Vessel 2' logbook data:

Loading...

The inspection of the logbook data shows that Vessel moved from its origin (Node 0) to its destination (Node 1). The print statements show that the length of the route from Node 0 to Node 1 is exactly 100 km. At a given speed of 1 m/s the trip duration should be exactly 100000 seconds, as is indeed shown to be the case.

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

The inspection of the logbook data shows that vessel 1 can simply sail from node 0 to node 4 in one go. Vessel 2 sails from node 0 to node 1. Vessel 2 has to wait for Vessel1 to give up the resource on nodes 1-3. Once vessel 1 enters edge (3,4), vessel 2 can start sailing onwards form node 1. Vessel 3 sails the other way. Vessel 3 has to wait at node 3 for the resource to be available.