<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Architecture on TransTTE</title><link>https://vlzm.github.io/TransTTE/docs/architecture/</link><description>Recent content in Architecture on TransTTE</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://vlzm.github.io/TransTTE/docs/architecture/index.xml" rel="self" type="application/rss+xml"/><item><title>Graphormer Service</title><link>https://vlzm.github.io/TransTTE/docs/architecture/graphormer-service/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vlzm.github.io/TransTTE/docs/architecture/graphormer-service/</guid><description>&lt;h1 id="graphormer-service"&gt;Graphormer Service&lt;a class="anchor" href="#graphormer-service"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The Graphormer service (&lt;code&gt;graphormer/&lt;/code&gt;) is the &lt;strong&gt;GPU side&lt;/strong&gt; of the pipeline. It loads a
trained Graphormer checkpoint per city and produces exactly one travel-time weight for
every edge of that city&amp;rsquo;s road graph. This is the expensive step, and it is normally run
&lt;strong&gt;once&lt;/strong&gt; — the results are cached as pickle files that the &lt;a href="https://vlzm.github.io/TransTTE/docs/architecture/backend-service/"&gt;backend&lt;/a&gt; reads at startup.&lt;/p&gt;
&lt;p&gt;Source:
&lt;a href="https://github.com/vlzm/TransTTE/blob/main/graphormer/app/app.py"&gt;&lt;code&gt;graphormer/app/app.py&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="the-endpoint"&gt;The endpoint&lt;a class="anchor" href="#the-endpoint"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;POST /get_weights → {&amp;#34;abakan&amp;#34;: [w0, w1, ...], &amp;#34;omsk&amp;#34;: [w0, w1, ...]}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The response is a JSON object with one key per city. Each value is a &lt;strong&gt;flat list of
floats&lt;/strong&gt; — one weight per edge, in graph edge order. There is no request body. A
&lt;code&gt;GET /&lt;/code&gt; returns &lt;code&gt;{&amp;quot;ping&amp;quot;: &amp;quot;pong&amp;quot;}&lt;/code&gt; as a liveness check.&lt;/p&gt;</description></item><item><title>Backend Service</title><link>https://vlzm.github.io/TransTTE/docs/architecture/backend-service/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vlzm.github.io/TransTTE/docs/architecture/backend-service/</guid><description>&lt;h1 id="backend-service"&gt;Backend Service&lt;a class="anchor" href="#backend-service"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The backend (&lt;code&gt;backend/&lt;/code&gt;) is the &lt;strong&gt;CPU side&lt;/strong&gt; plus the web UI. It loads the precomputed
edge weights and answers routing requests: given two coordinates, it returns a route and
an ETA for each available &lt;a href="https://vlzm.github.io/TransTTE/docs/architecture/routing-objectives/"&gt;routing objective&lt;/a&gt;. It also serves the interactive map at
&lt;code&gt;GET /&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Source:
&lt;a href="https://github.com/vlzm/TransTTE/blob/main/backend/app/app.py"&gt;&lt;code&gt;backend/app/app.py&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="the-endpoint"&gt;The endpoint&lt;a class="anchor" href="#the-endpoint"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;POST /get_path body: {start_lat, start_lon, end_lat, end_lon}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; → [ {path: [...], eta: &amp;lt;seconds&amp;gt;, type: &amp;#34;&amp;lt;objective&amp;gt;&amp;#34;}, ... ]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;GET / → the map UI (index.html)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Coordinates in the request body are always &lt;code&gt;(lat, lon)&lt;/code&gt;. The response is a &lt;strong&gt;list&lt;/strong&gt; — one
entry per weight variant, each tagged by its &lt;code&gt;type&lt;/code&gt;. Endpoint and payload details live in
the &lt;a href="https://vlzm.github.io/TransTTE/docs/reference/api/"&gt;API reference&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Weight Contract</title><link>https://vlzm.github.io/TransTTE/docs/architecture/weight-contract/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vlzm.github.io/TransTTE/docs/architecture/weight-contract/</guid><description>&lt;h1 id="weight-handoff-contract"&gt;Weight Handoff Contract&lt;a class="anchor" href="#weight-handoff-contract"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The Graphormer service and the backend communicate through &lt;strong&gt;pickled weight lists&lt;/strong&gt;, not
live HTTP, in normal operation. This page describes that handoff and the single invariant
that makes it work.&lt;/p&gt;
&lt;h2 id="the-artifacts"&gt;The artifacts&lt;a class="anchor" href="#the-artifacts"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Graphormer service writes (and can serve) two pickles:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;weights_abakan.pickle # one float per edge of the Abakan road graph
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;weights_omsk.pickle # one float per edge of the Omsk road graph&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The backend reads them from
&lt;code&gt;backend/app/data/graphormer_weights/&lt;/code&gt; and exposes them as the &lt;code&gt;graphormer_weights&lt;/code&gt;
route variant. Each pickle is just a flat list of floats.&lt;/p&gt;</description></item><item><title>ETA Paths</title><link>https://vlzm.github.io/TransTTE/docs/architecture/eta-paths/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vlzm.github.io/TransTTE/docs/architecture/eta-paths/</guid><description>&lt;h1 id="two-eta-paths"&gt;Two ETA Paths&lt;a class="anchor" href="#two-eta-paths"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Once the backend has a route, it has to turn that route into an &lt;strong&gt;estimated time of
arrival&lt;/strong&gt;. It does this in one of two ways, depending on the weight variant. Know which one
you are touching — they share no code.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;return_path&lt;/code&gt; in
&lt;a href="https://github.com/vlzm/TransTTE/blob/main/backend/app/app.py"&gt;&lt;code&gt;backend/app/app.py&lt;/code&gt;&lt;/a&gt;
picks the path per variant:&lt;/p&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Variant&lt;/th&gt;
					&lt;th&gt;ETA method&lt;/th&gt;
					&lt;th&gt;Where&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;Abakan non-Graphormer (&lt;code&gt;dist&lt;/code&gt;, &lt;code&gt;green&lt;/code&gt;, &lt;code&gt;hist&lt;/code&gt;, …)&lt;/td&gt;
					&lt;td&gt;Neural ETA (&lt;code&gt;FFNet&lt;/code&gt;)&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;ETAInf.forward&lt;/code&gt;&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Abakan &lt;code&gt;graphormer_weights&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;Weighted sum&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;get_shortest_path_grph&lt;/code&gt;&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;All Omsk variants (incl. &lt;code&gt;graphormer_weights&lt;/code&gt;)&lt;/td&gt;
					&lt;td&gt;Weighted sum&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;get_shortest_path_grph&lt;/code&gt;&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="1-neural-eta--ffnet"&gt;1. Neural ETA — &lt;code&gt;FFNet&lt;/code&gt;&lt;a class="anchor" href="#1-neural-eta--ffnet"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For the Abakan non-Graphormer variants the ETA comes from a small feed-forward network,
&lt;strong&gt;&lt;code&gt;FFNet&lt;/code&gt;&lt;/strong&gt; (152 inputs → 128 → 1, ReLU), defined in
&lt;a href="https://github.com/vlzm/TransTTE/blob/main/backend/app/ml.py"&gt;&lt;code&gt;ml.py&lt;/code&gt;&lt;/a&gt; and driven
by &lt;code&gt;ETAInf.forward&lt;/code&gt; in
&lt;a href="https://github.com/vlzm/TransTTE/blob/main/backend/app/eta_inference.py"&gt;&lt;code&gt;eta_inference.py&lt;/code&gt;&lt;/a&gt;.
The 152-dimensional input vector is assembled per request from:&lt;/p&gt;</description></item><item><title>Routing Objectives</title><link>https://vlzm.github.io/TransTTE/docs/architecture/routing-objectives/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://vlzm.github.io/TransTTE/docs/architecture/routing-objectives/</guid><description>&lt;h1 id="routing-objectives"&gt;Routing Objectives&lt;a class="anchor" href="#routing-objectives"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;A single &lt;code&gt;POST /get_path&lt;/code&gt; call returns &lt;strong&gt;several routes&lt;/strong&gt;, one per &lt;em&gt;objective&lt;/em&gt;. An
objective is nothing more than a per-edge weight list: change what the weights mean and you
change what &amp;ldquo;shortest&amp;rdquo; optimizes for — fastest, shortest distance, greenest, most
historic, and so on.&lt;/p&gt;
&lt;h2 id="where-they-come-from"&gt;Where they come from&lt;a class="anchor" href="#where-they-come-from"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The backend loads every objective for a city from a directory at startup:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; weight &lt;span style="color:#f92672"&gt;in&lt;/span&gt; sorted((BASE &lt;span style="color:#f92672"&gt;/&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;data/weights_abakan&amp;#39;&lt;/span&gt;)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;iterdir()):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;.pkl&amp;#39;&lt;/span&gt; &lt;span style="color:#f92672"&gt;in&lt;/span&gt; weight&lt;span style="color:#f92672"&gt;.&lt;/span&gt;name:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; weights_dict_abakan[weight&lt;span style="color:#f92672"&gt;.&lt;/span&gt;name&lt;span style="color:#f92672"&gt;.&lt;/span&gt;split(&lt;span style="color:#e6db74"&gt;&amp;#39;.&amp;#39;&lt;/span&gt;)[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;]] &lt;span style="color:#f92672"&gt;=&lt;/span&gt; pickle&lt;span style="color:#f92672"&gt;.&lt;/span&gt;load(fd)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So the &lt;strong&gt;file name (minus extension) becomes the &lt;code&gt;type&lt;/code&gt;&lt;/strong&gt; in the response, and &lt;code&gt;sorted()&lt;/code&gt;
fixes the order. The objectives shipped in the demo data are, for example:&lt;/p&gt;</description></item></channel></rss>