-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph-computing-python.html
161 lines (142 loc) · 7.14 KB
/
graph-computing-python.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2022-W11-4 02:13 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Graph-Based Agent Computing in Clojure</title>
<meta name="author" content="Inanna" />
<meta name="description" content="A short introduction to cyclic graphs computing and an implementation in clojure." />
<meta name="generator" content="Org Mode" />
<link href="/site.css" rel="stylesheet" type="text/css" /><link href="images/website-icon.png" rel="icon" />
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
displayAlign: "center",
displayIndent: "0em",
"HTML-CSS": { scale: 100,
linebreaks: { automatic: "false" },
webFont: "TeX"
},
SVG: {scale: 100,
linebreaks: { automatic: "false" },
font: "TeX"},
NativeMML: {scale: 100},
TeX: { equationNumbers: {autoNumber: "AMS"},
MultLineWidth: "85%",
TagSide: "right",
TagIndent: ".8em"
}
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body>
<div id="preamble" class="status">
<div><a href="/index.html"><img alt="An abstract logo representing a series of three assembly line stamping machines with the words CONS, DEV, and embalzoned in white on each machine." id="site-logo" src="/images/website-logo.png" /></a></div>
</div>
<div id="content" class="content">
<h1 class="title">Graph-Based Agent Computing in Clojure</h1>
<div id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#orgf3c2114">Introduction</a></li>
<li><a href="#org4942f26">Example</a></li>
<li><a href="#orgb7ab23d">Implementation</a>
<ul>
<li><a href="#org4a15e2f">The Meta Control System</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-orgf3c2114" class="outline-2">
<h2 id="orgf3c2114">Introduction</h2>
<div class="outline-text-2" id="text-orgf3c2114">
<p>
So a while back I had the idea of implementing a little cyclic graph programming language for fun. Honestly I was more optimistic about its capabilities than I am now. But, I still think its interesting to consider. So to do this we basically implement a simple language using agents.
</p>
</div>
</div>
<div id="outline-container-org4942f26" class="outline-2">
<h2 id="org4942f26">Example</h2>
<div class="outline-text-2" id="text-org4942f26">
<div class="org-src-container">
<pre class="src src-clojure">
</pre>
</div>
<p>
Wow! What a speed up!
</p>
</div>
</div>
<div id="outline-container-orgb7ab23d" class="outline-2">
<h2 id="orgb7ab23d">Implementation</h2>
<div class="outline-text-2" id="text-orgb7ab23d">
<p>
So to implement this we are first creating a simple series of agents that will send the results of their messages to a series of clients.
</p>
<div class="org-src-container">
<pre class="src src-clojure"><span style="color: #494949;">(</span><span style="color: #E53935; font-style: italic;">defn</span> <span style="font-weight: bold; font-style: italic;">default-agent</span> <span style="color: #bbb;">[</span>clients func<span style="color: #bbb;">]</span>
<span style="color: #bbb;">(</span>agent
<span style="color: #494949;">[]</span>
<span style="color: #494949;">(</span><span style="color: #E53935; font-style: italic;">fn</span> <span style="color: #bbb;">[</span><span style="color: #494949;">[</span>head & rest<span style="color: #494949;">]</span><span style="color: #bbb;">]</span>
<span style="color: #bbb;">(</span><span style="color: #E53935; font-style: italic;">let</span> <span style="color: #494949;">[</span>val <span style="color: #bbb;">(</span>func head<span style="color: #bbb;">)</span><span style="color: #494949;">]</span>
<span style="color: #494949;">(</span>map #<span style="color: #bbb;">(</span>send <span style="font-style: italic;">%</span> conj val<span style="color: #bbb;">)</span> clients<span style="color: #494949;">)</span>
rest<span style="color: #bbb;">)</span><span style="color: #494949;">)</span><span style="color: #bbb;">)</span><span style="color: #494949;">)</span>
</pre>
</div>
<p>
In order to do this though the system has to do it reverse.
</p>
<p>
However, in order to determine how many agents we want to produce we have to create a meta control system above our graph computing system in order to control the scaling of individual nodes.
</p>
</div>
<div id="outline-container-org4a15e2f" class="outline-3">
<h3 id="org4a15e2f">The Meta Control System</h3>
<div class="outline-text-3" id="text-org4a15e2f">
<p>
To implement this we can obviously understand this through control theory, and more specifically the implementation of an optimizing <a href="https://en.wikipedia.org/wiki/Distributed_control_system">distributed control system</a>. To do this we first must understand what we are optimizing for in our control system.
</p>
<p>
To put it simply we have a total of four independent factors that determine the optimal deployment at any one moment. The current input queue size, the available resources, and the overhead of additional nodes of that type.
</p>
<p>
Now rather than producing the amount of time it takes for each node to halt through static analysis<label class="sidenote-number" for="1"><sup>1</sup></label><input checked="checked" id="1" style="display:none" type="checkbox" /><span class="sidenote"><span class="sidenote-number"> 1</span> This would be optimal, but is hard to approximate and impossible to actually do.</span> we will simply measure it and then optimize from the mean time per unit through each node.
</p>
<pre class="example">
</pre>
<p>
Therefore the optimal execution will be produced by the linear equation
</p>
<p>
\(\displaystyle a\)
</p>
<p>
Which gives us our answer for our PID function that will operate in our control system.
</p>
<div class="org-src-container">
<pre class="src src-clojure">
</pre>
</div>
<p>
Therefore we can
</p>
<div class="org-src-container">
<pre class="src src-clojure">
</pre>
</div>
</div>
</div>
</div>
<!-- Footnotes --><!--
<div class="footdef"><sup><a id="fn.1" class="footnum" href="#fnr.1" role="doc-backlink">1</a></sup> <div class="footpara" role="doc-footnote"><p class="footpara">This would be optimal, but is hard to approximate and impossible to actually do.</p></div></div>
--></div>
<div id="postamble" class="status">
<p class="date">Last Modified: 2022-W08-3 01:21</p><p class="creator">Generated Using: <a href="https://www.gnu.org/software/emacs/">Emacs</a> 27.2 (<a href="https://orgmode.org">Org</a> mode 9.4.6)</p><p class="license">Except where otherwise noted content on <a href="https://cons.dev">cons.dev</a> is licensed under a <a href="https://creativecommons.org/licenses/by-sa/4.0/" rel="license">Creative Commons Attribution-ShareAlike 4.0 International License</a>.</p>
</div>
</body>
</html>