Skip to content

Commit

Permalink
build based on 10e16a6
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Jun 19, 2024
1 parent 08c914b commit d69ac51
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 64 deletions.
2 changes: 1 addition & 1 deletion dev/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-06-06T07:27:15","documenter_version":"1.4.1"}}
{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-06-19T09:31:35","documenter_version":"1.4.1"}}
2 changes: 1 addition & 1 deletion dev/0-quickstart/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@
:bread => 8.86076
:weizen =&gt; 2.05696</code></pre><p>How much extra resources is consumed by the factory?</p><pre><code class="language-julia hljs">optimal_c.factory.resources</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">ConstraintTrees.Tree{Float64} with 2 elements:
:heat =&gt; 50.4747
:water =&gt; 38.2911</code></pre><p>And what is the factory profit in the end?</p><pre><code class="language-julia hljs">optimal_c.factory.profit</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">361.5506329113926</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« README</a><a class="docs-footer-nextpage" href="../1-metabolic-modeling/">Example: Metabolic modeling »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.4.1 on <span class="colophon-date" title="Thursday 6 June 2024 07:27">Thursday 6 June 2024</span>. Using Julia version 1.10.4.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
:water =&gt; 38.2911</code></pre><p>And what is the factory profit in the end?</p><pre><code class="language-julia hljs">optimal_c.factory.profit</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">361.5506329113926</code></pre><hr/><p><em>This page was generated using <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a>.</em></p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« README</a><a class="docs-footer-nextpage" href="../1-metabolic-modeling/">Example: Metabolic modeling »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.4.1 on <span class="colophon-date" title="Wednesday 19 June 2024 09:31">Wednesday 19 June 2024</span>. Using Julia version 1.10.4.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
38 changes: 36 additions & 2 deletions dev/1-metabolic-modeling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,15 @@ Dict(k => v.fluxes.R_BIOMASS_Ecoli_core_w_GAM for (k, v) in result.community)
# change at a single place of the tree may easily change values also in other
# parts of any trees, including completely different trees
# - the "convenient way" of making sure that the above problem never happens is
# to deep-copy the whole tree structure, which is typically quite detrimental
# to memory use and program efficiency
# to copy-on-write the whole tree structure, which is typically quite
# detrimental to memory use and program efficiency
#
#md # !!! danger "Rules of thumb for safe use of in-place modification"
#md # Only use the in-place modifications if:
#md # - there is code that explicitly makes sure there is no false sharing via references, e.g. using a deep copy
#md # - the in-place modifications are the last thing happening to the constraint tree before it is used by the solver
#md # - the in-place modification code is not a part of a re-usable library
#md # - you are using a suitable wrapper interface such as [Accessors.jl](https://github.com/JuliaObjects/Accessors.jl)
#
# Now, if you are completely sure that ignoring the robustness guidelines will
# help your code, you can do the in-place tree modifications quite easily using
Expand All @@ -391,6 +392,39 @@ result.exchanges

@test result_with_more_oxygen.exchanges.oxygen < -19.0 #src

# ### Alternative: Using Accessors.jl
#
# Accessors.jl implement a "lensy" way to update immutable data structures.
# That comes with a nice outcome of doing the right amount of shallow copyies
# for you automatically, thus avoiding much of the technical danger of in-place
# modifications. (You still lose the equational reasoning on your code, but that
# may not be an issue at all in usual codebases.)
#
# Accessors interface is used simply through macros `@set` (which sets a deeply
# nested field in a structure, returning a modified copy), or with `@reset`
# which automatically "assigns" the result back to the original variable:

using Accessors

c = @set c.exchanges.biomass.bound = C.Between(-50, 50)

# The above code is equivalent to:

@reset c.exchanges.biomass.bound = C.Between(-50, 50)

# ...and it is also possible to use string and symbol indexes to pick the
# individual tree items:

@reset c[:exchanges]["biomass"].bound = C.Between(-50, 50)

# All of these operations give us:

c.exchanges.biomass

@test typeof(c.exchanges.biomass.bound) == C.Between #src
@test c.exchanges.biomass.bound.lower == -50 #src
@test c.exchanges.biomass.bound.upper == 50 #src

# ## Seeing the differences between the results
#
# ConstraintTrees.jl defines its own version of `zip` function that can apply a
Expand Down
Loading

0 comments on commit d69ac51

Please sign in to comment.