Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allocation: optimize per source (#1927)
# Optimizing per source Fixes #565 What happens now in optimizing per subnetwork per priority (see `optimize_priority!`): - `set_capacities_flow_demand_outflow!`: Set the capacity of outflow edge of a node with a flow demand (Inf if `priority == flow demand priority`, 0 otherwise) - `set_objective_priority!`: Set the equal ratio objective function (a term per demand of the current priority) - `allocate_to_users_from_connected_basin!`: Do allocation without optimization where users are directly connected to basins that can supply flow - `allocate_priority!`: solve the optimization problem - `assign_allocations!`: copy the allocated values to the proper places (either for UserDemand or a subnetwork treated as a UserDemand node) - `save_demands_and_allocations!`: Write allocation result data to the allocation record (`record_demand`) for the `allocation.arrow` output - `save_allocation_flows!`: Write allocation flow data to the allocation record (`record_flow`) for the `allocation_flow.arrow` output What has to change when optimizing per source: - [x] Add vector of sources in subnetwork in desired order to `AllocationModel` struct and add this to `AllocationModel` constructor in `allocation_init.jl`. Types of sources (in order used for now, 'use flow available within subnetwork first'): edge designated as source, basin with level demand, main network to subnetwork, connector node with flow demand (buffer) - [x] Add loop over sources in `allocate_priority!` - [x] Within this loop, set the capacity of the current source as the capacity of this source and the other sources 0, after which the optimization is run - [x] Adapt all `adjust_*` functions for use within this loop and make sure `flow_priority` is cumulative over all sources - [x] Call `save_demands_and_allocarions!` and `save_allocation_flows!` after the loop - [x] Adjust the allocation docs to solving per source (both `allocation.qmd` instances) # Limiting flow demand buffer inflow Fixes #1504 Fixes #1709 (hopefully) A bit of background here: nodes that have a flow demand have a flow buffer, which is implemented so that if the flow that goes from a source to a node with a flow demand has nowhere to go afterwards, it can be stored in the flow buffer to potentially be allocated downstream in subsequent optimizations. Currently the flow into the flow buffer is unconstrained, meaning that for each optimization an arbitrary amount of flow can end up in the buffer. The objective only cares about the flow over the edge into the node with the flow demand, not about the flow into the buffer. Changes: - [x] Remove flow demand outflow `0` or `Inf` constraints - [x] Use buffer inflow instead of flow to node with flow demand in objective function - [x] Flow that goes through the flow demand node but not into the buffer should still count towards what's allocated to the flow demand - [x] Fix tests - [x] Update inline docs - [x] Update online docs (both `allocation.qmd` instances) --------- Co-authored-by: Martijn Visser <[email protected]>
- Loading branch information