Repository: blue-marble/gridpath

Issue:
Endogenous availability availability calculation should be weighted
In both the continuous and the binary availability types, the unavailability calculated in the availability constraints (respectively [AvlBin_Tot_Sched_Unavl_per_Prd_Constraint](https://github.com/blue-marble/gridpath/blob/c0ec4d2d93592f9514169ab5cca5a655170e94d1/gridpath/project/availability/availability_types/binary.py#L223) and [AvlCont_Tot_Sched_Unavl_per_Prd_Constraint](https://github.com/blue-marble/gridpath/blob/c0ec4d2d93592f9514169ab5cca5a655170e94d1/gridpath/project/availability/availability_types/continuous.py#L227)) should be weighted by the timepoint weight.

Discussion:
anamileva: @PascalLesage, thanks for fixing this bug. If you set `unavailable_hours_per_period` for the project `Nuclear` (in its [endogenous availability CSV file](https://github.com/blue-marble/gridpath/blob/main/db/csvs_test_examples/project/project_availability/project_availability_endogenous/Nuclear-1-base.csv) used to bulid the test database), all tests should pass.
PascalLesage: @anamileva done, and passing. Thanks for identifying the test issue.

Patch:
diff --git a/gridpath/project/availability/availability_types/binary.py b/gridpath/project/availability/availability_types/binary.py
index e53176a4..7ff8fb74 100644
--- a/gridpath/project/availability/availability_types/binary.py
+++ b/gridpath/project/availability/availability_types/binary.py
@@ -231,7 +231,7 @@ def total_scheduled_availability_per_period_rule(mod, g, p):
     """
     return (
         sum(
-            mod.AvlBin_Unavailable[g, tmp] * mod.hrs_in_tmp[tmp]
+            mod.AvlBin_Unavailable[g, tmp] * mod.hrs_in_tmp[tmp] * mod.tmp_weight[tmp]
             for tmp in mod.TMPS_IN_PRD[p]
         )
         == mod.avl_bin_unavl_hrs_per_prd[g]
diff --git a/gridpath/project/availability/availability_types/continuous.py b/gridpath/project/availability/availability_types/continuous.py
index 3183f2fb..90da3eb4 100644
--- a/gridpath/project/availability/availability_types/continuous.py
+++ b/gridpath/project/availability/availability_types/continuous.py
@@ -235,7 +235,7 @@ def total_scheduled_availability_per_period_rule(mod, g, p):
     """
     return (
         sum(
-            mod.AvlCont_Unavailable[g, tmp] * mod.hrs_in_tmp[tmp]
+            mod.AvlCont_Unavailable[g, tmp] * mod.hrs_in_tmp[tmp] * mod.tmp_weight[tmp]
             for tmp in mod.TMPS_IN_PRD[p]
         )
         == mod.avl_cont_unavl_hrs_per_prd[g]


Test patch:
diff --git a/db/csvs_test_examples/project/project_availability/project_availability_endogenous/Nuclear-1-base.csv b/db/csvs_test_examples/project/project_availability/project_availability_endogenous/Nuclear-1-base.csv
index 55129839..675c216d 100644
--- a/db/csvs_test_examples/project/project_availability/project_availability_endogenous/Nuclear-1-base.csv
+++ b/db/csvs_test_examples/project/project_availability/project_availability_endogenous/Nuclear-1-base.csv
@@ -1,1 +1,1 @@
-unavailable_hours_per_period,unavailable_hours_per_event_min,available_hours_between_events_min1,1,1
\ No newline at end of file
+unavailable_hours_per_period,unavailable_hours_per_event_min,available_hours_between_events_min2190,1,1
\ No newline at end of file