Coverage for examples/OneRoom_CIA/predictor/simple_predictor.py: 100%
21 statements
« prev ^ index » next coverage.py v7.4.4, created at 2026-03-26 09:43 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2026-03-26 09:43 +0000
1import agentlib as al
2import numpy as np
3import pandas as pd
6class PredictorModuleConfig(al.BaseModuleConfig):
7 """Module that outputs a prediction of the heat load at a specified
8 interval."""
9 outputs: al.AgentVariables = [
10 al.AgentVariable(
11 name="r_pel", unit="ct/kWh", type="pd.Series", description="Weight for P_el in objective function"
12 ),
13 ]
14 parameters: al.AgentVariables = [
15 al.AgentVariable(
16 name="time_step", value=900, description="Sampling time for prediction."
17 ),
18 al.AgentVariable(
19 name="prediction_horizon",
20 value=8,
21 description="Number of sampling points for prediction.",
22 )
23 ]
25 shared_variable_fields: list[str] = ["outputs"]
28class PredictorModule(al.BaseModule):
29 """Module that outputs a prediction of the heat load at a specified
30 interval."""
32 config: PredictorModuleConfig
34 def register_callbacks(self):
35 pass
37 def process(self):
38 while True:
39 sample_time = self.env.config.t_sample
40 ts = self.get("time_step").value
41 k = self.get("prediction_horizon").value
42 now = self.env.now
44 grid = np.arange(now, now + k * ts + 1, sample_time)
45 p_traj = pd.Series([1 for i in grid], index=list(grid))
46 self.set("r_pel", p_traj)
48 yield self.env.timeout(sample_time)