Skip to content

Commit

Permalink
resolve all comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jingru923 committed Feb 13, 2024
1 parent a2fff21 commit d5b0cae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
8 changes: 1 addition & 7 deletions core/src/allocation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ function add_constraints_flow_conservation!(
p::Parameters,
allocation_network_id::Int,
)::Nothing
(; graph, allocation) = p
(; graph) = p
F = problem[:F]
node_ids = graph[].node_ids[allocation_network_id]
node_ids_conservation =
Expand Down Expand Up @@ -824,14 +824,11 @@ function set_objective_priority!(
ex = sum(problem[:F_abs])
end

demand_max = 0.0

# Terms for subnetworks as users
if is_main_network(allocation_network_id)
for connections_subnetwork in main_network_connections
for connection in connections_subnetwork
d = subnetwork_demands[connection][priority_idx]
demand_max = max(demand_max, d)
add_user_term!(ex, connection, objective_type, d, allocation_model)
end
end
Expand All @@ -853,7 +850,6 @@ function set_objective_priority!(
d = get_user_demand(user, node_id_user, priority_idx)
end

demand_max = max(demand_max, d)
add_user_term!(ex, edge_id, objective_type, d, allocation_model)
end

Expand Down Expand Up @@ -1114,8 +1110,6 @@ function allocate!(
if JuMP.termination_status(problem) !== JuMP.OPTIMAL
(; allocation_network_id) = allocation_model
priority = priorities[priority_idx]

Check warning on line 1112 in core/src/allocation.jl

View check run for this annotation

Codecov / codecov/patch

core/src/allocation.jl#L1112

Added line #L1112 was not covered by tests
println(JuMP.solution_summary(problem))
println(problem)
error(
"Allocation of subnetwork $allocation_network_id, priority $priority coudn't find optimal solution.",
)
Expand Down
7 changes: 3 additions & 4 deletions core/test/allocation_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ end
end

@test subnetwork_demands[(NodeID(:Basin, 2), NodeID(:Pump, 11))] [4.0, 4.0, 0.0]
@test subnetwork_demands[(NodeID(:Basin, 6), NodeID(:Pump, 24))]
[0.001333333333, 0.0, 0.0] broken = true
@test subnetwork_demands[(NodeID(:Basin, 6), NodeID(:Pump, 24))] [0.004, 0.0, 0.0]
@test subnetwork_demands[(NodeID(:Basin, 10), NodeID(:Pump, 38))]
[0.001, 0.002, 0.002]

Expand All @@ -307,9 +306,9 @@ end
Ribasim.update_allocation!((; p, t))

@test subnetwork_allocateds[NodeID(:Basin, 2), NodeID(:Pump, 11)]
[4.0, 0.49766666, 0.0] broken = true
[4.0, 0.49500000, 0.0]
@test subnetwork_allocateds[NodeID(:Basin, 6), NodeID(:Pump, 24)]
[0.00133333333, 0.0, 0.0] broken = true
[0.00399999999, 0.0, 0.0]
@test subnetwork_allocateds[NodeID(:Basin, 10), NodeID(:Pump, 38)] [0.001, 0.0, 0.0]

@test user.allocated[2] [4.0, 0.0, 0.0]
Expand Down

0 comments on commit d5b0cae

Please sign in to comment.