mable.simulation_space package

Submodules

mable.simulation_space.structure module

The space where the simulation and operation takes place including the seas and the ports.

class mable.simulation_space.structure.NetworkWithPortDict(ports=None)

Bases: ShippingNetwork, ABC

A space of operation that stores the ports in form of a dictionary.

__init__(ports=None)
get_port(name)

Returns the port with the name.

Parameters:

name – The name of a port.

Returns:

The port instance.

Return type:

Port

get_port_or_default(name, default=None)

Returns a port by name or the default value in case no port with the specified name exists. :param _sphinx_paramlinks_mable.simulation_space.structure.NetworkWithPortDict.get_port_or_default.name: str

The name of the port.

Parameters:

default – Any The default value to return. By default, this is None.

Returns:

default Whatever is passed to default or None if nothing is specified.

property ports
class mable.simulation_space.structure.ShippingNetwork

Bases: SimulationEngineAware

An abstract class for the space of operation.

__init__()
abstract static get_distance(location_one, location_two)

Returns the distance between two locations. :param _sphinx_paramlinks_mable.simulation_space.structure.ShippingNetwork.get_distance.location_one: Location

The first location.

Parameters:

location_two – Location The second location.

Returns:

float The distance.

abstract get_journey_location(journey, vessel, current_time)

Returns the current position of the vessel based on the journey information and the current time. :param _sphinx_paramlinks_mable.simulation_space.structure.ShippingNetwork.get_journey_location.journey: Journey

The journey object.

Parameters:
  • vessel – Vessel The vessel that is performing the journey

  • current_time – float The current time.

Returns:

Location The current location the vessel is in.

abstract get_port(name)

Returns a port by name. :param _sphinx_paramlinks_mable.simulation_space.structure.ShippingNetwork.get_port.name: str

The name of the port.

Returns:

Port The port by the name.

abstract get_port_or_default(name, default=None)

Returns a port by name or the default value in case no port with the specified name exists.

Parameters:
  • name (str) – The name of the port.

  • default (Any) – The default value to return. By default, this is None.

Returns:

Either the port or whatever is passed to default (None by default).

Return type:

Union[Port, None]

get_vessel_location(vessel, current_time)

Returns the location of the vessel assuming the vessel is either in a port or on a journey. If the vessel is on a journey the current time is used to determine the vessel’s location on the journey.

The method is robust to the vessel having a location by name or Location, i.e. if the vessel’s location is a port name the port will be determined by the name. :param _sphinx_paramlinks_mable.simulation_space.structure.ShippingNetwork.get_vessel_location.vessel: Vessel

The vessel.

Parameters:

current_time – float The current time.

Returns:

Location The current location of the vessel.

class mable.simulation_space.structure.UnitShippingNetwork(ports=None)

Bases: NetworkWithPortDict

A space of operation in the [0,1]^2 Euclidian space.

__init__(ports=None)

Constructor. :param _sphinx_paramlinks_mable.simulation_space.structure.UnitShippingNetwork.ports: dict | list

The collection of ports.

get_distance(location_one, location_two)

Returns the Euclidean distance between two locations. :param _sphinx_paramlinks_mable.simulation_space.structure.UnitShippingNetwork.get_distance.location_one: Location

The first location.

Parameters:

location_two – Location The second location.

Returns:

float The Euclidean distance. If the location are outside of [0,1]^2 float(‘inf’) is returned.

get_journey_location(journey, vessel, current_time)

Returns the current position of the vessel based on the journey information and the current time. If the current time is before the start time the origin is returned. Similarly, if the current time is beyond the start time plus the travel time the destination is returned. :param _sphinx_paramlinks_mable.simulation_space.structure.UnitShippingNetwork.get_journey_location.journey: Journey

The journey object.

Parameters:
  • vessel – Vessel The vessel that is performing the journey

  • current_time – float The current time.

Returns:

Location The current location the vessel is in or one of the endpoints.

mable.simulation_space.universe module

class mable.simulation_space.universe.Location(x, y, name=None)

Bases: object

A location in the operational space.

__init__(x, y, name=None)
Parameters:
  • x (float) – The x coordinate of the location.

  • y (float) – The y coordinate of the location.

  • name (str) – An optional name of the location.

property name
property x
property y
class mable.simulation_space.universe.OnJourney(origin: Location, destination: Location, start_time: float)

Bases: object

An indicator that a vessel is in transit, i.e. performing a journey.

Parameters:
  • origin (Location) – The start location of the journey.

  • destination (Location) – The end location of the journey.

  • start_time (float) – The time at which the journey started, i.e. the time the vessel left origin.

__init__(origin: Location, destination: Location, start_time: float) None

Method generated by attrs for class OnJourney.

destination: Location
origin: Location
start_time: float
class mable.simulation_space.universe.Port(name, x, y)

Bases: Location, JsonAble

A port, i.e. a location in the operational space at which cargo gets exchanged.

__init__(name, x, y)
Parameters:
  • name (str) – The name of the port.

  • x (float) – The x coordinate of the port.

  • y (float) – The y coordinate of the port.

to_json()
Returns:

Any A json encodable object.

Module contents