Skip to content

Commit

Permalink
added validation for positive allocation id and for non-negative user…
Browse files Browse the repository at this point in the history
… demand
  • Loading branch information
Jingru923 committed Jan 19, 2024
1 parent b67124c commit 306d29a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/src/create.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,19 @@ const nonconservative_nodetypes =
function generate_allocation_models!(p::Parameters, config::Config)::Nothing
(; graph, allocation_models) = p

errors = false

for allocation_network_id in keys(graph[].node_ids)
if (allocation_network_id <= 0)
@error "Allocation network id $allocation_network_id needs to be a positive integer."
errors = true
end
end

if errors
error("Allocation network initialization failed.")
end

for allocation_network_id in keys(graph[].node_ids)
push!(
allocation_models,
Expand Down Expand Up @@ -695,6 +708,10 @@ function User(db::DB, config::Config)::User
errors = true
end

if !all(all.(>(0), eachcol(interpolations)))
error("Demand should be a non-negative number")
end

if !isnothing(first_row)
min_level_ = coalesce(first_row.min_level, 0.0)
return_factor_ = first_row.return_factor
Expand Down

0 comments on commit 306d29a

Please sign in to comment.