Skip to content

Commit

Permalink
Inline docs updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Nov 7, 2024
1 parent 95a3372 commit e27f36a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions core/src/allocation_init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ function allocation_problem(
end

"""
Get the sources within the subnetwork in the order in which they will
be optimized over.
TODO: Get preferred source order from input
"""
function get_sources_in_order(
Expand Down
12 changes: 11 additions & 1 deletion core/src/allocation_optim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ function set_initial_capacities_source!(
return nothing
end

"""
Reduce the capacity of a source by the amount of flow taken from them in the latest optimization.
"""
function reduce_source_capacity!(problem::JuMP.Model, source::AllocationSource)::Nothing
(; edge) = source

Expand Down Expand Up @@ -870,6 +873,10 @@ function set_source_capacity!(
return nothing
end

"""
Solve the allocation problem for a single priority by optimizing for each source
in the subnetwork individually.
"""
function optimize_per_source!(
allocation::Allocation,
allocation_model::AllocationModel,
Expand Down Expand Up @@ -933,6 +940,9 @@ function optimize_per_source!(
return nothing
end

"""
Keep track of how much is taken from or added to the basins in the subnetwork.
"""
function increase_allocateds!(basin::Basin, problem::JuMP.Model)::Nothing
(; allocated) = basin

Expand Down Expand Up @@ -999,7 +1009,7 @@ function optimize_priority!(
end

"""
Set the initial capacities and demands which are recuded by usage.
Set the initial capacities and demands which are reduced by usage.
"""
function set_initial_values!(
allocation_model::AllocationModel,
Expand Down
7 changes: 7 additions & 0 deletions core/src/parameter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ cache(len::Int)::Cache = LazyBufferCache(Returns(len); initializer! = set_zero!)

@enumx AllocationSourceType edge basin main_to_sub user_return buffer

"""
Data structure for a single source within an allocation subnetwork.
edge: The outflow edge of the source
type: The type of source (edge, basin, main_to_sub, user_return, buffer)
capacity: The initial capacity of the source as determined by the physical layer
capacity_reduced: The capacity adjusted by passed optimizations
"""
@kwdef struct AllocationSource
edge::Tuple{NodeID, NodeID}
type::AllocationSourceType.T
Expand Down
3 changes: 0 additions & 3 deletions core/test/allocation_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
db = SQLite.DB(db_path)

p = Ribasim.Parameters(db, cfg)

model = Ribasim.Model(cfg)
(; p) = model.integrator
(; graph, allocation) = p

allocation.mean_input_flows[(NodeID(:FlowBoundary, 1, db), NodeID(:Basin, 2, db))] = 4.5
Expand Down

0 comments on commit e27f36a

Please sign in to comment.