Skip to content

Commit

Permalink
build based on e3cf8a0
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Jul 12, 2024
1 parent d76162a commit 62ed97d
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 124 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-07-12T00:45:36","documenter_version":"1.5.0"}}
{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-07-12T00:52:46","documenter_version":"1.5.0"}}
38 changes: 18 additions & 20 deletions dev/applications/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,23 @@
[:, :, 3] =
0 1 0
1 0 0
0 0 0</code></pre><p>Then we can simply contract <code>s</code> tensors to get the number of 3 colourings satisfying the above condition! E.g. for two vertices, we get 6 distinct colourings:</p><pre><code class="language-julia-repl hljs" style="display:block;">julia&gt; ein&quot;ijk,ijk-&gt;&quot;(s,s)[]</code><code class="nohighlight hljs ansi" style="display:block;">6</code></pre><p>Using that method, it&#39;s easy to find that e.g. the peterson graph allows no 3 colouring, since</p><pre><code class="language-julia-repl hljs" style="display:block;">julia&gt; code = ein&quot;afl,bhn,cjf,dlh,enj,ago,big,cki,dmk,eom-&gt;&quot;</code><code class="nohighlight hljs ansi" style="display:block;">afl, bhn, cjf, dlh, enj, ago, big, cki, dmk, eom -&gt;</code><br/><code class="language-julia-repl hljs" style="display:block;">julia&gt; afl, bhn, cjf, dlh, enj, ago, big, cki, dmk, eom</code><code class="nohighlight hljs ansi" style="display:block;">ERROR: UndefVarError: `afl` not defined</code><br/><code class="language-julia-repl hljs" style="display:block;">julia&gt; code(fill(s, 10)...)[]</code><code class="nohighlight hljs ansi" style="display:block;">0</code></pre><p>The peterson graph consists of 10 vertices and 15 edges and looks like a pentagram embedded in a pentagon as depicted here:</p><p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f5/Petersen_graph.svg/252px-Petersen_graph.svg.png" alt/></p><p><code>OMEinsum</code> does not optimie the contraction order by default, so the above contraction can be time consuming. To speed up the contraction, we can use <code>optimize_code</code> to optimize the contraction order:</p><pre><code class="language-julia-repl hljs" style="display:block;">julia&gt; optcode = optimize_code(code, uniformsize(code, 3), TreeSA())</code><code class="nohighlight hljs ansi" style="display:block;">SlicedEinsum{Char, DynamicNestedEinsum{Char}}(Char[], dhl, dlh -&gt;
├─ dmk, khml -&gt; dhl
│ ├─ dmk
│ └─ fegkh, gemfl -&gt; khml
│ ├─ cfen, gckhn -&gt; fegkh
│ │ ├─ cjf, enj -&gt; cfen
│ │ │ ├─ cjf
│ │ │ └─ enj
│ │ └─ bgck, bhn -&gt; gckhn
│ │ ├─ big, cki -&gt; bgck
│ │ │ ⋮
│ │ │
│ │ └─ bhn
│ └─ agem, afl -&gt; gemfl
│ ├─ ago, eom -&gt; agem
│ │ ├─ ago
│ │ └─ eom
│ └─ afl
└─ dlh
0 0 0</code></pre><p>Then we can simply contract <code>s</code> tensors to get the number of 3 colourings satisfying the above condition! E.g. for two vertices, we get 6 distinct colourings:</p><pre><code class="language-julia-repl hljs" style="display:block;">julia&gt; ein&quot;ijk,ijk-&gt;&quot;(s,s)[]</code><code class="nohighlight hljs ansi" style="display:block;">6</code></pre><p>Using that method, it&#39;s easy to find that e.g. the peterson graph allows no 3 colouring, since</p><pre><code class="language-julia-repl hljs" style="display:block;">julia&gt; code = ein&quot;afl,bhn,cjf,dlh,enj,ago,big,cki,dmk,eom-&gt;&quot;</code><code class="nohighlight hljs ansi" style="display:block;">afl, bhn, cjf, dlh, enj, ago, big, cki, dmk, eom -&gt;</code><br/><code class="language-julia-repl hljs" style="display:block;">julia&gt; afl, bhn, cjf, dlh, enj, ago, big, cki, dmk, eom</code><code class="nohighlight hljs ansi" style="display:block;">ERROR: UndefVarError: `afl` not defined</code><br/><code class="language-julia-repl hljs" style="display:block;">julia&gt; code(fill(s, 10)...)[]</code><code class="nohighlight hljs ansi" style="display:block;">0</code></pre><p>The peterson graph consists of 10 vertices and 15 edges and looks like a pentagram embedded in a pentagon as depicted here:</p><p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f5/Petersen_graph.svg/252px-Petersen_graph.svg.png" alt/></p><p><code>OMEinsum</code> does not optimie the contraction order by default, so the above contraction can be time consuming. To speed up the contraction, we can use <code>optimize_code</code> to optimize the contraction order:</p><pre><code class="language-julia-repl hljs" style="display:block;">julia&gt; optcode = optimize_code(code, uniformsize(code, 3), TreeSA())</code><code class="nohighlight hljs ansi" style="display:block;">SlicedEinsum{Char, DynamicNestedEinsum{Char}}(Char[], eom, ome -&gt;
├─ eom
└─ ago, maeg -&gt; ome
├─ ago
└─ dmk, daegk -&gt; maeg
├─ dmk
└─ dhaf, hegkf -&gt; daegk
├─ dlh, afl -&gt; dhaf
│ ├─ dlh
│ └─ afl
└─ bhej, bgkjf -&gt; hegkf
├─ bhn, enj -&gt; bhej
│ ⋮
└─ bgck, cjf -&gt; bgkjf

)</code><br/><code class="language-julia-repl hljs" style="display:block;">julia&gt; contraction_complexity(optcode, uniformsize(optcode, 3))</code><code class="nohighlight hljs ansi" style="display:block;">Time complexity: 2^12.737881076857779
Space complexity: 2^7.92481250360578
Read-write complexity: 2^11.247334178028728</code><br/><code class="language-julia-repl hljs" style="display:block;">julia&gt; optcode(fill(s, 10)...)[]</code><code class="nohighlight hljs ansi" style="display:block;">0</code></pre><p>We can see the time complexity of the optimized code is much smaller than the original one. To know more about the contraction order optimization, please check the Julia package <a href="https://github.com/TensorBFS/OMEinsumContractionOrders.jl"><code>OMEinsumContractionOrders.jl</code></a>.</p><p>Confronted with the above result, we can ask whether the peterson graph allows a relaxed variation of 3 colouring, having one vertex that might accept duplicate colours. The answer to that can be found using the gradient w.r.t a vertex:</p><pre><code class="language-julia-repl hljs" style="display:block;">julia&gt; using Zygote: gradient</code><code class="nohighlight hljs ansi" style="display:block;"></code><br/><code class="language-julia-repl hljs" style="display:block;">julia&gt; gradient(x-&gt;optcode(x,s,s,s,s,s,s,s,s,s)[], s)[1] |&gt; sum</code><code class="nohighlight hljs ansi" style="display:block;">0.0</code></pre><p>This tells us that even if we allow duplicates on one vertex, there are no 3-colourings for the peterson graph.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../cuda/">« CUDA</a><a class="docs-footer-nextpage" href="../docstrings/">Manual »</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><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.5.0 on <span class="colophon-date" title="Friday 12 July 2024 00:45">Friday 12 July 2024</span>. Using Julia version 1.10.4.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Read-write complexity: 2^11.247334178028728</code><br/><code class="language-julia-repl hljs" style="display:block;">julia&gt; optcode(fill(s, 10)...)[]</code><code class="nohighlight hljs ansi" style="display:block;">0</code></pre><p>We can see the time complexity of the optimized code is much smaller than the original one. To know more about the contraction order optimization, please check the Julia package <a href="https://github.com/TensorBFS/OMEinsumContractionOrders.jl"><code>OMEinsumContractionOrders.jl</code></a>.</p><p>Confronted with the above result, we can ask whether the peterson graph allows a relaxed variation of 3 colouring, having one vertex that might accept duplicate colours. The answer to that can be found using the gradient w.r.t a vertex:</p><pre><code class="language-julia-repl hljs" style="display:block;">julia&gt; using Zygote: gradient</code><code class="nohighlight hljs ansi" style="display:block;"></code><br/><code class="language-julia-repl hljs" style="display:block;">julia&gt; gradient(x-&gt;optcode(x,s,s,s,s,s,s,s,s,s)[], s)[1] |&gt; sum</code><code class="nohighlight hljs ansi" style="display:block;">0.0</code></pre><p>This tells us that even if we allow duplicates on one vertex, there are no 3-colourings for the peterson graph.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../cuda/">« CUDA</a><a class="docs-footer-nextpage" href="../docstrings/">Manual »</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><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.5.0 on <span class="colophon-date" title="Friday 12 July 2024 00:52">Friday 12 July 2024</span>. Using Julia version 1.10.4.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Loading

0 comments on commit 62ed97d

Please sign in to comment.