Skip to content

Commit

Permalink
Updated tank volume recovery in problem forms owf and ne
Browse files Browse the repository at this point in the history
To solve the problem for multiple non-consecutive representative days, tank volume needs to be updated at the end of every day.
  • Loading branch information
hskkanth committed Apr 18, 2023
1 parent 7d6d45e commit aa17241
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core/pump.jl
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ function _calc_pump_power_points(wm::AbstractWaterModel, nw::Int, pump_id::Int,
end


function _calc_ne_pump_power_points(wm::AbstractWaterModel, nw::Int, pump_id::Int, num_points::Int)
function _calc_pump_power_points_ne(wm::AbstractWaterModel, nw::Int, pump_id::Int, num_points::Int)
ne_pump = ref(wm, nw, :ne_pump, pump_id)
head_curve_function = ref(wm, nw, :ne_pump, pump_id, "head_curve_function")

Expand Down
14 changes: 11 additions & 3 deletions src/prob/ne.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ function build_mn_ne(wm::AbstractWaterModel)
# Ensure tanks recover their initial volume.
n_1, n_f = network_ids[1], network_ids[end]

for i in ids(wm, n_f, :tank)
constraint_tank_volume_recovery(wm, i, n_1, n_f)
if(haskey(wm.ref[:it][wm_it_sym],:tank_volume_recovery_time_points))
tank_volume_recovery_time_points = wm.ref[:it][wm_it_sym][:tank_volume_recovery_time_points]
else
tank_volume_recovery_time_points = Set([])
end
union(tank_volume_recovery_time_points ,n_f)
for n_tank in tank_volume_recovery_time_points
for i in ids(wm, n_tank, :tank)
constraint_tank_volume_recovery(wm, i, n_1, n_tank)
end
end

# Add the optimal network expansion objective.
objective_ne(wm)
end
end
12 changes: 10 additions & 2 deletions src/prob/owf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,16 @@ function build_mn_owf(wm::AbstractWaterModel)
# Ensure tanks recover their initial volume.
n_1, n_f = network_ids[1], network_ids[end]

for i in ids(wm, n_f, :tank)
constraint_tank_volume_recovery(wm, i, n_1, n_f)
if(haskey(wm.ref[:it][wm_it_sym],:tank_volume_recovery_time_points))
tank_volume_recovery_time_points = wm.ref[:it][wm_it_sym][:tank_volume_recovery_time_points]
else
tank_volume_recovery_time_points = Set([])
end
union(tank_volume_recovery_time_points ,n_f)
for n_tank in tank_volume_recovery_time_points
for i in ids(wm, n_tank, :tank)
constraint_tank_volume_recovery(wm, i, n_1, n_tank)
end
end

# Add the optimal water flow objective.
Expand Down
2 changes: 0 additions & 2 deletions src/prob/wf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ function build_mn_wf(wm::AbstractWaterModel)
# Start with the first network, representing the initial time step.
n_1 = network_ids[1]

# Constraints on tank volumes.
for i in ids(wm, :tank; nw = n_1)
# Set initial conditions of tanks.
constraint_tank_volume(wm, i; nw = n_1)
Expand Down Expand Up @@ -271,7 +270,6 @@ function build_mn_wf(wm::AbstractWaterModel)

# Add the objective.
objective_wf(wm)
println(wm.model)
end


Expand Down

0 comments on commit aa17241

Please sign in to comment.