From d5b0cae1531341bd2a73ea977d42e05f0b734188 Mon Sep 17 00:00:00 2001 From: Jingru Feng Date: Tue, 13 Feb 2024 13:31:22 +0100 Subject: [PATCH] resolve all comments --- core/src/allocation.jl | 8 +------- core/test/allocation_test.jl | 7 +++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/core/src/allocation.jl b/core/src/allocation.jl index c5731cf61..82018d55e 100644 --- a/core/src/allocation.jl +++ b/core/src/allocation.jl @@ -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 = @@ -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 @@ -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 @@ -1114,8 +1110,6 @@ function allocate!( if JuMP.termination_status(problem) !== JuMP.OPTIMAL (; allocation_network_id) = allocation_model priority = priorities[priority_idx] - println(JuMP.solution_summary(problem)) - println(problem) error( "Allocation of subnetwork $allocation_network_id, priority $priority coudn't find optimal solution.", ) diff --git a/core/test/allocation_test.jl b/core/test/allocation_test.jl index 88ba04592..dd994a453 100644 --- a/core/test/allocation_test.jl +++ b/core/test/allocation_test.jl @@ -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] @@ -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]