Skip to content

Commit

Permalink
deploy: 19139f1
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Apr 12, 2024
1 parent 2e73918 commit efc6731
Show file tree
Hide file tree
Showing 37 changed files with 261 additions and 299 deletions.
412 changes: 190 additions & 222 deletions build/index.html

Large diffs are not rendered by default.

65 changes: 26 additions & 39 deletions core/allocation.html
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ <h2 data-number="4.2" class="anchored" data-anchor-id="the-optimization-objectiv
\min E_{\text{user demand}} + E_{\text{level demand}} + E_{\text{flow demand}}
\]</span></p>
<p>The error between the flows and user demands is denoted by <span class="math inline">\(E_{\text{user demand}}\)</span>, where <span class="math display">\[
E_{\text{user demand}} = \sum_{(i,j)\in E_S\;:\; i\in U_S} \left| F_{ij} - d_j^p(t)\right|
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
\]</span></p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
Expand All @@ -491,13 +491,12 @@ <h2 data-number="4.2" class="anchored" data-anchor-id="the-optimization-objectiv
<p>When performing main network allocation, the connections to subnetworks are also interpreted as UserDemand with demands determined by subnetwork demand collection.</p>
</div>
</div>
<p>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.</p>
<p>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 <a href="https://optimization.cbe.cornell.edu/index.php?title=Optimization_with_absolute_values">here</a>.</p>
<p>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.</p>
<p>Likewise, the error of level demands from basins is the absolute difference between flows consumed by basins and basin demands. <span class="math display">\[
E_{\text{level demand}} = \sum_{i \in B_S} \left| F_i^\text{basin in} - d_i^p(t)\right|
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
\]</span></p>
<p>Lastly, the error of the flow demands is given as below. <span class="math display">\[
E_{\text{flow demand}} = \sum_{i \in FD_S} \left| F_i^\text{buffer in} - d_i^p(t)\right|
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
\]</span></p>
</section>
<section id="the-optimization-constraints" class="level2" data-number="4.3">
Expand Down Expand Up @@ -566,8 +565,8 @@ <h2 data-number="4.3" class="anchored" data-anchor-id="the-optimization-constrai
</section>
<section id="example" class="level2" data-number="4.4">
<h2 data-number="4.4" class="anchored" data-anchor-id="example"><span class="header-section-number">4.4</span> Example</h2>
<p>The following is an example of an optimization problem for the example shown <a href="../python/examples.html#model-with-allocation-user-demand">here</a>:</p>
<div id="2e25a5f3" class="cell" data-execution_count="1">
<p>The following is an example of an optimization problem for the example model shown <a href="../python/examples.html#model-with-allocation-user-demand">here</a>:</p>
<div id="ac9e84e8" class="cell" data-execution_count="1">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">Ribasim</span></span>
Expand All @@ -590,49 +589,37 @@ <h2 data-number="4.4" class="anchored" data-anchor-id="example"><span class="hea
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a><span class="fu">println</span>(p.allocation.allocation_models[<span class="fl">1</span>].problem)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>Min F_abs_user_demand[UserDemand #13] + F_abs_user_demand[UserDemand #3] + F_abs_user_demand[UserDemand #6] + F_abs_level_demand[Basin #12] + F_abs_level_demand[Basin #5] + F_abs_level_demand[Basin #2]
<pre><code>Min F[(Basin #12, UserDemand #13)]² + F[(Basin #5, UserDemand #6)]² + F[(Basin #2, UserDemand #3)]² + F_basin_in[Basin #2]² + F_basin_in[Basin #5]² + F_basin_in[Basin #12]²
Subject to
abs_positive_user_demand[UserDemand #13] : -F[(Basin #12, UserDemand #13)] + F_abs_user_demand[UserDemand #13] ≥ 0
abs_positive_user_demand[UserDemand #3] : -F[(Basin #2, UserDemand #3)] + F_abs_user_demand[UserDemand #3] ≥ 0
abs_positive_user_demand[UserDemand #6] : -F[(Basin #5, UserDemand #6)] + F_abs_user_demand[UserDemand #6] ≥ 0
abs_negative_user_demand[UserDemand #13] : F[(Basin #12, UserDemand #13)] + F_abs_user_demand[UserDemand #13] ≥ 0
abs_negative_user_demand[UserDemand #3] : F[(Basin #2, UserDemand #3)] + F_abs_user_demand[UserDemand #3] ≥ 0
abs_negative_user_demand[UserDemand #6] : F[(Basin #5, UserDemand #6)] + F_abs_user_demand[UserDemand #6] ≥ 0
abs_positive_basin[Basin #12] : -F_basin_in[Basin #12] + F_abs_level_demand[Basin #12] ≥ 0
abs_positive_basin[Basin #5] : -F_basin_in[Basin #5] + F_abs_level_demand[Basin #5] ≥ 0
abs_positive_basin[Basin #2] : -F_basin_in[Basin #2] + F_abs_level_demand[Basin #2] ≥ 0
abs_negative_basin[Basin #12] : F_basin_in[Basin #12] + F_abs_level_demand[Basin #12] ≥ 0
abs_negative_basin[Basin #5] : F_basin_in[Basin #5] + F_abs_level_demand[Basin #5] ≥ 0
abs_negative_basin[Basin #2] : F_basin_in[Basin #2] + F_abs_level_demand[Basin #2] ≥ 0
F[(Basin #5, UserDemand #6)] ≥ 0
F[(TabulatedRatingCurve #7, Basin #12)] ≥ 0
F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0
F[(Basin #12, UserDemand #13)] ≥ 0
F[(TabulatedRatingCurve #7, Terminal #10)] ≥ 0
F[(Basin #2, UserDemand #3)] ≥ 0
F[(UserDemand #6, Basin #5)] ≥ 0
F[(FlowBoundary #1, Basin #2)] ≥ 0
F[(UserDemand #3, Basin #2)] ≥ 0
F[(Basin #5, UserDemand #6)] ≥ 0
F[(Basin #5, Basin #2)] ≥ 0
F[(UserDemand #3, Basin #2)] ≥ 0
F[(Basin #5, TabulatedRatingCurve #7)] ≥ 0
F[(FlowBoundary #1, Basin #2)] ≥ 0
F[(Basin #2, Basin #5)] ≥ 0
F[(UserDemand #6, Basin #5)] ≥ 0
F[(UserDemand #13, Terminal #10)] ≥ 0
F_basin_in[Basin #12] ≥ 0
F_basin_in[Basin #5] ≥ 0
F[(TabulatedRatingCurve #7, Basin #12)] ≥ 0
F[(Basin #2, UserDemand #3)] ≥ 0
F_basin_in[Basin #2] ≥ 0
F_basin_out[Basin #12] ≥ 0
F_basin_out[Basin #5] ≥ 0
F_basin_in[Basin #5] ≥ 0
F_basin_in[Basin #12] ≥ 0
F_basin_out[Basin #2] ≥ 0
F_basin_out[Basin #5] ≥ 0
F_basin_out[Basin #12] ≥ 0
source[(FlowBoundary #1, Basin #2)] : F[(FlowBoundary #1, Basin #2)] ≤ 1
F[(UserDemand #13, Terminal #10)] ≤ 0
F[(UserDemand #3, Basin #2)] ≤ 0
F[(UserDemand #6, Basin #5)] ≤ 0
fractional_flow[(TabulatedRatingCurve #7, Basin #12)] : F[(TabulatedRatingCurve #7, Basin #12)] - 0.4 F[(Basin #5, TabulatedRatingCurve #7)] ≤ 0
basin_outflow[Basin #12] : F_basin_out[Basin #12] ≤ 0
basin_outflow[Basin #5] : F_basin_out[Basin #5] ≤ 0
F[(UserDemand #3, Basin #2)] ≤ 0
F[(UserDemand #13, Terminal #10)] ≤ 0
fractional_flow[(TabulatedRatingCurve #7, Basin #12)] : -0.4 F[(Basin #5, TabulatedRatingCurve #7)] + F[(TabulatedRatingCurve #7, Basin #12)] ≤ 0
basin_outflow[Basin #2] : F_basin_out[Basin #2] ≤ 0
flow_conservation_basin[Basin #12] : -F[(TabulatedRatingCurve #7, Basin #12)] + F[(Basin #12, UserDemand #13)] + F_basin_in[Basin #12] - F_basin_out[Basin #12] = 0
flow_conservation_basin[Basin #5] : F[(Basin #5, UserDemand #6)] + F[(Basin #5, TabulatedRatingCurve #7)] - F[(UserDemand #6, Basin #5)] + F[(Basin #5, Basin #2)] - F[(Basin #2, Basin #5)] + F_basin_in[Basin #5] - F_basin_out[Basin #5] = 0
flow_conservation_basin[Basin #2] : F[(Basin #2, UserDemand #3)] - F[(FlowBoundary #1, Basin #2)] - F[(UserDemand #3, Basin #2)] - F[(Basin #5, Basin #2)] + F[(Basin #2, Basin #5)] + F_basin_in[Basin #2] - F_basin_out[Basin #2] = 0
basin_outflow[Basin #5] : F_basin_out[Basin #5] ≤ 0
basin_outflow[Basin #12] : F_basin_out[Basin #12] ≤ 0
flow_conservation_basin[Basin #2] : -F[(Basin #5, Basin #2)] - F[(UserDemand #3, Basin #2)] - F[(FlowBoundary #1, Basin #2)] + F[(Basin #2, Basin #5)] + F[(Basin #2, UserDemand #3)] + F_basin_in[Basin #2] - F_basin_out[Basin #2] = 0
flow_conservation_basin[Basin #5] : F[(Basin #5, UserDemand #6)] + F[(Basin #5, Basin #2)] + F[(Basin #5, TabulatedRatingCurve #7)] - F[(Basin #2, Basin #5)] - F[(UserDemand #6, Basin #5)] + F_basin_in[Basin #5] - F_basin_out[Basin #5] = 0
flow_conservation_basin[Basin #12] : F[(Basin #12, UserDemand #13)] - F[(TabulatedRatingCurve #7, Basin #12)] + F_basin_in[Basin #12] - F_basin_out[Basin #12] = 0
</code></pre>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions core/equations.html
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ <h2 data-number="2.1" class="anchored" data-anchor-id="sec-reduction_factor"><sp
\end{cases}
\end{align}\]</span></p>
<p>Here <span class="math inline">\(p &gt; 0\)</span> is the threshold value which determines the interval <span class="math inline">\([0,p]\)</span> of the smooth transition between <span class="math inline">\(0\)</span> and <span class="math inline">\(1\)</span>, see the plot below.</p>
<div id="a0b3646a" class="cell" data-execution_count="1">
<div id="c631e217" class="cell" data-execution_count="1">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> numpy <span class="im">as</span> np</span>
Expand Down Expand Up @@ -475,7 +475,7 @@ <h2 data-number="2.1" class="anchored" data-anchor-id="sec-reduction_factor"><sp

invalid escape sequence '\p'

/tmp/ipykernel_5276/665069857.py:31: SyntaxWarning:
/tmp/ipykernel_5297/665069857.py:31: SyntaxWarning:

invalid escape sequence '\p'
</code></pre>
Expand Down
4 changes: 2 additions & 2 deletions core/validation.html
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ <h1 class="title">Validation</h1>
<section id="connectivity" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Connectivity</h1>
<p>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.</p>
<div id="bebf2164" class="cell" data-execution_count="1">
<div id="1840fd64" class="cell" data-execution_count="1">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">Ribasim</span></span>
Expand Down Expand Up @@ -546,7 +546,7 @@ <h1 data-number="1"><span class="header-section-number">1</span> Connectivity</h
<section id="neighbor-amounts" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Neighbor amounts</h1>
<p>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.</p>
<div id="7cda45f8" class="cell" data-execution_count="2">
<div id="1c942b3b" class="cell" data-execution_count="2">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>flow_in_min <span class="op">=</span> <span class="fu">Vector</span><span class="dt">{String}</span>()</span>
Expand Down
Binary file modified python/examples_files/figure-html/cell-59-output-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified python/examples_files/figure-html/cell-60-output-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit efc6731

Please sign in to comment.