Skip to content

Commit

Permalink
fix(drawer): don't crash when rates are at 1
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Nov 12, 2024
1 parent b0ca796 commit 31beb29
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/antares/tsgen/ts_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,11 @@ def _categorize_outages(available_units: int, po_candidates: int, fo_candidates:

class ForcedOutagesDrawer:
def __init__(self, rng: RNG, unit_count: int, failure_rate: FloatArray):
days = len(failure_rate)
self.rng = rng
self.failure_rate = failure_rate
self.ff = np.zeros(days, dtype=float) # ff = lf / (1 - lf)
a = np.zeros(shape=days, dtype=float)
mask = failure_rate <= FAILURE_RATE_EQ_1
a[mask] = 1 - failure_rate[mask]
self.ff[mask] = failure_rate[mask] / a
a = np.where(mask, 1 - failure_rate, 0)
self.ff = np.where(mask, failure_rate / a, 0) # ff = lf / (1 - lf)
self.fpow = _column_powers(a, unit_count + 1)

def draw(self, available_units: int, day: int) -> int:
Expand All @@ -269,14 +266,11 @@ def draw(self, available_units: int, day: int) -> int:

class PlannedOutagesDrawer:
def __init__(self, rng: RNG, unit_count: int, failure_rate: FloatArray):
days = len(failure_rate)
self.rng = rng
self.failure_rate = failure_rate
self.pp = np.zeros(days, dtype=float) # pp = lp / (1 - lp)
a = np.zeros(shape=days, dtype=float)
mask = failure_rate <= FAILURE_RATE_EQ_1
a[mask] = 1 - failure_rate[mask]
self.pp[mask] = failure_rate[mask] / a
a = np.where(mask, 1 - failure_rate, 0)
self.pp = np.where(mask, failure_rate / a, 0) # pp = lp / (1 - lp)
self.ppow = _column_powers(a, unit_count + 1)

def draw(self, available_units: int, day: int, stock: int) -> Tuple[int, int]:
Expand Down

0 comments on commit 31beb29

Please sign in to comment.