OpenCLSim¶
This page lists all functions and classes available in the OpenCLSim.model and OpenCLSim.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.
Submodules¶
The main components are the Model module and the Core module. All of their components are listed below.
openclsim.model module¶
Directory for the simulation activities.
-
class
openclsim.model.
AbstractPluginClass
[source]¶ Bases:
abc.ABC
Abstract class used as the basis for all Classes implementing a plugin for a specific Activity.
Instance checks will be performed on this class level.
-
class
openclsim.model.
PluginActivity
(*args, **kwargs)[source]¶ Bases:
openclsim.core.identifiable.Identifiable
,openclsim.core.log.Log
Base class for all activities which will provide a plugin mechanism.
The plugin mechanism foresees that the plugin function pre_process is called before the activity is executed, while the function post_process is called after the activity has been executed.
-
class
openclsim.model.
GenericActivity
(registry, start_event=None, requested_resources={}, keep_resources=[], *args, **kwargs)[source]¶ Bases:
openclsim.model.base_activities.PluginActivity
The GenericActivity Class forms a generic class which sets up all activites.
-
class
openclsim.model.
MoveActivity
(mover, destination, duration=None, show=False, engine_order=1, *args, **kwargs)[source]¶ Bases:
openclsim.model.base_activities.GenericActivity
MoveActivity Class forms a specific class for a single move activity within a simulation.
It deals with a single origin container, destination container and a single combination of equipment to move substances from the origin to the destination. It will initiate and suspend processes according to a number of specified conditions. To run an activity after it has been initialized call env.run() on the Simpy environment with which it was initialized.
To check when a transportation of substances can take place, the Activity class uses three different condition arguments: start_condition, stop_condition and condition. These condition arguments should all be given a condition object which has a satisfied method returning a boolean value. True if the condition is satisfied, False otherwise.
destination: object inheriting from HasContainer, HasResource, Locatable, Identifiable and Log mover: moves to ‘origin’ if it is not already there, is loaded, then moves to ‘destination’ and is unloaded
should inherit from Movable, HasContainer, HasResource, Identifiable and Log after the simulation is complete, its log will contain entries for each time it started moving, stopped moving, started loading / unloading and stopped loading / unloading- start_event: the activity will start as soon as this event is triggered
- by default will be to start immediately
-
main_process_function
(activity_log, env)[source]¶ Return a generator which can be added as a process to a simpy.Environment.
In the process, a move will be made by the mover, moving it to the destination.
activity_log: the core.Log object in which log_entries about the activities progress will be added. env: the simpy.Environment in which the process will be run mover: moves from its current position to the destination
should inherit from core.Movable- destination: the location the mover will move to
- should inherit from core.Locatable
- engine_order: optional parameter specifying at what percentage of the maximum speed the mover should sail.
- for example, engine_order=0.5 corresponds to sailing at 50% of max speed
-
class
openclsim.model.
BasicActivity
(duration, additional_logs=None, show=False, *args, **kwargs)[source]¶ Bases:
openclsim.model.base_activities.GenericActivity
BasicActivity Class is a generic class to describe an activity, which does not require any specific resource, but has a specific duration.
duration: time required to perform the described activity. additional_logs: list of other concepts, where the start and the stop of the basic activity should be recorded. start_event: the activity will start as soon as this event is triggered
by default will be to start immediately-
main_process_function
(activity_log, env)[source]¶ Return a generator which can be added as a process to a simpy.Environment.
The process will report the start of the activity, delay the execution for the provided duration, and finally report the completion of the activiy.
activity_log: the core.Log object in which log_entries about the activities progress will be added. env: the simpy.Environment in which the process will be run stop_event: a simpy.Event object, when this event occurs, the conditional process will finish executing its current
run of its sub_processes and then finish- sub_processes: an Iterable of methods which will be called with the activity_log and env parameters and should
- return a generator which could be added as a process to a simpy.Environment the sub_processes will be executed sequentially, in the order in which they are given as long as the stop_event has not occurred.
-
-
class
openclsim.model.
SequentialActivity
(sub_processes, show=False, *args, **kwargs)[source]¶ Bases:
openclsim.model.base_activities.GenericActivity
,openclsim.model.base_activities.RegisterSubProcesses
SequenceActivity Class forms a specific class.
This is for executing multiple activities in a dedicated order within a simulation. It is a structural activity, which does not require specific resources.
- sub_processes:
- a list of activities to be executed in the provided sequence.
- start_event:
- The activity will start as soon as this event is triggered by default will be to start immediately
-
class
openclsim.model.
WhileActivity
(sub_processes, condition_event, show=False, *args, **kwargs)[source]¶ Bases:
openclsim.model.base_activities.GenericActivity
,openclsim.model.while_activity.ConditionProcessMixin
,openclsim.model.base_activities.RegisterSubProcesses
WhileActivity Class forms a specific class for executing multiple activities in a dedicated order within a simulation.
The while activity is a structural activity, which does not require specific resources.
- sub_processes
- the sub_processes which is executed in sequence in every iteration
- condition_event
- a condition event provided in the expression language which will stop the iteration as soon as the event is fulfilled.
- start_event
- the activity will start as soon as this event is triggered by default will be to start immediately
-
class
openclsim.model.
RepeatActivity
(sub_processes, repetitions: int, show=False, *args, **kwargs)[source]¶ Bases:
openclsim.model.base_activities.GenericActivity
,openclsim.model.while_activity.ConditionProcessMixin
,openclsim.model.base_activities.RegisterSubProcesses
RepeatActivity Class forms a specific class for executing multiple activities in a dedicated order within a simulation.
- sub_processes
- the sub_processes which is executed in sequence in every iteration
- repetitions
- Number of times the subprocess is repeated
- start_event
- the activity will start as soon as this event is triggered by default will be to start immediately
-
openclsim.model.
single_run_process
(env, registry, name, origin, destination, mover, loader, unloader, start_event=None, stop_event=[], requested_resources={})[source]¶ Single run activity for the simulation.
-
class
openclsim.model.
ShiftAmountActivity
(processor, origin, destination, duration=None, amount=None, id_='default', show=False, phase=None, *args, **kwargs)[source]¶ Bases:
openclsim.model.base_activities.GenericActivity
ShiftAmountActivity Class forms a specific class for shifting material from an origin to a destination.
It deals with a single origin container, destination container and a single processor to move substances from the origin to the destination. It will initiate and suspend processes according to a number of specified conditions. To run an activity after it has been initialized call env.run() on the Simpy environment with which it was initialized.
origin: container where the source objects are located. destination: container, where the objects are assigned to processor: resource responsible to implement the transfer. amount: the maximum amount of objects to be transfered. duration: time specified in seconds on how long it takes to transfer the objects. id_: in case of MultiContainers the id_ of the container, where the objects should be removed from or assiged to respectively. start_event: the activity will start as soon as this event is triggered
by default will be to start immediately
-
class
openclsim.model.
ParallelActivity
(sub_processes, show=False, *args, **kwargs)[source]¶ Bases:
openclsim.model.base_activities.GenericActivity
,openclsim.model.base_activities.RegisterSubProcesses
ParallelActivity Class forms a specific class.
This is for executing multiple activities in a dedicated order within a simulation. It is a structural activity, which does not require specific resources.
- sub_processes:
- a list of activities to be executed in Parallel.
- start_event:
- The activity will start as soon as this event is triggered by default will be to start immediately
openclsim.core module¶
Core of the simulation Package.
-
class
openclsim.core.
HasContainer
(capacity: float, store_capacity: int = 1, level: float = 0.0, *args, **kwargs)[source]¶ Bases:
openclsim.core.simpy_object.SimpyObject
A class which can hold information about objects of the same type.
- capacity
- amount the container can hold
- level
- Amount the container holds initially
- store_capacity
- The number of different types of information can be stored. In this class it usually is 1.
-
class
openclsim.core.
HasMultiContainer
(initials, store_capacity=10, *args, **kwargs)[source]¶ Bases:
openclsim.core.container.HasContainer
A class which can represent information of objects of multiple types.
store_capacity: The number of different types of information can be stored. In this calss it is usually >1. initials: a list of dictionaries describing the id_ of the container, the level of the individual container and the capacity of the individual container.
-
class
openclsim.core.
EventsContainer
(env, store_capacity: int = 1, *args, **kwargs)[source]¶ Bases:
simpy.resources.store.FilterStore
EventsContainer provide a basic class for managing information which has to be stored in an object.
It is a generic container, which has a default behavior, but can be used for storing arbitrary objects.
- store_capacity
- Number of stores that can be contained by the multicontainer
-
container_list
¶
-
empty_event
¶ Properties that are kept for backwards compatibility. mThey are NOT applicable for MultiContainers.
-
full_event
¶ Properties that are kept for backwards compatibility. mThey are NOT applicable for MultiContainers.
-
get
(amount, id_='default')[source]¶ Request to get an item from the store matching the filter. The request is triggered once there is such an item available in the store.
filter is a function receiving one item. It should return
True
for items matching the filter criterion. The default function returnsTrue
for all items, which makes the request to behave exactly likeStoreGet
.
-
initialize
(init=0, capacity=0)[source]¶ Initialize method is a convenience method for backwards compatibility reasons.
-
class
openclsim.core.
Identifiable
(name: str, ID: str = None, *args, **kwargs)[source]¶ Bases:
object
OpenCLSim Identifiable with tags and a description.
- name
- a name
- ID : UUID
- a unique id generated with uuid
- description
- Text that can be used to describe a simulation object. Note that this field does not influence the simulation.
- tags
- List of tags that can be used to identify objects. Note that this field does not influence the simulation.
-
class
openclsim.core.
Locatable
(geometry, *args, **kwargs)[source]¶ Bases:
object
Something with a geometry (geojson format).
- lat : degrees
- can be a point as well as a polygon
lon : degrees
-
class
openclsim.core.
Log
(*args, **kwargs)[source]¶ Bases:
openclsim.core.simpy_object.SimpyObject
Log class to log the object activities.
-
class
openclsim.core.
LogState
[source]¶ Bases:
enum.Enum
LogState enumeration of all possible states of a Log object.
Access the name using .name and the integer value using .value
-
START
= 1¶
-
STOP
= 2¶
-
UNKNOWN
= -1¶
-
WAIT_START
= 3¶
-
WAIT_STOP
= 4¶
-
-
class
openclsim.core.
Movable
(v: float = 1, *args, **kwargs)[source]¶ Bases:
openclsim.core.simpy_object.SimpyObject
,openclsim.core.locatable.Locatable
Movable class.
Used for object that can move with a fixed speed geometry: point used to track its current location
- v
- speed
-
current_speed
¶
-
class
openclsim.core.
ContainerDependentMovable
(compute_v, *args, **kwargs)[source]¶ Bases:
openclsim.core.movable.Movable
,openclsim.core.container.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
- v_empty
- Velocity of the vessel when empty
- v_full
- Velocity of the vessel when full
-
current_speed
¶
-
class
openclsim.core.
MultiContainerDependentMovable
(compute_v, *args, **kwargs)[source]¶ Bases:
openclsim.core.movable.Movable
,openclsim.core.container.HasMultiContainer
MultiContainerDependentMovable class.
Used for objects that move with a speed dependent on the container level. This movable is provided with a MultiContainer, thus can handle container containing different object. compute_v: a function, given the fraction the container is filled (in [0,1]), returns the current speed
-
current_speed
¶
-
-
class
openclsim.core.
Processor
(*args, **kwargs)[source]¶ Bases:
openclsim.core.simpy_object.SimpyObject
Processor class.
Adds the loading and unloading components and checks for possible downtime.
If the processor class is used to allow “loading” or “unloading” the mixins “LoadingFunction” and “UnloadingFunction” should be added as well. If no functions are used a subcycle should be used, which is possible with the mixins “LoadingSubcycle” and “UnloadingSubcycle”.
-
check_possible_shift
(origin, destination, amount, activity, id_='default')[source]¶ Check if all the material is available.
If the amount is not available in the origin or in the destination yield a put or get. Time will move forward until the amount can be retrieved from the origin or placed into the destination.
-
-
class
openclsim.core.
LoadingFunction
(loading_rate: float, load_manoeuvring: float = 0, *args, **kwargs)[source]¶ Bases:
object
Create a loading function and add it a processor.
This is a generic and easy to read function, you can create your own LoadingFunction class and add this as a mixin.
- loading_rate : amount / second
- The rate at which units are loaded per second
- load_manoeuvring : seconds
- The time it takes to manoeuvring in minutes
-
class
openclsim.core.
UnloadingFunction
(unloading_rate: float, unload_manoeuvring: float = 0, *args, **kwargs)[source]¶ Bases:
object
Create an unloading function and add it a processor.
This is a generic and easy to read function, you can create your own LoadingFunction class and add this as a mixin.
- unloading_rate : volume / second
- the rate at which units are loaded per second
- unload_manoeuvring : minutes
- the time it takes to manoeuvring in minutes
-
class
openclsim.core.
HasResource
(nr_resources: int = 1, *args, **kwargs)[source]¶ Bases:
openclsim.core.simpy_object.SimpyObject
HasProcessingLimit class.
Adds a limited Simpy resource which should be requested before the object is used for processing.
- nr_resources
- Number of rescources of the object
openclsim.server module¶
Module contents¶
Top-level package for OpenCLSim.