Skip to content

Commit

Permalink
Comments adressed
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Jan 16, 2024
1 parent 2210cf6 commit 26287a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/allocation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function valid_sources(p::Parameters, allocation_network_id::Int)::Bool
else
from_main_network = graph[id_source].allocation_network_id == 1

if !from_source_node & !from_main_network
if !from_source_node && !from_main_network
errors = true
@error "The source node of source edge $edge for subnetwork $allocation_network_id is neither a source node nor is it coming from the main network."
end
Expand Down
7 changes: 7 additions & 0 deletions core/test/allocation_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,27 @@ end
p = Ribasim.Parameters(db, cfg)
(; allocation, graph) = p
(; main_network_connections) = allocation

# Connections from main network to subnetworks
@test isempty(main_network_connections[1])
@test only(main_network_connections[2]) == (NodeID(2), NodeID(11))
@test only(main_network_connections[3]) == (NodeID(6), NodeID(24))
@test only(main_network_connections[4]) == (NodeID(10), NodeID(38))

# main-sub connections are part of main network allocation graph
allocation_edges_main_network = graph[].edge_ids[1]
@test Tuple{NodeID, NodeID}[(2, 11), (6, 24), (10, 38)] allocation_edges_main_network

# Subnetworks interpreted as users require variables and constraints to
# support absolute value expressions in the objective function
allocation_model_main_network = Ribasim.get_allocation_model(p, 1)
problem = allocation_model_main_network.problem
@test problem[:F_abs].axes[1] == NodeID[11, 24, 38]
@test problem[:abs_positive].axes[1] == NodeID[11, 24, 38]
@test problem[:abs_negative].axes[1] == NodeID[11, 24, 38]

# In each subnetwork, the connection from the main network to the subnetwork is
# interpreted as a source
@test Ribasim.get_allocation_model(p, 2).problem[:source].axes[1] ==
Tuple{NodeID, NodeID}[(2, 11)]
@test Ribasim.get_allocation_model(p, 3).problem[:source].axes[1] ==
Expand Down

0 comments on commit 26287a5

Please sign in to comment.