From 981cb2acc23a9ac9da3fe70bf23d353df8115014 Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Wed, 24 Jan 2024 17:07:33 +0100 Subject: [PATCH] Bugfixing and adding tests --- Manifest.toml | 339 ++++++++++++++++++++++++++++++++++- Project.toml | 1 + core/src/allocation.jl | 67 +++++-- core/src/bmi.jl | 4 + core/test/allocation_test.jl | 33 +++- 5 files changed, 422 insertions(+), 22 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index 326f174c5..bf1c03e9d 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -2,7 +2,7 @@ julia_version = "1.10.0" manifest_format = "2.0" -project_hash = "77dde6fd5d6ca1581c6694925c34d2bb0d69830e" +project_hash = "56e85094b0c50de007783e4beb216b74b2604624" [[deps.ADTypes]] git-tree-sha1 = "41c37aa88889c171f1300ceac1313c06e891d245" @@ -14,6 +14,17 @@ git-tree-sha1 = "574baf8110975760d391c710b6341da1afa48d8c" uuid = "a4c015fc-c6ff-483c-b24f-f7ea428134e9" version = "0.0.1" +[[deps.AbstractFFTs]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "d92ad398961a3ed262d8bf04a1a2b8340f915fef" +uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c" +version = "1.5.0" +weakdeps = ["ChainRulesCore", "Test"] + + [deps.AbstractFFTs.extensions] + AbstractFFTsChainRulesCoreExt = "ChainRulesCore" + AbstractFFTsTestExt = "Test" + [[deps.AbstractTrees]] git-tree-sha1 = "faa260e4cb5aba097a73fab382dd4b5819d8ec8c" uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" @@ -48,6 +59,12 @@ weakdeps = ["StaticArrays"] [deps.Adapt.extensions] AdaptStaticArraysExt = "StaticArrays" +[[deps.ArchGDAL]] +deps = ["CEnum", "ColorTypes", "Dates", "DiskArrays", "Extents", "GDAL", "GeoFormatTypes", "GeoInterface", "GeoInterfaceRecipes", "ImageCore", "Tables"] +git-tree-sha1 = "0ca60eb1896df6ca2f2a856faf287c0dd6f27a32" +uuid = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3" +version = "0.10.1" + [[deps.ArgCheck]] git-tree-sha1 = "a3a402a35a2f7e0b87828ccabbd5ebfbebe356b4" uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197" @@ -107,6 +124,12 @@ git-tree-sha1 = "404265cd8128a2515a81d5eae16de90fdef05101" uuid = "31f734f8-188a-4ce0-8406-c8a06bd891cd" version = "2.3.0" +[[deps.Arrow_jll]] +deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Lz4_jll", "Pkg", "Thrift_jll", "Zlib_jll", "boost_jll", "snappy_jll"] +git-tree-sha1 = "d64cb60c0e6a138fbe5ea65bcbeea47813a9a700" +uuid = "8ce61222-c28f-5041-a97a-c2198fb817bf" +version = "10.0.0+1" + [[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" @@ -142,6 +165,11 @@ git-tree-sha1 = "19a35467a82e236ff51bc17a3a44b69ef35185a2" uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0" version = "1.0.8+0" +[[deps.CEnum]] +git-tree-sha1 = "eb4cb44a499229b3b8426dcfb5dd85333951ff90" +uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" +version = "0.4.2" + [[deps.CPUSummary]] deps = ["CpuId", "IfElse", "PrecompileTools", "Static"] git-tree-sha1 = "601f7e7b3d36f18790e2caf83a882d88e9b71ff1" @@ -194,6 +222,24 @@ git-tree-sha1 = "f69e46bf7b307d15a896b57d5b3321c01cd64923" uuid = "6b39b394-51ab-5f42-8807-6242bab2b4c2" version = "0.8.1" +[[deps.ColorTypes]] +deps = ["FixedPointNumbers", "Random"] +git-tree-sha1 = "eb7f0f8307f71fac7c606984ea5fb2817275d6e4" +uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" +version = "0.11.4" + +[[deps.ColorVectorSpace]] +deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "SpecialFunctions", "Statistics", "TensorCore"] +git-tree-sha1 = "600cc5508d66b78aae350f7accdb58763ac18589" +uuid = "c3611d14-8923-5661-9e6a-0046d554d3a4" +version = "0.9.10" + +[[deps.Colors]] +deps = ["ColorTypes", "FixedPointNumbers", "Reexport"] +git-tree-sha1 = "fc08e5930ee9a4e03f84bfb5211cb54e7769758a" +uuid = "5ae59095-9a9b-59fe-a467-6f913c188581" +version = "0.12.10" + [[deps.CommonSolve]] git-tree-sha1 = "0eee5eb66b1cf62cd6ad1b460238e60e4b09400c" uuid = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2" @@ -411,6 +457,12 @@ git-tree-sha1 = "23163d55f885173722d1e4cf0f6110cdbaf7e272" uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" version = "1.15.1" +[[deps.DiskArrays]] +deps = ["OffsetArrays"] +git-tree-sha1 = "1bfa9de80f35ac63c6c381b2d43c590875896a1f" +uuid = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3" +version = "0.3.22" + [[deps.DisplayAs]] git-tree-sha1 = "43c017d5dd3a48d56486055973f443f8a39bb6d9" uuid = "0b91fe84-8a4c-11e9-3e1d-67c38462b6d6" @@ -468,6 +520,12 @@ weakdeps = ["Adapt"] [deps.EnzymeCore.extensions] AdaptExt = "Adapt" +[[deps.Expat_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "4558ab818dcceaab612d1bb8c19cee87eda2b83c" +uuid = "2e619515-83b5-522b-bb60-26c02a35a201" +version = "2.5.0+0" + [[deps.ExponentialUtilities]] deps = ["Adapt", "ArrayInterface", "GPUArraysCore", "GenericSchur", "LinearAlgebra", "PrecompileTools", "Printf", "SparseArrays", "libblastrampoline_jll"] git-tree-sha1 = "602e4585bcbd5a25bc06f514724593d13ff9e862" @@ -484,6 +542,11 @@ git-tree-sha1 = "fbc390c2f896031db5484bc152a7e805ecdfb01f" uuid = "55351af7-c7e9-48d6-89ff-24e801d99491" version = "0.10.5" +[[deps.Extents]] +git-tree-sha1 = "2140cd04483da90b2da7f99b2add0750504fc39c" +uuid = "411431e0-e8b7-467b-b5e0-f676ba4f2910" +version = "0.1.2" + [[deps.FastBroadcast]] deps = ["ArrayInterface", "LinearAlgebra", "Polyester", "Static", "StaticArrayInterface", "StrideArraysCore"] git-tree-sha1 = "a6e756a880fc419c8b41592010aebe6a5ce09136" @@ -542,6 +605,12 @@ version = "2.22.0" BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +[[deps.FixedPointNumbers]] +deps = ["Statistics"] +git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc" +uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" +version = "0.8.4" + [[deps.ForwardDiff]] deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions"] git-tree-sha1 = "cf0fe81336da9fb90944683b8c41984b08793dad" @@ -573,6 +642,24 @@ version = "0.4.5" deps = ["Random"] uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" +[[deps.GDAL]] +deps = ["CEnum", "GDAL_jll", "NetworkOptions", "PROJ_jll"] +git-tree-sha1 = "869f2652f447faad2d44975f27b14510e0d9d24b" +uuid = "add2ef01-049f-52c4-9ee2-e494f65e021a" +version = "1.7.0" + +[[deps.GDAL_jll]] +deps = ["Arrow_jll", "Artifacts", "Expat_jll", "GEOS_jll", "HDF5_jll", "JLLWrappers", "LibCURL_jll", "LibPQ_jll", "Libdl", "Libtiff_jll", "NetCDF_jll", "OpenJpeg_jll", "PROJ_jll", "SQLite_jll", "Zlib_jll", "Zstd_jll", "libgeotiff_jll"] +git-tree-sha1 = "dcced38655efae6e0da596b40c732f652dc780de" +uuid = "a7073274-a066-55f0-b90d-d619367d196c" +version = "301.700.200+0" + +[[deps.GEOS_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "e143352a8a1b1c7236d05bc9e0982420099c46af" +uuid = "d604d12d-fa86-5845-992e-78dc15976526" +version = "3.12.0+0" + [[deps.GPUArraysCore]] deps = ["Adapt"] git-tree-sha1 = "2d6ca471a6c7b536127afccfa7564b5b39227fe0" @@ -585,17 +672,46 @@ git-tree-sha1 = "fb69b2a645fa69ba5f474af09221b9308b160ce6" uuid = "c145ed77-6b09-5dd9-b285-bf645a82121e" version = "0.5.3" +[[deps.GeoFormatTypes]] +git-tree-sha1 = "59107c179a586f0fe667024c5eb7033e81333271" +uuid = "68eda718-8dee-11e9-39e7-89f7f65f511f" +version = "0.4.2" + +[[deps.GeoInterface]] +deps = ["Extents"] +git-tree-sha1 = "d53480c0793b13341c40199190f92c611aa2e93c" +uuid = "cf35fbd7-0cd7-5166-be24-54bfbe79505f" +version = "1.3.2" + +[[deps.GeoInterfaceRecipes]] +deps = ["GeoInterface", "RecipesBase"] +git-tree-sha1 = "0e26e1737e94de57c858649dc28e482b6c87d341" +uuid = "0329782f-3d07-4b52-b9f6-d3137cf03c7a" +version = "1.0.1" + [[deps.Glob]] git-tree-sha1 = "97285bbd5230dd766e9ef6749b80fc617126d496" uuid = "c27321d9-0574-5035-807b-f59d2c89b15c" version = "1.3.1" +[[deps.Graphics]] +deps = ["Colors", "LinearAlgebra", "NaNMath"] +git-tree-sha1 = "d61890399bc535850c4bf08e4e0d3a7ad0f21cbd" +uuid = "a2bd30eb-e257-5431-a919-1863eab51364" +version = "1.1.2" + [[deps.Graphs]] deps = ["ArnoldiMethod", "Compat", "DataStructures", "Distributed", "Inflate", "LinearAlgebra", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics"] git-tree-sha1 = "899050ace26649433ef1af25bc17a815b3db52b7" uuid = "86223c79-3864-5bf0-83f7-82e725a168b6" version = "1.9.0" +[[deps.HDF5_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LLVMOpenMP_jll", "LazyArtifacts", "LibCURL_jll", "Libdl", "MPICH_jll", "MPIPreferences", "MPItrampoline_jll", "MicrosoftMPI_jll", "OpenMPI_jll", "OpenSSL_jll", "TOML", "Zlib_jll", "libaec_jll"] +git-tree-sha1 = "38c8874692d48d5440d5752d6c74b0c6b0b60739" +uuid = "0234f1f7-429e-5d53-9886-15a909be8d59" +version = "1.14.2+1" + [[deps.HiGHS]] deps = ["HiGHS_jll", "MathOptInterface", "PrecompileTools", "SparseArrays"] git-tree-sha1 = "fce13308f09771b160232903cad57be39a8a0ebb" @@ -614,6 +730,18 @@ git-tree-sha1 = "eb8fed28f4994600e29beef49744639d985a04b2" uuid = "3e5b6fbb-0976-4d2c-9146-d79de83f2fb0" version = "0.1.16" +[[deps.Hwloc_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "ca0f6bf568b4bfc807e7537f081c81e35ceca114" +uuid = "e33a78d0-f292-5ffc-b300-72abe9b543c8" +version = "2.10.0+0" + +[[deps.ICU_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "20b6765a3016e1fca0c9c93c80d50061b94218b7" +uuid = "a51ab1cf-af8e-5615-a023-bc2c838bba6b" +version = "69.1.0+0" + [[deps.IJulia]] deps = ["Base64", "Conda", "Dates", "InteractiveUtils", "JSON", "Libdl", "Logging", "Markdown", "MbedTLS", "Pkg", "Printf", "REPL", "Random", "SoftGlobalScope", "Test", "UUIDs", "ZMQ"] git-tree-sha1 = "47ac8cc196b81001a711f4b2c12c97372338f00c" @@ -631,6 +759,12 @@ git-tree-sha1 = "debdd00ffef04665ccbb3e150747a77560e8fad1" uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173" version = "0.1.1" +[[deps.ImageCore]] +deps = ["AbstractFFTs", "ColorVectorSpace", "Colors", "FixedPointNumbers", "Graphics", "MappedArrays", "MosaicViews", "OffsetArrays", "PaddedViews", "Reexport"] +git-tree-sha1 = "acf614720ef026d38400b3817614c45882d75500" +uuid = "a09fc81d-aa75-5fe9-8630-4744c3626534" +version = "0.9.4" + [[deps.Indexing]] git-tree-sha1 = "ce1566720fd6b19ff3411404d4b977acd4814f9f" uuid = "313cdc1a-70c2-5d6a-ae34-0150d3930a38" @@ -717,6 +851,12 @@ weakdeps = ["ArrowTypes"] [deps.JSON3.extensions] JSON3ArrowExt = ["ArrowTypes"] +[[deps.JpegTurbo_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "6f2675ef130a300a112286de91973805fcc5ffbc" +uuid = "aacddb02-875f-59d6-b918-886e6ef4fbf8" +version = "2.1.91+0" + [[deps.JuMP]] deps = ["LinearAlgebra", "MacroTools", "MathOptInterface", "MutableArithmetics", "OrderedCollections", "PrecompileTools", "Printf", "SparseArrays"] git-tree-sha1 = "adef1dfbafeab635664fb3249b58be8d290ed49d" @@ -741,12 +881,36 @@ git-tree-sha1 = "884c2968c2e8e7e6bf5956af88cb46aa745c854b" uuid = "ef3ab10e-7fda-4108-b977-705223b18434" version = "0.4.1" +[[deps.Kerberos_krb5_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "60274b4ab38e8d1248216fe6b6ace75ae09b0502" +uuid = "b39eb1a6-c29a-53d7-8c32-632cd16f18da" +version = "1.19.3+0" + [[deps.Krylov]] deps = ["LinearAlgebra", "Printf", "SparseArrays"] git-tree-sha1 = "8a6837ec02fe5fb3def1abc907bb802ef11a0729" uuid = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7" version = "0.9.5" +[[deps.LERC_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "bf36f528eec6634efc60d7ec062008f171071434" +uuid = "88015f11-f218-50d7-93a8-a6af411a945d" +version = "3.0.0+1" + +[[deps.LLVMOpenMP_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "f689897ccbe049adb19a065c495e75f372ecd42b" +uuid = "1d63c593-3942-5779-bab2-d838dc0a180e" +version = "15.0.4+0" + +[[deps.LZO_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "e5b909bcf985c5e2605737d2ce278ed791b89be6" +uuid = "dd4b983a-f0e5-5f8d-a1b7-129d4a5fb1ac" +version = "2.10.1+0" + [[deps.LaTeXStrings]] git-tree-sha1 = "50901ebc375ed41dbf8058da26f9de442febbbec" uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" @@ -809,6 +973,12 @@ deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" version = "1.6.4+0" +[[deps.LibPQ_jll]] +deps = ["Artifacts", "ICU_jll", "JLLWrappers", "Kerberos_krb5_jll", "Libdl", "OpenSSL_jll", "Zstd_jll"] +git-tree-sha1 = "09163f837936c8cc44f4691cb41d805eb1769642" +uuid = "08be9ffa-1c94-5ee5-a977-46a84ec9b350" +version = "16.0.0+0" + [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" @@ -817,6 +987,18 @@ version = "1.11.0+1" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +[[deps.Libiconv_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "f9557a255370125b405568f9767d6d195822a175" +uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" +version = "1.17.0+0" + +[[deps.Libtiff_jll]] +deps = ["Artifacts", "JLLWrappers", "JpegTurbo_jll", "LERC_jll", "Libdl", "XZ_jll", "Zlib_jll", "Zstd_jll"] +git-tree-sha1 = "2da088d113af58221c52828a80378e16be7d037a" +uuid = "89763e89-9b03-5906-acba-b20f662cd828" +version = "4.5.1+1" + [[deps.LineSearches]] deps = ["LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "Printf"] git-tree-sha1 = "7bbea35cec17305fc70a0e5b4641477dc0789d9d" @@ -862,6 +1044,12 @@ version = "2.22.1" Pardiso = "46dd5b70-b6fb-5a00-ae2d-e8fea33afaf2" RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd" +[[deps.LittleCMS_jll]] +deps = ["Artifacts", "JLLWrappers", "JpegTurbo_jll", "Libdl", "Libtiff_jll"] +git-tree-sha1 = "08ed30575ffc5651a50d3291beaf94c3e7996e55" +uuid = "d3a379c0-f9a3-5b72-a4c0-6bf4d2e8af0f" +version = "2.15.0+0" + [[deps.LogExpFunctions]] deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"] git-tree-sha1 = "7d6dd4e9212aebaeed356de34ccf262a3cd415aa" @@ -916,6 +1104,24 @@ git-tree-sha1 = "72dc3cf284559eb8f53aa593fe62cb33f83ed0c0" uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7" version = "2024.0.0+0" +[[deps.MPICH_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"] +git-tree-sha1 = "8a5b4d2220377d1ece13f49438d71ad20cf1ba83" +uuid = "7cb0a576-ebde-5e09-9194-50597f1243b4" +version = "4.1.2+0" + +[[deps.MPIPreferences]] +deps = ["Libdl", "Preferences"] +git-tree-sha1 = "8f6af051b9e8ec597fa09d8885ed79fd582f33c9" +uuid = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267" +version = "0.1.10" + +[[deps.MPItrampoline_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"] +git-tree-sha1 = "6979eccb6a9edbbb62681e158443e79ecc0d056a" +uuid = "f1f71cc9-e9ae-5b93-9b94-4fe0e1ad3748" +version = "5.3.1+0" + [[deps.MacroTools]] deps = ["Markdown", "Random"] git-tree-sha1 = "b211c553c199c111d998ecdaf7623d1b89b69f93" @@ -927,6 +1133,11 @@ git-tree-sha1 = "bcaef4fc7a0cfe2cba636d84cda54b5e4e4ca3cd" uuid = "d125e4d3-2237-4719-b19c-fa641b8a4667" version = "0.1.8" +[[deps.MappedArrays]] +git-tree-sha1 = "2dab0221fe2b0f2cb6754eaa743cc266339f527e" +uuid = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900" +version = "0.4.2" + [[deps.Markdown]] deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" @@ -972,6 +1183,12 @@ git-tree-sha1 = "a385fe5aa1384647e55c0c8773457b71e9b08518" uuid = "fa8bd995-216d-47f1-8a91-f3b68fbeb377" version = "0.7.0" +[[deps.MicrosoftMPI_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "b01beb91d20b0d1312a9471a36017b5b339d26de" +uuid = "9237b28f-5490-5468-be7b-bb81f5f5e6cf" +version = "10.1.4+1" + [[deps.Missings]] deps = ["DataAPI"] git-tree-sha1 = "f66bdc5de519e8f8ae43bdc598782d35a25b1272" @@ -987,6 +1204,12 @@ git-tree-sha1 = "4cc0c5a83933648b615c36c2b956d94fda70641e" uuid = "78c3b35d-d492-501b-9361-3d52fe80e533" version = "0.7.7" +[[deps.MosaicViews]] +deps = ["MappedArrays", "OffsetArrays", "PaddedViews", "StackViews"] +git-tree-sha1 = "7b86a5d4d70a9f5cdf2dacb3cbe6d251d1a61dbe" +uuid = "e94cdb99-869f-56ef-bcf0-1ae2bcbe0389" +version = "0.3.4" + [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" version = "2023.1.10" @@ -1020,6 +1243,12 @@ git-tree-sha1 = "0877504529a3e5c3343c6f8b4c0381e57e4387e4" uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" version = "1.0.2" +[[deps.NetCDF_jll]] +deps = ["Artifacts", "Bzip2_jll", "HDF5_jll", "JLLWrappers", "LibCURL_jll", "Libdl", "XML2_jll", "Zlib_jll", "Zstd_jll"] +git-tree-sha1 = "10c612c81eaffdd6b7c28a45a554cdd9d2f40ff1" +uuid = "7243133f-43d8-5620-bbf4-c2c921802cf3" +version = "400.902.208+0" + [[deps.NetworkOptions]] uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" version = "1.2.0" @@ -1068,11 +1297,29 @@ deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" version = "0.3.23+2" +[[deps.OpenJpeg_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Libtiff_jll", "LittleCMS_jll", "libpng_jll"] +git-tree-sha1 = "8d4c87ffaf09dbdd82bcf8c939843e94dd424df2" +uuid = "643b3616-a352-519d-856d-80112ee9badc" +version = "2.5.0+0" + [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" version = "0.8.1+2" +[[deps.OpenMPI_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "PMIx_jll", "TOML", "Zlib_jll", "libevent_jll", "prrte_jll"] +git-tree-sha1 = "694458ae803b684f09c07f90459cb79655fb377d" +uuid = "fe0851c0-eecd-5654-98d4-656369965a5c" +version = "5.0.0+0" + +[[deps.OpenSSL_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "cc6e1927ac521b659af340e0ca45828a3ffc748f" +uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" +version = "3.0.12+0" + [[deps.OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1" @@ -1090,6 +1337,18 @@ git-tree-sha1 = "7c6738f21fba2ccd07b7eaa9d23b437a8a97f1a1" uuid = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" version = "6.69.0" +[[deps.PMIx_jll]] +deps = ["Artifacts", "Hwloc_jll", "JLLWrappers", "Libdl", "Zlib_jll", "libevent_jll"] +git-tree-sha1 = "8b3b19351fa24791f94d7ae85faf845ca1362541" +uuid = "32165bc3-0280-59bc-8c0b-c33b6203efab" +version = "4.2.7+0" + +[[deps.PROJ_jll]] +deps = ["Artifacts", "JLLWrappers", "LibCURL_jll", "Libdl", "Libtiff_jll", "SQLite_jll"] +git-tree-sha1 = "f3e45027ea0f44a2725fbedfdb7ed118d5deec8d" +uuid = "58948b4f-47e0-5654-a9ad-f609743f8632" +version = "901.300.0+0" + [[deps.PackageCompiler]] deps = ["Artifacts", "Glob", "LazyArtifacts", "Libdl", "Pkg", "Printf", "RelocatableFolders", "TOML", "UUIDs", "p7zip_jll"] git-tree-sha1 = "48d4429862157ad5500c4f61444db1b8c32e0a2b" @@ -1102,6 +1361,12 @@ uuid = "65ce6f38-6b18-4e1d-a461-8949797d7930" version = "1.0.2" weakdeps = ["Requires", "TOML"] +[[deps.PaddedViews]] +deps = ["OffsetArrays"] +git-tree-sha1 = "0fac6313486baae819364c52b4f483450a9d793f" +uuid = "5432bcbf-9aad-5242-b902-cca2824c8663" +version = "0.5.12" + [[deps.Parameters]] deps = ["OrderedCollections", "UnPack"] git-tree-sha1 = "34c0e9ad262e5f7fc75b10a9952ca7692cfc5fbe" @@ -1418,6 +1683,12 @@ weakdeps = ["ChainRulesCore"] [deps.SpecialFunctions.extensions] SpecialFunctionsChainRulesCoreExt = "ChainRulesCore" +[[deps.StackViews]] +deps = ["OffsetArrays"] +git-tree-sha1 = "46e589465204cd0c08b4bd97385e4fa79a0c770c" +uuid = "cae243ae-269e-4f55-b966-ac2d0dc13c15" +version = "0.1.1" + [[deps.Static]] deps = ["IfElse"] git-tree-sha1 = "f295e0a1da4ca425659c57441bcb59abb035a4bc" @@ -1528,6 +1799,12 @@ deps = ["ArgTools", "SHA"] uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" version = "1.10.0" +[[deps.TensorCore]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "1feb45f88d133a655e001435632f019a9a1bcdb6" +uuid = "62fd8b95-f654-4bbd-a8a5-9c27f68ccd50" +version = "0.1.1" + [[deps.TerminalLoggers]] deps = ["LeftChildRightSiblingTrees", "Logging", "Markdown", "Printf", "ProgressLogging", "UUIDs"] git-tree-sha1 = "f133fab380933d042f6796eda4e130272ba520ca" @@ -1550,6 +1827,12 @@ git-tree-sha1 = "eda08f7e9818eb53661b3deb74e3159460dfbc27" uuid = "8290d209-cae3-49c0-8002-c8c24d57dab5" version = "0.5.2" +[[deps.Thrift_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "boost_jll"] +git-tree-sha1 = "fd7da49fae680c18aa59f421f0ba468e658a2d7a" +uuid = "e0b8ae26-5307-5830-91fd-398402328850" +version = "0.16.0+0" + [[deps.TimeZones]] deps = ["Artifacts", "Dates", "Downloads", "InlineStrings", "Mocking", "Printf", "Scratch", "TZJData", "Unicode", "p7zip_jll"] git-tree-sha1 = "021f851fb28228de4df641cd128f1ad702cd24df" @@ -1629,6 +1912,18 @@ git-tree-sha1 = "b1be2855ed9ed8eac54e5caff2afcdb442d52c23" uuid = "ea10d353-3f73-51f8-a26c-33c1cb351aa5" version = "1.4.2" +[[deps.XML2_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Zlib_jll"] +git-tree-sha1 = "801cbe47eae69adc50f36c3caec4758d2650741b" +uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a" +version = "2.12.2+0" + +[[deps.XZ_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "522b8414d40c4cbbab8dee346ac3a09f9768f25d" +uuid = "ffd25f8a-64ca-5728-b0f7-c24cf3aae800" +version = "5.4.5+0" + [[deps.ZMQ]] deps = ["FileWatching", "Sockets", "ZeroMQ_jll"] git-tree-sha1 = "356d2bdcc0bce90aabee1d1c0f6d6f301eda8f77" @@ -1652,6 +1947,12 @@ git-tree-sha1 = "49ce682769cd5de6c72dcf1b94ed7790cd08974c" uuid = "3161d3a3-bdf6-5164-811a-617609db77b4" version = "1.5.5+0" +[[deps.boost_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"] +git-tree-sha1 = "7a89efe0137720ca82f99e8daa526d23120d0d37" +uuid = "28df3c45-c428-5900-9ff8-a3135698ca75" +version = "1.76.0+1" + [[deps.create_binaries]] deps = ["Artifacts", "LibGit2", "PackageCompiler", "TOML", "TimeZones"] path = "build/create_binaries" @@ -1664,11 +1965,35 @@ path = "docs" uuid = "8daea9ca-fc6c-4731-aa85-717fa0b706bc" version = "0.1.0" +[[deps.libaec_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "eddd19a8dea6b139ea97bdc8a0e2667d4b661720" +uuid = "477f73a3-ac25-53e9-8cc3-50b2fa2566f0" +version = "1.0.6+1" + [[deps.libblastrampoline_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" version = "5.8.0+1" +[[deps.libevent_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "OpenSSL_jll"] +git-tree-sha1 = "f04ec6d9a186115fb38f858f05c0c4e1b7fc9dcb" +uuid = "1080aeaf-3a6a-583e-a51c-c537b09f60ec" +version = "2.1.13+1" + +[[deps.libgeotiff_jll]] +deps = ["Artifacts", "JLLWrappers", "LibCURL_jll", "Libdl", "Libtiff_jll", "PROJ_jll"] +git-tree-sha1 = "b1df2e0dd651ef0d2e9f4bdf9f2c4b121f79b345" +uuid = "06c338fa-64ff-565b-ac2f-249532af990e" +version = "100.701.100+0" + +[[deps.libpng_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Zlib_jll"] +git-tree-sha1 = "93284c28274d9e75218a416c65ec49d0e0fcdf3d" +uuid = "b53b4c65-9356-5827-b1ea-8c7a1a84506f" +version = "1.6.40+0" + [[deps.libribasim]] deps = ["BasicModelInterface", "Dates", "Ribasim", "TOML"] path = "build/libribasim" @@ -1691,8 +2016,20 @@ deps = ["Artifacts", "Libdl"] uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" version = "17.4.0+2" +[[deps.prrte_jll]] +deps = ["Artifacts", "Hwloc_jll", "JLLWrappers", "Libdl", "PMIx_jll", "libevent_jll"] +git-tree-sha1 = "5adb2d7a18a30280feb66cad6f1a1dfdca2dc7b0" +uuid = "eb928a42-fffd-568d-ab9c-3f5d54fc65b9" +version = "3.0.2+0" + [[deps.ribasim_cli]] deps = ["Dates", "Logging", "Ribasim", "SciMLBase", "TOML", "TerminalLoggers"] path = "build/ribasim_cli" uuid = "e45c999e-e944-4589-a8e6-7d0b7a60140a" version = "0.1.0" + +[[deps.snappy_jll]] +deps = ["Artifacts", "JLLWrappers", "LZO_jll", "Libdl", "Pkg", "Zlib_jll"] +git-tree-sha1 = "985c1da710b0e43f7c52f037441021dfd0e3be14" +uuid = "fe1e1685-f7be-5f59-ac9f-4ca204017dfd" +version = "1.1.9+1" diff --git a/Project.toml b/Project.toml index 2bd113459..c54feef01 100644 --- a/Project.toml +++ b/Project.toml @@ -3,6 +3,7 @@ authors = ["Deltares and contributors "] description = "Meta-project used to share the Manifest of Ribasim and its dependents" [deps] +ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3" Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45" BasicModelInterface = "59605e27-edc0-445a-b93d-c09a3a50b330" Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4" diff --git a/core/src/allocation.jl b/core/src/allocation.jl index 146e5fd7f..5067f7938 100644 --- a/core/src/allocation.jl +++ b/core/src/allocation.jl @@ -445,12 +445,15 @@ function add_constraints_capacity!( p::Parameters, allocation_network_id::Int, )::Nothing - (; graph) = p + (; graph, allocation) = p + (; main_network_connections, allocation_network_ids) = allocation + idx = findsorted(allocation_network_ids, allocation_network_id) + main_network_source_edges = main_network_connections[idx] F = problem[:F] edge_ids = graph[].edge_ids[allocation_network_id] edge_ids_finite_capacity = Tuple{NodeID, NodeID}[] for edge in edge_ids - if !isinf(capacity[edge...]) + if !isinf(capacity[edge...]) && edge ∉ main_network_source_edges push!(edge_ids_finite_capacity, edge) end end @@ -532,13 +535,21 @@ function add_constraints_flow_conservation!( p::Parameters, allocation_network_id::Int, )::Nothing - (; graph) = p + (; graph, allocation) = p + (; main_network_connections, allocation_network_ids) = allocation F = problem[:F] node_ids = graph[].node_ids[allocation_network_id] - node_ids_basin = [node_id for node_id in node_ids if graph[node_id].type == :basin] + node_ids_conservation = + [node_id for node_id in node_ids if graph[node_id].type == :basin] + idx = findsorted(allocation_network_ids, allocation_network_id) + main_network_source_edges = main_network_connections[idx] + for edge in main_network_source_edges + push!(node_ids_conservation, edge[2]) + end + unique!(node_ids_conservation) problem[:flow_conservation] = JuMP.@constraint( problem, - [node_id = node_ids_basin], + [node_id = node_ids_conservation], sum([ F[(node_id, outneighbor_id)] for outneighbor_id in outflow_ids_allocation(graph, node_id) @@ -906,15 +917,20 @@ function assign_allocations!( )::Nothing (; problem, allocation_network_id) = allocation_model (; graph, user, allocation) = p - (; subnetwork_demands) = allocation + (; subnetwork_demands, main_network_connections, allocation_network_ids) = allocation (; record) = user edge_ids = graph[].edge_ids[allocation_network_id] + idx = findsorted(allocation_network_ids, allocation_network_id) + main_network_source_edges = main_network_connections[idx] F = problem[:F] for edge_id in edge_ids + # If this edge is a source edge from the main network to a subnetwork, + # and demands are being collected, add its flow to the demand of this edge if collect_demands && - graph[edge_id...].allocation_network_id_source == allocation_network_id - source_flow = JuMP.value(F[edge_id]) - subnetwork_demands[edge_id][priority_index] += source_flow + graph[edge_id...].allocation_network_id_source == allocation_network_id && + edge_id ∈ main_network_source_edges + allocated = JuMP.value(F[edge_id]) + subnetwork_demands[edge_id][priority_idx] += allocated end user_node_id = edge_id[2] @@ -945,9 +961,10 @@ end """ Adjust the source flows. """ -function adjust_source_flows!( +function adjust_source_capacities!( allocation_model::AllocationModel, p::Parameters, + t::Float64, priority_idx::Int; collect_demands::Bool = false, )::Nothing @@ -1012,17 +1029,23 @@ function adjust_edge_capacities!( p::Parameters, priority_idx::Int, )::Nothing - (; graph) = p + (; graph, allocation) = p (; problem, capacity, allocation_network_id) = allocation_model + (; main_network_connections, allocation_network_ids) = allocation edge_ids = graph[].edge_ids[allocation_network_id] constraints_capacity = problem[:capacity] F = problem[:F] + idx = findsorted(allocation_network_ids, allocation_network_id) + main_network_sources = main_network_connections[idx] + for edge_id in edge_ids c = capacity[edge_id...] - # Edges with infinite capacity have no capacity constraints - if isinf(c) + # These edges have no capacity constraints: + # - With infinite capacity + # - Being a source from the main network to a subnetwork + if isinf(c) || edge_id ∈ main_network_sources continue end @@ -1051,7 +1074,8 @@ function allocate!( collect_demands::Bool = false, )::Nothing (; user, allocation) = p - (; problem) = allocation_model + (; problem, allocation_network_id) = allocation_model + (; allocation_network_ids, main_network_connections) = allocation (; priorities) = user (; subnetwork_demands) = allocation @@ -1060,14 +1084,19 @@ function allocate!( # in the flow_conservation constraints if the net flow is positive. # Solve this as a separate problem before the priorities below + idx = findsorted(allocation_network_ids, allocation_network_id) + main_network_source_edges = main_network_connections[idx] + if collect_demands for main_network_connection in keys(subnetwork_demands) - subnetwork_demands[main_network_connection] .= 0.0 + if main_network_connection in main_network_source_edges + subnetwork_demands[main_network_connection] .= 0.0 + end end end for priority_idx in eachindex(priorities) - adjust_source_flows!(allocation_model, p, priority_idx; collect_demands) + adjust_source_capacities!(allocation_model, p, t, priority_idx; collect_demands) # Subtract the flows used by the allocation of the previous priority from the capacities of the edges # or set edge capacities if priority_idx = 1 @@ -1084,7 +1113,11 @@ function allocate!( JuMP.optimize!(problem) @debug JuMP.solution_summary(problem) if JuMP.termination_status(problem) !== JuMP.OPTIMAL - error("Allocation coudn't find optimal solution.") + (; allocation_network_id) = allocation_model + priority = priorities[priority_index] + error( + "Allocation of subnetwork $allocation_network_id, priority $priority coudn't find optimal solution.", + ) end # Assign the allocations to the users for this priority diff --git a/core/src/bmi.jl b/core/src/bmi.jl index f8b939fab..4fd5b7667 100644 --- a/core/src/bmi.jl +++ b/core/src/bmi.jl @@ -591,12 +591,16 @@ function update_allocation!(integrator)::Nothing (; allocation) = p (; allocation_models) = allocation + # If a main network is present, collect demands of subnetworks if has_main_network(allocation) for allocation_model in allocation_models[2:end] allocate!(p, allocation_model, t; collect_demands = true) end end + # Solve the allocation problems + # If a main network is present this is solved first, + # which provides allocation to the subnetworks for allocation_model in allocation_models allocate!(p, allocation_model, t) end diff --git a/core/test/allocation_test.jl b/core/test/allocation_test.jl index f0ac72763..78aaee3b1 100644 --- a/core/test/allocation_test.jl +++ b/core/test/allocation_test.jl @@ -1,5 +1,4 @@ @testitem "Allocation solve" begin - using PreallocationTools: get_tmp using Ribasim: NodeID import SQLite import JuMP @@ -214,6 +213,7 @@ end @testitem "allocation with main network optimization problem" begin using SQLite using Ribasim: NodeID + using JuMP toml_path = normpath( @__DIR__, @@ -224,12 +224,37 @@ end db_path = Ribasim.input_path(cfg, cfg.database) db = SQLite.DB(db_path) p = Ribasim.Parameters(db, cfg) + close(db) - allocation_model_main_network = p.allocation.allocation_models[1] + (; allocation, user, graph) = p + (; allocation_models, subnetwork_demands) = allocation + t = 0.0 # Collecting demands + for allocation_model in allocation_models[2:end] + Ribasim.allocate!(p, allocation_model, t; collect_demands = true) + end + + @test subnetwork_demands[(NodeID(2), NodeID(11))] ≈ [4.0, 4.0, 0.0] + @test subnetwork_demands[(NodeID(6), NodeID(24))] ≈ [0.001333333333, 0.0, 0.0] + @test subnetwork_demands[(NodeID(10), NodeID(38))] ≈ [0.001, 0.002, 0.002] - # Setting objective function for main network + # Solving for the main network, + # containing subnetworks as users + allocation_model = allocation_models[1] + (; problem) = allocation_model + Ribasim.allocate!(p, allocation_model, t) + + # Main network objective function + objective = JuMP.objective_function(problem) + objective_variables = keys(objective.terms) + F_abs = problem[:F_abs] + @test F_abs[NodeID(11)] ∈ objective_variables + @test F_abs[NodeID(24)] ∈ objective_variables + @test F_abs[NodeID(38)] ∈ objective_variables - # Running model until endtime + # Running full allocation algorithm + # Ribasim.set_flow!(graph, NodeID(1), NodeID(2), 4.5) + # Ribasim.update_allocation!((; p, t)) + # user.allocated end