Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using iterator optimally #684

Merged
merged 36 commits into from
Oct 19, 2023
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6239397
Move `get_max_flow_graph` to Ribasim core
SouthEndMusic Oct 4, 2023
c10b95a
Move functions `allocate!` and `plot_graph_max_flow` to Ribasim core
SouthEndMusic Oct 5, 2023
ea8fd24
Add `Subnetwork` struct
SouthEndMusic Oct 5, 2023
e61b54e
Merge branch 'main' into allocation
SouthEndMusic Oct 5, 2023
1903edd
Add start of looped_subnetwork_model testmodel
SouthEndMusic Oct 5, 2023
b4a582a
Compute `node_id_mapping_inverse` only once
SouthEndMusic Oct 5, 2023
e36d325
Towards return flow support in allocation
SouthEndMusic Oct 6, 2023
00d634f
Merge branch 'main' into allocation
SouthEndMusic Oct 6, 2023
328bac1
Merge branch 'main' into allocation
SouthEndMusic Oct 10, 2023
dd325bb
user static sorting in ribasim python
SouthEndMusic Oct 10, 2023
80ae966
Make allocation compatible with multiple demands per user
SouthEndMusic Oct 10, 2023
a5b46d3
Allocation solve with juMP.jl and HiGHS half a POC
SouthEndMusic Oct 11, 2023
0f99889
Introduce AllocationModel struct
SouthEndMusic Oct 11, 2023
32959fc
Start docs page on allocation
SouthEndMusic Oct 11, 2023
41c18b0
Allocation documentation update
SouthEndMusic Oct 13, 2023
488429c
Remove unused packages from project
SouthEndMusic Oct 13, 2023
4884eb1
Update get_allocation_model
SouthEndMusic Oct 13, 2023
76c8db6
Merge branch 'main' into allocation_beyond_max_flow
SouthEndMusic Oct 13, 2023
2f69eda
Small updates
SouthEndMusic Oct 16, 2023
bd4d19e
Merge branch 'main' into allocation_beyond_max_flow
SouthEndMusic Oct 16, 2023
d7c613a
Stop users from using their own return flow
SouthEndMusic Oct 17, 2023
98528a5
Add tests
SouthEndMusic Oct 17, 2023
370b08b
Fixing tests
SouthEndMusic Oct 17, 2023
1b2a7bc
Merge branch 'main' into allocation_beyond_max_flow
SouthEndMusic Oct 17, 2023
548a98a
Fix allocation test
SouthEndMusic Oct 17, 2023
959075f
opt in to extrapolation for rating curves on DataInterpolations 4.4
visr Oct 17, 2023
9d4dea5
Review comments adressed
SouthEndMusic Oct 18, 2023
d64024b
Merge branch 'main' into allocation_beyond_max_flow
SouthEndMusic Oct 18, 2023
ab716a9
Refactor: divide generating JuMP model in subfunctions
SouthEndMusic Oct 18, 2023
5ce6d5e
Refactor: divide performing allocation in subfunctions
SouthEndMusic Oct 19, 2023
3b82615
Refactor: divide constructing allocation graph into subfunctions
SouthEndMusic Oct 19, 2023
c02ee56
Remarks by Julian processed
SouthEndMusic Oct 19, 2023
eb68873
Merge branch 'main' into allocation_beyond_max_flow
SouthEndMusic Oct 19, 2023
ec8b416
Update manifest
SouthEndMusic Oct 19, 2023
fd7e33e
Better iteration
SouthEndMusic Oct 19, 2023
74452cb
Merge branch 'main' into allocation_beyond_max_flow
SouthEndMusic Oct 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions core/src/allocation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,27 +205,26 @@
# The start and end subnetwork nodes of the composite allocgraph
# edge are now nodes that have an equivalent in the allocgraph graph,
# these do not constrain the composite edge capacity
for allocgraph_edge_composite_triplet in
for (subnetwork_node_id_1, subnetwork_node_id_2, subnetwork_node_id_3) in
IterTools.partition(allocgraph_edge_composite, 3, 1)
node_type = lookup[allocgraph_edge_composite_triplet[2]]
node_type = lookup[subnetwork_node_id_2]
node = getfield(p, node_type)

# Find flow constraints
if is_flow_constraining(node)
problem_node_idx =
Ribasim.findsorted(node.node_id, allocgraph_edge_composite_triplet[2])
problem_node_idx = Ribasim.findsorted(node.node_id, subnetwork_node_id_2)
allocgraph_edge_capacity =
min(allocgraph_edge_capacity, node.max_flow_rate[problem_node_idx])
end

# Find flow direction constraints
if is_flow_direction_constraining(node)
subnetwork_inneighbor_node_id =
only(inneighbors(graph_flow, allocgraph_edge_composite_triplet[2]))
only(inneighbors(graph_flow, subnetwork_node_id_2))

if subnetwork_inneighbor_node_id == allocgraph_edge_composite_triplet[1]
if subnetwork_inneighbor_node_id == subnetwork_node_id_1
negative_flow = false
elseif subnetwork_inneighbor_node_id == allocgraph_edge_composite_triplet[3]
elseif subnetwork_inneighbor_node_id == subnetwork_node_id_3

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

View check run for this annotation

Codecov / codecov/patch

core/src/allocation.jl#L227

Added line #L227 was not covered by tests
positive_flow = false
end
end
Expand Down