Skip to content

Commit

Permalink
Comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Nov 26, 2024
1 parent b067036 commit 16447e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions core/src/allocation_optim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ function reduce_source_capacity!(problem::JuMP.Model, source::AllocationSource):
JuMP.value(problem[:F_basin_out][edge[1]])
elseif source.type == AllocationSourceType.buffer
JuMP.value(problem[:F_flow_buffer_out][edge[1]])
else
error("Unknown source type")
end

source.capacity_reduced[] = max(source.capacity_reduced[] - used_capacity, 0.0)
Expand Down Expand Up @@ -641,9 +643,8 @@ function save_demands_and_allocations!(
)::Nothing
(; graph, allocation, user_demand, flow_demand, basin) = p
(; record_demand, priorities, mean_realized_flows) = allocation
(; subnetwork_id, problem, sources, flow) = allocation_model
(; subnetwork_id, sources, flow) = allocation_model
node_ids = graph[].node_ids[subnetwork_id]
constraints_outflow = problem[:basin_outflow]

# Loop over nodes in subnetwork
for node_id in node_ids
Expand Down Expand Up @@ -716,7 +717,7 @@ function save_allocation_flows!(
priority::Int32,
optimization_type::OptimizationType.T,
)::Nothing
(; flow, problem, subnetwork_id, capacity) = allocation_model
(; flow, problem, subnetwork_id) = allocation_model
(; allocation, graph) = p
(; record_flow) = allocation
F_basin_in = problem[:F_basin_in]
Expand Down
4 changes: 2 additions & 2 deletions docs/concept/allocation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Allocation is the process of assigning an allocated flow rate to demand nodes in

The allocation problem is solved per subnetwork (and main network) of the Ribasim model. Each subnetwork is used to formulate an optimization problem with the [JuMP](https://jump.dev/JuMP.jl/stable/) package, which is solved using the [HiGHS solver](https://highs.dev/). For more in-depth information see also the example of solving the maximum flow problem with `JuMP.jl` [here](https://jump.dev/JuMP.jl/stable/tutorials/linear/network_flows/#The-max-flow-problem).

Before the optimization for each priority there is a simple step that tries to allocate flow to the `UserDemand` nodes from the basin directly upstream.
Before the optimization for each priority there is a simple step that tries to allocate flow to the UserDemand nodes from the Basin directly upstream.

:::{.callout-note}
within this *Allocation* section the main network is also considered to be a subnetwork.
Expand Down Expand Up @@ -77,7 +77,7 @@ for all $i \in FD_S$. Here $d^{p_{\text{df}}}$ is given by the original flow dem

### Vertical fluxes and local storage

Apart from the source flows denoted by edges, there are other sources of water in the subnetwork, associated with the basins in the subnetwork $B_S = B \cap S$. First, there is the average over the last allocation interval $\Delta t_{\text{alloc}}$ of the vertical fluxes (precipitation, evaporation, infiltration and drainage) for each basin:
Apart from the source flows denoted by edges, there are other sources of water in the subnetwork, associated with the Basins in the subnetwork $B_S = B \cap S$. First, there is the average over the last allocation interval $\Delta t_{\text{alloc}}$ of the vertical fluxes (precipitation, evaporation, infiltration and drainage) for each Basin:
$$
\phi_i(t) = \frac{1}{\Delta t_{\text{alloc}}}\int_{t - \Delta t_{\text{alloc}}}^t \left[Q_{P,i}(t') - Q_{E,i}(t') + Q_{\text{drn},i}(t') - Q_{\text{inf},i}(t') \right] dt', \quad \forall i \in B_S.
$$
Expand Down

0 comments on commit 16447e3

Please sign in to comment.