Skip to content

Commit 124824a

Browse files
committed
try to defer gist loading
1 parent 035cf94 commit 124824a

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

_posts/2022-09-06-ant-colony-optimization-tsp.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ That is, the probability of choosing a certain edge will be proportional to:
8787

8888
Where P is the level of pheromones in that edge, and D the distance the edge covers. To get the distribution we sample from at each random jump, we normalize these weight coefficients so they add up to one.
8989
<div class="wide-eighty">
90-
{% raw %}<script defer src="https://gist.github.com/StrikingLoo/432302f114822d24504cf6bab0ab3964.js"></script>{% endraw %}
90+
{% raw %}<div id="gist1"></div>{% endraw %}
9191
</div>
9292
After that, the optimization procedure itself consists of:
9393

@@ -107,7 +107,7 @@ Additionally, I tried a few more modifications to the algorithm: the 'elite' or
107107
Here is the whole function in all its glory (with comments for sanity).
108108

109109
<div class="wide-eighty">
110-
{% raw %}<script defer src="https://gist.github.com/StrikingLoo/778db2438b18d38f126082c046b19acd.js"></script>{% endraw %}
110+
{% raw %}<div id="gist2"></div>{% endraw %}
111111
</div>
112112

113113
Some possible improvements for this algorithm that I didn't have the time for:
@@ -179,4 +179,28 @@ I would like to try Ant Colony Optimization for problems other than TSP in the f
179179
- Reddit User _/u/git_'s comments on [Ant Behavior](https://www.reddit.com/r/programming/comments/wx69fs/comment/ilplkgs/) and [Ant Trails](https://www.reddit.com/r/funny/comments/wt1fcr/comment/il1w9u2/), which originally inspired me to write this post.
180180
- [Solving the Large-Scale TSP Problem in 1 h: Santa Claus Challenge 2020](https://www.frontiersin.org/articles/10.3389/frobt.2021.689908/full): A fun challenge and a good explanation of TSP.
181181
- [Automatic Relation-aware Graph Network Proliferation](https://arxiv.org/pdf/2205.15678v1.pdf): Using Graph Neural Networks to solve, among other things, TSP.
182-
- [TSP Genetic Python](https://github.com/maoaiz/tsp-genetic-python): A genetic algorithm for solving TSP.
182+
- [TSP Genetic Python](https://github.com/maoaiz/tsp-genetic-python): A genetic algorithm for solving TSP.
183+
184+
{% raw %}
185+
<script>
186+
function setUpGists() {
187+
const url1 = "https://gist.github.com/StrikingLoo/432302f114822d24504cf6bab0ab3964.js";
188+
const url2 ="https://gist.github.com/StrikingLoo/778db2438b18d38f126082c046b19acd.js";
189+
190+
const container1 = document.createElement('div');
191+
container1.id = 'gist-container-1';
192+
document.getElementById('gist1').appendChild(container1);
193+
const script1 = document.createElement('script');
194+
script1.src = url1;
195+
container1.appendChild(script1);
196+
197+
const container2 = document.createElement('div');
198+
container2.id = 'gist-container-2';
199+
document.getElementById('gist2').appendChild(container2);
200+
const script2 = document.createElement('script');
201+
script2.src = url2;
202+
container2.appendChild(script2);
203+
}
204+
window.addEventListener('DOMContentLoaded', setUpGists);
205+
</script>
206+
{% endraw %}

0 commit comments

Comments
 (0)