From 510fa6c29db7e602a446d39254bcdec9b4c003a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:18:16 +0200 Subject: [PATCH 01/56] Bump prefix-dev/setup-pixi from 0.5.1 to 0.5.2 (#1381) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [prefix-dev/setup-pixi](https://github.com/prefix-dev/setup-pixi) from 0.5.1 to 0.5.2.
Release notes

Sourced from prefix-dev/setup-pixi's releases.

v0.5.2

What's Changed

👷🏻 CI

🐛 Bug fixes

📝 Documentation

⬆️ Dependency updates

🤷🏻 Other changes

New Contributors

Full Changelog: https://github.com/prefix-dev/setup-pixi/compare/v0.5.1...v0.5.2

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=prefix-dev/setup-pixi&package-manager=github_actions&previous-version=0.5.1&new-version=0.5.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/core_testmodels.yml | 2 +- .github/workflows/core_tests.yml | 2 +- .github/workflows/docs.yml | 2 +- .github/workflows/julia_auto_update.yml | 2 +- .github/workflows/mypy.yml | 2 +- .github/workflows/pixi_auto_update.yml | 2 +- .github/workflows/python_codegen.yml | 2 +- .github/workflows/python_tests.yml | 2 +- .github/workflows/qgis.yml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/core_testmodels.yml b/.github/workflows/core_testmodels.yml index 8833f6fe7..2c1328740 100644 --- a/.github/workflows/core_testmodels.yml +++ b/.github/workflows/core_testmodels.yml @@ -33,7 +33,7 @@ jobs: with: cache-compiled: "true" cache-registries: "true" - - uses: prefix-dev/setup-pixi@v0.5.1 + - uses: prefix-dev/setup-pixi@v0.5.2 with: pixi-version: "latest" - name: Prepare pixi diff --git a/.github/workflows/core_tests.yml b/.github/workflows/core_tests.yml index d85f5ab2e..e687075e7 100644 --- a/.github/workflows/core_tests.yml +++ b/.github/workflows/core_tests.yml @@ -33,7 +33,7 @@ jobs: with: cache-compiled: "true" cache-registries: "true" - - uses: prefix-dev/setup-pixi@v0.5.1 + - uses: prefix-dev/setup-pixi@v0.5.2 with: pixi-version: "latest" - name: Prepare pixi diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c0a59462e..8864587b8 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -24,7 +24,7 @@ jobs: with: cache-compiled: "true" cache-registries: "true" - - uses: prefix-dev/setup-pixi@v0.5.1 + - uses: prefix-dev/setup-pixi@v0.5.2 with: pixi-version: "latest" - name: Prepare pixi diff --git a/.github/workflows/julia_auto_update.yml b/.github/workflows/julia_auto_update.yml index f0011c3c8..dd0050fef 100644 --- a/.github/workflows/julia_auto_update.yml +++ b/.github/workflows/julia_auto_update.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v4 with: ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} - - uses: prefix-dev/setup-pixi@v0.5.1 + - uses: prefix-dev/setup-pixi@v0.5.2 with: pixi-version: "latest" - name: Update Julia manifest file diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 44bf1d363..dca14991d 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -16,7 +16,7 @@ jobs: continue-on-error: true steps: - uses: actions/checkout@v4 - - uses: prefix-dev/setup-pixi@v0.5.1 + - uses: prefix-dev/setup-pixi@v0.5.2 with: pixi-version: "latest" - name: Prepare pixi diff --git a/.github/workflows/pixi_auto_update.yml b/.github/workflows/pixi_auto_update.yml index 0b9096599..39a34c520 100644 --- a/.github/workflows/pixi_auto_update.yml +++ b/.github/workflows/pixi_auto_update.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v4 with: ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} - - uses: prefix-dev/setup-pixi@v0.5.1 + - uses: prefix-dev/setup-pixi@v0.5.2 with: pixi-version: "latest" cache: false diff --git a/.github/workflows/python_codegen.yml b/.github/workflows/python_codegen.yml index 6f027ca04..0062e307f 100644 --- a/.github/workflows/python_codegen.yml +++ b/.github/workflows/python_codegen.yml @@ -16,7 +16,7 @@ jobs: continue-on-error: true steps: - uses: actions/checkout@v4 - - uses: prefix-dev/setup-pixi@v0.5.1 + - uses: prefix-dev/setup-pixi@v0.5.2 with: pixi-version: "latest" - name: Prepare pixi diff --git a/.github/workflows/python_tests.yml b/.github/workflows/python_tests.yml index 9770ccc46..485e2e834 100644 --- a/.github/workflows/python_tests.yml +++ b/.github/workflows/python_tests.yml @@ -26,7 +26,7 @@ jobs: - py310 steps: - uses: actions/checkout@v4 - - uses: prefix-dev/setup-pixi@v0.5.1 + - uses: prefix-dev/setup-pixi@v0.5.2 with: pixi-version: "latest" - name: Prepare pixi diff --git a/.github/workflows/qgis.yml b/.github/workflows/qgis.yml index 6bc4d97fb..70429ed7e 100644 --- a/.github/workflows/qgis.yml +++ b/.github/workflows/qgis.yml @@ -22,7 +22,7 @@ jobs: - windows-latest steps: - uses: actions/checkout@v4 - - uses: prefix-dev/setup-pixi@v0.5.1 + - uses: prefix-dev/setup-pixi@v0.5.2 with: pixi-version: "latest" - name: Prepare pixi From 799a2d58908635af2a0fe9db8c536891f502a03a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:19:14 +0200 Subject: [PATCH 02/56] Bump peaceiris/actions-gh-pages from 3 to 4 (#1382) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages) from 3 to 4.
Release notes

Sourced from peaceiris/actions-gh-pages's releases.

actions-github-pages v4.0.0

See CHANGELOG.md for more details.

actions-github-pages v3.9.3

See CHANGELOG.md for more details.

actions-github-pages v3.9.2

See CHANGELOG.md for more details.

actions-github-pages v3.9.1

  • update deps

See CHANGELOG.md for more details.

actions-github-pages v3.9.0

  • deps: bump node12 to node16
  • deps: bump @​actions/core from 1.6.0 to 1.10.0

See CHANGELOG.md for more details.

actions-github-pages v3.8.0

See CHANGELOG.md for more details.

actions-github-pages v3.7.3

See CHANGELOG.md for more details.

actions-github-pages v3.7.2

See CHANGELOG.md for more details.

actions-github-pages v3.7.1

See CHANGELOG.md for more details.

actions-github-pages v3.7.0

See CHANGELOG.md for more details.

Overviews:

  • Add .nojekyll file by default for all branches (#438) (079d483), closes #438
  • Add destination_dir option (#403) (f30118c), closes #403 #324 #390
  • Add exclude_assets option (#416) (0f5c65e), closes #416 #163
  • exclude_assets supports glob patterns (#417) (6f45501), closes #417 #163

actions-github-pages v3.6.4

See CHANGELOG.md for more details.

actions-github-pages v3.6.3

See CHANGELOG.md for more details.

actions-github-pages v3.6.2

See CHANGELOG.md for more details.

... (truncated)

Changelog

Sourced from peaceiris/actions-gh-pages's changelog.

3.9.3 (2023-03-30)

docs

fix

3.9.2 (2023-01-17)

chore

ci

deps

3.9.1 (2023-01-05)

chore

ci

  • add Renovate config (#802) (072d16c), closes #802
  • bump actions/dependency-review-action from 2 to 3 (#799) (e3b45f2), closes #799
  • bump peaceiris/actions-github-app-token from 1.1.4 to 1.1.5 (#798) (a5f971f), closes #798
  • bump peaceiris/actions-mdbook from 1.1.14 to 1.2.0 (#793) (9af6a68), closes #793
  • bump peaceiris/workflows from 0.17.1 to 0.17.2 (#794) (087a759), closes #794

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=peaceiris/actions-gh-pages&package-manager=github_actions&previous-version=3&new-version=4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 8864587b8..ae317c17f 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -41,7 +41,7 @@ jobs: - name: Publish Quarto Project if: github.ref == 'refs/heads/main' - uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./docs/_site From 0574470c910f9e26e8e009a49911a7c964f4198b Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Mon, 15 Apr 2024 15:00:51 +0200 Subject: [PATCH 03/56] Revert "Equal ratio allocation objective (#1366)" (#1385) This reverts commit 19139f1c8cc7c539e7f18ea329b14f8226ceb79d, https://github.com/Deltares/Ribasim/pull/1366. It introduced some non-deterministic failures, that would be best to investigate outside of main. See https://github.com/Deltares/Ribasim/issues/1383. To land this again we should also include https://github.com/Deltares/Ribasim/pull/1384, which addressed one of the failures. --- core/src/allocation_init.jl | 158 +++++++++++++++++- core/src/allocation_optim.jl | 105 ++++++++---- core/test/allocation_test.jl | 115 +++++-------- docs/core/allocation.qmd | 12 +- .../ribasim_testmodels/__init__.py | 2 - .../ribasim_testmodels/allocation.py | 97 ----------- 6 files changed, 281 insertions(+), 208 deletions(-) diff --git a/core/src/allocation_init.jl b/core/src/allocation_init.jl index 0f16cb2b4..d17ffc094 100644 --- a/core/src/allocation_init.jl +++ b/core/src/allocation_init.jl @@ -5,8 +5,7 @@ function find_subnetwork_connections!(p::Parameters)::Nothing (; subnetwork_demands, subnetwork_allocateds) = allocation for node_id in graph[].node_ids[1] for outflow_id in outflow_ids(graph, node_id) - if (graph[outflow_id].allocation_network_id != 1) | - (graph[node_id, outflow_id].allocation_network_id_source == 1) + if graph[outflow_id].allocation_network_id != 1 main_network_source_edges = get_main_network_connections(p, graph[outflow_id].allocation_network_id) edge = (node_id, outflow_id) @@ -406,6 +405,55 @@ function add_variables_flow_buffer!( return nothing end +""" +Certain allocation distribution types use absolute values in the objective function. +Since most optimization packages do not support the absolute value function directly, +New variables are introduced that act as the absolute value of an expression by +posing the appropriate constraints. +""" +function add_variables_absolute_value!( + problem::JuMP.Model, + p::Parameters, + allocation_network_id::Int32, +)::Nothing + (; graph, allocation) = p + (; main_network_connections) = allocation + + node_ids = graph[].node_ids[allocation_network_id] + node_ids_user_demand = NodeID[] + node_ids_level_demand = NodeID[] + node_ids_flow_demand = NodeID[] + + for node_id in node_ids + type = node_id.type + if type == NodeType.UserDemand + push!(node_ids_user_demand, node_id) + elseif type == NodeType.Basin + push!(node_ids_level_demand, node_id) + elseif has_external_demand(graph, node_id, :flow_demand)[1] + push!(node_ids_flow_demand, node_id) + end + end + + # For the main network, connections to subnetworks are treated as UserDemands + if is_main_network(allocation_network_id) + for connections_subnetwork in main_network_connections + for connection in connections_subnetwork + push!(node_ids_user_demand, connection[2]) + end + end + end + + problem[:F_abs_user_demand] = + JuMP.@variable(problem, F_abs_user_demand[node_id = node_ids_user_demand]) + problem[:F_abs_level_demand] = + JuMP.@variable(problem, F_abs_level_demand[node_id = node_ids_level_demand]) + problem[:F_abs_flow_demand] = + JuMP.@variable(problem, F_abs_flow_demand[node_id = node_ids_flow_demand]) + + return nothing +end + """ Add the flow capacity constraints to the allocation problem. Only finite capacities get a constraint. @@ -420,6 +468,7 @@ function add_constraints_capacity!( p::Parameters, allocation_network_id::Int32, )::Nothing + (; graph) = p main_network_source_edges = get_main_network_connections(p, allocation_network_id) F = problem[:F] edge_ids_finite_capacity = Tuple{NodeID, NodeID}[] @@ -643,6 +692,106 @@ function add_constraints_conservation_basin!( return nothing end +""" +Minimizing |expr| can be achieved by introducing a new variable expr_abs +and posing the following constraints: +expr_abs >= expr +expr_abs >= -expr +""" +function add_constraints_absolute_value!( + problem::JuMP.Model, + flow_per_node::Dict{NodeID, JuMP.VariableRef}, + F_abs::JuMP.Containers.DenseAxisArray, + variable_type::String, +)::Nothing + # Example demand + d = 2.0 + + node_ids = only(F_abs.axes) + + # These constraints together make sure that F_abs_* acts as the absolute + # value F_abs_* = |x| where x = F-d (here for example d = 2) + base_name = "abs_positive_$variable_type" + problem[Symbol(base_name)] = JuMP.@constraint( + problem, + [node_id = node_ids], + F_abs[node_id] >= (flow_per_node[node_id] - d), + base_name = base_name + ) + base_name = "abs_negative_$variable_type" + problem[Symbol(base_name)] = JuMP.@constraint( + problem, + [node_id = node_ids], + F_abs[node_id] >= -(flow_per_node[node_id] - d), + base_name = base_name + ) + + return nothing +end + +""" +Add constraints so that variables F_abs_user_demand act as the +absolute value of the expression comparing flow to a UserDemand to its demand. +""" +function add_constraints_absolute_value_user_demand!( + problem::JuMP.Model, + p::Parameters, +)::Nothing + (; graph) = p + + F = problem[:F] + F_abs_user_demand = problem[:F_abs_user_demand] + + flow_per_node = Dict( + node_id => F[(only(inflow_ids_allocation(graph, node_id)), node_id)] for + node_id in only(F_abs_user_demand.axes) + ) + + add_constraints_absolute_value!( + problem, + flow_per_node, + F_abs_user_demand, + "user_demand", + ) + + return nothing +end + +""" +Add constraints so that variables F_abs_level_demand act as the +absolute value of the expression comparing flow to a basin to its demand. +""" +function add_constraints_absolute_value_level_demand!(problem::JuMP.Model)::Nothing + F_basin_in = problem[:F_basin_in] + F_abs_level_demand = problem[:F_abs_level_demand] + flow_per_node = + Dict(node_id => F_basin_in[node_id] for node_id in only(F_abs_level_demand.axes)) + + add_constraints_absolute_value!(problem, flow_per_node, F_abs_level_demand, "basin") + + return nothing +end + +""" +Add constraints so that variables F_abs_flow_demand act as the +absolute value of the expression comparing flow to a flow buffer to the flow demand. +""" +function add_constraints_absolute_value_flow_demand!(problem::JuMP.Model)::Nothing + F_flow_buffer_in = problem[:F_flow_buffer_in] + F_abs_flow_demand = problem[:F_abs_flow_demand] + flow_per_node = Dict( + node_id => F_flow_buffer_in[node_id] for node_id in only(F_abs_flow_demand.axes) + ) + + add_constraints_absolute_value!( + problem, + flow_per_node, + F_abs_flow_demand, + "flow_demand", + ) + return nothing +end + """ Add the fractional flow constraints to the allocation problem. The constraint indices are allocation edges over a fractional flow node. @@ -772,6 +921,7 @@ function allocation_problem( # Add variables to problem add_variables_flow!(problem, p, allocation_network_id) add_variables_basin!(problem, p, allocation_network_id) + add_variables_absolute_value!(problem, p, allocation_network_id) add_variables_flow_buffer!(problem, p, allocation_network_id) # Add constraints to problem @@ -779,6 +929,10 @@ function allocation_problem( add_constraints_conservation_flow_demand!(problem, p, allocation_network_id) add_constraints_conservation_subnetwork!(problem, p, allocation_network_id) + add_constraints_absolute_value_user_demand!(problem, p) + add_constraints_absolute_value_flow_demand!(problem) + add_constraints_absolute_value_level_demand!(problem) + add_constraints_capacity!(problem, capacity, p, allocation_network_id) add_constraints_source!(problem, p, allocation_network_id) add_constraints_user_source!(problem, p, allocation_network_id) diff --git a/core/src/allocation_optim.jl b/core/src/allocation_optim.jl index 9172c13b2..b42393f75 100644 --- a/core/src/allocation_optim.jl +++ b/core/src/allocation_optim.jl @@ -1,26 +1,67 @@ @enumx OptimizationType internal_sources collect_demands allocate """ -Add an objective term `demand * (1 - flow/demand)^2`. If the absolute -value of the demand is very small, this would lead to huge coefficients, -so in that case a term of the form (flow - demand)^2 is used. +Add a term to the objective function given by the objective type, +depending in the provided flow variable and the associated demand. """ function add_objective_term!( - ex::JuMP.QuadExpr, demand::Float64, - F::JuMP.VariableRef, + constraint_abs_positive::Union{JuMP.ConstraintRef, Nothing} = nothing, + constraint_abs_negative::Union{JuMP.ConstraintRef, Nothing} = nothing, )::Nothing - if abs(demand) < 1e-5 - # Error term (F - d)^2 = F² - 2dF + d² - JuMP.add_to_expression!(ex, 1.0, F, F) - JuMP.add_to_expression!(ex, -2.0 * demand, F) - JuMP.add_to_expression!(ex, demand^2) - else - # Error term d*(1 - F/d)^2 = F²/d - 2F + d - JuMP.add_to_expression!(ex, 1.0 / demand, F, F) - JuMP.add_to_expression!(ex, -2.0, F) - JuMP.add_to_expression!(ex, demand) + # Objective function ∑ |F - d| + JuMP.set_normalized_rhs(constraint_abs_positive, -demand) + JuMP.set_normalized_rhs(constraint_abs_negative, demand) + return nothing +end + +""" +Add a term to the expression of the objective function corresponding to +the demand of a UserDemand. +""" +function add_user_demand_term!( + edge::Tuple{NodeID, NodeID}, + demand::Float64, + problem::JuMP.Model, +)::Nothing + node_id_user_demand = edge[2] + + constraint_abs_positive = problem[:abs_positive_user_demand][node_id_user_demand] + constraint_abs_negative = problem[:abs_negative_user_demand][node_id_user_demand] + + add_objective_term!(demand, constraint_abs_positive, constraint_abs_negative) +end + +""" +Add a term to the expression of the objective function corresponding to +the demand of a node with a a flow demand. +""" +function add_flow_demand_term!( + edge::Tuple{NodeID, NodeID}, + demand::Float64, + problem::JuMP.Model, +)::Nothing + node_id_flow_demand = edge[2] + + constraint_abs_positive = problem[:abs_positive_flow_demand][node_id_flow_demand] + constraint_abs_negative = problem[:abs_negative_flow_demand][node_id_flow_demand] + + add_objective_term!(demand, constraint_abs_positive, constraint_abs_negative) +end + +""" +Add a term to the expression of the objective function corresponding to +the demand of a basin. +""" +function add_basin_term!(problem::JuMP.Model, demand::Float64, node_id::NodeID)::Nothing + constraint_abs_positive = get(problem[:abs_positive_basin], node_id) + constraint_abs_negative = get(problem[:abs_negative_basin], node_id) + + if isnothing(constraint_abs_positive) + return end + + add_objective_term!(demand, constraint_abs_positive, constraint_abs_negative) return nothing end @@ -40,17 +81,29 @@ function set_objective_priority!( (; node_id, demand_reduced) = user_demand (; main_network_connections, subnetwork_demands) = allocation edge_ids = graph[].edge_ids[allocation_network_id] - F = problem[:F] - ex = JuMP.QuadExpr() + ex = JuMP.AffExpr() + + F_abs_user_demand = problem[:F_abs_user_demand] + F_abs_level_demand = problem[:F_abs_level_demand] + F_abs_flow_demand = problem[:F_abs_flow_demand] + + if !isempty(only(F_abs_user_demand.axes)) + ex += sum(F_abs_user_demand) + end + if !isempty(only(F_abs_level_demand.axes)) + ex += sum(F_abs_level_demand) + end + if !isempty(only(F_abs_flow_demand.axes)) + ex += sum(F_abs_flow_demand) + end # Terms for subnetworks as UserDemand if is_main_network(allocation_network_id) - for connections_subnetwork in main_network_connections[2:end] + for connections_subnetwork in main_network_connections for connection in connections_subnetwork d = subnetwork_demands[connection][priority_idx] - F_inlet = F[connection] - add_objective_term!(ex, d, F_inlet) + add_user_demand_term!(connection, d, problem) end end end @@ -63,8 +116,7 @@ function set_objective_priority!( # UserDemand user_demand_idx = findsorted(node_id, to_node_id) d = demand_reduced[user_demand_idx, priority_idx] - F_ud = F[edge_id] - add_objective_term!(ex, d, F_ud) + add_user_demand_term!(edge_id, d, problem) else has_demand, demand_node_id = has_external_demand(graph, to_node_id, :flow_demand) @@ -75,9 +127,8 @@ function set_objective_priority!( priority_idx == flow_priority_idx ? flow_demand.demand[findsorted(flow_demand.node_id, demand_node_id)] : 0.0 - F_fd = F[edge_id] - add_objective_term!(ex, d, F_fd) + add_flow_demand_term!(edge_id, d, problem) end end end @@ -91,8 +142,7 @@ function set_objective_priority!( get_basin_demand(allocation_model, u, p, t, node_id) : 0.0 _, basin_idx = id_index(basin.node_id, node_id) basin.demand[basin_idx] = d - F_ld = F_basin_in[node_id] - add_objective_term!(ex, d, F_ld) + add_basin_term!(problem, d, node_id) end new_objective = JuMP.@expression(problem, ex) @@ -209,8 +259,7 @@ function set_initial_capacities_source!( for edge_id in edge_ids if graph[edge_id...].allocation_network_id_source == allocation_network_id # If it is a source edge for this allocation problem - if (edge_id ∉ main_network_source_edges) | - is_main_network(allocation_network_id) + if edge_id ∉ main_network_source_edges # Reset the source to the current flow from the physical layer. source_capacity = get_flow(graph, edge_id..., 0) JuMP.set_normalized_rhs( diff --git a/core/test/allocation_test.jl b/core/test/allocation_test.jl index 262c4e736..d804d8020 100644 --- a/core/test/allocation_test.jl +++ b/core/test/allocation_test.jl @@ -44,7 +44,7 @@ @test allocated[3, :] ≈ [0.0, 2.0] end -@testitem "Allocation objective" begin +@testitem "Allocation objective: linear absolute" begin using DataFrames: DataFrame using SciMLBase: successful_retcode using Ribasim: NodeID @@ -57,23 +57,15 @@ end config = Ribasim.Config(toml_path) model = Ribasim.run(config) @test successful_retcode(model) - (; p) = model.integrator - (; user_demand) = p - problem = p.allocation.allocation_models[1].problem + problem = model.integrator.p.allocation.allocation_models[1].problem objective = JuMP.objective_function(problem) - @test objective isa JuMP.QuadExpr # Quadratic expression + @test objective isa JuMP.AffExpr # Affine expression + @test :F_abs_user_demand in keys(problem.obj_dict) F = problem[:F] + F_abs_user_demand = problem[:F_abs_user_demand] - to_user_5 = F[(NodeID(:Basin, 4), NodeID(:UserDemand, 5))] - to_user_6 = F[(NodeID(:Basin, 4), NodeID(:UserDemand, 6))] - - @test objective.aff.constant ≈ sum(user_demand.demand) - @test objective.aff.terms[to_user_5] ≈ -2.0 - @test objective.aff.terms[to_user_6] ≈ -2.0 - @test objective.terms[JuMP.UnorderedPair(to_user_5, to_user_5)] ≈ - 1 / user_demand.demand[1] - @test objective.terms[JuMP.UnorderedPair(to_user_6, to_user_6)] ≈ - 1 / user_demand.demand[2] + @test objective.terms[F_abs_user_demand[NodeID(:UserDemand, 5)]] == 1.0 + @test objective.terms[F_abs_user_demand[NodeID(:UserDemand, 6)]] == 1.0 end @testitem "Allocation with controlled fractional flow" begin @@ -168,7 +160,7 @@ end @test Ribasim.is_main_network(first(allocation_network_ids)) # Connections from main network to subnetworks - @test only(main_network_connections[1]) == (NodeID(:FlowBoundary, 1), NodeID(:Basin, 2)) + @test isempty(main_network_connections[1]) @test only(main_network_connections[2]) == (NodeID(:Basin, 2), NodeID(:Pump, 11)) @test only(main_network_connections[3]) == (NodeID(:Basin, 6), NodeID(:Pump, 24)) @test only(main_network_connections[4]) == (NodeID(:Basin, 10), NodeID(:Pump, 38)) @@ -181,6 +173,14 @@ end (NodeID(:Basin, 10), NodeID(:Pump, 38)), ] ⊆ allocation_edges_main_network + # Subnetworks interpreted as user_demands require variables and constraints to + # support absolute value expressions in the objective function + allocation_model_main_network = Ribasim.get_allocation_model(p, Int32(1)) + problem = allocation_model_main_network.problem + @test problem[:F_abs_user_demand].axes[1] == NodeID.(:Pump, [11, 24, 38]) + @test problem[:abs_positive_user_demand].axes[1] == NodeID.(:Pump, [11, 24, 38]) + @test problem[:abs_negative_user_demand].axes[1] == NodeID.(:Pump, [11, 24, 38]) + # In each subnetwork, the connection from the main network to the subnetwork is # interpreted as a source @test Ribasim.get_allocation_model(p, Int32(3)).problem[:source].axes[1] == @@ -223,40 +223,33 @@ end # See the difference between these values here and in # "subnetworks_with_sources" - @test subnetwork_demands[(NodeID(:Basin, 2), NodeID(:Pump, 11))] ≈ [4.0, 4.0, 0.0] atol = - 1e-4 + @test subnetwork_demands[(NodeID(:Basin, 2), NodeID(:Pump, 11))] ≈ [4.0, 4.0, 0.0] @test subnetwork_demands[(NodeID(:Basin, 6), NodeID(:Pump, 24))] ≈ [0.004, 0.0, 0.0] - @test subnetwork_demands[(NodeID(:Basin, 10), NodeID(:Pump, 38))][1:2] ≈ [0.001, 0.002] rtol = - 1e-4 + @test subnetwork_demands[(NodeID(:Basin, 10), NodeID(:Pump, 38))][1:2] ≈ [0.001, 0.002] # Solving for the main network, containing subnetworks as UserDemands allocation_model = allocation_models[1] (; problem) = allocation_model - Ribasim.allocate_priority!(allocation_model, u, p, t, 1, OptimizationType.allocate) + Ribasim.allocate!(p, allocation_model, t, u, OptimizationType.allocate) # Main network objective function - F = problem[:F] objective = JuMP.objective_function(problem) - objective_edges = keys(objective.terms) - F_1 = F[(NodeID(:Basin, 2), NodeID(:Pump, 11))] - F_2 = F[(NodeID(:Basin, 6), NodeID(:Pump, 24))] - F_3 = F[(NodeID(:Basin, 10), NodeID(:Pump, 38))] - @test JuMP.UnorderedPair(F_1, F_1) ∈ objective_edges - @test JuMP.UnorderedPair(F_2, F_2) ∈ objective_edges - @test JuMP.UnorderedPair(F_3, F_3) ∈ objective_edges + objective_variables = keys(objective.terms) + F_abs_user_demand = problem[:F_abs_user_demand] + @test F_abs_user_demand[NodeID(:Pump, 11)] ∈ objective_variables + @test F_abs_user_demand[NodeID(:Pump, 24)] ∈ objective_variables + @test F_abs_user_demand[NodeID(:Pump, 38)] ∈ objective_variables # Running full allocation algorithm Ribasim.set_flow!(graph, NodeID(:FlowBoundary, 1), NodeID(:Basin, 2), 4.5) u = ComponentVector(; storage = zeros(length(p.basin.node_id))) Ribasim.update_allocation!((; p, t, u)) - @test subnetwork_allocateds[NodeID(:Basin, 2), NodeID(:Pump, 11)] ≈ [4.0, 0.4947, 0.0] atol = - 1e-4 - @test subnetwork_allocateds[NodeID(:Basin, 6), NodeID(:Pump, 24)] ≈ [0.004, 0.0, 0.0] rtol = - 1e-3 - - @test subnetwork_allocateds[NodeID(:Basin, 10), NodeID(:Pump, 38)] ≈ - [0.001, 2.473e-4, 0.0] rtol = 1e-3 + @test subnetwork_allocateds[NodeID(:Basin, 2), NodeID(:Pump, 11)] ≈ + [4.0, 0.49500000, 0.0] + @test subnetwork_allocateds[NodeID(:Basin, 6), NodeID(:Pump, 24)] ≈ + [0.00399999999, 0.0, 0.0] + @test subnetwork_allocateds[NodeID(:Basin, 10), NodeID(:Pump, 38)] ≈ [0.001, 0.0, 0.0] # Test for existence of edges in allocation flow record allocation_flow = DataFrame(record_flow) @@ -269,7 +262,7 @@ end @test all(allocation_flow.edge_exists) @test user_demand.allocated[2, :] ≈ [4.0, 0.0, 0.0] - @test all(isapprox.(user_demand.allocated[7, :], [0.001, 0.0, 0.0], atol = 1e-5)) + @test user_demand.allocated[7, :] ≈ [0.001, 0.0, 0.0] end @testitem "subnetworks with sources" begin @@ -299,7 +292,7 @@ end # Collecting demands u = ComponentVector(; storage = zeros(length(basin.node_id))) - for (i, allocation_model) in enumerate(allocation_models[2:end]) + for allocation_model in allocation_models[2:end] Ribasim.allocate!(p, allocation_model, t, u, OptimizationType.internal_sources) Ribasim.allocate!(p, allocation_model, t, u, OptimizationType.collect_demands) end @@ -307,8 +300,7 @@ end # See the difference between these values here and in # "allocation with main network optimization problem", internal sources # lower the subnetwork demands - @test subnetwork_demands[(NodeID(:Basin, 2), NodeID(:Pump, 11))] ≈ [3.1, 4.0, 0.0] atol = - 1e-4 + @test subnetwork_demands[(NodeID(:Basin, 2), NodeID(:Pump, 11))] ≈ [3.1, 4.0, 0.0] @test subnetwork_demands[(NodeID(:Basin, 6), NodeID(:Pump, 24))] ≈ [0.004, 0.0, 0.0] @test subnetwork_demands[(NodeID(:Basin, 10), NodeID(:Pump, 38))][1:2] ≈ [0.001, 0.001] end @@ -407,6 +399,7 @@ end F = problem[:F] F_flow_buffer_in = problem[:F_flow_buffer_in] F_flow_buffer_out = problem[:F_flow_buffer_out] + F_abs_flow_demand = problem[:F_abs_flow_demand] node_id_with_flow_demand = NodeID(NodeType.TabulatedRatingCurve, 2) constraint_flow_out = problem[:flow_demand_outflow][node_id_with_flow_demand] @@ -442,8 +435,9 @@ end optimization_type, ) objective = JuMP.objective_function(problem) + @test F_abs_flow_demand[node_id_with_flow_demand] in keys(objective.terms) # Reduced demand - @test flow_demand.demand[1] ≈ flow_demand.demand_itp[1](t) - 0.001 rtol = 1e-3 + @test flow_demand.demand[1] == flow_demand.demand_itp[1](t) - 0.001 @test JuMP.normalized_rhs(constraint_flow_out) == Inf ## Priority 2 @@ -456,9 +450,9 @@ end optimization_type, ) # No demand left - @test flow_demand.demand[1] < 1e-10 + @test flow_demand.demand[1] ≈ 0.0 # Allocated - @test JuMP.value(only(F_flow_buffer_in)) ≈ 0.001 rtol = 1e-3 + @test JuMP.value(only(F_flow_buffer_in)) == 0.001 @test JuMP.normalized_rhs(constraint_flow_out) == 0.0 ## Priority 3 @@ -474,10 +468,9 @@ end # The flow from the source is used up in previous priorities @test JuMP.value(F[(NodeID(NodeType.LevelBoundary, 1), node_id_with_flow_demand)]) == 0 # So flow from the flow buffer is used for UserDemand #4 - @test JuMP.value(F_flow_buffer_out[node_id_with_flow_demand]) ≈ 0.001 rtol = 1e-3 - + @test JuMP.value(F_flow_buffer_out[node_id_with_flow_demand]) == 0.001 # Flow taken from buffer - @test JuMP.value(only(F_flow_buffer_out)) ≈ user_demand.demand_itp[1][3](t) rtol = 1e-3 + @test JuMP.value(only(F_flow_buffer_out)) == user_demand.demand_itp[1][3](t) # No flow coming from level boundary @test JuMP.value(F[(only(level_boundary.node_id), node_id_with_flow_demand)]) == 0 @@ -492,9 +485,8 @@ end ) # Get demand from buffers d = user_demand.demand_itp[3][4](t) - @test JuMP.value(F[(NodeID(NodeType.UserDemand, 4), NodeID(NodeType.Basin, 7))]) + - JuMP.value(F[(NodeID(NodeType.UserDemand, 6), NodeID(NodeType.Basin, 7))]) ≈ d rtol = - 1e-3 + @assert JuMP.value(F[(NodeID(NodeType.UserDemand, 4), NodeID(NodeType.Basin, 7))]) + + JuMP.value(F[(NodeID(NodeType.UserDemand, 6), NodeID(NodeType.Basin, 7))]) == d end @testitem "flow_demand_with_max_flow_rate" begin @@ -518,28 +510,3 @@ end ) @test constraint.set.upper == 2.0 end - -@testitem "equal_fraction_allocation" begin - using Ribasim: NodeID, NodeType - using StructArrays: StructVector - using DataFrames: DataFrame - - toml_path = - normpath(@__DIR__, "../../generated_testmodels/fair_distribution/ribasim.toml") - @test ispath(toml_path) - model = Ribasim.run(toml_path) - (; user_demand, graph) = model.integrator.p - - data_allocation = DataFrame(Ribasim.allocation_table(model)) - fractions = Vector{Float64}[] - - for id in user_demand.node_id - data_allocation_id = filter(:node_id => ==(id.value), data_allocation) - frac = data_allocation_id.allocated ./ data_allocation_id.demand - push!(fractions, frac) - end - - @test all(isapprox.(fractions[1], fractions[2], atol = 1e-4)) - @test all(isapprox.(fractions[1], fractions[3], atol = 1e-4)) - @test all(isapprox.(fractions[1], fractions[4], atol = 1e-4)) -end diff --git a/docs/core/allocation.qmd b/docs/core/allocation.qmd index b0aa5e336..e3669da7d 100644 --- a/docs/core/allocation.qmd +++ b/docs/core/allocation.qmd @@ -158,23 +158,25 @@ $$ The error between the flows and user demands is denoted by $E_{\text{user demand}}$, where $$ - E_{\text{user demand}} = \sum_{(i,j)\in E_S\;:\; i\in U_S} d_j^p(t)\left(1 - \frac{F_{ij}}{d_j^p(t)}\right)^2 + E_{\text{user demand}} = \sum_{(i,j)\in E_S\;:\; i\in U_S} \left| F_{ij} - d_j^p(t)\right| $$ :::{.callout-note} When performing main network allocation, the connections to subnetworks are also interpreted as UserDemand with demands determined by subnetwork demand collection. ::: -This type of objective cares about the fraction of the demand allocated, and will lead to an equal fraction of all demands allocated when possible. +This type of objective cares about the absolute amount of water allocated to a demand. It treats all deviations equally which means it doesn't give larger punishment per flow unit if deviations increase. + +The absolute value applied here is not supported in a linear programming context directly; this requires introduction of new variables and constraints. For more details see [here](https://optimization.cbe.cornell.edu/index.php?title=Optimization_with_absolute_values). Likewise, the error of level demands from basins is the absolute difference between flows consumed by basins and basin demands. $$ - E_{\text{level demand}} = \sum_{i \in B_S} d_i^p(t)\left(1 - \frac{F_i^\text{basin in}}{d_i^p(t)}\right)^2 + E_{\text{level demand}} = \sum_{i \in B_S} \left| F_i^\text{basin in} - d_i^p(t)\right| $$ Lastly, the error of the flow demands is given as below. $$ - E_{\text{flow demand}} = \sum_{i \in FD_S} d_i^p(t)\left(1 - \frac{F_i^\text{buffer in}}{d_i^p(t)}\right)^2 + E_{\text{flow demand}} = \sum_{i \in FD_S} \left| F_i^\text{buffer in} - d_i^p(t)\right| $$ ## The optimization constraints @@ -236,7 +238,7 @@ $$ {#eq-fractionalflowconstraint} ## Example -The following is an example of an optimization problem for the example model shown [here](../python/examples.ipynb#model-with-allocation-user-demand): +The following is an example of an optimization problem for the example shown [here](../python/examples.ipynb#model-with-allocation-user-demand): ```{julia} diff --git a/python/ribasim_testmodels/ribasim_testmodels/__init__.py b/python/ribasim_testmodels/ribasim_testmodels/__init__.py index 3706e2173..ceeb1fad2 100644 --- a/python/ribasim_testmodels/ribasim_testmodels/__init__.py +++ b/python/ribasim_testmodels/ribasim_testmodels/__init__.py @@ -7,7 +7,6 @@ import ribasim_testmodels from ribasim_testmodels.allocation import ( allocation_example_model, - fair_distribution_model, flow_demand_model, fractional_flow_subnetwork_model, level_demand_model, @@ -67,7 +66,6 @@ "bucket_model", "discrete_control_of_pid_control_model", "dutch_waterways_model", - "fair_distribution_model", "flow_boundary_time_model", "flow_condition_model", "flow_demand_model", diff --git a/python/ribasim_testmodels/ribasim_testmodels/allocation.py b/python/ribasim_testmodels/ribasim_testmodels/allocation.py index 5172a8dd8..1e102e8c0 100644 --- a/python/ribasim_testmodels/ribasim_testmodels/allocation.py +++ b/python/ribasim_testmodels/ribasim_testmodels/allocation.py @@ -1029,100 +1029,3 @@ def linear_resistance_demand_model(): model.edge.add(model.flow_demand[4], model.linear_resistance[2]) return model - - -def fair_distribution_model(): - model = Model( - starttime="2020-01-01 00:00:00", - endtime="2020-01-07 00:00:00", - crs="EPSG:28992", - allocation=Allocation(use_allocation=True), - ) - - model.level_boundary.add( - Node(1, Point(0, 0), subnetwork_id=1), - [ - level_boundary.Static( - level=[1.0], - ) - ], - ) - - model.pump.add( - Node( - 2, - Point(1, 0), - subnetwork_id=1, - ), - [pump.Static(flow_rate=9.0, max_flow_rate=[9.0])], - ) - - model.basin.add( - Node(3, Point(2, 0), subnetwork_id=1), - [basin.Profile(area=1e3, level=[0.0, 1.0]), basin.State(level=[1.0])], - ) - - model.linear_resistance.add( - Node(4, Point(3, 0), subnetwork_id=1), - [linear_resistance.Static(resistance=[1.0])], - ) - - model.basin.add( - Node(5, Point(4, 0), subnetwork_id=1), - [basin.Profile(area=1e3, level=[0.0, 1.0]), basin.State(level=[1.0])], - ) - - model.user_demand.add( - Node(6, Point(2, 1), subnetwork_id=1), - [ - user_demand.Static( - priority=[1], demand=1.0, return_factor=1.0, min_level=0.2 - ) - ], - ) - - model.user_demand.add( - Node(7, Point(2, -1), subnetwork_id=1), - [ - user_demand.Static( - priority=[1], demand=2.0, return_factor=1.0, min_level=0.2 - ) - ], - ) - - model.user_demand.add( - Node(8, Point(4, 1), subnetwork_id=1), - [ - user_demand.Static( - priority=[1], demand=3.0, return_factor=1.0, min_level=0.2 - ) - ], - ) - - model.user_demand.add( - Node(9, Point(4, -1), subnetwork_id=1), - [ - user_demand.Time( - priority=1, - time=pd.date_range(start="2020-01", end="2021-01", freq="MS"), - demand=np.linspace(1.0, 5.0, 13), - return_factor=1.0, - min_level=0.2, - ) - ], - ) - - model.edge.add(model.level_boundary[1], model.pump[2], subnetwork_id=1) - model.edge.add(model.pump[2], model.basin[3]) - model.edge.add(model.basin[3], model.linear_resistance[4]) - model.edge.add(model.linear_resistance[4], model.basin[5]) - model.edge.add(model.basin[3], model.user_demand[6]) - model.edge.add(model.basin[3], model.user_demand[7]) - model.edge.add(model.basin[5], model.user_demand[8]) - model.edge.add(model.basin[5], model.user_demand[9]) - model.edge.add(model.user_demand[6], model.basin[3]) - model.edge.add(model.user_demand[7], model.basin[3]) - model.edge.add(model.user_demand[8], model.basin[5]) - model.edge.add(model.user_demand[9], model.basin[5]) - - return model From 221155667a7c63164b17bf108b1411eb91888218 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 11:12:52 +0200 Subject: [PATCH 04/56] TeamCity change in 'Ribasim / Linux' project: 'Build' build template was extracted from 'Build libribasim' build configuration --- .../buildTypes/Ribasim_Linux_Build.xml | 65 +++++++++++++++++++ .../Ribasim_Linux_BuildLibribasim.xml | 61 ++--------------- 2 files changed, 70 insertions(+), 56 deletions(-) create mode 100644 .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml new file mode 100644 index 000000000..50b575465 --- /dev/null +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml @@ -0,0 +1,65 @@ + + + diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_BuildLibribasim.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_BuildLibribasim.xml index 411c2ddcf..3cda8935d 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_BuildLibribasim.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_BuildLibribasim.xml @@ -2,64 +2,13 @@ Build libribasim - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - + From f70aaccb8a80afdd44e45fdeaf5e6f680f491855 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 11:33:25 +0200 Subject: [PATCH 05/56] TeamCity change in 'Ribasim / Linux' project: requirements of 'Build' build template were updated --- .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml index 50b575465..53027c4ec 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml @@ -46,7 +46,7 @@ pixi run build-libribasim]]> - + From 48a770e5b93bb1ccd2f092ad856cf3305be01835 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 11:34:06 +0200 Subject: [PATCH 06/56] TeamCity change in 'Ribasim / Linux' project: requirements of 'Build' build template were updated --- .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml index 53027c4ec..4be8aaa2d 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml @@ -46,7 +46,7 @@ pixi run build-libribasim]]> - + From 2b5f0bd9a14eabc8085a48f441b97bb49e774585 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 11:34:27 +0200 Subject: [PATCH 07/56] TeamCity change in 'Ribasim / Linux' project: requirements of 'Build' build template were updated --- .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml index 4be8aaa2d..50b575465 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml @@ -46,7 +46,7 @@ pixi run build-libribasim]]> - + From 391129adb5070ffe5fe16fbf01753a5087e5ed5b Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 11:40:56 +0200 Subject: [PATCH 08/56] TeamCity change in 'Ribasim / Linux' project: requirements of 'Build' build template were updated --- .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml index 50b575465..86ecc3d31 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml @@ -46,7 +46,7 @@ pixi run build-libribasim]]> - + From bf3c6ef160759162ea4d8d36514e6d264027eab1 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 11:52:29 +0200 Subject: [PATCH 09/56] TeamCity change in 'Ribasim / Linux' project: 'Build' build template settings were updated --- .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml index 86ecc3d31..3a1244512 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml @@ -8,6 +8,9 @@ - - - - - - - - From b956f00702449177d72a4fe796b83c283684e861 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:01:45 +0200 Subject: [PATCH 19/56] TeamCity change in 'Ribasim / Linux' project: 'Test ribasim_cli' build configuration was attached to 'Build' template --- .../Ribasim_Linux_TestRibasimCli.xml | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml index 8f64b9a8c..8a7ca3254 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml @@ -2,10 +2,9 @@ Test ribasim_cli - + @@ -40,11 +39,7 @@ pixi run test-ribasim-cli]]> - - - - - + @@ -74,14 +69,6 @@ pixi run test-ribasim-cli]]> - - - - - - - - @@ -108,3 +95,4 @@ pixi run test-ribasim-cli]]> + From 6ae873ac92268c1436451c8f57b2ee9407e71cfd Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:16:09 +0200 Subject: [PATCH 20/56] TeamCity change in 'Ribasim / Linux' project: 'Build' build template settings were updated --- .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml index 935189868..3a1244512 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml @@ -9,7 +9,6 @@ + + + + + + + + From 39d3c65dfc68f6ee14b5d60546e97076443f9d5a Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:21:39 +0200 Subject: [PATCH 26/56] TeamCity change in 'Ribasim / Linux' project: 'Test ribasim_api' build configuration was detached from 'Build' template --- .../Ribasim_Linux_TestRibasimApi.xml | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml index 06ae7975f..56c94aaa9 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml @@ -2,9 +2,12 @@ Test ribasim_api - + @@ -39,9 +42,14 @@ pixi run test-ribasim-api]]> - + + + + + + @@ -76,6 +84,14 @@ pixi run test-ribasim-api]]> + + + + + + + + From b5aba731238a5d13dd6db41a34189357d3602cc5 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:25:42 +0200 Subject: [PATCH 27/56] TeamCity change in 'Ribasim / Linux' project: 'Os' build template was created --- .../Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml new file mode 100644 index 000000000..3321ccad1 --- /dev/null +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml @@ -0,0 +1,14 @@ + + + From b17196fb759af5a7b35ae33eb6558c4bc4c8df91 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:27:03 +0200 Subject: [PATCH 28/56] TeamCity change in 'Ribasim / Linux' project: general settings of 'Os' build template were updated --- .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml index 3321ccad1..20e3b701e 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml @@ -3,6 +3,9 @@ Os Template for agent that uses Linux OS + + From d1c7377f5122b473c6f3a7d4afc2886eb1aa8833 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:28:03 +0200 Subject: [PATCH 29/56] TeamCity change in 'Ribasim / Linux' project: requirements of 'Os' build template were updated --- .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml index 20e3b701e..5fb92150b 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml @@ -9,7 +9,9 @@ - + + + From 97214a1534103b5ddb8a3ecca1a3d3a00aba5e92 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:30:45 +0200 Subject: [PATCH 30/56] TeamCity change in 'Ribasim / Linux' project: VCS roots of 'Os' build template were updated --- .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml index 5fb92150b..5e73b1d7a 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml @@ -4,6 +4,7 @@ Template for agent that uses Linux OS + From 5d640dbe520ed8cba431079fa93f855c89ee8e6c Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:32:42 +0200 Subject: [PATCH 31/56] TeamCity change in 'Ribasim / Linux' project: 'Build ribasim_cli' build configuration was attached to 'Os' template --- .../buildTypes/Ribasim_Linux_BuildRibasimCli.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_BuildRibasimCli.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_BuildRibasimCli.xml index dc2bffb65..ecdc60598 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_BuildRibasimCli.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_BuildRibasimCli.xml @@ -2,10 +2,9 @@ Build ribasim_cli - + @@ -70,3 +69,4 @@ pixi run build-ribasim-cli]]> + From 186b5091c0c9b2f425b153b77cb192d4c9bba8c4 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:33:10 +0200 Subject: [PATCH 32/56] TeamCity change in 'Ribasim / Linux' project: 'Test ribasim_api' build configuration was attached to 'Os' template --- .../buildTypes/Ribasim_Linux_TestRibasimApi.xml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml index 56c94aaa9..91bb162e9 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml @@ -2,12 +2,10 @@ Test ribasim_api - + @@ -49,7 +47,6 @@ pixi run test-ribasim-api]]> - From d7341a009becbb4b9e6b026219fad3b3cff1afe7 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:33:18 +0200 Subject: [PATCH 33/56] TeamCity change in 'Ribasim / Linux' project: 'Test ribasim_cli' build configuration was attached to 'Os' template --- .../buildTypes/Ribasim_Linux_TestRibasimCli.xml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml index 1892b5879..39e00aba1 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml @@ -2,12 +2,10 @@ Test ribasim_cli - + @@ -49,7 +47,6 @@ pixi run test-ribasim-cli]]> - From 4ba0d9a99dba6330609a689bd133411f9bfe849e Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:33:29 +0200 Subject: [PATCH 34/56] TeamCity change in 'Ribasim / Linux' project: 'Build libribasim' build configuration was attached to 'Os' template --- .../buildTypes/Ribasim_Linux_BuildLibribasim.xml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_BuildLibribasim.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_BuildLibribasim.xml index f9ad518e0..1bca99252 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_BuildLibribasim.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_BuildLibribasim.xml @@ -2,12 +2,10 @@ Build libribasim - + @@ -46,9 +44,7 @@ pixi run build-libribasim]]> - - - + From 3057347b6305dd055f1f3a5c3681b0de4b88c956 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:33:44 +0200 Subject: [PATCH 35/56] TeamCity change in 'Ribasim / Linux' project: 'Build' build template was removed --- .../buildTypes/Ribasim_Linux_Build.xml | 69 ------------------- 1 file changed, 69 deletions(-) delete mode 100644 .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml deleted file mode 100644 index 935189868..000000000 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Build.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - From c70a1e6478e23e07c093a4bb8ba191c763c34a0c Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:37:50 +0200 Subject: [PATCH 36/56] TeamCity change in 'Ribasim / Windows' project: 'Build libribasim' build configuration settings were updated --- .../buildTypes/Ribasim_Windows_BuildLibribasim.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml index 2f95b2615..2b3c25366 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml @@ -5,7 +5,6 @@ - From cd55be2d4c9094959a48d7bee3c70038e162da64 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:37:55 +0200 Subject: [PATCH 37/56] TeamCity change in 'Ribasim / Windows' project: 'Build libribasim' build configuration settings were updated --- .../buildTypes/Ribasim_Windows_BuildLibribasim.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml index 2b3c25366..e781aa589 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml @@ -5,7 +5,6 @@ - From e8b86ac5b9ab62acf4ff6034817568fbeda1eac5 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:38:10 +0200 Subject: [PATCH 38/56] TeamCity change in 'Ribasim / Windows' project: 'Build libribasim' build configuration was detached from 'Build' template --- .../Ribasim_Windows_BuildLibribasim.xml | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml index e781aa589..c5be9f380 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml @@ -2,17 +2,57 @@ Build libribasim - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a7e6dbe71affc430527c996519980964a3ae2d84 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:44:24 +0200 Subject: [PATCH 39/56] TeamCity change in 'Ribasim / Windows' project: 'Build' build template was removed --- .../buildTypes/Ribasim_Windows_Build.xml | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 .teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Build.xml diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Build.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Build.xml deleted file mode 100644 index d2d6be2b8..000000000 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Build.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - From d3f1c441bc297e006d8bc74aeb385e3d62e95c62 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:45:35 +0200 Subject: [PATCH 40/56] TeamCity change in 'Ribasim / Windows' project: 'Os' build template was created --- .../buildTypes/Ribasim_Windows_Os.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml new file mode 100644 index 000000000..f575b6919 --- /dev/null +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml @@ -0,0 +1,14 @@ + + + From 4f52f45a734122214d70a6984051a06d4ebae00e Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:45:53 +0200 Subject: [PATCH 41/56] TeamCity change in 'Ribasim / Windows' project: VCS roots of 'Os' build template were updated --- .teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml index f575b6919..a2a6b8f92 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml @@ -3,6 +3,9 @@ Os Template for agent that uses Windows OS + + From a1b205f6aba59c0ffaa43a99c73d2de231d7d272 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:46:26 +0200 Subject: [PATCH 42/56] TeamCity change in 'Ribasim / Windows' project: requirements of 'Os' build template were updated --- .teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml index a2a6b8f92..87b1a65fa 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_Os.xml @@ -9,7 +9,9 @@ - + + + From 4054219f79b2be62c8031db2a9e0632d1045aae8 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:53:27 +0200 Subject: [PATCH 43/56] TeamCity change in 'Ribasim / Windows' project: 'Build libribasim' build configuration was attached to 'Os' template --- .../buildTypes/Ribasim_Windows_BuildLibribasim.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml index c5be9f380..d2249ca64 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildLibribasim.xml @@ -2,10 +2,9 @@ Build libribasim - + @@ -39,7 +38,6 @@ pixi run build-libribasim]]> - From 18d06ace41b0d35fe88c34aec70208676889f800 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:53:55 +0200 Subject: [PATCH 44/56] TeamCity change in 'Ribasim / Windows' project: 'Build ribasim_cli' build configuration was attached to 'Os' template --- .../buildTypes/Ribasim_Windows_BuildRibasimCli.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildRibasimCli.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildRibasimCli.xml index f9c3f4f6a..0979e904c 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildRibasimCli.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_BuildRibasimCli.xml @@ -2,10 +2,9 @@ Build ribasim_cli - + @@ -58,3 +57,4 @@ pixi run build-ribasim-cli]]> + From 941e68bdac37f5be2b5c44a8b0bba716c8fe5024 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:54:06 +0200 Subject: [PATCH 45/56] TeamCity change in 'Ribasim / Windows' project: 'Test ribasim_api' build configuration was attached to 'Os' template --- .../buildTypes/Ribasim_Windows_TestRibasimApi.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimApi.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimApi.xml index bb6b05130..173949191 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimApi.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimApi.xml @@ -2,10 +2,9 @@ Test ribasim_api - + From 5e46eae86fa161a70c9342cb6fbadd8e720fc7d5 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 13:54:17 +0200 Subject: [PATCH 46/56] TeamCity change in 'Ribasim / Windows' project: 'Test ribasim_cli' build configuration was attached to 'Os' template --- .../buildTypes/Ribasim_Windows_TestRibasimCli.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimCli.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimCli.xml index 7edcc1961..b6de156b6 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimCli.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimCli.xml @@ -2,10 +2,9 @@ Test ribasim_cli - + @@ -97,3 +96,4 @@ + From 184827a964fc5bed356f86e0fc2d367caf1c7d0b Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Tue, 16 Apr 2024 14:06:30 +0200 Subject: [PATCH 47/56] Run allocation first after BMI stop (#1390) This allows allocation over period `(t, t + dt)` to use variables set over BMI at time `t`. We no longer run allocation as a callback, but call it ourselves, such that we can control that BMI runs allocation first before running the physical layer. --- core/src/Ribasim.jl | 1 + core/src/bmi.jl | 7 +++--- core/src/callback.jl | 10 -------- core/src/main.jl | 7 +++--- core/src/model.jl | 56 ++++++++++++++++++++++++++++++++++++------ core/src/util.jl | 2 +- core/src/validation.jl | 11 +++++++++ 7 files changed, 67 insertions(+), 27 deletions(-) diff --git a/core/src/Ribasim.jl b/core/src/Ribasim.jl index 6d6128bb8..f8d027f63 100644 --- a/core/src/Ribasim.jl +++ b/core/src/Ribasim.jl @@ -56,6 +56,7 @@ using SciMLBase: solve!, step!, SciMLBase, + ReturnCode, successful_retcode, CallbackSet, ODEFunction, diff --git a/core/src/bmi.jl b/core/src/bmi.jl index 6595e6390..d598722f8 100644 --- a/core/src/bmi.jl +++ b/core/src/bmi.jl @@ -17,16 +17,15 @@ function BMI.update(model::Model)::Model return model end -function BMI.update_until(model::Model, time)::Model - integrator = model.integrator - t = integrator.t +function BMI.update_until(model::Model, time::Float64)::Model + (; t) = model.integrator dt = time - t if dt < 0 error("The model has already passed the given timestamp.") elseif dt == 0 return model else - step!(integrator, dt, true) + step!(model, dt) end return model end diff --git a/core/src/callback.jl b/core/src/callback.jl index bd94043a5..242c1eafa 100644 --- a/core/src/callback.jl +++ b/core/src/callback.jl @@ -51,16 +51,6 @@ function create_callbacks( ) push!(callbacks, tabulated_rating_curve_cb) - if config.allocation.use_allocation - allocation_cb = PeriodicCallback( - update_allocation!, - config.allocation.timestep; - initial_affect = false, - save_positions = (false, false), - ) - push!(callbacks, allocation_cb) - end - # If saveat is a vector which contains 0.0 this callback will still be called # at t = 0.0 despite save_start = false saveat = saveat isa Vector ? filter(x -> x != 0.0, saveat) : saveat diff --git a/core/src/main.jl b/core/src/main.jl index 78d4823ad..1e75e721f 100644 --- a/core/src/main.jl +++ b/core/src/main.jl @@ -54,8 +54,7 @@ function main(ARGS::Vector{String})::Cint config = Config(arg) mkpath(results_path(config, ".")) open(results_path(config, "ribasim.log"), "w") do io - logger = - Ribasim.setup_logger(; verbosity = config.logging.verbosity, stream = io) + logger = setup_logger(; verbosity = config.logging.verbosity, stream = io) with_logger(logger) do cli = (; ribasim_version = string(pkgversion(Ribasim))) (; starttime, endtime) = config @@ -63,13 +62,13 @@ function main(ARGS::Vector{String})::Cint @warn "The Ribasim version in the TOML config file does not match the used Ribasim CLI version." config.ribasim_version cli.ribasim_version end @info "Starting a Ribasim simulation." cli.ribasim_version starttime endtime - model = Ribasim.run(config) + model = run(config) if successful_retcode(model) @info "The model finished successfully" return 0 end - t = Ribasim.datetime_since(model.integrator.t, starttime) + t = datetime_since(model.integrator.t, starttime) retcode = model.integrator.sol.retcode @error "The model exited at model time $t with return code $retcode.\nSee https://docs.sciml.ai/DiffEqDocs/stable/basics/solution/#retcodes" return 1 diff --git a/core/src/model.jl b/core/src/model.jl index 241ba2ec6..7ac16aea1 100644 --- a/core/src/model.jl +++ b/core/src/model.jl @@ -29,6 +29,9 @@ end function Model(config_path::AbstractString)::Model config = Config(config_path) + if !valid_config(config) + error("Invalid configuration in TOML.") + end return Model(config) end @@ -44,11 +47,6 @@ function Model(config::Config)::Model TimerOutputs.enable_debug_timings(Ribasim) # causes recompilation (!) end - t_end = seconds_since(config.endtime, config.starttime) - if t_end <= 0 - error("Model starttime is not before endtime.") - end - # All data from the database that we need during runtime is copied into memory, # so we can directly close it again. db = SQLite.DB(db_path) @@ -114,6 +112,7 @@ function Model(config::Config)::Model integral = zeros(length(parameters.pid_control.node_id)) u0 = ComponentVector{Float64}(; storage, integral) # for Float32 this method allows max ~1000 year simulations without accuracy issues + t_end = seconds_since(config.endtime, config.starttime) @assert eps(t_end) < 3600 "Simulation time too long" t0 = zero(t_end) timespan = (t0, t_end) @@ -188,10 +187,51 @@ function SciMLBase.successful_retcode(model::Model)::Bool end """ - solve!(model::Model)::ODESolution + step!(model::Model, dt::Float64)::Model + +Take Model timesteps until `t + dt` is reached exactly. +""" +function SciMLBase.step!(model::Model, dt::Float64)::Model + (; config, integrator) = model + (; t) = integrator + # If we are at an allocation time, run allocation before the next physical + # layer timestep. This allows allocation over period (t, t + dt) to use variables + # set over BMI at time t before calling this function. + # Also, don't run allocation at t = 0 since there are no flows yet (#1389). + ntimes = t / config.allocation.timestep + if t > 0 && round(ntimes) ≈ ntimes + update_allocation!(integrator) + end + step!(integrator, dt, true) + return model +end + +""" + solve!(model::Model)::Model Solve a Model until the configured `endtime`. """ -function SciMLBase.solve!(model::Model)::ODESolution - return solve!(model.integrator) +function SciMLBase.solve!(model::Model)::Model + (; config, integrator) = model + if config.allocation.use_allocation + (; tspan) = integrator.sol.prob + (; timestep) = config.allocation + allocation_times = timestep:timestep:(tspan[end] - timestep) + n_allocation_times = length(allocation_times) + # Don't run allocation at t = 0 since there are no flows yet (#1389). + step!(integrator, timestep, true) + for _ in 1:n_allocation_times + update_allocation!(integrator) + step!(integrator, timestep, true) + end + + if integrator.sol.retcode != ReturnCode.Default + return model + end + # TODO replace with `check_error!` https://github.com/SciML/SciMLBase.jl/issues/669 + integrator.sol = SciMLBase.solution_new_retcode(integrator.sol, ReturnCode.Success) + else + solve!(integrator) + end + return model end diff --git a/core/src/util.jl b/core/src/util.jl index 9f28670cf..46a3643b9 100644 --- a/core/src/util.jl +++ b/core/src/util.jl @@ -683,7 +683,7 @@ function get_Δt(integrator)::Float64 elseif isinf(saveat) t else - t_end = integrator.sol.prob.tspan[2] + t_end = integrator.sol.prob.tspan[end] if t_end - t > saveat saveat else diff --git a/core/src/validation.jl b/core/src/validation.jl index 202eec6a8..72fcb55ff 100644 --- a/core/src/validation.jl +++ b/core/src/validation.jl @@ -146,6 +146,17 @@ function sorted_table!( return table end +function valid_config(config::Config)::Bool + errors = false + + if config.starttime >= config.endtime + errors = true + @error "The model starttime must be before the endtime." + end + + return !errors +end + """ Test for each node given its node type whether the nodes that # are downstream ('down-edge') of this node are of an allowed type From 2a1adc3a66fe64d39450b70b748d42b1e9a7f596 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 14:06:39 +0200 Subject: [PATCH 48/56] TeamCity change in 'Ribasim / Linux' project: 'Os' build template was moved to 'Ribasim' project --- .../{Ribasim_Linux => Ribasim}/buildTypes/Ribasim_Linux_Os.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .teamcity/{Ribasim_Linux => Ribasim}/buildTypes/Ribasim_Linux_Os.xml (100%) diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml b/.teamcity/Ribasim/buildTypes/Ribasim_Linux_Os.xml similarity index 100% rename from .teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_Os.xml rename to .teamcity/Ribasim/buildTypes/Ribasim_Linux_Os.xml From d6c1a40cde5407cf47f02366a76e2abfd37108f6 Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 16 Apr 2024 14:07:20 +0200 Subject: [PATCH 49/56] TeamCity change in 'Ribasim' project: general settings of 'Linux' build template were updated --- .../buildTypes/{Ribasim_Linux_Os.xml => Ribasim_Linux.xml} | 2 +- .../Ribasim_Linux/buildTypes/Ribasim_Linux_BuildLibribasim.xml | 2 +- .../Ribasim_Linux/buildTypes/Ribasim_Linux_BuildRibasimCli.xml | 2 +- .../Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml | 2 +- .../Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename .teamcity/Ribasim/buildTypes/{Ribasim_Linux_Os.xml => Ribasim_Linux.xml} (97%) diff --git a/.teamcity/Ribasim/buildTypes/Ribasim_Linux_Os.xml b/.teamcity/Ribasim/buildTypes/Ribasim_Linux.xml similarity index 97% rename from .teamcity/Ribasim/buildTypes/Ribasim_Linux_Os.xml rename to .teamcity/Ribasim/buildTypes/Ribasim_Linux.xml index 5e73b1d7a..901a95ae3 100644 --- a/.teamcity/Ribasim/buildTypes/Ribasim_Linux_Os.xml +++ b/.teamcity/Ribasim/buildTypes/Ribasim_Linux.xml @@ -1,6 +1,6 @@