Skip to content

Commit bd38e61

Browse files
authored
Fix call to get_retirement_stage by casting lifetime to integer (#840)
Fix small bug where if a resource lifetime is not an integer, the multi stage code will not work.
1 parent 776337c commit bd38e61

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Models running with, non-default, solvers Cbc and Clp will fail unless
1515
`"EnableJuMPDirectMode"` is set to false (#835).
1616
- Improve `@expressions` performance by pre-processing sets (#815).
1717

18+
### Fixed
19+
- Fix call to `get_retirement_stage` by casting `lifetime` to integer (#840).
20+
1821
## [0.4.4] - 2025-02-04
1922

2023
### Added

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GenX"
22
uuid = "5d317b1e-30ec-4ed6-a8ce-8d2d88d7cfac"
33
authors = ["Bonaldo, Luca", "Chakrabarti, Sambuddha", "Cheng, Fangwei", "Ding, Yifu", "Jenkins, Jesse D.", "Luo, Qian", "Macdonald, Ruaridh", "Mallapragada, Dharik", "Manocha, Aneesha", "Mantegna, Gabe ", "Morris, Jack", "Patankar, Neha", "Pecci, Filippo", "Schwartz, Aaron", "Schwartz, Jacob", "Schivley, Greg", "Sepulveda, Nestor", "Xu, Qingyu", "Zhou, Justin"]
4-
version = "0.4.4-dev.5"
4+
version = "0.4.4-dev.6"
55

66
[deps]
77
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"

src/multi_stage/endogenous_retirement.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function endogenous_retirement_discharge!(EP::Model,
220220
@expression(EP,
221221
eNewCapTrack[y in RET_CAP],
222222
sum(EP[:vCAPTRACK][y, p]
223-
for p in 1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens)))
223+
for p in 1:get_retirement_stage(cur_stage, Int(floor(lifetime(gen[y]))), stage_lens)))
224224
@expression(EP, eMinRetCapTrack[y in RET_CAP],
225225
if y in COMMIT
226226
cum_min_retired_cap_mw(gen[y]) / cap_size(gen[y])
@@ -302,7 +302,7 @@ function endogenous_retirement_charge!(EP::Model,
302302
@expression(EP,
303303
eNewCapTrackCharge[y in RET_CAP_CHARGE],
304304
sum(EP[:vCAPTRACKCHARGE][y, p]
305-
for p in 1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens)))
305+
for p in 1:get_retirement_stage(cur_stage, Int(floor(lifetime(gen[y]))), stage_lens)))
306306
@expression(EP,
307307
eMinRetCapTrackCharge[y in RET_CAP_CHARGE],
308308
cum_min_retired_charge_cap_mw(gen[y]))
@@ -368,7 +368,7 @@ function endogenous_retirement_energy!(EP::Model,
368368
@expression(EP,
369369
eNewCapTrackEnergy[y in RET_CAP_ENERGY],
370370
sum(EP[:vCAPTRACKENERGY][y, p]
371-
for p in 1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens)))
371+
for p in 1:get_retirement_stage(cur_stage, Int(floor(lifetime(gen[y]))), stage_lens)))
372372
@expression(EP,
373373
eMinRetCapTrackEnergy[y in RET_CAP_ENERGY],
374374
cum_min_retired_energy_cap_mw(gen[y]))
@@ -434,7 +434,7 @@ function endogenous_retirement_vre_stor_dc!(EP::Model,
434434
@expression(EP,
435435
eNewCapTrackDC[y in RET_CAP_DC],
436436
sum(EP[:vCAPTRACKDC][y, p]
437-
for p in 1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens)))
437+
for p in 1:get_retirement_stage(cur_stage, Int(floor(lifetime(gen[y]))), stage_lens)))
438438
@expression(EP,
439439
eMinRetCapTrackDC[y in RET_CAP_DC],
440440
cum_min_retired_cap_inverter_mw(gen[y]))
@@ -500,7 +500,7 @@ function endogenous_retirement_vre_stor_solar!(EP::Model,
500500
@expression(EP,
501501
eNewCapTrackSolar[y in RET_CAP_SOLAR],
502502
sum(EP[:vCAPTRACKSOLAR][y, p]
503-
for p in 1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens)))
503+
for p in 1:get_retirement_stage(cur_stage, Int(floor(lifetime(gen[y]))), stage_lens)))
504504
@expression(EP,
505505
eMinRetCapTrackSolar[y in RET_CAP_SOLAR],
506506
cum_min_retired_cap_solar_mw(gen[y]))
@@ -566,7 +566,7 @@ function endogenous_retirement_vre_stor_wind!(EP::Model,
566566
@expression(EP,
567567
eNewCapTrackWind[y in RET_CAP_WIND],
568568
sum(EP[:vCAPTRACKWIND][y, p]
569-
for p in 1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens)))
569+
for p in 1:get_retirement_stage(cur_stage, Int(floor(lifetime(gen[y]))), stage_lens)))
570570
@expression(EP,
571571
eMinRetCapTrackWind[y in RET_CAP_WIND],
572572
cum_min_retired_cap_wind_mw(gen[y]))
@@ -630,7 +630,7 @@ function endogenous_retirement_vre_stor_elec!(EP::Model,
630630
sum(EP[:vRETCAPTRACKELEC][y, p] for p in 1:cur_stage))
631631
@expression(EP, eNewCapTrackElec[y in RET_CAP_ELEC],
632632
sum(EP[:vCAPTRACKELEC][y, p]
633-
for p in 1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens)))
633+
for p in 1:get_retirement_stage(cur_stage, Int(floor(lifetime(gen[y]))), stage_lens)))
634634
@expression(EP, eMinRetCapTrackElec[y in RET_CAP_ELEC],
635635
cum_min_retired_cap_elec_mw(gen[y]))
636636

@@ -687,7 +687,7 @@ function endogenous_retirement_vre_stor_stor!(
687687
@expression(EP,
688688
eNewCapTrackEnergy_VS[y in RET_CAP_STOR],
689689
sum(EP[:vCAPTRACKENERGY_VS][y, p]
690-
for p in 1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens)))
690+
for p in 1:get_retirement_stage(cur_stage, Int(floor(lifetime(gen[y]))), stage_lens)))
691691
@expression(EP,
692692
eMinRetCapTrackEnergy_VS[y in RET_CAP_STOR],
693693
cum_min_retired_energy_cap_mw(gen[y]))
@@ -755,7 +755,7 @@ function endogenous_retirement_vre_stor_discharge_dc!(EP::Model,
755755
@expression(EP,
756756
eNewCapTrackDischargeDC[y in RET_CAP_DISCHARGE_DC],
757757
sum(EP[:vCAPTRACKDISCHARGEDC][y, p]
758-
for p in 1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens)))
758+
for p in 1:get_retirement_stage(cur_stage, Int(floor(lifetime(gen[y]))), stage_lens)))
759759
@expression(EP,
760760
eMinRetCapTrackDischargeDC[y in RET_CAP_DISCHARGE_DC],
761761
cum_min_retired_cap_discharge_dc_mw(gen[y]))
@@ -821,7 +821,7 @@ function endogenous_retirement_vre_stor_charge_dc!(EP::Model,
821821
@expression(EP,
822822
eNewCapTrackChargeDC[y in RET_CAP_CHARGE_DC],
823823
sum(EP[:vCAPTRACKCHARGEDC][y, p]
824-
for p in 1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens)))
824+
for p in 1:get_retirement_stage(cur_stage, Int(floor(lifetime(gen[y]))), stage_lens)))
825825
@expression(EP,
826826
eMinRetCapTrackChargeDC[y in RET_CAP_CHARGE_DC],
827827
cum_min_retired_cap_charge_dc_mw(gen[y]))
@@ -888,7 +888,7 @@ function endogenous_retirement_vre_stor_discharge_ac!(EP::Model,
888888
@expression(EP,
889889
eNewCapTrackDischargeAC[y in RET_CAP_DISCHARGE_AC],
890890
sum(EP[:vCAPTRACKDISCHARGEAC][y, p]
891-
for p in 1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens)))
891+
for p in 1:get_retirement_stage(cur_stage, Int(floor(lifetime(gen[y]))), stage_lens)))
892892
@expression(EP,
893893
eMinRetCapTrackDischargeAC[y in RET_CAP_DISCHARGE_AC],
894894
cum_min_retired_cap_discharge_ac_mw(gen[y]))
@@ -954,7 +954,7 @@ function endogenous_retirement_vre_stor_charge_ac!(EP::Model,
954954
@expression(EP,
955955
eNewCapTrackChargeAC[y in RET_CAP_CHARGE_AC],
956956
sum(EP[:vCAPTRACKCHARGEAC][y, p]
957-
for p in 1:get_retirement_stage(cur_stage, lifetime(gen[y]), stage_lens)))
957+
for p in 1:get_retirement_stage(cur_stage, Int(floor(lifetime(gen[y]))), stage_lens)))
958958
@expression(EP,
959959
eMinRetCapTrackChargeAC[y in RET_CAP_CHARGE_AC],
960960
cum_min_retired_cap_charge_ac_mw(gen[y]))

test/test_electrolyzer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Test
44

55
include(joinpath(@__DIR__, "utilities.jl"))
66

7-
obj_true = 34275.8599
7+
obj_true = 34277.0607
88
test_path = "electrolyzer"
99

1010
# Define test inputs

0 commit comments

Comments
 (0)