Skip to content

Commit

Permalink
Merge pull request #282 from stevebuk1/dev
Browse files Browse the repository at this point in the history
Bugfix - factoring applied twice.
  • Loading branch information
stevebuk1 authored Oct 29, 2024
2 parents e3889bf + 6e0ccf5 commit 072cea5
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions apps/pv_opt/pvpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,8 +1058,24 @@ def optimised_force(self, initial_soc, static_flows, contract: Contract, **kwarg

# Each slot is assigned a value of 1, if already in a slot then factor for time already gone.


#self.log("Time logging")
#self.log(f"Timenow = {pd.Timestamp.utcnow().tz_localize(None)}")

#Test: Code for not doing factoring if in a partial slot
#for slot in window:
# factors.append(1)

for slot in window:
if log:
self.log(f"Slot time = {slot.tz_localize(None)}")

if pd.Timestamp.utcnow().tz_localize(None) > slot.tz_localize(None):
#if log:
# self.log("Partial slot detected")
# self.log("Factor to be written is....")
# self.log(((slot.tz_localize(None) + pd.Timedelta(30, 'minutes')) - pd.Timestamp.utcnow().tz_localize(None)).total_seconds() / 1800)

factors.append(
(
(slot.tz_localize(None) + pd.Timedelta(30, "minutes"))
Expand All @@ -1074,8 +1090,9 @@ def optimised_force(self, initial_soc, static_flows, contract: Contract, **kwarg

factors = [f / sum(factors) for f in factors]

# self.log("Factors =")
# self.log(factors)
#if log:
# self.log("Factors =")
# self.log(factors)

if round(cost_at_min_price, 1) < round(max_import_cost, 1):

Expand Down

0 comments on commit 072cea5

Please sign in to comment.