Skip to content

Commit

Permalink
Change multi-year fixed and investment costs to help differentiate an…
Browse files Browse the repository at this point in the history
…d fix objective fixed costs

The objective fixed cost were being selected from milestone_years only.

Closes #1046
  • Loading branch information
abelsiqueira committed Feb 24, 2025
1 parent a7c7b36 commit d578618
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 40 deletions.
19 changes: 13 additions & 6 deletions src/objective.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ function add_objective!(connection, model, variables, expressions, model_paramet
"SELECT
expr.index,
t_objective_assets.weight_for_operation_discounts
* t_objective_assets.fixed_cost
* asset_commission.fixed_cost
* t_objective_assets.capacity
AS cost,
FROM expr_available_asset_units AS expr
LEFT JOIN asset_commission
ON expr.asset = asset_commission.asset
AND expr.commission_year = asset_commission.commission_year
LEFT JOIN t_objective_assets
ON expr.asset = t_objective_assets.asset
AND expr.milestone_year = t_objective_assets.milestone_year
Expand Down Expand Up @@ -98,10 +101,13 @@ function add_objective!(connection, model, variables, expressions, model_paramet
"SELECT
expr.index,
t_objective_assets.weight_for_operation_discounts
* t_objective_assets.fixed_cost_storage_energy
* asset_commission.fixed_cost_storage_energy
* t_objective_assets.capacity_storage_energy
AS cost,
FROM expr_available_energy_units AS expr
LEFT JOIN asset_commission
ON expr.asset = asset_commission.asset
AND expr.commission_year = asset_commission.commission_year
LEFT JOIN t_objective_assets
ON expr.asset = t_objective_assets.asset
AND expr.milestone_year = t_objective_assets.milestone_year
Expand Down Expand Up @@ -149,10 +155,14 @@ function add_objective!(connection, model, variables, expressions, model_paramet
"SELECT
expr.index,
t_objective_flows.weight_for_operation_discounts
* t_objective_flows.fixed_cost / 2
* flow_commission.fixed_cost / 2
* t_objective_flows.capacity
AS cost,
FROM expr_available_flow_units AS expr
LEFT JOIN flow_commission
ON expr.from_asset = flow_commission.from_asset
AND expr.to_asset = flow_commission.to_asset
AND expr.commission_year = flow_commission.commission_year
LEFT JOIN t_objective_flows
ON expr.from_asset = t_objective_flows.from_asset
AND expr.to_asset = t_objective_flows.to_asset
Expand Down Expand Up @@ -275,10 +285,8 @@ function _create_objective_auxiliary_table(connection, constants)
asset_milestone.milestone_year,
-- copied over
asset_commission.investment_cost,
asset_commission.fixed_cost,
asset.capacity,
asset_commission.investment_cost_storage_energy,
asset_commission.fixed_cost_storage_energy,
asset.capacity_storage_energy,
asset_milestone.units_on_cost,
-- computed
Expand Down Expand Up @@ -321,7 +329,6 @@ function _create_objective_auxiliary_table(connection, constants)
flow_milestone.milestone_year,
-- copied over
flow_commission.investment_cost,
flow_commission.fixed_cost,
flow.capacity,
flow_milestone.variable_cost,
-- computed
Expand Down
30 changes: 16 additions & 14 deletions test/inputs/Multi-year Investments/asset-both.csv
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
asset,milestone_year,commission_year,active,decommissionable,initial_units,initial_storage_units
ocgt,2030,2030,true,false,0.0,0.0
ccgt,2030,2028,true,true,1.0,0.0
ccgt,2030,2030,true,false,0.0,0.0
battery,2030,2020,true,true,0.07,0.0
battery,2030,2025,true,true,1.00,0.0
battery,2030,2030,true,false,0.02,0.0
wind,2030,2020,true,true,0.07,0.0
wind,2030,2030,true,false,0.02,0.0
solar,2030,2030,true,false,0.0,0.0
ens,2030,2030,true,false,1.0,0.0
demand,2030,2030,true,true,0.0,0.0
ocgt,2050,2050,true,false,0.0,0.0
battery,2050,2030,true,true,0.02,0.0
battery,2050,2040,true,true,2.00,0.0
battery,2050,2050,true,false,0.0,0.0
ccgt,2030,2028,true,true,1.0,0.0
ccgt,2030,2030,true,false,0.0,0.0
ccgt,2050,2028,true,true,1.0,0.0
ccgt,2050,2030,true,true,0.0,0.0
ccgt,2050,2050,true,false,0.0,0.0
battery,2050,2030,true,true,0.02,0.0
battery,2050,2050,true,false,0.0,0.0
demand,2030,2030,true,true,0.0,0.0
demand,2050,2050,false,false,0.0,0.0
ens,2030,2030,true,false,1.0,0.0
ens,2050,2050,true,false,1.0,0.0
ocgt,2030,2030,true,false,0.0,0.0
ocgt,2050,2050,true,false,0.0,0.0
solar,2030,2030,true,false,0.0,0.0
solar,2050,2050,true,false,0.0,0.0
wind,2030,2020,true,true,0.07,0.0
wind,2030,2030,true,false,0.02,0.0
wind,2050,2030,true,true,0.02,0.0
wind,2050,2050,true,false,0.0,0.0
solar,2050,2050,true,false,0.0,0.0
ens,2050,2050,true,false,1.0,0.0
demand,2050,2050,false,false,0.0,0.0
36 changes: 19 additions & 17 deletions test/inputs/Multi-year Investments/asset-commission.csv
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
asset,commission_year,fixed_cost,investment_cost,investment_limit,fixed_cost_storage_energy,investment_cost_storage_energy,investment_limit_storage_energy
wind,2020,20.0,70.0,,5.0,0.0,
demand,2050,20.0,0.0,,5.0,0.0,
battery,2030,20.0,70.0,,5.0,0.0,
ccgt,2050,20.0,40.0,10000.0,5.0,0.0,
wind,2050,20.0,70.0,,5.0,0.0,
solar,2050,20.0,50.0,,5.0,0.0,
battery,2020,20.0,70.0,,5.0,0.0,
demand,2030,20.0,0.0,,5.0,0.0,
ccgt,2030,20.0,40.0,10000.0,5.0,0.0,
wind,2030,20.0,70.0,,5.0,0.0,
solar,2030,20.0,50.0,,5.0,0.0,
battery,2050,20.0,70.0,,5.0,0.0,
ccgt,2028,20.0,40.0,10000.0,5.0,0.0,
ens,2030,0.0,0.0,,5.0,0.0,
ocgt,2030,20.0,25.0,,5.0,0.0,
ens,2050,0.0,0.0,,5.0,0.0,
ocgt,2050,20.0,25.0,,5.0,0.0,
battery,2020,21.0,71.0,,15.0,1.0,
battery,2025,22.0,72.0,,25.0,2.0,
battery,2030,23.0,73.0,,35.0,3.0,
battery,2040,24.0,74.0,,45.0,4.0,
battery,2050,25.0,75.0,,55.0,5.0,
ccgt,2028,31.0,41.0,10000.0,0.0,0.0,
ccgt,2030,32.0,42.0,10000.0,0.0,0.0,
ccgt,2050,33.0,43.0,10000.0,0.0,0.0,
demand,2030,0.0,0.0,,0.0,0.0,
demand,2050,0.0,0.0,,0.0,0.0,
ens,2030,0.0,0.0,,0.0,0.0,
ens,2050,0.0,0.0,,0.0,0.0,
ocgt,2030,41.0,25.0,,0.0,0.0,
ocgt,2050,42.0,26.0,,0.0,0.0,
solar,2030,51.0,51.0,,0.0,0.0,
solar,2050,52.0,52.0,,0.0,0.0,
wind,2020,61.0,81.0,,0.0,0.0,
wind,2030,62.0,82.0,,0.0,0.0,
wind,2050,63.0,83.0,,0.0,0.0,
5 changes: 3 additions & 2 deletions test/inputs/Multi-year Investments/flow-commission.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ from_asset,to_asset,commission_year,fixed_cost,investment_cost,efficiency,invest
battery,demand,2030,0.0,350.0,0.95,
wind,demand,2030,0.0,350.0,0.0,
ens,demand,2050,0.0,350.0,0.0,
ccgt,demand,2030,0.0,350.0,0.0,100.0
ccgt,demand,2028,1.0,350.0,0.0,
ccgt,demand,2030,2.0,350.0,0.0,100.0
ocgt,demand,2030,0.0,350.0,0.0,
solar,demand,2050,0.0,350.0,0.0,
demand,battery,2050,0.0,350.0,0.95,
demand,battery,2030,0.0,350.0,0.95,
solar,demand,2030,0.0,350.0,0.0,
ocgt,demand,2050,0.0,350.0,0.0,
ccgt,demand,2050,0.0,350.0,0.0,100.0
ccgt,demand,2050,3.0,350.0,0.0,100.0
ens,demand,2030,0.0,350.0,0.0,
battery,demand,2050,0.0,350.0,0.95,
wind,demand,2050,0.0,350.0,0.0,
2 changes: 1 addition & 1 deletion test/test-case-studies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ end
connection;
model_parameters_file = joinpath(@__DIR__, "inputs", "model-parameters-example.toml"),
)
@test energy_problem.objective_value 2368623.97046 atol = 1e-5
@test energy_problem.objective_value 4507633.87546 atol = 1e-5
end

@testset "Infeasible Case Study" begin
Expand Down

0 comments on commit d578618

Please sign in to comment.