Allocation: optimize per source#1927
Conversation
|
Note (@visr @gijsber): this PR changes (again) how |
|
Hi @SouthEndMusic , I prefer the new behaviour. The old behaviour did not have my preference but seemed like unavoidable at that time. |
|
Another point of attention: I think I already assumed this before, but I will rely on it now/again: for flow demands only flows in the direction of the edge count, not the other way. I think this is a reasonable assumption and requires less complexity |
|
Maintaining the allocation developer docs seems a bit of a chore, especially with the call stacks in place in combination with inline documentation. @FaridAlavi, I'd be interested to hear what you think the value of this documentation page is from your perspective. |
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 ifpriority == 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 flowallocate_priority!: solve the optimization problemassign_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 theallocation.arrowoutputsave_allocation_flows!: Write allocation flow data to the allocation record (record_flow) for theallocation_flow.arrowoutputWhat has to change when optimizing per source:
AllocationModelstruct and add this toAllocationModelconstructor inallocation_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)allocate_priority!adjust_*functions for use within this loop and make sureflow_priorityis cumulative over all sourcessave_demands_and_allocarions!andsave_allocation_flows!after the loopallocation.qmdinstances)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:
0orInfconstraintsallocation.qmdinstances)