-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
The ProcessingStorageLocation fragment at: https://openclsim.readthedocs.io/en/latest/examples.html
does not compile correctly. It throws:
Traceback (most recent call last):
File "/home/lemoine/int4agri/code/test.py", line 37, in <module>
location_03 = ProcessingStorageLocation(**location_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lemoine/.local/lib/python3.12/site-packages/openclsim/core/identifiable.py", line 39, in __init__
super().__init__(*args, **kwargs)
File "/home/lemoine/.local/lib/python3.12/site-packages/openclsim/core/log.py", line 56, in __init__
super().__init__(*args, **kwargs)
File "/home/lemoine/.local/lib/python3.12/site-packages/openclsim/core/resource.py", line 24, in __init__
super().__init__(*args, **kwargs)
File "/home/lemoine/.local/lib/python3.12/site-packages/openclsim/core/locatable.py", line 27, in __init__
super().__init__(*args, **kwargs)
File "/home/lemoine/.local/lib/python3.12/site-packages/openclsim/core/container.py", line 30, in __init__
super().__init__(*args, **kwargs)
File "/home/lemoine/.local/lib/python3.12/site-packages/openclsim/core/processor.py", line 26, in __init__
super().__init__(*args, **kwargs)
File "/home/lemoine/.local/lib/python3.12/site-packages/openclsim/core/simpy_object.py", line 15, in __init__
super().__init__(*args, **kwargs)
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
Full code below
import openclsim.model as model
import openclsim.core as core
# Import simpy for the simulation environment
import simpy
import shapely.geometry
# Start the SimPy environment
env = simpy.Environment()
# Create a location class
ProcessingStorageLocation = type(
"ProcessingStorageLocation",
(
core.Identifiable, # Give it a name and unique UUID
core.Log, # To keep track of all events
core.HasResource, # Add information on the number of resources
core.Locatable, # Add coordinates to extract distance information
core.HasContainer, # Add information on storage capacity
core.Processor, # Add information on processing
),
{},
)
# Create a processing function
processing_rate = lambda x: x
location_data = {
"env": env, # The SimPy environment
"name": "Location 03", # Name of the location
"geometry": shapely.geometry.Point(0, 1), # The lat, lon coordinates
"capacity": 10_000, # The maximum number of units
"level": 0, # The number of units in the location
"loading_func": processing_rate, # Loading rate of 1 unit per 1 unit time
"unloading_func": processing_rate, # Unloading rate of 1 unit per 1 unit time
}
location_03 = ProcessingStorageLocation(**location_data)
Metadata
Metadata
Assignees
Labels
No labels