Skip to content

Commit

Permalink
fix test, change to ObjectivePenalties
Browse files Browse the repository at this point in the history
  • Loading branch information
adfarth committed Jan 23, 2024
1 parent 60c423c commit 4271de0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Classify the change according to the following categories:

## Develop 2024-01-16
### Fixed
- In `reopt.jl`, group objective function incentives and avoid directly modifying m[:Costs]. Previously, some of these were incorrectly included in the reported **Financial.lcc**
- In `reopt.jl`, group objective function incentives (into **ObjectivePenalties**) and avoid directly modifying m[:Costs]. Previously, some of these were incorrectly included in the reported **Financial.lcc**.

## v0.39.1
### Changed
Expand Down
10 changes: 5 additions & 5 deletions src/core/reopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function build_reopt!(m::JuMP.AbstractModel, p::REoptInputs)
m[:GHPOMCosts] = 0.0
m[:AvoidedCapexByGHP] = 0.0
m[:ResidualGHXCapCost] = 0.0
m[:ObjectiveIncentives] = 0.0
m[:ObjectivePenalties] = 0.0

if !isempty(p.techs.all)
add_tech_size_constraints(m, p)
Expand Down Expand Up @@ -468,21 +468,21 @@ function build_reopt!(m::JuMP.AbstractModel, p::REoptInputs)

## Modify objective with incentives that are not part of the LCC
# 1. Comfort limit violation costs
m[:ObjectiveIncentives] += m[:dvComfortLimitViolationCost]
m[:ObjectivePenalties] += m[:dvComfortLimitViolationCost]
# 2. Incentive to keep SOC high
if !(isempty(p.s.storage.types.elec)) && p.s.settings.add_soc_incentive
m[:ObjectiveIncentives] += -1 * sum(
m[:ObjectivePenalties] += -1 * sum(
m[:dvStoredEnergy][b, ts] for b in p.s.storage.types.elec, ts in p.time_steps
) / (8760. / p.hours_per_time_step)
end
# 3. Incentive to minimize unserved load in each outage, not just the max over outage start times
if !isempty(p.s.electric_utility.outage_durations)
m[:ObjectiveIncentives] += sum(sum(0.0001 * m[:dvUnservedLoad][s, tz, ts] for ts in 1:p.s.electric_utility.outage_durations[s])
m[:ObjectivePenalties] += sum(sum(0.0001 * m[:dvUnservedLoad][s, tz, ts] for ts in 1:p.s.electric_utility.outage_durations[s])
for s in p.s.electric_utility.scenarios, tz in p.s.electric_utility.outage_start_time_steps)
end

# Set model objective
@objective(m, Min, m[:Costs] + m[:ObjectiveIncentives] )
@objective(m, Min, m[:Costs] + m[:ObjectivePenalties] )

for b in p.s.storage.types.elec
if p.s.storage.attr[b].model_degradation
Expand Down
2 changes: 1 addition & 1 deletion test/test_with_xpress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ end
@test results["Site"]["total_renewable_energy_fraction_bau"] 0.132118 atol=1e-3 # 0.1354 atol=1e-3
# CO2 emissions - totals ≈ from grid, from fuelburn, ER, $/tCO2 breakeven
@test results["Site"]["lifecycle_emissions_reduction_CO2_fraction"] 0.8 atol=1e-3 # 0.8
@test results["Financial"]["breakeven_cost_of_emissions_reduction_per_tonne_CO2"] 373.9 atol=1e-1
@test results["Financial"]["breakeven_cost_of_emissions_reduction_per_tonne_CO2"] 374.0 atol=1e-1
@test results["Site"]["annual_emissions_tonnes_CO2"] 14.2 atol=1
@test results["Site"]["annual_emissions_tonnes_CO2_bau"] 70.99 atol=1
@test results["Site"]["annual_emissions_from_fuelburn_tonnes_CO2"] 0.0 atol=1 # 0.0
Expand Down

0 comments on commit 4271de0

Please sign in to comment.