Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/file-logger
Browse files Browse the repository at this point in the history
# Conflicts:
#	Manifest.toml
  • Loading branch information
deltamarnix committed Dec 15, 2023
2 parents 5fcc874 + 641758f commit 9910205
Show file tree
Hide file tree
Showing 29 changed files with 411 additions and 130 deletions.
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<build-type xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" uuid="5fa3a42d-6a7b-4820-95c1-c550d6648ae7" xsi:noNamespaceSchemaLocation="https://www.jetbrains.com/teamcity/schemas/2021.1/project-config.xsd">
<name>Push release build to S3</name>
<name>Make GitHub Release</name>
<description />
<settings>
<disabled-settings>
<setting-ref ref="RUNNER_2523" />
</disabled-settings>
<parameters />
<parameters>
<param name="env.GITHUB_TOKEN" value="%github_teamcity-deltares_public_access_token%" />
</parameters>
<build-runners>
<runner id="RUNNER_537" name="Push release to S3" type="simpleRunner">
<runner id="RUNNER_2523" name="Push release to GitHub" type="simpleRunner">
<parameters>
<param name="script.content"><![CDATA[#!/usr/bin/env bash
set -euxo pipefail
. /usr/share/Modules/init/bash
module load aws
aws s3 cp ribasim_cli.zip s3://ribasim/teamcity/Ribasim_Ribasim/BuildRibasimCliWindows/%teamcity.build.branch%/ribasim_cli.zip
aws s3 cp ribasim_qgis.zip s3://ribasim/teamcity/Ribasim_Ribasim/BuildRibasimCliWindows/%teamcity.build.branch%/ribasim_qgis.zip
aws s3 cp ribasim*.whl s3://ribasim/teamcity/Ribasim_Ribasim/BuildRibasimCliWindows/%teamcity.build.branch%/]]></param>
<param name="teamcity.step.mode" value="default" />
<param name="use.custom.script" value="true" />
</parameters>
</runner>
<runner id="RUNNER_2523" name="Push release to GitHub" type="simpleRunner">
<parameters>
<param name="script.content"><![CDATA[#!/usr/bin/env bash
set -euxo pipefail
. /usr/share/Modules/init/bash]]></param>
module load github
# Get the name of the currently checked out tag
tag_name=$(git describe --tags --exact-match 2>/dev/null)
# Check if a tag is checked out
if [ -n "$tag_name" ]; then
echo "Currently checked out tag: $tag_name"
# Create a release using gh
gh release create "$tag_name" \
--generate-notes \
ribasim*.whl \
ribasim_cli.zip \
ribasim_qgis.zip
echo "Release created successfully."
else
echo "No tag is currently checked out."
fi]]></param>
<param name="teamcity.step.mode" value="default" />
<param name="use.custom.script" value="true" />
</parameters>
</runner>
</build-runners>
<vcs-settings />
<vcs-settings>
<vcs-entry-ref root-id="Ribasim_Ribasim_Ribasim" />
</vcs-settings>
<requirements>
<equals id="RQ_294" name="teamcity.agent.jvm.os.name" value="Linux" />
</requirements>
<build-triggers>
<build-trigger id="TRIGGER_492" type="buildDependencyTrigger">
<build-trigger id="TRIGGER_637" type="vcsTrigger">
<parameters>
<param name="afterSuccessfulBuildOnly" value="true" />
<param name="branchFilter" value="+:v*" />
<param name="dependsOn" value="BuildRibasimCliWindows" />
<param name="branchFilter" value="+:v20*" />
<param name="enableQueueOptimization" value="true" />
<param name="quietPeriodMode" value="DO_NOT_USE" />
</parameters>
</build-trigger>
</build-triggers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
<param name="script.content"><![CDATA[#!/usr/bin/env bash
set -euxo pipefail
. /usr/share/Modules/init/bash
module load github
gh pr list --repo https://github.com/Deltares/Ribasim.git
module load aws
aws s3 cp ribasim_cli.zip s3://ribasim/teamcity/Ribasim_Ribasim/BuildRibasimCliWindows/latest/ribasim_cli.zip
aws s3 cp ribasim_qgis.zip s3://ribasim/teamcity/Ribasim_Ribasim/BuildRibasimCliWindows/latest/ribasim_qgis.zip
Expand Down
78 changes: 76 additions & 2 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.0-rc2"
manifest_format = "2.0"
project_hash = "a192a3f7817549dd7334c11699bb5edae92a0eb1"
project_hash = "ffe3d5f3606c1f85a4bca07ee2df86a28560d8a2"

[[deps.ADTypes]]
git-tree-sha1 = "332e5d7baeff8497b923b730b994fa480601efc7"
Expand Down Expand Up @@ -48,6 +48,11 @@ weakdeps = ["StaticArrays"]
[deps.Adapt.extensions]
AdaptStaticArraysExt = "StaticArrays"

[[deps.ArgCheck]]
git-tree-sha1 = "a3a402a35a2f7e0b87828ccabbd5ebfbebe356b4"
uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197"
version = "2.3.0"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
version = "1.1.1"
Expand Down Expand Up @@ -256,6 +261,12 @@ git-tree-sha1 = "8cfa272e8bdedfa88b6aefbbca7c19f1befac519"
uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb"
version = "2.3.0"

[[deps.Conda]]
deps = ["Downloads", "JSON", "VersionParsing"]
git-tree-sha1 = "51cab8e982c5b598eea9c8ceaced4b58d9dd37c9"
uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d"
version = "1.10.0"

[[deps.Configurations]]
deps = ["ExproniconLite", "OrderedCollections", "TOML"]
git-tree-sha1 = "4358750bb58a3caefd5f37a4a0c5bfdbbf075252"
Expand Down Expand Up @@ -297,6 +308,12 @@ git-tree-sha1 = "8da84edb865b0b5b0100c0666a9bc9a0b71c553c"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.15.0"

[[deps.DataFrames]]
deps = ["Compat", "DataAPI", "DataStructures", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrecompileTools", "PrettyTables", "Printf", "REPL", "Random", "Reexport", "SentinelArrays", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "04c738083f29f86e62c8afc341f0967d8717bdb8"
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
version = "1.6.1"

[[deps.DataInterpolations]]
deps = ["LinearAlgebra", "PrettyTables", "RecipesBase", "RecursiveArrayTools", "Reexport", "Requires"]
git-tree-sha1 = "97b5c6115165fc9f99908cbdd2ea4c0efda0843e"
Expand Down Expand Up @@ -394,6 +411,11 @@ git-tree-sha1 = "23163d55f885173722d1e4cf0f6110cdbaf7e272"
uuid = "b552c78f-8df3-52c6-915a-8e097449b14b"
version = "1.15.1"

[[deps.DisplayAs]]
git-tree-sha1 = "43c017d5dd3a48d56486055973f443f8a39bb6d9"
uuid = "0b91fe84-8a4c-11e9-3e1d-67c38462b6d6"
version = "0.1.6"

[[deps.Distances]]
deps = ["LinearAlgebra", "Statistics", "StatsAPI"]
git-tree-sha1 = "5225c965635d8c21168e32a12954675e7bea1151"
Expand Down Expand Up @@ -589,6 +611,12 @@ git-tree-sha1 = "eb8fed28f4994600e29beef49744639d985a04b2"
uuid = "3e5b6fbb-0976-4d2c-9146-d79de83f2fb0"
version = "0.1.16"

[[deps.IJulia]]
deps = ["Base64", "Conda", "Dates", "InteractiveUtils", "JSON", "Libdl", "Logging", "Markdown", "MbedTLS", "Pkg", "Printf", "REPL", "Random", "SoftGlobalScope", "Test", "UUIDs", "ZMQ"]
git-tree-sha1 = "47ac8cc196b81001a711f4b2c12c97372338f00c"
uuid = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
version = "1.24.2"

[[deps.IOCapture]]
deps = ["Logging", "Random"]
git-tree-sha1 = "d75853a0bdbfb1ac815478bacd89cd27b550ace6"
Expand Down Expand Up @@ -637,6 +665,11 @@ git-tree-sha1 = "68772f49f54b479fa88ace904f6127f0a3bb2e46"
uuid = "3587e190-3f89-42d0-90ee-14403ec27112"
version = "0.1.12"

[[deps.InvertedIndices]]
git-tree-sha1 = "0dc7b50b8d436461be01300fd8cd45aa0274b038"
uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
version = "1.3.0"

[[deps.IrrationalConstants]]
git-tree-sha1 = "630b497eafcc20001bba38a4651b327dcfc491d2"
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
Expand Down Expand Up @@ -885,12 +918,24 @@ version = "0.1.8"
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[deps.MarkdownTables]]
deps = ["ArgCheck", "DisplayAs", "DocStringExtensions", "Tables"]
git-tree-sha1 = "65dff26519116033543e644fb8cf2e5869469c0b"
uuid = "1862ce21-31c7-451e-824c-f20fa3f90fa2"
version = "1.1.0"

[[deps.MathOptInterface]]
deps = ["BenchmarkTools", "CodecBzip2", "CodecZlib", "DataStructures", "ForwardDiff", "JSON", "LinearAlgebra", "MutableArithmetics", "NaNMath", "OrderedCollections", "PrecompileTools", "Printf", "SparseArrays", "SpecialFunctions", "Test", "Unicode"]
git-tree-sha1 = "70ea2892b8bfffecc0387ba1a6a21192814f120c"
uuid = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
version = "1.22.0"

[[deps.MbedTLS]]
deps = ["Dates", "MbedTLS_jll", "MozillaCACerts_jll", "NetworkOptions", "Random", "Sockets"]
git-tree-sha1 = "c067a280ddc25f196b5e7df3877c6b226d390aaf"
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
version = "1.1.9"

[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
Expand Down Expand Up @@ -1316,6 +1361,12 @@ version = "1.5.0"
[[deps.Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[deps.SoftGlobalScope]]
deps = ["REPL"]
git-tree-sha1 = "986ec2b6162ccb95de5892ed17832f95badf770c"
uuid = "b85f4697-e234-5449-a836-ec8e2f98b302"
version = "1.1.0"

[[deps.SortingAlgorithms]]
deps = ["DataStructures"]
git-tree-sha1 = "5165dfb9fd131cf0c6957a3a7605dede376e7b63"
Expand Down Expand Up @@ -1556,6 +1607,11 @@ git-tree-sha1 = "b182207d4af54ac64cbc71797765068fdeff475d"
uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
version = "0.21.64"

[[deps.VersionParsing]]
git-tree-sha1 = "58d6e80b4ee071f5efd07fda82cb9fbe17200868"
uuid = "81def892-9a0e-5fdd-b105-ffc91e053289"
version = "1.3.0"

[[deps.VertexSafeGraphs]]
deps = ["Graphs"]
git-tree-sha1 = "8351f8d73d7e880bfc042a8b6922684ebeafb35c"
Expand All @@ -1568,6 +1624,18 @@ git-tree-sha1 = "b1be2855ed9ed8eac54e5caff2afcdb442d52c23"
uuid = "ea10d353-3f73-51f8-a26c-33c1cb351aa5"
version = "1.4.2"

[[deps.ZMQ]]
deps = ["FileWatching", "Sockets", "ZeroMQ_jll"]
git-tree-sha1 = "356d2bdcc0bce90aabee1d1c0f6d6f301eda8f77"
uuid = "c2297ded-f4af-51ae-bb23-16f91089e4e1"
version = "1.2.2"

[[deps.ZeroMQ_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "libsodium_jll"]
git-tree-sha1 = "fe5c65a526f066fb3000da137d5785d9649a8a47"
uuid = "8f1865be-045e-5c20-9c9f-bfbfb0764568"
version = "4.3.4+0"

[[deps.Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
Expand All @@ -1586,7 +1654,7 @@ uuid = "3cfb6a46-05f0-43df-bb16-bf763deb14b4"
version = "0.1.0"

[[deps.docs]]
deps = ["Configurations", "Dates", "Documenter", "DocumenterMarkdown", "InteractiveUtils", "JSON3", "Legolas", "Logging", "OrderedCollections", "Ribasim"]
deps = ["Configurations", "DataFrames", "Dates", "Documenter", "DocumenterMarkdown", "IJulia", "InteractiveUtils", "JSON3", "Legolas", "Logging", "MarkdownTables", "OrderedCollections", "Ribasim"]
path = "docs"
uuid = "8daea9ca-fc6c-4731-aa85-717fa0b706bc"
version = "0.1.0"
Expand All @@ -1602,6 +1670,12 @@ path = "build/libribasim"
uuid = "f319f290-633d-4573-adfe-d6d5548b6388"
version = "0.1.0"

[[deps.libsodium_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "848ab3d00fe39d6fbc2a8641048f8f272af1c51e"
uuid = "a9144af2-ca23-56d9-984f-0d03f7b5ccf8"
version = "1.0.20+0"

[[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
Expand Down
19 changes: 19 additions & 0 deletions core/src/allocation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,8 @@ function set_objective_priority!(
ex = sum(problem[:F_abs])
end

demand_max = 0.0

for edge_id in edge_ids
node_id_user = edge_id[2]
if graph[node_id_user].type != :user
Expand All @@ -669,6 +671,7 @@ function set_objective_priority!(

user_idx = findsorted(node_id, node_id_user)
d = demand[user_idx][priority_idx](t)
demand_max = max(demand_max, d)
F_edge = F[edge_id]

if objective_type == :quadratic_absolute
Expand Down Expand Up @@ -707,6 +710,22 @@ function set_objective_priority!(
error("Invalid allocation objective type $objective_type.")
end
end

# Add flow cost
if objective_type == :linear_absolute
cost_per_flow = 0.5 / length(F)
for flow in F
JuMP.add_to_expression!(ex, cost_per_flow * flow)
end
elseif objective_type == :linear_relative
if demand_max > 0.0
cost_per_flow = 0.5 / (demand_max * length(F))
for flow in F
JuMP.add_to_expression!(ex, cost_per_flow * flow)
end
end
end

new_objective = JuMP.@expression(problem, ex)
JuMP.@objective(problem, Min, new_objective)
return nothing
Expand Down
2 changes: 1 addition & 1 deletion core/src/bmi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function create_callbacks(
save_subgrid_level,
saved_subgrid_level;
saveat,
save_start = false,
save_start = true,
)
push!(callbacks, export_cb)
end
Expand Down
2 changes: 1 addition & 1 deletion core/src/config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ end
@option struct Allocation <: TableOption
timestep::Union{Float64, Nothing} = nothing
use_allocation::Bool = false
objective_type::String = "quadratic_relative"
objective_type::String = "linear_absolute"
end

@option @addnodetypes struct Toml <: TableOption
Expand Down
4 changes: 4 additions & 0 deletions core/src/create.jl
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,10 @@ function Parameters(db::DB, config::Config)::Parameters
graph = create_graph(db, config, chunk_sizes)
allocation_models = Vector{AllocationModel}()

if !valid_edges(graph)
error("Invalid edge(s) found.")
end

linear_resistance = LinearResistance(db, config)
manning_resistance = ManningResistance(db, config)
tabulated_rating_curve = TabulatedRatingCurve(db, config)
Expand Down
1 change: 1 addition & 0 deletions core/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function create_graph(db::DB, config::Config, chunk_sizes::Vector{Int})::MetaGra
flow_vertical,
)
graph = @set graph.graph_data = graph_data

return graph
end

Expand Down
2 changes: 1 addition & 1 deletion core/src/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ function valid_edges(graph::MetaGraph)::Bool
if !(type_dst in neighbortypes(type_src))
errors = true
edge_id = graph[id_src, id_dst].id
@error "Cannot connect a $type_src to a $type_dst (edge #$edge_id from node $id_src to $id_dst)."
@error "Cannot connect a $type_src to a $type_dst." edge_id id_src id_dst
end
end
return !errors
Expand Down
Loading

0 comments on commit 9910205

Please sign in to comment.