File tree 2 files changed +43
-42
lines changed
2 files changed +43
-42
lines changed Original file line number Diff line number Diff line change @@ -292,48 +292,6 @@ def render(self, mode="human"):
292
292
def sample_action (self , strict_bound = False , sample_flex_modules = False ):
293
293
return self .action_space .sample ()
294
294
295
- def compute_net_load (self , normalized = False ):
296
- """
297
- Compute the net load at the current step.
298
-
299
- Net load is load minus renewables.
300
- -------
301
-
302
- Returns
303
- -------
304
- net_load : float
305
- Net load.
306
-
307
- """
308
-
309
- try :
310
- fixed_consumption = self .modules .fixed .get_attrs ('max_consumption' , as_pandas = False , drop_attr_names = True )
311
- fixed_consumption = np .sum (list (fixed_consumption .values ()))
312
- except AttributeError :
313
- fixed_consumption = 0.0
314
- except IndexError :
315
- # Exhausted available data. Episode should be over
316
- assert self .current_step == self .final_step
317
- return 0.0
318
-
319
- try :
320
- flex_max_prod = [m .max_production for m in self .modules .flex .iterlist () if m .marginal_cost == 0 ]
321
- except IndexError :
322
- # Exhausted available data. Episode should be over
323
- assert self .current_step == self .final_step
324
- return 0.0
325
-
326
- flex_production = sum (flex_max_prod )
327
-
328
- net_load = fixed_consumption - flex_production
329
-
330
- if normalized :
331
- if fixed_consumption :
332
- return net_load / fixed_consumption
333
- return - 1.0
334
-
335
- return net_load
336
-
337
295
def state_dict (self , normalized = False , as_run_output = False , _initial = None ):
338
296
net_load = self .compute_net_load (normalized = normalized )
339
297
Original file line number Diff line number Diff line change @@ -600,6 +600,49 @@ def set_forecaster(self,
600
600
except AttributeError :
601
601
pass
602
602
603
+ def compute_net_load (self , normalized = False ):
604
+ """
605
+ Compute the net load at the current step.
606
+
607
+ Net load is load minus renewables.
608
+ -------
609
+
610
+ Returns
611
+ -------
612
+ net_load : float
613
+ Net load.
614
+
615
+ """
616
+
617
+ try :
618
+ fixed_consumption = self .modules .fixed .get_attrs ('max_consumption' , as_pandas = False , drop_attr_names = True )
619
+ fixed_consumption = np .sum (list (fixed_consumption .values ()))
620
+ except AttributeError :
621
+ fixed_consumption = 0.0
622
+ except IndexError :
623
+ # Exhausted available data. Episode should be over
624
+ assert self .current_step == self .final_step
625
+ return 0.0
626
+
627
+ try :
628
+ flex_max_prod = [m .max_production for m in self .modules .flex .iterlist () if m .marginal_cost == 0 ]
629
+ except IndexError :
630
+ # Exhausted available data. Episode should be over
631
+ assert self .current_step == self .final_step
632
+ return 0.0
633
+
634
+ flex_production = sum (flex_max_prod )
635
+
636
+ net_load = fixed_consumption - flex_production
637
+
638
+ if normalized :
639
+ if fixed_consumption :
640
+ return net_load / fixed_consumption
641
+ return - 1.0
642
+
643
+ return net_load
644
+
645
+
603
646
def get_forecast_horizon (self ):
604
647
"""
605
648
Get the forecast horizon of timeseries modules contained in the microgrid.
You can’t perform that action at this time.
0 commit comments