Skip to content

Commit

Permalink
Creation stage has issues fixed. Currently on build_connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgrguric96 committed Nov 18, 2024
1 parent 2070e73 commit 67d6dfe
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
5 changes: 4 additions & 1 deletion examples/adder_copy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ models: # list of models for the energy network
param1: "adding hundreds"
connections:
- from: Adder1.out1 # start model, pattern: model_name.output_name/input_name
to: Adder2.in1 # end model
to: Adder2.in1n # end model
# TODO: Below is what Illuminator looks for, but is not valid. Needs to be fixed
# - from: Adder1-0.hybrid_0.out1
# to: Adder2-0.hybrid_0.in1

#monitor: # a list of models, its inputs, output and states to be monitored and logged
#- Adder2.out2 # pattern model_name.state_name
Expand Down
13 changes: 8 additions & 5 deletions src/illuminator/builder/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,15 @@ def init(self, sid, time_resolution=1, **sim_params): # can be use to update mo
# self.model = self.load_model_class(self.model_data['model_path'], self.model_data['model_type'])
return self._model.simulator_meta

def create(self, num: int) -> List:
def create(self, num:int, model:str, **model_params) -> List[dict]: # This change is mandatory. It MUST contain num and model as parameters otherwise it receives an incorrect number of parameters
"""Creates an instance of the model"""
for i in range(num):
eid = f"{self._model.simulator_type.value}_{i}"
self.model_entities[eid] = self._model
return list(self.model_entities.keys())
new_entities = [] # See below why this was created
for i in range(num): # this seems ok
eid = f"{self._model.simulator_type.value}_{i}" # this seems ok
self.model_entities[eid] = self._model # this seems fine
# return list(self.model_entities.keys()) # I removed this bit for now. Create is expected to return a list of dictionaries
new_entities.append({'eid': eid, 'type': model}) # So basically, like this. Later on we can look into other alternatives if needed.
return new_entities

def current_time(self):
"""Returns the current time of the simulation"""
Expand Down
21 changes: 13 additions & 8 deletions src/illuminator/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,19 @@ def start_simulators(world: MosaikWorld, models: list) -> dict:

# TODO:
# this is a temporary solution to continue developing the CLI
entity = model_factory.create(num=1, sim_start='2012-01-01 00:00:00',
panel_data={'Module_area': 1.26, 'NOCT': 44, 'Module_Efficiency': 0.198, 'Irradiance_at_NOCT': 800,
'Power_output_at_STC': 250,'peak_power':600},
m_tilt=14,
m_az=180,
cap=500,
output_type='power'
)

# TODO: If we wish to use different values here, we must define the parameters used here within the appropriate .yaml file.
# Right now adder.yaml defines the custom parameters as "param1"

# entity = model_factory.create(num=1, sim_start='2012-01-01 00:00:00',
# panel_data={'Module_area': 1.26, 'NOCT': 44, 'Module_Efficiency': 0.198, 'Irradiance_at_NOCT': 800,
# 'Power_output_at_STC': 250,'peak_power':600},
# m_tilt=14,
# m_az=180,
# cap=500,
# output_type='power'
# )
entity = model_factory.create(num=1, param1="Not in use")

model_entities[model_name] = entity
print(model_entities)
Expand Down
1 change: 1 addition & 0 deletions src/illuminator/schema/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# monitor and connections sections enforce a format such as
# <model>.<input/output/state>
valid_model_item_format = r'^\w+\.\w+$'
# valid_model_item_format = r'^([\w-]+\.?)+$' # This is kept here as an alternative. I believe this might be useful later on



Expand Down

0 comments on commit 67d6dfe

Please sign in to comment.