simplay.components — Components

class simplay.components.VisualProcess(env: VisualEnvironment, id: str, visual: str, tint: int = 16777215)

Bases: VisualComponent

Shorthand for creating an entity of type PROCESS.

Parameters:
  • env – The environment instance.

  • id – The id of the component.

  • visual – The visualization of the component, must be registered in the VisualizationManager.

  • tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.

class simplay.components.VisualResource(env: VisualEnvironment, id: str, capacity: int, visual: str, tint: int = 16777215)

Bases: VisualComponent, Resource

Extends the Resource class with

visualization.

Parameters:
  • env – The environment instance.

  • id – The id of the component.

  • capacity – The capacity of the resource.

  • visual – The visualization of the component, must be registered in the VisualizationManager.

  • tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.

Raises:
  • ValueError – If the capacity is not a positive integer.

  • TypeError – If the capacity is not a integer.

property capacity: int | float

Maximum capacity of the resource.

release(request: Request) Release

Releases the usage of resource granted by request. This event is triggered immediately. Subclass of simpy.resources.base.Get.

request() Request

Request usage of the resource. The event is triggered once access is granted. Subclass of simpy.resources.base.Put.

If the maximum capacity of users has not yet been reached, the request is triggered immediately. If the maximum capacity has been reached, the request is triggered once an earlier usage request on the resource is released.

The request is automatically released when the request was created within a with statement.

class simplay.components.VisualPreemptiveResource(env: VisualEnvironment, id: str, capacity: int, visual: str, tint: int = 16777215)

Bases: VisualComponent, PreemptiveResource

Extends the PreemptiveResource class

with visualization.

Parameters:
  • env – The environment instance.

  • id – The id of the component.

  • capacity – The capacity of the resource.

  • visual – The visualization of the component, must be registered in the VisualizationManager.

  • tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.

Raises:
  • TypeError – If the capacity is not a integer.

  • ValueError – If the capacity is not a positive integer.

property capacity: int | float

Maximum capacity of the resource.

release(request: PriorityRequest) Release

Releases the usage of resource granted by request. This event is triggered immediately. Subclass of simpy.resources.base.Get.

request(priority: int = 0, preempt: bool = True) PriorityRequest

Request the usage of resource with a given priority. If the resource supports preemption and preempt is True other usage requests of the resource may be preempted (see PreemptiveResource for details).

This event type inherits Request and adds some additional attributes needed by PriorityResource and PreemptiveResource

users: List[PriorityRequest]

List of Request events for the processes that are currently using the resource.

class simplay.components.VisualPriorityResource(env: VisualEnvironment, id: str, capacity: int, visual: str, tint: int = 16777215)

Bases: VisualComponent, PriorityResource

Extends the PriorityResource class with

visualization.

Parameters:
  • env – The environment instance.

  • id – The id of the component.

  • capacity – The capacity of the resource.

  • visual – The visualization of the component, must be registered in the VisualizationManager.

  • tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.

Raises:
  • TypeError – If the capacity is not a integer.

  • ValueError – If the capacity is not a positive integer.

property capacity: int | float

Maximum capacity of the resource.

release(request: PriorityRequest) Release

Releases the usage of resource granted by request. This event is triggered immediately. Subclass of simpy.resources.base.Get.

request(priority: int = 0, preempt: bool = True) PriorityRequest

Request the usage of resource with a given priority. If the resource supports preemption and preempt is True other usage requests of the resource may be preempted (see PreemptiveResource for details).

This event type inherits Request and adds some additional attributes needed by PriorityResource and PreemptiveResource

class simplay.components.VisualStore(env: VisualEnvironment, id: str, visual: str, tint: int = 16777215, capacity: float | int = inf)

Bases: VisualComponent, Store

Extends the Store class with visualization.

Parameters:
  • env – The environment instance.

  • id – The id of the component.

  • capacity – The capacity of the store.

  • visual – The visualization of the component, must be registered in the VisualizationManager.

  • tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.

Raises:
  • TypeError – If the capacity is not a integer or float.

  • ValueError – If the capacity is not a positive integer or float.

property capacity: float | int

Maximum capacity of the resource.

get() StoreGet

Request to get an item from the store. The request is triggered once there is an item available in the store.

put(item) StorePut

Request to put item into the store. The request is triggered once there is space for the item in the store.

class simplay.components.VisualFilterStore(env: VisualEnvironment, id: str, capacity: int, visual: str, tint: int = 16777215)

Bases: VisualComponent, FilterStore

Extends the FilterStore class with

visualization.

Parameters:
  • env – The environment instance.

  • id – The id of the component.

  • capacity – The capacity of the store.

  • visual – The visualization of the component, must be registered in the VisualizationManager.

  • tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.

Raises:
  • TypeError – If the capacity is not a integer or float.

  • ValueError – If the capacity is not a positive integer or float.

property capacity: int

Maximum capacity of the resource.

get(filter: ~typing.Callable[[~typing.Any], bool] = <function VisualFilterStore.<lambda>>) FilterStoreGet

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 returns True for all items, which makes the request to behave exactly like StoreGet.

put(item) StorePut

Request to put item into the store. The request is triggered once there is space for the item in the store.

class simplay.components.VisualContainer(env: VisualEnvironment, id: str, visual: str, tint: int = 16777215, capacity: int | float = inf, init: int | float = 0)

Bases: VisualComponent, Container

Extends the Container class with

visualization.

Parameters:
  • env – The environment instance.

  • id – The id of the component.

  • capacity – The capacity of the container.

  • init – The initial amount of the container.

  • visual – The visualization of the component, must be registered in the VisualizationManager.

  • tint – The tint of the component. The tint is multiplied with the pixel value of each pixel. To use HEX values, write them as 0xRRGGBB. For example: 0xFF0000 is red, 0x00FF00 is green, 0x0000FF is blue. If the whole image is white, tinting it will change the color of the image. If the image is black, tinting it will have no effect. If no tint should be applied, set it to 0xFFFFFF, which is the default value.

Raises:
  • TypeError – If the capacity is not a integer or float.

  • ValueError – If the capacity is not a positive integer or float.

property capacity: int | float

Maximum capacity of the resource.

get(amount: int | float) ContainerGet

Request to get amount of matter from the container. The request will be triggered once there is enough matter available in the container.

Raise a ValueError if amount <= 0.

put(amount: int | float) ContainerPut

Request to put amount of matter into the container. The request will be triggered once there is enough space in the container available.

Raise a ValueError if amount <= 0.