This page lists all functions and classes available in the OpenTNSim.model and OpenTNSim.core modules. For examples on how to use these submodules please check out the Examples page, information on installing OpenCLSim can be found on the Installation page.


The main components are the Model module and the Core module. All of their components are listed below.

opentnsim.model module

Vessel generator.

class opentnsim.model.Simulation(simulation_start, graph, scenario=None)[source]

Bases: opentnsim.core.Identifiable

A class to generate vessels from a database

add_vessels(vessel_generator, origin, destination, arrival_distribution=1, arrival_process='Markovian')[source]

Make arrival process

environment: simpy environment arrival_distribution: specify the distribution from which vessels are generated, int or list arrival_process: process of arrivals


Run the simulation

duration: specify the duration of the simulation in seconds

class opentnsim.model.VesselGenerator(vessel_type, vessel_database, loaded=None, random_seed=4)[source]

Bases: object

A class to generate vessels from a database

arrival_process(environment, origin, destination, arrival_distribution, scenario, arrival_process)[source]

Make arrival process

environment: simpy environment arrival_distribution: specify the distribution from which vessels are generated, int or list arrival_process: process of arrivals

generate(environment, vessel_name, scenario=None)[source]

Generate a vessel

opentnsim.core module

Main module.

class opentnsim.core.ContainerDependentMovable(compute_v, *args, **kwargs)[source]

Bases: opentnsim.core.Movable, opentnsim.core.HasContainer

ContainerDependentMovable class

Used for objects that move with a speed dependent on the container level compute_v: a function, given the fraction the container is filled (in [0,1]), returns the current speed

class opentnsim.core.HasContainer(capacity, level=0, total_requested=0, *args, **kwargs)[source]

Bases: opentnsim.core.SimpyObject

Container class

capacity: amount the container can hold level: amount the container holds initially container: a simpy object that can hold stuff

class opentnsim.core.HasEnergy(emissionfactor, *args, **kwargs)[source]

Bases: object

Add information on energy use and effects on energy use.


Calculation of energy consumption based on total time in system and properties

class opentnsim.core.HasResource(nr_resources=1, priority=False, *args, **kwargs)[source]

Bases: opentnsim.core.SimpyObject

HasProcessingLimit class

Adds a limited Simpy resource which should be requested before the object is used for processing.

class opentnsim.core.Identifiable(name, id=None, *args, **kwargs)[source]

Bases: object

Something that has a name and id

name: a name id: a unique id generated with uuid

class opentnsim.core.IsLock(node_1, node_2, lock_length, lock_width, lock_depth, doors_open, doors_close, operating_time, waiting_area=True, *args, **kwargs)[source]

Bases: opentnsim.core.HasResource, opentnsim.core.Identifiable, opentnsim.core.Log

Create a lock object

properties in meters operation in seconds


Change water level and priorities in queue

convert_chamber(environment, new_level)[source]

Convert the water level

class opentnsim.core.Locatable(geometry, *args, **kwargs)[source]

Bases: object

Something with a geometry (geojson format)

geometry: can be a point as well as a polygon

class opentnsim.core.Log(*args, **kwargs)[source]

Bases: opentnsim.core.SimpyObject

Log class

log: log message [format: ‘start activity’ or ‘stop activity’] t: timestamp value: a value can be logged as well geometry: value from locatable (lat, lon)

log_entry(log, t, value, geometry_log)[source]


class opentnsim.core.Movable(v=1, *args, **kwargs)[source]

Bases: opentnsim.core.Locatable, opentnsim.core.Routeable, opentnsim.core.Log

Movable class

Used for object that can move with a fixed speed geometry: point used to track its current location v: speed


determine distance between origin and destination, and yield the time it takes to travel it

Assumption is that self.path is in the right order - vessel moves from route[0] to route[-1].

pass_edge(origin, destination)[source]
pass_lock(origin, destination, lock_id)[source]

Pass the lock

class opentnsim.core.Neighbours[source]

Bases: object

Can be added to a locatable object (list)

travel_to: list of locatables to which can be travelled

class opentnsim.core.Routeable(route, complete_path=None, *args, **kwargs)[source]

Bases: object

Something with a route (networkx format) route: a networkx path

class opentnsim.core.SimpyObject(env, *args, **kwargs)[source]

Bases: object

General object which can be extended by any class requiring a simpy environment

env: a simpy Environment

class opentnsim.core.VesselProperties(vessel_type, installed_power, width, length, height_empty, height_full, draught_empty, draught_full, *args, **kwargs)[source]

Bases: object

Add information on possible restrictions to the vessels. Height, width, etc.


Calculate current draught based on filling degree


Calculate current height based on filling degree

get_route(origin, destination, graph=None, minWidth=None, minHeight=None, minDepth=None, randomSeed=4)[source]

Calculate a path based on vessel restrictions

Module contents

Top-level package for OpenTNSim.