Skip to content

Commit

Permalink
Adjusted/cleaned up osd capacity change fn. Added solver arg to clipp…
Browse files Browse the repository at this point in the history
…ing call in DH. Adjusted timeshift class attributes to plot convex problem w1 opt. Adjusted test fixtures. Added skipping logic for MOSEK tests.
  • Loading branch information
pluflou committed Aug 3, 2023
1 parent b29f3d1 commit 70246de
Show file tree
Hide file tree
Showing 19 changed files with 634 additions and 593 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
$pythonLocation/bin/python3 -m pip list
sudo git clone https://github.com/cvxgrp/signal-decomposition.git
sudo $pythonLocation/bin/python3 -m pip install -r signal-decomposition/requirements.txt
sudo $pythonLocation/bin/python3 -m pip install -e ./signal-decomposition/.
sudo $pythonLocation/bin/python3 -m pip install ./signal-decomposition/.
- name: Setup Mosek License File
run: |
Expand Down
6 changes: 2 additions & 4 deletions solardatatools/_osd_signal_decompositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def _osd_l1_l1d1_l2d2p365(
w0=2e-6, # l1 term, scaled
w1=40e-6, # l1d1 term, scaled
w2=6e-3, # seasonal term, scaled
w3=1e-6, # linear term, scaled
return_all=False,
solver=None,
sum_card=False,
Expand All @@ -136,15 +135,14 @@ def _osd_l1_l1d1_l2d2p365(
Periodic(365)
])
else:
w1 /= 4.9 # PWC weight needs adjusting when dataset is short
w1 /= 5 # PWC weight needs adjusting when dataset is short

if sum_card:
c3 = SumCard(weight=w1, diff=1)
else:
c3 = SumAbs(weight=w1, diff=1)

c4 = Aggregate([NoCurvature(weight=w3),
Inequality(vmin=-0.1, vmax=0.01, diff=1),
c4 = Aggregate([NoCurvature(),
FirstValEqual(0)
])

Expand Down
3 changes: 1 addition & 2 deletions solardatatools/algorithms/capacity_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self):
self.metric = None
self.s1 = None
self.s2 = None
self.s3 = None
self.labels = None

def run(
Expand All @@ -33,7 +34,6 @@ def run(
quantile=1.00,
w1=40e-6, # scaled weights for QSS
w2=6561e-6,
w3=1e-6,
solver=None
):
if filter is None:
Expand All @@ -47,7 +47,6 @@ def run(
use_ixs=filter,
w1=w1,
w2=w2,
w3=w3,
solver=solver,
sum_card=True
)
Expand Down
13 changes: 7 additions & 6 deletions solardatatools/algorithms/time_shifts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(self):
self.jumps_per_year = None
self.best_w1 = None
self.best_ix = None
self.w1_vals = None
self.baseline = None
self.periodic_detector = None
self.__recursion_depth = 0
Expand Down Expand Up @@ -81,12 +82,12 @@ def run(
best_w1 = w1s[best_ix]
else:
best_w1 = w1
hn = None
rn = None
tv_metric = None
jpy = None
w1s = None
best_ix = None
hn = self.normalized_holdout_error
rn = self.normalized_train_error
tv_metric = self.tv_metric
jpy = self.jumps_per_year
w1s = self.w1_vals
best_ix = self.best_ix
s1, s2 = self.estimate_components(
metric, best_w1, w2, use_ixs, periodic_detector, solver=solver, sum_card=sum_card
)
Expand Down
3 changes: 1 addition & 2 deletions solardatatools/data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ def clipping_check(self, solver="OSQP"):

def find_clipped_times(self):
if self.clipping_analysis is None:
self.clipping_check()
self.clipping_check(solver=solver_convex)
self.clipping_analysis.find_clipped_times()
self.boolean_masks.clipped_times = self.clipping_analysis.clipping_mask

Expand All @@ -894,7 +894,6 @@ def capacity_clustering(
quantile=1.00,
w1=40e-6, # scaled weights for QSS
w2=6561e-6,
w3=1e-6,
solver=solver,
)
if len(set(self.capacity_analysis.labels)) > 1:
Expand Down
2 changes: 0 additions & 2 deletions solardatatools/signal_decompositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def l1_l1d1_l2d2p365(
w0=2e-6, # l1 term, scaled
w1=40e-6, # l1d1 term, scaled
w2=6e-3, # seasonal term, scaled
w3=1e-6, # linear term, scaled
return_all=False,
solver=None,
sum_card=False, # OSD only
Expand All @@ -161,7 +160,6 @@ def l1_l1d1_l2d2p365(
w0=w0,
w1=w1,
w2=w2,
w3=w3,
return_all=return_all,
solver=solver,
sum_card=sum_card,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/scoring/clipping_2.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
2.668741250924743236e-01
2.641264801564077169e-01
2.015992346365793053e-01
2.429244651835558710e-01
2.429243661166819446e-01
2.417860890302446220e-01
1.952380725068751099e-01
2.350504606995748313e-01
Expand Down
Loading

0 comments on commit 70246de

Please sign in to comment.