diff --git a/concept/allocation.html b/concept/allocation.html index 03b763377..b03ec6a99 100644 --- a/concept/allocation.html +++ b/concept/allocation.html @@ -584,7 +584,7 @@

4.4 Example

The following is an example of an optimization problem for the example shown here:

-
+
Code
using Ribasim
@@ -609,25 +609,25 @@ 

Min F[(Basin #5, UserDemand #6)]² + F[(Basin #2, UserDemand #3)]²
 Subject to
+ source[(FlowBoundary #1, Basin #2)] : F[(FlowBoundary #1, Basin #2)] ≤ 172800
+ source_user[UserDemand #3] : F[(UserDemand #3, Basin #2)] ≤ 0
+ source_user[UserDemand #6] : F[(UserDemand #6, Basin #5)] ≤ 0
+ flow_conservation[LinearResistance #4] : -F[(LinearResistance #4, Basin #5)] + F[(Basin #5, LinearResistance #4)] + F[(Basin #2, LinearResistance #4)] - F[(LinearResistance #4, Basin #2)] = 0
+ flow_conservation[TabulatedRatingCurve #7] : F[(Basin #5, TabulatedRatingCurve #7)] - F[(TabulatedRatingCurve #7, Terminal #1)] = 0
+ flow_conservation[Basin #5] : -F[(Basin #5, UserDemand #6)] - F[(Basin #5, TabulatedRatingCurve #7)] + F[(LinearResistance #4, Basin #5)] - F[(Basin #5, LinearResistance #4)] + F[(UserDemand #6, Basin #5)] = 0
+ flow_conservation[Basin #2] : F[(FlowBoundary #1, Basin #2)] + F[(UserDemand #3, Basin #2)] - F[(Basin #2, UserDemand #3)] - F[(Basin #2, LinearResistance #4)] + F[(LinearResistance #4, Basin #2)] = 0
+ flow_conservation[Terminal #1] : F[(TabulatedRatingCurve #7, Terminal #1)] = 0
+ F[(FlowBoundary #1, Basin #2)] ≥ 0
+ F[(Basin #5, UserDemand #6)] ≥ 0
  F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0
  F[(LinearResistance #4, Basin #5)] ≥ 0
  F[(Basin #5, LinearResistance #4)] ≥ 0
- F[(FlowBoundary #1, Basin #2)] ≥ 0
- F[(Basin #5, UserDemand #6)] ≥ 0
- F[(UserDemand #6, Basin #5)] ≥ 0
+ F[(UserDemand #3, Basin #2)] ≥ 0
  F[(TabulatedRatingCurve #7, Terminal #1)] ≥ 0
  F[(Basin #2, UserDemand #3)] ≥ 0
  F[(Basin #2, LinearResistance #4)] ≥ 0
  F[(LinearResistance #4, Basin #2)] ≥ 0
- F[(UserDemand #3, Basin #2)] ≥ 0
- flow_conservation[Terminal #1] : F[(TabulatedRatingCurve #7, Terminal #1)] = 0
- flow_conservation[LinearResistance #4] : -F[(LinearResistance #4, Basin #5)] + F[(Basin #5, LinearResistance #4)] + F[(Basin #2, LinearResistance #4)] - F[(LinearResistance #4, Basin #2)] = 0
- flow_conservation[TabulatedRatingCurve #7] : F[(Basin #5, TabulatedRatingCurve #7)] - F[(TabulatedRatingCurve #7, Terminal #1)] = 0
- flow_conservation[Basin #5] : -F[(Basin #5, TabulatedRatingCurve #7)] + F[(LinearResistance #4, Basin #5)] - F[(Basin #5, LinearResistance #4)] - F[(Basin #5, UserDemand #6)] + F[(UserDemand #6, Basin #5)] = 0
- flow_conservation[Basin #2] : F[(FlowBoundary #1, Basin #2)] - F[(Basin #2, UserDemand #3)] - F[(Basin #2, LinearResistance #4)] + F[(LinearResistance #4, Basin #2)] + F[(UserDemand #3, Basin #2)] = 0
- source[(FlowBoundary #1, Basin #2)] : F[(FlowBoundary #1, Basin #2)] ≤ 172800
- source_user[UserDemand #6] : F[(UserDemand #6, Basin #5)] ≤ 0
- source_user[UserDemand #3] : F[(UserDemand #3, Basin #2)] ≤ 0
+ F[(UserDemand #6, Basin #5)] ≥ 0
 

diff --git a/guide/examples.html b/guide/examples.html index 76240b069..15db02279 100644 --- a/guide/examples.html +++ b/guide/examples.html @@ -499,7 +499,7 @@

1 Basic model wit
-

+

diff --git a/guide/examples_files/figure-html/cell-18-output-1.png b/guide/examples_files/figure-html/cell-18-output-1.png index dc2bf2f68..070b6948e 100644 Binary files a/guide/examples_files/figure-html/cell-18-output-1.png and b/guide/examples_files/figure-html/cell-18-output-1.png differ diff --git a/guide/examples_files/figure-html/cell-19-output-1.png b/guide/examples_files/figure-html/cell-19-output-1.png index 375f15520..5a5e70e6f 100644 Binary files a/guide/examples_files/figure-html/cell-19-output-1.png and b/guide/examples_files/figure-html/cell-19-output-1.png differ diff --git a/guide/examples_files/figure-html/cell-31-output-1.png b/guide/examples_files/figure-html/cell-31-output-1.png index df8e1afbe..b9376f8a3 100644 Binary files a/guide/examples_files/figure-html/cell-31-output-1.png and b/guide/examples_files/figure-html/cell-31-output-1.png differ diff --git a/guide/examples_files/figure-html/cell-43-output-1.png b/guide/examples_files/figure-html/cell-43-output-1.png index feaf23492..c4ea49570 100644 Binary files a/guide/examples_files/figure-html/cell-43-output-1.png and b/guide/examples_files/figure-html/cell-43-output-1.png differ diff --git a/guide/examples_files/figure-html/cell-56-output-1.png b/guide/examples_files/figure-html/cell-56-output-1.png index 5a08ff5da..4dd26aa63 100644 Binary files a/guide/examples_files/figure-html/cell-56-output-1.png and b/guide/examples_files/figure-html/cell-56-output-1.png differ diff --git a/guide/examples_files/figure-html/cell-57-output-2.png b/guide/examples_files/figure-html/cell-57-output-2.png index 42981c7cf..248a20b68 100644 Binary files a/guide/examples_files/figure-html/cell-57-output-2.png and b/guide/examples_files/figure-html/cell-57-output-2.png differ diff --git a/guide/examples_files/figure-html/cell-68-output-1.png b/guide/examples_files/figure-html/cell-68-output-1.png index 9d1c067b8..45b4f4e39 100644 Binary files a/guide/examples_files/figure-html/cell-68-output-1.png and b/guide/examples_files/figure-html/cell-68-output-1.png differ diff --git a/guide/examples_files/figure-html/cell-79-output-1.png b/guide/examples_files/figure-html/cell-79-output-1.png index d5185aee2..faa3f54e3 100644 Binary files a/guide/examples_files/figure-html/cell-79-output-1.png and b/guide/examples_files/figure-html/cell-79-output-1.png differ diff --git a/guide/examples_files/figure-html/cell-79-output-2.png b/guide/examples_files/figure-html/cell-79-output-2.png index 564512baf..fb94ac7a3 100644 Binary files a/guide/examples_files/figure-html/cell-79-output-2.png and b/guide/examples_files/figure-html/cell-79-output-2.png differ diff --git a/guide/examples_files/figure-html/cell-80-output-1.png b/guide/examples_files/figure-html/cell-80-output-1.png index 8fe3549a4..ebde9c6f3 100644 Binary files a/guide/examples_files/figure-html/cell-80-output-1.png and b/guide/examples_files/figure-html/cell-80-output-1.png differ diff --git a/guide/examples_files/figure-html/cell-81-output-1.png b/guide/examples_files/figure-html/cell-81-output-1.png index 81a31582f..5d40d5a22 100644 Binary files a/guide/examples_files/figure-html/cell-81-output-1.png and b/guide/examples_files/figure-html/cell-81-output-1.png differ diff --git a/guide/examples_files/figure-html/cell-93-output-1.png b/guide/examples_files/figure-html/cell-93-output-1.png index 581ea52b2..692c6fc26 100644 Binary files a/guide/examples_files/figure-html/cell-93-output-1.png and b/guide/examples_files/figure-html/cell-93-output-1.png differ diff --git a/reference/node/basin.html b/reference/node/basin.html index 1da06e2cd..ca3ac1f2d 100644 --- a/reference/node/basin.html +++ b/reference/node/basin.html @@ -832,7 +832,7 @@

Here \(p > 0\) is the threshold value which determines the interval \([0,p]\) of the smooth transition between \(0\) and \(1\), see the plot below.

-
+
Code
import numpy as np
diff --git a/reference/node/discrete-control.html b/reference/node/discrete-control.html
index 58a4fb28e..215851384 100644
--- a/reference/node/discrete-control.html
+++ b/reference/node/discrete-control.html
@@ -386,7 +386,7 @@ 

DiscreteControl

Set parameters of other nodes based on model state conditions (e.g. Basin level). The table below shows which parameters are controllable for a given node type.

-
+
Code
using Ribasim
diff --git a/reference/test-models.html b/reference/test-models.html
index c0e88a6c3..76eb080f4 100644
--- a/reference/test-models.html
+++ b/reference/test-models.html
@@ -346,7 +346,7 @@ 

Test models

Ribasim developers use the following models in their testbench and in order to test new features.

-
+
Code
import ribasim_testmodels
diff --git a/reference/validation.html b/reference/validation.html
index cf8846bbb..1cd8f37fb 100644
--- a/reference/validation.html
+++ b/reference/validation.html
@@ -356,7 +356,7 @@ 

Validation

1 Connectivity

In the table below, each column shows which node types are allowed to be downstream (or ‘down-control’) of the node type at the top of the column.

-
+
Code
using Ribasim
@@ -706,7 +706,7 @@ 

1 Connectivity

2 Neighbor amounts

The table below shows for each node type between which bounds the amount of in- and outneighbors must be, for both flow and control edges.

-
+
Code
flow_in_min = Vector{String}()
diff --git a/search.json b/search.json
index 7ea0c8c0d..6b5d5532e 100644
--- a/search.json
+++ b/search.json
@@ -1450,7 +1450,7 @@
     "href": "concept/allocation.html#example",
     "title": "Allocation",
     "section": "4.4 Example",
-    "text": "4.4 Example\nThe following is an example of an optimization problem for the example shown here:\n\n\nCode\nusing Ribasim\nusing Ribasim: NodeID\nusing SQLite\nusing ComponentArrays: ComponentVector\n\ntoml_path = normpath(@__DIR__, \"../../generated_testmodels/allocation_example/ribasim.toml\")\np = Ribasim.Model(toml_path).integrator.p\nu = ComponentVector(; storage = zeros(length(p.basin.node_id)))\n\nallocation_model = p.allocation.allocation_models[1]\nt = 0.0\npriority_idx = 1\n\nRibasim.set_flow!(p.graph, NodeID(:FlowBoundary, 1, p), NodeID(:Basin, 2, p), 1.0)\nRibasim.set_objective_priority!(allocation_model, p, u, t, priority_idx)\nRibasim.set_initial_values!(allocation_model, p, u, t)\n\nprintln(p.allocation.allocation_models[1].problem)\n\n\nMin F[(Basin #5, UserDemand #6)]² + F[(Basin #2, UserDemand #3)]²\nSubject to\n F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0\n F[(LinearResistance #4, Basin #5)] ≥ 0\n F[(Basin #5, LinearResistance #4)] ≥ 0\n F[(FlowBoundary #1, Basin #2)] ≥ 0\n F[(Basin #5, UserDemand #6)] ≥ 0\n F[(UserDemand #6, Basin #5)] ≥ 0\n F[(TabulatedRatingCurve #7, Terminal #1)] ≥ 0\n F[(Basin #2, UserDemand #3)] ≥ 0\n F[(Basin #2, LinearResistance #4)] ≥ 0\n F[(LinearResistance #4, Basin #2)] ≥ 0\n F[(UserDemand #3, Basin #2)] ≥ 0\n flow_conservation[Terminal #1] : F[(TabulatedRatingCurve #7, Terminal #1)] = 0\n flow_conservation[LinearResistance #4] : -F[(LinearResistance #4, Basin #5)] + F[(Basin #5, LinearResistance #4)] + F[(Basin #2, LinearResistance #4)] - F[(LinearResistance #4, Basin #2)] = 0\n flow_conservation[TabulatedRatingCurve #7] : F[(Basin #5, TabulatedRatingCurve #7)] - F[(TabulatedRatingCurve #7, Terminal #1)] = 0\n flow_conservation[Basin #5] : -F[(Basin #5, TabulatedRatingCurve #7)] + F[(LinearResistance #4, Basin #5)] - F[(Basin #5, LinearResistance #4)] - F[(Basin #5, UserDemand #6)] + F[(UserDemand #6, Basin #5)] = 0\n flow_conservation[Basin #2] : F[(FlowBoundary #1, Basin #2)] - F[(Basin #2, UserDemand #3)] - F[(Basin #2, LinearResistance #4)] + F[(LinearResistance #4, Basin #2)] + F[(UserDemand #3, Basin #2)] = 0\n source[(FlowBoundary #1, Basin #2)] : F[(FlowBoundary #1, Basin #2)] ≤ 172800\n source_user[UserDemand #6] : F[(UserDemand #6, Basin #5)] ≤ 0\n source_user[UserDemand #3] : F[(UserDemand #3, Basin #2)] ≤ 0",
+    "text": "4.4 Example\nThe following is an example of an optimization problem for the example shown here:\n\n\nCode\nusing Ribasim\nusing Ribasim: NodeID\nusing SQLite\nusing ComponentArrays: ComponentVector\n\ntoml_path = normpath(@__DIR__, \"../../generated_testmodels/allocation_example/ribasim.toml\")\np = Ribasim.Model(toml_path).integrator.p\nu = ComponentVector(; storage = zeros(length(p.basin.node_id)))\n\nallocation_model = p.allocation.allocation_models[1]\nt = 0.0\npriority_idx = 1\n\nRibasim.set_flow!(p.graph, NodeID(:FlowBoundary, 1, p), NodeID(:Basin, 2, p), 1.0)\nRibasim.set_objective_priority!(allocation_model, p, u, t, priority_idx)\nRibasim.set_initial_values!(allocation_model, p, u, t)\n\nprintln(p.allocation.allocation_models[1].problem)\n\n\nMin F[(Basin #5, UserDemand #6)]² + F[(Basin #2, UserDemand #3)]²\nSubject to\n source[(FlowBoundary #1, Basin #2)] : F[(FlowBoundary #1, Basin #2)] ≤ 172800\n source_user[UserDemand #3] : F[(UserDemand #3, Basin #2)] ≤ 0\n source_user[UserDemand #6] : F[(UserDemand #6, Basin #5)] ≤ 0\n flow_conservation[LinearResistance #4] : -F[(LinearResistance #4, Basin #5)] + F[(Basin #5, LinearResistance #4)] + F[(Basin #2, LinearResistance #4)] - F[(LinearResistance #4, Basin #2)] = 0\n flow_conservation[TabulatedRatingCurve #7] : F[(Basin #5, TabulatedRatingCurve #7)] - F[(TabulatedRatingCurve #7, Terminal #1)] = 0\n flow_conservation[Basin #5] : -F[(Basin #5, UserDemand #6)] - F[(Basin #5, TabulatedRatingCurve #7)] + F[(LinearResistance #4, Basin #5)] - F[(Basin #5, LinearResistance #4)] + F[(UserDemand #6, Basin #5)] = 0\n flow_conservation[Basin #2] : F[(FlowBoundary #1, Basin #2)] + F[(UserDemand #3, Basin #2)] - F[(Basin #2, UserDemand #3)] - F[(Basin #2, LinearResistance #4)] + F[(LinearResistance #4, Basin #2)] = 0\n flow_conservation[Terminal #1] : F[(TabulatedRatingCurve #7, Terminal #1)] = 0\n F[(FlowBoundary #1, Basin #2)] ≥ 0\n F[(Basin #5, UserDemand #6)] ≥ 0\n F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0\n F[(LinearResistance #4, Basin #5)] ≥ 0\n F[(Basin #5, LinearResistance #4)] ≥ 0\n F[(UserDemand #3, Basin #2)] ≥ 0\n F[(TabulatedRatingCurve #7, Terminal #1)] ≥ 0\n F[(Basin #2, UserDemand #3)] ≥ 0\n F[(Basin #2, LinearResistance #4)] ≥ 0\n F[(LinearResistance #4, Basin #2)] ≥ 0\n F[(UserDemand #6, Basin #5)] ≥ 0",
     "crumbs": [
       "Concepts",
       "Implementation",