<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[autorouting]]></title><description><![CDATA[Algorithms, benchmarks and open datasets for open-source PCB autorouting]]></description><link>https://blog.autorouting.com</link><image><url>https://substackcdn.com/image/fetch/$s_!Cwtu!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc458374f-2a43-4c52-bbe7-823f9faf0fa2_200x200.png</url><title>autorouting</title><link>https://blog.autorouting.com</link></image><generator>Substack</generator><lastBuildDate>Wed, 13 May 2026 02:06:06 GMT</lastBuildDate><atom:link href="https://blog.autorouting.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[tscircuit]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[autorouting@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[autorouting@substack.com]]></itunes:email><itunes:name><![CDATA[Seve Ibarluzea]]></itunes:name></itunes:owner><itunes:author><![CDATA[Seve Ibarluzea]]></itunes:author><googleplay:owner><![CDATA[autorouting@substack.com]]></googleplay:owner><googleplay:email><![CDATA[autorouting@substack.com]]></googleplay:email><googleplay:author><![CDATA[Seve Ibarluzea]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[The Unravel Algorithm - Untwisting PCB traces]]></title><description><![CDATA[An algorithm for untwisting PCB traces within a HyperGraph]]></description><link>https://blog.autorouting.com/p/the-unravel-algorithm-untwisting</link><guid isPermaLink="false">https://blog.autorouting.com/p/the-unravel-algorithm-untwisting</guid><dc:creator><![CDATA[Seve Ibarluzea]]></dc:creator><pubDate>Tue, 07 Apr 2026 20:18:50 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!O-9F!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>After we run a <a href="https://blog.autorouting.com/p/hypergraph-autorouting">HyperGraph Autorouter</a>, we&#8217;re left with a &#8220;high level plan&#8221; on how to route our circuit board. HyperGraph multi-path pathfinders are great at minimizing the number of trace intersections using the space on the board- but they suffer from the same issue that almost all sequential path finders suffer from: they are highly sensitive to the order you choose to route traces in.</p><p>We do many tricks to reduce the impact of ordering, such as building congestion maps and using rip&#8217;n&#8217;replace, but at the end of the day there are just too many possible orderings, for a simple board with 50 traces, there are 30,414,093,201,713,378,043,612,608,166,064,768,844,377,641,568,960,512,000,000,000,000 possible ways to order the traces. You&#8217;re not going to enumerate that!</p><p>So what can we do? Enter the Unravel Algorithm.</p><h2>Unraveling a HyperGraph</h2><p>The unraveling algorithm takes an existing hypergraph, or a section of an existing hypergraph, and asks &#8220;what would happen if I swapped the assignment of ports at the boundary between regions?&#8221; This swap is a &#8220;mutation&#8221;, and our goal with the unravel algorithm is to improve small sections by finding small sets of mutations that reduce the number of via-causing intersections.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!O-9F!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!O-9F!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png 424w, https://substackcdn.com/image/fetch/$s_!O-9F!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png 848w, https://substackcdn.com/image/fetch/$s_!O-9F!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png 1272w, https://substackcdn.com/image/fetch/$s_!O-9F!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!O-9F!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png" width="1456" height="765" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:765,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1385300,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/193503717?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!O-9F!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png 424w, https://substackcdn.com/image/fetch/$s_!O-9F!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png 848w, https://substackcdn.com/image/fetch/$s_!O-9F!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png 1272w, https://substackcdn.com/image/fetch/$s_!O-9F!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c07f0fa-6465-4ff3-9402-43167aabcb57_4416x2320.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Unravelling uses A* and tracks a &#8220;path&#8221; of mutations. If a mutation path is winning, it continues to follow it. If a mutation path gets long or isn&#8217;t yielding wins, then it is pushed to the back of the queue.</p><p>Because unraveling can work on sections of a HyperGraph, it can execute in parallel and even has the possibility of recalling cached graphs. We&#8217;re able to correct all the &#8220;criss-crossing&#8221; that would have made for a messy, via-heavy high density route.</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;5b03c847-7216-4546-b02e-30eeb0220fed&quot;,&quot;duration&quot;:null}"></div><p>Because there is often a port at each layer of the PCB on each point, layer swapping is built in. Where it&#8217;s possible to swap to a different layer to avoid vias way later in our path, our mutation will apply it.</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;f7f5ccc7-dfe0-40fc-b4fd-c31dc165cf2c&quot;,&quot;duration&quot;:null}"></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Xzne!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1500140d-b45d-46da-9de5-437f694e3cc6_3746x2469.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Xzne!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1500140d-b45d-46da-9de5-437f694e3cc6_3746x2469.png 424w, https://substackcdn.com/image/fetch/$s_!Xzne!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1500140d-b45d-46da-9de5-437f694e3cc6_3746x2469.png 848w, https://substackcdn.com/image/fetch/$s_!Xzne!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1500140d-b45d-46da-9de5-437f694e3cc6_3746x2469.png 1272w, https://substackcdn.com/image/fetch/$s_!Xzne!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1500140d-b45d-46da-9de5-437f694e3cc6_3746x2469.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Xzne!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1500140d-b45d-46da-9de5-437f694e3cc6_3746x2469.png" width="1456" height="960" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1500140d-b45d-46da-9de5-437f694e3cc6_3746x2469.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:960,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1150007,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/193503717?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1500140d-b45d-46da-9de5-437f694e3cc6_3746x2469.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Xzne!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1500140d-b45d-46da-9de5-437f694e3cc6_3746x2469.png 424w, https://substackcdn.com/image/fetch/$s_!Xzne!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1500140d-b45d-46da-9de5-437f694e3cc6_3746x2469.png 848w, https://substackcdn.com/image/fetch/$s_!Xzne!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1500140d-b45d-46da-9de5-437f694e3cc6_3746x2469.png 1272w, https://substackcdn.com/image/fetch/$s_!Xzne!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1500140d-b45d-46da-9de5-437f694e3cc6_3746x2469.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Our routes are now ready for high-density routing with the lowest number of vias.</p><h2>Conclusion</h2><p>The Unravel algorithm enables adjustments to global pathing to minimize the complexity of high density routing and reduce the impact of trace ordering on global pathing. It&#8217;s a highly parallelizable algorithm that can do no harm because it only accepts beneficial mutations.</p><p>If you&#8217;re interested in contributing to our autorouter or attempting some difficult algorithms, join the <a href="https://tscircuit.com/join">tscircuit discord</a> or yell at me <a href="https://x.com/seveibar">on twitter</a>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.autorouting.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Hear about more autorouting algorithms!</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Sequential Optimal Packing for PCB Placement]]></title><description><![CDATA[A simple deterministic packing strategy that benefits from feedback loops]]></description><link>https://blog.autorouting.com/p/sequential-optimal-packing-for-pcb</link><guid isPermaLink="false">https://blog.autorouting.com/p/sequential-optimal-packing-for-pcb</guid><dc:creator><![CDATA[Seve Ibarluzea]]></dc:creator><pubDate>Wed, 01 Apr 2026 19:23:02 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!NbDr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Placing chips on a PCB is a difficult and consequential task. The way you place chips dramatically impacts how difficult it will be to route the PCB. There are signal integrity and power management issues with creating long paths between different components. The size of the PCB or where ports appear often is a design requirement that has to be considered and in some cases- pushed back on.</p><p>How does automatic placement fare? If you use a regular packing algorithm that minimizes the space usage, you will create a board that is nearly impossible to route. If you use a force-directed packing, where the netlist forms springs that pull chips close together based on their connections, you&#8217;ll get an unusual shape and suffer local minimums (it&#8217;s also wildly unpredictable)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NbDr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NbDr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png 424w, https://substackcdn.com/image/fetch/$s_!NbDr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png 848w, https://substackcdn.com/image/fetch/$s_!NbDr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png 1272w, https://substackcdn.com/image/fetch/$s_!NbDr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NbDr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png" width="1456" height="836" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:836,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:71232,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/192874110?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!NbDr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png 424w, https://substackcdn.com/image/fetch/$s_!NbDr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png 848w, https://substackcdn.com/image/fetch/$s_!NbDr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png 1272w, https://substackcdn.com/image/fetch/$s_!NbDr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42fe8350-ad89-4328-aedd-be50608ca90c_1502x862.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">An example component placement, considering the direct-path length of each trace that will need to be created</figcaption></figure></div><p>When we&#8217;re thinking about packing algorithms, the first concern should be capturing human design requirements. The algorithm should, as closely as possible, understand statements like:</p><ul><li><p>The USB port must be 2mm from the left edge on the top side</p></li><li><p>The decoupling capacitors must be near the power pins on the microcontroller</p></li><li><p>The left and right headers must be spaced 20mm apart, and aligned</p></li><li><p>Copy the placement from the datasheet EXACTLY for this subcircuit</p></li></ul><p>How do we capture these requirements? In tscircuit, they are captured through <code>&lt;group&gt;/&lt;subcircuit&gt;</code> tags with different <code>layoutMode</code> properties, also coordinate specifications like <code>pcbLeftEdgeX=calc(board.minx + 2mm)</code>. In some cases, the entire layout can be resolved by ordering the computations properly, but more often than not, this way of specification is arduous for the user and inflexible as a design grows.</p><p>For underspecified placements,  Sequential Optimal Packing is a fast, deterministic and legible solution for packing. It allows us to capture &#8220;flexible&#8221; design constraints in a predictable way.</p><h2>Sequential Optimal Packing</h2><p>Sequential Optimal packing sequentially packs chips in the Pack Order. Each time it packs a new chip, it selects the Optimal position based on the Cost Function. The Cost Function is established from the design intent for that specific chip.</p><p>Here&#8217;s the algorithm in a nutshell:</p><ul><li><p>Order your chips in the Pack Order</p></li><li><p>If there are no preplaced chips, pack the first chip in the center</p></li><li><p>Main Loop:</p><ul><li><p>Pick the next chip</p></li><li><p>Find the optimal placement and rotation for that chip and place</p></li><li><p>Repeat until all chips are packed</p></li></ul></li></ul><p>Simple!</p><p>This algorithm can be made fast because you can quickly compute a boundary along our existing packed chips and pads, then find the Cost Function minimum along each segment of the boundary. </p><p>In the animation below, you can see the algorithm in action. The lines from pin to pad help show what the components of the Cost Function are. You can think of the Cost Function as &#8220;summing&#8221; the lengths of all the lines or taking the minimum of all the line lengths as the cost.</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;1547ecf2-62bb-46e7-82d5-ab38940a270a&quot;,&quot;duration&quot;:null}"></div><h2>Sequential Optimal Packing is great</h2><p>Sequential optimal packing is easy to understand and visualize. You can easily watch each component pack one by one and vary the pack order or optimal packing function to achieve a desired outcome. Every individual packing decision is easy to understand.</p><p>If you are using tscircuit, you can debug the packing algorithm using the &#8220;Solvers&#8221; tab.</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;fbf5ba9a-1caf-48cf-b41c-57195233ca51&quot;,&quot;duration&quot;:null}"></div><p>Sequential optimal packing is also extremely compatible with other layout mechanisms, like when you want to have a group of components that are in a reference configuration (from a datasheet) but should be packed together. You can also layout pre-computed positions before you begin packing- it&#8217;s compatible with partially packed existing layouts.</p><h2>Downsides</h2><p>Sequential optimal packing is flawed in two major ways:</p><ul><li><p>The best pack order is not initially obvious, early chips can be placed such that later chips don&#8217;t pack well</p></li><li><p>Sometimes the global optimal placement is impossible, because it requires two chips to be packed in locally sub-optimal positions</p></li></ul><p>Both of these issues can be mitigated by treating sequential optimal placements as an initial approximation, then refining by &#8220;hardening&#8221; constraints. e.g. if you know you want a decoupling capacitor in an exact position relative to a chip, encode that such that the chip and decoupling capacitor are packed together. LLM loops can easily adapt the design intent representation to do this!</p><h2>Conclusion</h2><p>Sequential Optimal Packing is one of the key algorithms that should be included in the standard constraint algorithms for PCB design. It is highly debuggable, easy to understand, and can be tweaked in a feedback loop until you reach a global optimal placement. It should be a fundamental algorithm, similar to flexbox or CSS Grid, baked into every PCB engine.</p><p>If you&#8217;re interested in algorithm development, join <a href="https://tscircuit.com/join">our discord</a> or follow me on <a href="https://x.com/seveibar">twitter</a>.</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.autorouting.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading autorouting! Subscribe for free to receive new posts.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><p></p>]]></content:encoded></item><item><title><![CDATA[Caching algorithms without knowing how they work]]></title><description><![CDATA[Everything worth computing is worth caching. Using vector similarity and synthetic problem generation to discover efficient hidden solution topologies]]></description><link>https://blog.autorouting.com/p/caching-algorithms-without-knowing</link><guid isPermaLink="false">https://blog.autorouting.com/p/caching-algorithms-without-knowing</guid><dc:creator><![CDATA[Seve Ibarluzea]]></dc:creator><pubDate>Sat, 28 Mar 2026 21:55:42 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!GSS5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Here&#8217;s an interesting idea: You have an algorithm. It works but it&#8217;s slow. When you look at the solutions, you notice there&#8217;s commonality in a way that&#8217;s a bit difficult to describe. If the algorithm just knew it had solved a similar problem hundreds of times before, it could just recall that solution and &#8220;adapt&#8221; it a bit.</p><p>This is the situation we&#8217;re in with autorouting. We have a many similar solutions, but we don&#8217;t yet have a mechanism to retrieve those solutions and apply them to similar problems. More importantly, we don&#8217;t know how many of these solutions we would need to store to have something effective.</p><p>If you naively &#8220;cache&#8221; the exact coordinates of every pad, every hole and every required trace, you will find that you&#8217;ve stored terabytes of useless data- after all, every circuit board is unique and any slight change breaks the cache. If you store circuits lossy however, say by only storing the netlist and footprints, you&#8217;re likely to have a solution that is unusable as components are moved around.</p><p>So what do you store? How do you look up what you&#8217;ve stored? How do you apply it to a unique dataset?</p><h2>Our Case Study: Zero-Obstacle Autorouting</h2><p>We&#8217;re going to study an approach to caching algorithms through the lens of the &#8220;zero-obstacle autorouting&#8221; problem, which is the most pure form of &#8220;the autorouting problem&#8221;. For the <a href="https://github.com/tscircuit/tscircuit-autorouter">tscircuit autorouter</a>, this is also the slowest phase of our autorouter and runs just after <a href="https://blog.autorouting.com/p/hypergraph-autorouting">HyperGraph Autorouting</a>. It is the algorithm that runs on &#8220;open space&#8221; in a PCB where there are no pads, holes or keepout obstacles.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GSS5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GSS5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png 424w, https://substackcdn.com/image/fetch/$s_!GSS5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png 848w, https://substackcdn.com/image/fetch/$s_!GSS5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png 1272w, https://substackcdn.com/image/fetch/$s_!GSS5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GSS5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png" width="1184" height="612" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:612,&quot;width&quot;:1184,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:71861,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/192437686?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GSS5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png 424w, https://substackcdn.com/image/fetch/$s_!GSS5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png 848w, https://substackcdn.com/image/fetch/$s_!GSS5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png 1272w, https://substackcdn.com/image/fetch/$s_!GSS5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1fa94920-c0dd-4610-8106-66707c57a053_1184x612.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">An example of a zero-obstacle autorouting problem and solution. The dashed lines represent the bottom layer, the circles represent vias.</figcaption></figure></div><h2>Thinking of problems as vectors</h2><p>The first, most important problem to solve is the representation of the problem. Our problem representation gives us a clear insight into the &#8220;problem space&#8221;. The problem space is basically the number of unique problems that exist. In general, if you need more numbers or more data, the problem space is really big.</p><p>So let&#8217;s start by breaking down the problem into a vector, using as little data as possible. Sometimes to reduce the data representing a problem, you can &#8220;project&#8221; into a problem space that is more constrained. For example, instead of storing X and Y for each coordinate, we can just store the angle relative to the origin and the overall size of the problem. This great simplifies our representation of the problem, we now can represent each point of our problem with (angle, z) instead of (x,y,z)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TpdL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf25102-861f-4dae-9728-25c71b054408_2186x1006.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TpdL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf25102-861f-4dae-9728-25c71b054408_2186x1006.png 424w, https://substackcdn.com/image/fetch/$s_!TpdL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf25102-861f-4dae-9728-25c71b054408_2186x1006.png 848w, https://substackcdn.com/image/fetch/$s_!TpdL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf25102-861f-4dae-9728-25c71b054408_2186x1006.png 1272w, https://substackcdn.com/image/fetch/$s_!TpdL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf25102-861f-4dae-9728-25c71b054408_2186x1006.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TpdL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf25102-861f-4dae-9728-25c71b054408_2186x1006.png" width="1456" height="670" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3bf25102-861f-4dae-9728-25c71b054408_2186x1006.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:670,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:439387,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/192437686?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf25102-861f-4dae-9728-25c71b054408_2186x1006.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TpdL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf25102-861f-4dae-9728-25c71b054408_2186x1006.png 424w, https://substackcdn.com/image/fetch/$s_!TpdL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf25102-861f-4dae-9728-25c71b054408_2186x1006.png 848w, https://substackcdn.com/image/fetch/$s_!TpdL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf25102-861f-4dae-9728-25c71b054408_2186x1006.png 1272w, https://substackcdn.com/image/fetch/$s_!TpdL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bf25102-861f-4dae-9728-25c71b054408_2186x1006.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Projecting our points onto a simpler, more constrained, problem space by looking at it&#8217;s angle relative to the origin. We now can store the problem with less numbers- which is useful later!</figcaption></figure></div><p>Trying to find ways to compress the problem space is a great exercise in exploring &#8220;what is actually important&#8221; for your problem. When we convert this problem into angles, we constrain the problem space. We can no longer handle points that have the same angle but are different distances from the origin- however, we never needed that problem space to begin with! We always organize points on the edge of a rect, so this is a GOOD constraint. If you can reduce the problem space to avoid invalid representations being possible, that is worth exploring!! </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Hm2J!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa38d71b9-0933-4168-81dc-e923ac8483d7_4111x2815.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Hm2J!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa38d71b9-0933-4168-81dc-e923ac8483d7_4111x2815.png 424w, https://substackcdn.com/image/fetch/$s_!Hm2J!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa38d71b9-0933-4168-81dc-e923ac8483d7_4111x2815.png 848w, https://substackcdn.com/image/fetch/$s_!Hm2J!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa38d71b9-0933-4168-81dc-e923ac8483d7_4111x2815.png 1272w, https://substackcdn.com/image/fetch/$s_!Hm2J!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa38d71b9-0933-4168-81dc-e923ac8483d7_4111x2815.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Hm2J!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa38d71b9-0933-4168-81dc-e923ac8483d7_4111x2815.png" width="1456" height="997" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a38d71b9-0933-4168-81dc-e923ac8483d7_4111x2815.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:997,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1507086,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/192437686?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa38d71b9-0933-4168-81dc-e923ac8483d7_4111x2815.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Hm2J!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa38d71b9-0933-4168-81dc-e923ac8483d7_4111x2815.png 424w, https://substackcdn.com/image/fetch/$s_!Hm2J!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa38d71b9-0933-4168-81dc-e923ac8483d7_4111x2815.png 848w, https://substackcdn.com/image/fetch/$s_!Hm2J!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa38d71b9-0933-4168-81dc-e923ac8483d7_4111x2815.png 1272w, https://substackcdn.com/image/fetch/$s_!Hm2J!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa38d71b9-0933-4168-81dc-e923ac8483d7_4111x2815.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Vector Distance and Canonicalization</h2><p>Now that we can think of our problems as vectors, it becomes possible to compute a &#8220;vector distance&#8221; between two problems. But before we get excited, we need to consider the type of similarity we&#8217;re interested in. We&#8217;re interested in a special kind of similarity, where two problems are similar only if they can share the same solution with some &#8220;tweaking&#8221;. We can&#8217;t just naively take the difference between each number in the vector and add up the differences, we have to find a more complex vector difference function that is tuned to return low distances for problems that can share a solution.</p><p>The &#8220;gotcha&#8221; of similarity functions in geometric spaces is you don&#8217;t really know if you&#8217;re comparing &#8220;apples to apples&#8221; when you&#8217;re comparing two parts of the vector. For our case-study, if we compare the two numbers in the array, we don&#8217;t know which two points we&#8217;re comparing. We might could have the exact same problem but with a totally different point order. The problems would appear to be very distant when we take the vector difference even though they share the exact same solution!</p><p>This is where the notion of &#8220;Geometric Canonicalization&#8221; comes in. This is where we sort or rearrange our vectors in a way that ensures we&#8217;re always comparing &#8220;apples to apples&#8221;. In our case, we can simple sort points by making the &#8220;lowest z, then lowest angles come first&#8221; Canonicalization can often create issues. For example in our case two angles may be very close together but sort such that they&#8217;re very far apart- like 0&#176; and 359&#176;. These issues can be mitigated elsewhere or absorbed into the size of the cache.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4rxi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f2bebe1-c05e-44c2-be0c-18200865d758_1798x992.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4rxi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f2bebe1-c05e-44c2-be0c-18200865d758_1798x992.png 424w, https://substackcdn.com/image/fetch/$s_!4rxi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f2bebe1-c05e-44c2-be0c-18200865d758_1798x992.png 848w, https://substackcdn.com/image/fetch/$s_!4rxi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f2bebe1-c05e-44c2-be0c-18200865d758_1798x992.png 1272w, https://substackcdn.com/image/fetch/$s_!4rxi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f2bebe1-c05e-44c2-be0c-18200865d758_1798x992.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4rxi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f2bebe1-c05e-44c2-be0c-18200865d758_1798x992.png" width="1456" height="803" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1f2bebe1-c05e-44c2-be0c-18200865d758_1798x992.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:803,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:147716,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/192437686?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f2bebe1-c05e-44c2-be0c-18200865d758_1798x992.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!4rxi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f2bebe1-c05e-44c2-be0c-18200865d758_1798x992.png 424w, https://substackcdn.com/image/fetch/$s_!4rxi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f2bebe1-c05e-44c2-be0c-18200865d758_1798x992.png 848w, https://substackcdn.com/image/fetch/$s_!4rxi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f2bebe1-c05e-44c2-be0c-18200865d758_1798x992.png 1272w, https://substackcdn.com/image/fetch/$s_!4rxi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f2bebe1-c05e-44c2-be0c-18200865d758_1798x992.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Messing up the point order can increase the distance even if problems are identical, canonicalization fixes this!</figcaption></figure></div><p>Ultimately, techniques like canonicalization and complex vector distance functions trade runtime for cache size. In our case, I knew we could reasonably handle 1 million entries in our cache, so we tuned our similarity functions and tweaking functions (which we&#8217;ll discuss below) until we had the runtime and cache-space tradeoff best for the autorouter.</p><h2>Putting square pegs in square-ish holes (the &#8220;adapt&#8221; function)</h2><p>When you have a &#8220;lossy&#8221; cache, you need to be able to pull a solution that may not be perfect and adapt it to the current problem. You can think of this as the &#8220;reverse cache transform&#8221; or the &#8220;adapt function&#8221;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6Y75!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31333342-26f8-4c16-9be0-24dcdedbeee0_1774x806.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6Y75!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31333342-26f8-4c16-9be0-24dcdedbeee0_1774x806.png 424w, https://substackcdn.com/image/fetch/$s_!6Y75!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31333342-26f8-4c16-9be0-24dcdedbeee0_1774x806.png 848w, https://substackcdn.com/image/fetch/$s_!6Y75!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31333342-26f8-4c16-9be0-24dcdedbeee0_1774x806.png 1272w, https://substackcdn.com/image/fetch/$s_!6Y75!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31333342-26f8-4c16-9be0-24dcdedbeee0_1774x806.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6Y75!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31333342-26f8-4c16-9be0-24dcdedbeee0_1774x806.png" width="1456" height="662" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/31333342-26f8-4c16-9be0-24dcdedbeee0_1774x806.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:662,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:60691,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/192437686?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31333342-26f8-4c16-9be0-24dcdedbeee0_1774x806.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6Y75!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31333342-26f8-4c16-9be0-24dcdedbeee0_1774x806.png 424w, https://substackcdn.com/image/fetch/$s_!6Y75!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31333342-26f8-4c16-9be0-24dcdedbeee0_1774x806.png 848w, https://substackcdn.com/image/fetch/$s_!6Y75!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31333342-26f8-4c16-9be0-24dcdedbeee0_1774x806.png 1272w, https://substackcdn.com/image/fetch/$s_!6Y75!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31333342-26f8-4c16-9be0-24dcdedbeee0_1774x806.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The reverse cache transform should execute quickly, because it is a runtime penalty. It should check and fail if it&#8217;s unable to adapt a solution, because this signals that a different cache entry should be used or generated. Later, we&#8217;ll use the adapt function to avoid populating our cache with entries that don&#8217;t improve the overall system accuracy.</p><p>Below, our &#8220;force-directed&#8221; adaption increases the &#8220;reusability&#8221; of cached entries by allowing them to tolerate shifting of problem points without DRC checks. This is a very simple and fast way to adapt a solution to a new problem.</p><p></p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;f930edab-94b0-4506-9a89-22de0df0192b&quot;,&quot;duration&quot;:null}"></div><p></p><h2>Synthetic problem generation &#8594; Optimal Cache</h2><p>For the zero-obstacle routing problem, we were able to generate a cache with 4,000 entries that can solve 99.9% of 4-trace problems. But to do this, we had to generate over 1 million synthetic problems to test on.</p><p>Because we don&#8217;t completely understand the underlying algorithm and what &#8220;hidden&#8221; solution topologies exist, we have to keep throwing random solutions at the cache to see what is solvable and what needs a new cache entry. After doing this for hours, we eventually start to see less and less DRC (design rule check) failures on our cache-adapted samples.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JQxl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67e6193a-e394-4123-a507-3ac4c9ecef05_1822x692.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JQxl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67e6193a-e394-4123-a507-3ac4c9ecef05_1822x692.png 424w, https://substackcdn.com/image/fetch/$s_!JQxl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67e6193a-e394-4123-a507-3ac4c9ecef05_1822x692.png 848w, https://substackcdn.com/image/fetch/$s_!JQxl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67e6193a-e394-4123-a507-3ac4c9ecef05_1822x692.png 1272w, https://substackcdn.com/image/fetch/$s_!JQxl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67e6193a-e394-4123-a507-3ac4c9ecef05_1822x692.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JQxl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67e6193a-e394-4123-a507-3ac4c9ecef05_1822x692.png" width="1456" height="553" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/67e6193a-e394-4123-a507-3ac4c9ecef05_1822x692.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:553,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:296120,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/192437686?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67e6193a-e394-4123-a507-3ac4c9ecef05_1822x692.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JQxl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67e6193a-e394-4123-a507-3ac4c9ecef05_1822x692.png 424w, https://substackcdn.com/image/fetch/$s_!JQxl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67e6193a-e394-4123-a507-3ac4c9ecef05_1822x692.png 848w, https://substackcdn.com/image/fetch/$s_!JQxl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67e6193a-e394-4123-a507-3ac4c9ecef05_1822x692.png 1272w, https://substackcdn.com/image/fetch/$s_!JQxl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67e6193a-e394-4123-a507-3ac4c9ecef05_1822x692.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Every iteration we generate a problem, then test it against our cache and adapt function, if the solution passes DRC checks, we know our cache is effective, otherwise we generate a new entry</figcaption></figure></div><p>This is why synthetic datasets are so valuable. If solving a problem as simple as a 10x10mm square with 4 traces takes a million samples, then there isn&#8217;t enough human data in the world to tune an autorouting algorithm on a full board!</p><h2>K-Nearest Neighbor, Shrink the cache for a slower runtime</h2><p>The &#8220;Nearest Neighbor&#8221; is a super simple algorithm where you say &#8220;What data point is closest to the data point I&#8217;ve been presented with?&#8221; and return it. That is essentially what we&#8217;re doing- we measure what is &#8220;closest&#8221; with vector distance, and return the nearest solution. A well-known adaption to nearest neighbor is to take the K nearest neighbors instead of just the nearest neighbor. Each of these neighbors also &#8220;looks similar&#8221; to the problem at hand and is worth trying.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yBvx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d7a2353-7139-47cc-a4e5-b77e55235076_1702x1266.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yBvx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d7a2353-7139-47cc-a4e5-b77e55235076_1702x1266.png 424w, https://substackcdn.com/image/fetch/$s_!yBvx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d7a2353-7139-47cc-a4e5-b77e55235076_1702x1266.png 848w, https://substackcdn.com/image/fetch/$s_!yBvx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d7a2353-7139-47cc-a4e5-b77e55235076_1702x1266.png 1272w, https://substackcdn.com/image/fetch/$s_!yBvx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d7a2353-7139-47cc-a4e5-b77e55235076_1702x1266.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yBvx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d7a2353-7139-47cc-a4e5-b77e55235076_1702x1266.png" width="643" height="478.2754120879121" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7d7a2353-7139-47cc-a4e5-b77e55235076_1702x1266.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1083,&quot;width&quot;:1456,&quot;resizeWidth&quot;:643,&quot;bytes&quot;:171071,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/192437686?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d7a2353-7139-47cc-a4e5-b77e55235076_1702x1266.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!yBvx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d7a2353-7139-47cc-a4e5-b77e55235076_1702x1266.png 424w, https://substackcdn.com/image/fetch/$s_!yBvx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d7a2353-7139-47cc-a4e5-b77e55235076_1702x1266.png 848w, https://substackcdn.com/image/fetch/$s_!yBvx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d7a2353-7139-47cc-a4e5-b77e55235076_1702x1266.png 1272w, https://substackcdn.com/image/fetch/$s_!yBvx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d7a2353-7139-47cc-a4e5-b77e55235076_1702x1266.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">This is what K-Nearest Neighbors looks like in 2 dimensional space. In practice, we&#8217;re in a high dimensional space, a 4 trace zero-obstacle problem should have 9-18 dimensions- depending on your representation.</figcaption></figure></div><p>The benefit of K-nearest neighbor is you can get away with having a smaller cache and just pay higher runtime costs, since you have to adapt K neighbors instead of 1. In our case, we set K=16 because the runtime overhead didn&#8217;t cause much of a delay and our accuracy jumped up considerably with a smaller cache, making it so users can run the autorouter on their local machine. This is another knob to play with- sometimes storage is preferable, e.g. where you have a cloud machine backed by a massive KV store.</p><h2>Exploit geometric symmetry (shrink the cache by 16x!)</h2><p>The zero-obstacle routing problem has a lot of symmetry you can exploit. Symmetry means that a transformed version of the problem has the same solution, transformed. For example, negating all the X coordinates (flipping over the X axis) produces a problem that has the same solution just flipped over the X axis.</p><p>Each &#8220;axis of symmetry&#8221; halves the cache space you need to represent the problem. In our case, we can exploit this to reduce the cache size by 16x- meaning we only need to store 6% as many solutions in our cache. Here are the axes we exploit:</p><ul><li><p>Rotating the problem by 90 degrees</p></li><li><p>Flipping over the X axis</p></li><li><p>Flipping over the Y Axis</p></li><li><p>Inverting the Z Layers (Top becomes bottom, bottom becomes top)</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Koro!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe7ddbc1-9c00-460c-826d-948cf68248fb_1436x1614.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Koro!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe7ddbc1-9c00-460c-826d-948cf68248fb_1436x1614.png 424w, https://substackcdn.com/image/fetch/$s_!Koro!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe7ddbc1-9c00-460c-826d-948cf68248fb_1436x1614.png 848w, https://substackcdn.com/image/fetch/$s_!Koro!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe7ddbc1-9c00-460c-826d-948cf68248fb_1436x1614.png 1272w, https://substackcdn.com/image/fetch/$s_!Koro!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe7ddbc1-9c00-460c-826d-948cf68248fb_1436x1614.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Koro!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe7ddbc1-9c00-460c-826d-948cf68248fb_1436x1614.png" width="1436" height="1614" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fe7ddbc1-9c00-460c-826d-948cf68248fb_1436x1614.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1614,&quot;width&quot;:1436,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:796589,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/192437686?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe7ddbc1-9c00-460c-826d-948cf68248fb_1436x1614.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Koro!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe7ddbc1-9c00-460c-826d-948cf68248fb_1436x1614.png 424w, https://substackcdn.com/image/fetch/$s_!Koro!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe7ddbc1-9c00-460c-826d-948cf68248fb_1436x1614.png 848w, https://substackcdn.com/image/fetch/$s_!Koro!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe7ddbc1-9c00-460c-826d-948cf68248fb_1436x1614.png 1272w, https://substackcdn.com/image/fetch/$s_!Koro!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffe7ddbc1-9c00-460c-826d-948cf68248fb_1436x1614.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">These are all the same solutions, just with different transformations applied </figcaption></figure></div><p>There are four ways to exploit symmetry:</p><ul><li><p>Store all variants in the cache (reduce cache generation time)</p></li><li><p>Check all variants at runtime (reduce cache size, increase lookup cost)</p></li><li><p>Make vector distance functions understand symmetry (less conventional/supported vector lookup)</p></li><li><p>Canonicalize to a single variant (difficult to get right!)</p></li></ul><h2>Conclusion</h2><p>This method of speeding up algorithm runtimes is fantastic because it adapts to any algorithm complexity. The framework of canonicalization, vector distance, and adaption greatly improves the efficacy of a cache and makes it possible to model complex geometric algorithms.</p><p>Here are some examples of our cache being used against generated problems:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jBTT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd722042-4a31-4d0b-ad60-31a924106db5_1982x1366.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jBTT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd722042-4a31-4d0b-ad60-31a924106db5_1982x1366.png 424w, https://substackcdn.com/image/fetch/$s_!jBTT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd722042-4a31-4d0b-ad60-31a924106db5_1982x1366.png 848w, https://substackcdn.com/image/fetch/$s_!jBTT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd722042-4a31-4d0b-ad60-31a924106db5_1982x1366.png 1272w, https://substackcdn.com/image/fetch/$s_!jBTT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd722042-4a31-4d0b-ad60-31a924106db5_1982x1366.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jBTT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd722042-4a31-4d0b-ad60-31a924106db5_1982x1366.png" width="1456" height="1003" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fd722042-4a31-4d0b-ad60-31a924106db5_1982x1366.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1003,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:501565,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/192437686?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd722042-4a31-4d0b-ad60-31a924106db5_1982x1366.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!jBTT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd722042-4a31-4d0b-ad60-31a924106db5_1982x1366.png 424w, https://substackcdn.com/image/fetch/$s_!jBTT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd722042-4a31-4d0b-ad60-31a924106db5_1982x1366.png 848w, https://substackcdn.com/image/fetch/$s_!jBTT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd722042-4a31-4d0b-ad60-31a924106db5_1982x1366.png 1272w, https://substackcdn.com/image/fetch/$s_!jBTT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd722042-4a31-4d0b-ad60-31a924106db5_1982x1366.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Example matching and adaption of a random generated problem against a 4k problem cache</figcaption></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nWKe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cdb652-a7a7-4107-8066-965034e0d21e_1702x960.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nWKe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cdb652-a7a7-4107-8066-965034e0d21e_1702x960.png 424w, https://substackcdn.com/image/fetch/$s_!nWKe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cdb652-a7a7-4107-8066-965034e0d21e_1702x960.png 848w, https://substackcdn.com/image/fetch/$s_!nWKe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cdb652-a7a7-4107-8066-965034e0d21e_1702x960.png 1272w, https://substackcdn.com/image/fetch/$s_!nWKe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cdb652-a7a7-4107-8066-965034e0d21e_1702x960.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nWKe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cdb652-a7a7-4107-8066-965034e0d21e_1702x960.png" width="1456" height="821" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c9cdb652-a7a7-4107-8066-965034e0d21e_1702x960.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:821,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:227864,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/192437686?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cdb652-a7a7-4107-8066-965034e0d21e_1702x960.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!nWKe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cdb652-a7a7-4107-8066-965034e0d21e_1702x960.png 424w, https://substackcdn.com/image/fetch/$s_!nWKe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cdb652-a7a7-4107-8066-965034e0d21e_1702x960.png 848w, https://substackcdn.com/image/fetch/$s_!nWKe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cdb652-a7a7-4107-8066-965034e0d21e_1702x960.png 1272w, https://substackcdn.com/image/fetch/$s_!nWKe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9cdb652-a7a7-4107-8066-965034e0d21e_1702x960.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Another example where the solved cache looks a bit different</figcaption></figure></div><p>If you&#8217;re interested in contributing to our autorouter or attempting some difficult algorithms, join the <a href="https://tscircuit.com/join">tscircuit discord</a> or yell at me <a href="https://x.com/seveibar">on twitter</a>. </p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.autorouting.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading! Subscribe to hear more!</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[HyperGraph Autorouting]]></title><description><![CDATA[The perfect datastructure for representing autorouting problems]]></description><link>https://blog.autorouting.com/p/hypergraph-autorouting</link><guid isPermaLink="false">https://blog.autorouting.com/p/hypergraph-autorouting</guid><dc:creator><![CDATA[Seve Ibarluzea]]></dc:creator><pubDate>Thu, 19 Mar 2026 23:26:55 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Done!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39ee623f-5416-4367-bc4e-0c5e78c20d7f_3840x2771.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>HyperGraphs are a graph construction where in addition to edges and vertices you also have &#8220;regions&#8221;. These regions allow you to have more complex pathfinding functions that help with &#8220;global routing&#8221; of circuit boards by estimating the congestion of empty areas of the board. Hopefully by the end of this article I can convince you that this is the perfect primitive and methodology for PCB autorouting.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Done!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39ee623f-5416-4367-bc4e-0c5e78c20d7f_3840x2771.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Done!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39ee623f-5416-4367-bc4e-0c5e78c20d7f_3840x2771.png 424w, https://substackcdn.com/image/fetch/$s_!Done!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39ee623f-5416-4367-bc4e-0c5e78c20d7f_3840x2771.png 848w, https://substackcdn.com/image/fetch/$s_!Done!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39ee623f-5416-4367-bc4e-0c5e78c20d7f_3840x2771.png 1272w, https://substackcdn.com/image/fetch/$s_!Done!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39ee623f-5416-4367-bc4e-0c5e78c20d7f_3840x2771.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Done!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39ee623f-5416-4367-bc4e-0c5e78c20d7f_3840x2771.png" width="508" height="366.69505494505495" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/39ee623f-5416-4367-bc4e-0c5e78c20d7f_3840x2771.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1051,&quot;width&quot;:1456,&quot;resizeWidth&quot;:508,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;undefined&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="undefined" title="undefined" srcset="https://substackcdn.com/image/fetch/$s_!Done!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39ee623f-5416-4367-bc4e-0c5e78c20d7f_3840x2771.png 424w, https://substackcdn.com/image/fetch/$s_!Done!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39ee623f-5416-4367-bc4e-0c5e78c20d7f_3840x2771.png 848w, https://substackcdn.com/image/fetch/$s_!Done!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39ee623f-5416-4367-bc4e-0c5e78c20d7f_3840x2771.png 1272w, https://substackcdn.com/image/fetch/$s_!Done!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39ee623f-5416-4367-bc4e-0c5e78c20d7f_3840x2771.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">The wikipedia image for HyperGraphs</figcaption></figure></div><p></p><h2>Why grid-based autorouters are ineffective</h2><p>Normally when people think about autorouting, they think of grids and pathfinding. This simplification is why most autorouters can only route 50-100 traces then must give up or run for days to get a solution. </p><p>A grid creates an enormous solution space size. Because traces are very thin, the cell size of your grid must be 0.05mm or 0.1mm. Each of those cells can be &#8220;assigned&#8221; to any of your nets or marked as not-connected. Then you need to replicate the grid for each layer of the circuit board. For a modest 70x50mm 4-layer board, you&#8217;re looking at 280k cells with 50 possible assignments per cell. Or 50^280_000 possible states.</p><p>Now you might argue that not all of these states are possible (e.g. they are occupied by pads, keepouts etc.), but that&#8217;s precisely why the grid is a terrible data structure for an autorouter. Great data representations only represent valid states, and as a result the algorithms that operate on them are much simpler. </p><h2>Enter HyperGraphs</h2><p>Wikipedia defines <a href="https://en.wikipedia.org/wiki/Hypergraph">HyperGraphs</a> as follows:</p><blockquote><p>In <a href="https://en.wikipedia.org/wiki/Mathematics">mathematics</a>, a <strong>hypergraph</strong> is a generalization of a <a href="https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)">graph</a> in which an <a href="https://en.wikipedia.org/wiki/Graph_theory">edge</a> can join any number of <a href="https://en.wikipedia.org/wiki/Vertex_(graph_theory)">vertices</a>. In contrast, in an ordinary graph, an edge connects exactly two vertices.</p></blockquote><p>This wide definition is more than we need, let&#8217;s focus on a subset of HyperGraphs called &#8220;2-regular HyperGraphs&#8221;. These are HyperGraphs where each vertex belongs to 2 hyperedges (regions). With a bit of effort, we can convert any PCB routing problem into a 2-regular HyperGraph where the regions represent empty space, and the vertices represent available space on the edge of regions.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RKP8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa092fbc3-e050-4b8d-be98-efc4a403303c_7664x4129.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RKP8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa092fbc3-e050-4b8d-be98-efc4a403303c_7664x4129.png 424w, https://substackcdn.com/image/fetch/$s_!RKP8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa092fbc3-e050-4b8d-be98-efc4a403303c_7664x4129.png 848w, https://substackcdn.com/image/fetch/$s_!RKP8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa092fbc3-e050-4b8d-be98-efc4a403303c_7664x4129.png 1272w, https://substackcdn.com/image/fetch/$s_!RKP8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa092fbc3-e050-4b8d-be98-efc4a403303c_7664x4129.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RKP8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa092fbc3-e050-4b8d-be98-efc4a403303c_7664x4129.png" width="1456" height="784" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a092fbc3-e050-4b8d-be98-efc4a403303c_7664x4129.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:784,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:3694793,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/191525221?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa092fbc3-e050-4b8d-be98-efc4a403303c_7664x4129.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RKP8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa092fbc3-e050-4b8d-be98-efc4a403303c_7664x4129.png 424w, https://substackcdn.com/image/fetch/$s_!RKP8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa092fbc3-e050-4b8d-be98-efc4a403303c_7664x4129.png 848w, https://substackcdn.com/image/fetch/$s_!RKP8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa092fbc3-e050-4b8d-be98-efc4a403303c_7664x4129.png 1272w, https://substackcdn.com/image/fetch/$s_!RKP8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa092fbc3-e050-4b8d-be98-efc4a403303c_7664x4129.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>We can now route through a much smaller solution space, instead of routing over a grid that takes up this entire space, we can focus on only routing over relevant &#8220;bottlenecks&#8221; that relate to obstacles likes pads. This type of pathfinding is almost instantaneous, it only takes a few iterations to get across the board!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KpyK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94c159e2-612f-4cc3-a8a4-64ad53968eca_702x1204.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KpyK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94c159e2-612f-4cc3-a8a4-64ad53968eca_702x1204.png 424w, https://substackcdn.com/image/fetch/$s_!KpyK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94c159e2-612f-4cc3-a8a4-64ad53968eca_702x1204.png 848w, https://substackcdn.com/image/fetch/$s_!KpyK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94c159e2-612f-4cc3-a8a4-64ad53968eca_702x1204.png 1272w, https://substackcdn.com/image/fetch/$s_!KpyK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94c159e2-612f-4cc3-a8a4-64ad53968eca_702x1204.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KpyK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94c159e2-612f-4cc3-a8a4-64ad53968eca_702x1204.png" width="362" height="620.8660968660969" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/94c159e2-612f-4cc3-a8a4-64ad53968eca_702x1204.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1204,&quot;width&quot;:702,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:118104,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/191525221?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94c159e2-612f-4cc3-a8a4-64ad53968eca_702x1204.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!KpyK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94c159e2-612f-4cc3-a8a4-64ad53968eca_702x1204.png 424w, https://substackcdn.com/image/fetch/$s_!KpyK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94c159e2-612f-4cc3-a8a4-64ad53968eca_702x1204.png 848w, https://substackcdn.com/image/fetch/$s_!KpyK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94c159e2-612f-4cc3-a8a4-64ad53968eca_702x1204.png 1272w, https://substackcdn.com/image/fetch/$s_!KpyK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94c159e2-612f-4cc3-a8a4-64ad53968eca_702x1204.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Routes through the ports at the border of HyperGraph regions</figcaption></figure></div><h2>HyperGraph A* </h2><p>So HyperGraph autorouters are really fast. But they don&#8217;t work quite the same as grid autorouters. In grid autorouters, doing an &#8220;occupancy check&#8221; is O(1), you simply ask &#8220;is there anything in the cell I want to move to?&#8221;. If there&#8217;s nothing there, that means you can explore it. </p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;e4886d8a-028c-4c6c-9be9-db89aeee0b16&quot;,&quot;duration&quot;:null}"></div><p>In HyperGraph Autorouting, you do something completely different. You use fast vector intersection math to check if moving through a port would trigger an intersection. This is the performance tradeoff, but it&#8217;s a good one. If your topology is set up well, you&#8217;re often not checking for intersections often, and when you do there&#8217;s only 1-2 traces to run intersection math on. Considering you can easily hop over 200 grid cells in a single iteration, this is much faster.</p><p>Here&#8217;s an animation of a HyperGraph autorouter solving how to connect 3 traces through 4 jumpers.</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;b0c00e81-4a6c-4338-9d98-8ebc341a9051&quot;,&quot;duration&quot;:null}"></div><p></p><h2>Handling Layers and Vias</h2><p>HyperGraph regions, unlike grid cells, should occupy multiple layers. This can make the &#8220;topology construction&#8221;, the step where you generate the HyperGraph from pads and obstacles, very difficult (worthy of it&#8217;s own article). Every port is duplicated for each layer it could occupy, to represent all the different ways a trace could enter a region.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Fjen!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F553f933c-fb23-40c1-8665-edd5b4899b1c_1548x1006.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Fjen!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F553f933c-fb23-40c1-8665-edd5b4899b1c_1548x1006.png 424w, https://substackcdn.com/image/fetch/$s_!Fjen!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F553f933c-fb23-40c1-8665-edd5b4899b1c_1548x1006.png 848w, https://substackcdn.com/image/fetch/$s_!Fjen!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F553f933c-fb23-40c1-8665-edd5b4899b1c_1548x1006.png 1272w, https://substackcdn.com/image/fetch/$s_!Fjen!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F553f933c-fb23-40c1-8665-edd5b4899b1c_1548x1006.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Fjen!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F553f933c-fb23-40c1-8665-edd5b4899b1c_1548x1006.png" width="1456" height="946" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/553f933c-fb23-40c1-8665-edd5b4899b1c_1548x1006.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:946,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:162683,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/191525221?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F553f933c-fb23-40c1-8665-edd5b4899b1c_1548x1006.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Fjen!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F553f933c-fb23-40c1-8665-edd5b4899b1c_1548x1006.png 424w, https://substackcdn.com/image/fetch/$s_!Fjen!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F553f933c-fb23-40c1-8665-edd5b4899b1c_1548x1006.png 848w, https://substackcdn.com/image/fetch/$s_!Fjen!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F553f933c-fb23-40c1-8665-edd5b4899b1c_1548x1006.png 1272w, https://substackcdn.com/image/fetch/$s_!Fjen!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F553f933c-fb23-40c1-8665-edd5b4899b1c_1548x1006.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">In our visualizer, we offset ports slightly for each layer. If you look carefully, you can see that the top layer has routes going through it while the bottom ports for both routes are unoccupied (gray)</figcaption></figure></div><p>Now we&#8217;re in an interesting situation. It is actually possible for routes to &#8220;intersect&#8221; within a region because a via could be placed to make the crossing possible. Instead of not allowing crossings, we instead compute a &#8220;cost&#8221; for each crossing so that A* explores routes where intersections may take place.</p><h2>Handling Zero-Obstacle Crossing Routes within a Region</h2><p>So let&#8217;s say we&#8217;ve solved our HyperGraph, but we have crossing routes within our region. What do we do?</p><p>This type of problem is called the &#8220;zero-obstacle routing problem&#8221;. It is a beautifully simple problem. You have a rect, and you have pairs of points which you must connect without them touching using vias. There are no obstacles, and you can use any cell size that&#8217;s convenient. You can use a conventional grid based solver on this small region, or you can use vector-based methods. You can even combine solvers together. The zero-obstacle problem on rects with &lt;20 traces is already known to be easy. We&#8217;ve successfully broken down the problem to a point where grid-based solvers are already known to work. In fact, you can have AI vibe-code you a decent zero-obstacle grid-based autorouter in couple minutes. Relative to full board solving, it is trivial!</p><p>Here&#8217;s a zero-obstacle A* grid-based solver in action, I got a bit impatient (there&#8217;s so much to explore!) but you can see even though it takes a lot of iterations, they&#8217;re particularly good for zero-obstacle problems and solve quickly (in clock time)</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;0e4dfcbc-4cf8-46ac-a319-a10c4b83e2a6&quot;,&quot;duration&quot;:null}"></div><h2>The perfect cost function for regions?</h2><p>When you&#8217;re autorouting boards you can slowly build up a dataset of &#8220;high density zero-obstacle&#8221; problems, each of these problems may have zero-obstacle routing problems you could or couldn&#8217;t solve with your zero-obstacle router.</p><p>If you are clever, you can compose a cost function that predicts whether or not a region is solvable, then cost appropriately so that your &#8220;HyperGraph stage&#8221; heavily penalizes regions that are unlikely to be solvable with your zero-obstacle high density problem solver (usually a grid solver)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wV42!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13a33e2b-df12-461e-b666-31b83708131f_1064x862.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wV42!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13a33e2b-df12-461e-b666-31b83708131f_1064x862.png 424w, https://substackcdn.com/image/fetch/$s_!wV42!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13a33e2b-df12-461e-b666-31b83708131f_1064x862.png 848w, https://substackcdn.com/image/fetch/$s_!wV42!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13a33e2b-df12-461e-b666-31b83708131f_1064x862.png 1272w, https://substackcdn.com/image/fetch/$s_!wV42!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13a33e2b-df12-461e-b666-31b83708131f_1064x862.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wV42!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13a33e2b-df12-461e-b666-31b83708131f_1064x862.png" width="522" height="422.8984962406015" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/13a33e2b-df12-461e-b666-31b83708131f_1064x862.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:862,&quot;width&quot;:1064,&quot;resizeWidth&quot;:522,&quot;bytes&quot;:186290,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/191525221?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13a33e2b-df12-461e-b666-31b83708131f_1064x862.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wV42!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13a33e2b-df12-461e-b666-31b83708131f_1064x862.png 424w, https://substackcdn.com/image/fetch/$s_!wV42!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13a33e2b-df12-461e-b666-31b83708131f_1064x862.png 848w, https://substackcdn.com/image/fetch/$s_!wV42!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13a33e2b-df12-461e-b666-31b83708131f_1064x862.png 1272w, https://substackcdn.com/image/fetch/$s_!wV42!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13a33e2b-df12-461e-b666-31b83708131f_1064x862.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Example region cost function based on an estimate of the max number of vias that would be required and that could fit within a region</figcaption></figure></div><p></p><h2>Conclusion</h2><p>See it all come together:</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;a288e683-1075-4c2c-a9aa-60c2ebc23dbd&quot;,&quot;duration&quot;:null}"></div><p>HyperGraphs are an incredible and underutilized way to solve autorouting problems. If you&#8217;re interested in developing open-source autorouting algorithms with us please get in touch with me (<a href="https://x.com/seveibar">seveibar</a>) via our <a href="https://tscircuit.com/join">discord</a> or <a href="mailto:contact@tscircuit.com">contact@tscircuit.com</a></p><p>Want to see the code? Check out our state-of-the-art, <a href="https://github.com/tscircuit/tscircuit-autorouter">lightening fast MIT-open-source autorouter</a>!</p>]]></content:encoded></item><item><title><![CDATA[We're releasing Z01, 1 million autorouting samples for training vision models on autorouting]]></title><description><![CDATA[Today we&#8217;re releasing Z01, 1 million autorouting input and output sample images for training vision models to autoroute 2-layer printed circuits.]]></description><link>https://blog.autorouting.com/p/were-releasing-z01-1-million-autorouting</link><guid isPermaLink="false">https://blog.autorouting.com/p/were-releasing-z01-1-million-autorouting</guid><dc:creator><![CDATA[Seve Ibarluzea]]></dc:creator><pubDate>Thu, 26 Feb 2026 07:35:10 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!U3pM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Today we&#8217;re releasing Z01, 1 million autorouting input and output sample images for training vision models to autoroute 2-layer printed circuits. You can download the <a href="https://huggingface.co/datasets/tscircuit/zero-obstacle-high-density-z01">dataset on huggingface</a>.</p><blockquote><p>Before we get into the details, huge shout out to <a href="https://x.com/makeshifted">Johnathon Selstad</a> who inspired and guided me through the process of creating this dataset, without him this would not have happened!</p></blockquote><p>This dataset was created by running <a href="https://github.com/tscircuit/high-density-a01">@tscircuit/high-density-a01</a> on 1 million randomly-created configurations of connection pairs in a 10x10mm rectangle with zero pads, keepouts or other obstacles within the rectangle.</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;8968e742-e5fe-4ecb-bd0f-5260fc80d006&quot;,&quot;duration&quot;:null}"></div><p>This dataset represents the core problem of autorouting, which is generating viable trace paths that do not cross on the same layer within a dense space. Competing concerns with obstacle avoidance, DRC compliance, impedance matching etc. all are dependent on how you solve the &#8220;multi-agent pathfinding&#8221; problem at the core of autorouting.</p><p>The purpose of this dataset is to enable the development of vision models that can prove the viability of autorouting with vision models, not to build a full autorouting pipeline or production-ready printed circuit boards.</p><p>Here is an example of input and output data from the dataset:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!U3pM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!U3pM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png 424w, https://substackcdn.com/image/fetch/$s_!U3pM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png 848w, https://substackcdn.com/image/fetch/$s_!U3pM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png 1272w, https://substackcdn.com/image/fetch/$s_!U3pM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!U3pM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png" width="1456" height="778" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:778,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:195018,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/189226023?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!U3pM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png 424w, https://substackcdn.com/image/fetch/$s_!U3pM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png 848w, https://substackcdn.com/image/fetch/$s_!U3pM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png 1272w, https://substackcdn.com/image/fetch/$s_!U3pM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0959e0dd-906a-4655-a8d3-94001ff16dce_1846x986.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The output of this autorouter, after parsing, can be input directly into the HighDensity phase of the <a href="https://github.com/tscircuit/tscircuit-autorouter">tscircuit autorouter</a>, so can be run as part of a larger autorouting pipeline.</p><p>This is far from a comprehensive autorouting dataset to cover all the edge cases and functions that are needed for a proper pipeline, but should pave the wave for researchers to determine if vision models are practical for autorouting.</p><p><a href="https://huggingface.co/datasets/tscircuit/zero-obstacle-high-density-z01">Hugging Face</a> &#12539;<a href="https://tscircuit.com/join">Discord</a></p><p>- <a href="https://x.com/seveibar">@seveibar</a></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.autorouting.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">We love autorouting. Do you&#8230; love autorouting?</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[13 things I would have told myself before building an autorouter]]></title><description><![CDATA[Important lessons from trying to build the world's fastest autorouter for about a year]]></description><link>https://blog.autorouting.com/p/13-things-i-would-have-told-myself</link><guid isPermaLink="false">https://blog.autorouting.com/p/13-things-i-would-have-told-myself</guid><dc:creator><![CDATA[Seve Ibarluzea]]></dc:creator><pubDate>Fri, 28 Mar 2025 00:37:30 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c9da8e1-4e35-4cf8-9b56-f6f1d7f7ed3f_1536x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I&#8217;ve spent about a year working on an autorouter for <a href="https://tscircuit.com">tscircuit</a> (an open-source electronics CAD kernel written in Typescript). If I could go back a year, these are the 13 things I would tell myself:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wuEp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc47a4ad2-a5e8-45fe-a96b-3a6ea491aa0f_2586x1336.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wuEp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc47a4ad2-a5e8-45fe-a96b-3a6ea491aa0f_2586x1336.png 424w, https://substackcdn.com/image/fetch/$s_!wuEp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc47a4ad2-a5e8-45fe-a96b-3a6ea491aa0f_2586x1336.png 848w, https://substackcdn.com/image/fetch/$s_!wuEp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc47a4ad2-a5e8-45fe-a96b-3a6ea491aa0f_2586x1336.png 1272w, https://substackcdn.com/image/fetch/$s_!wuEp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc47a4ad2-a5e8-45fe-a96b-3a6ea491aa0f_2586x1336.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wuEp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc47a4ad2-a5e8-45fe-a96b-3a6ea491aa0f_2586x1336.png" width="1456" height="752" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c47a4ad2-a5e8-45fe-a96b-3a6ea491aa0f_2586x1336.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:752,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!wuEp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc47a4ad2-a5e8-45fe-a96b-3a6ea491aa0f_2586x1336.png 424w, https://substackcdn.com/image/fetch/$s_!wuEp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc47a4ad2-a5e8-45fe-a96b-3a6ea491aa0f_2586x1336.png 848w, https://substackcdn.com/image/fetch/$s_!wuEp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc47a4ad2-a5e8-45fe-a96b-3a6ea491aa0f_2586x1336.png 1272w, https://substackcdn.com/image/fetch/$s_!wuEp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc47a4ad2-a5e8-45fe-a96b-3a6ea491aa0f_2586x1336.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">An intermediate stage of our autorouting routing a keyboard.</figcaption></figure></div><p></p><h2>1. Know A* like the back of your hand, use it everywhere</h2><p>If I was king for a day, I would rename A* to &#8220;Fundamental Algorithm&#8221;. It is truly one of the most adaptable and important algorithms for _any kind_ of search. It is simply the best foundation for any kind of informed search (not just for 2d grids!)</p><p>Here&#8217;s an animated version of A* versus &#8220;breadth first search&#8221; on a 2d grid:</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;9141f1eb-bb8c-4ea9-b69d-184fd9159026&quot;,&quot;duration&quot;:null}"></div><p>The way A* explores nodes is a lot faster and more intuitive. The major difference between these two algorithms is BFS explores all adjacent nodes, while A* prioritizes exploring nodes that are closer to the destination. Because it considers a metric outside the graph (the distance to the destination) it&#8217;s an <em>informed search</em>.</p><p><strong>You are already either using BFS or DFS (depth-first search) in your code.</strong> A recursive algorithm is a depth first search. Any loop that explores candidates/neighbors without sorting the candidates is a BFS. <strong>99% of the time you can convert it to A* and get dramatic performance gains!</strong></p><p>One of my favorite techniques in our autorouter is we run multiple levels of A* to discover the optimal hyperparameters for a particular problem. So we&#8217;re basically running each autorouter as a candidate, then using A* to determine which autorouters we should spend the most time on!</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;d8315356-3cff-4dfd-a1f5-74eeb3bf726b&quot;,&quot;duration&quot;:null}"></div><p>See all those numbers at the top? Those are each different configurations of hyper parameters. Running each autorouter fairly would be a huge waste of time- if one autorouter starts to win (it is successfully routing with good costs) allocate more iterations to it! This kind of meta-A* combines a regular cost function that penalizes distance with a cost function that penalizes iterations.</p><h2>2. Implementation Language doesn&#8217;t matter</h2><p>I&#8217;m controversially writing our autorouter in Javascript. This is the first thing people call out, but it&#8217;s not as unreasonable as you might expect. Consider that when optimizing an algorithm, you&#8217;re basically looking at improving two things:</p><ol><li><p>Lowering the number of iterations required (make the algorithm smart)</p></li><li><p>Increasing the speed of each iteration</p></li></ol><p>People focus <em>way too much</em> on improving the speed of each iteration. If you are doing something dumb (like converting everything to a grid for overlap testing), Javascript performance will beat you no matter what language you use!</p><div class="pullquote"><p>Dumb algorithms in optimal assembly <em>are slower than smart algorithms in Javascript! <strong>Algorithm &gt; Language!</strong></em></p></div><p>95% of your focus should be on reducing the number of iterations. This is why language doesn&#8217;t matter. Whatever gets you to the smartest, most cacheable algorithm fastest is the best language.</p><h2>3. Spatial Hash Indexing &gt; Tree Data Structures</h2><p>You can&#8217;t walk 5 feet into multi-dimensional space optimization without someone mentioning a QuadTree, this incredible data structure that makes <code>O(N)</code> search <code>O(log(N))</code> when searching for nearby objects in 2d/3d space.</p><p><strong>The QuadTree and every general-purpose tree data structure are insanely slow.</strong> <strong>Trees are not an informed representation of your data.</strong></p><div class="pullquote"><p>Any time you&#8217;re using a tree you&#8217;re ignoring an  <code>O(~1)</code> hash algorithm for a more complicated <code>O(log(N))</code> algorithm</p></div><p>Why does Javascript use HashSets and HashMaps by default and every chance it gets? <strong>They&#8217;re super super fast. </strong>A Spatial Hash Index is the same concept as a HashMap, but instead of hashing the object we hash it&#8217;s location and store it in a Cell (or &#8220;bucket of things that are close together&#8221;)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1QLF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0140680c-0a0d-4ca8-9691-ecdbe4d72059_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1QLF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0140680c-0a0d-4ca8-9691-ecdbe4d72059_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!1QLF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0140680c-0a0d-4ca8-9691-ecdbe4d72059_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!1QLF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0140680c-0a0d-4ca8-9691-ecdbe4d72059_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!1QLF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0140680c-0a0d-4ca8-9691-ecdbe4d72059_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1QLF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0140680c-0a0d-4ca8-9691-ecdbe4d72059_1536x1024.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0140680c-0a0d-4ca8-9691-ecdbe4d72059_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1994340,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/160020973?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0140680c-0a0d-4ca8-9691-ecdbe4d72059_1536x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1QLF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0140680c-0a0d-4ca8-9691-ecdbe4d72059_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!1QLF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0140680c-0a0d-4ca8-9691-ecdbe4d72059_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!1QLF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0140680c-0a0d-4ca8-9691-ecdbe4d72059_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!1QLF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0140680c-0a0d-4ca8-9691-ecdbe4d72059_1536x1024.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Let&#8217;s look at how we might replace the QuadTree with a SpatialHashIndex with 20% as much code:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6Lvc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffce23d89-c75d-4697-b17f-6316ea274097_1408x1950.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6Lvc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffce23d89-c75d-4697-b17f-6316ea274097_1408x1950.png 424w, https://substackcdn.com/image/fetch/$s_!6Lvc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffce23d89-c75d-4697-b17f-6316ea274097_1408x1950.png 848w, https://substackcdn.com/image/fetch/$s_!6Lvc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffce23d89-c75d-4697-b17f-6316ea274097_1408x1950.png 1272w, https://substackcdn.com/image/fetch/$s_!6Lvc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffce23d89-c75d-4697-b17f-6316ea274097_1408x1950.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6Lvc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffce23d89-c75d-4697-b17f-6316ea274097_1408x1950.png" width="465" height="643.9985795454545" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fce23d89-c75d-4697-b17f-6316ea274097_1408x1950.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1950,&quot;width&quot;:1408,&quot;resizeWidth&quot;:465,&quot;bytes&quot;:393368,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/160020973?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffce23d89-c75d-4697-b17f-6316ea274097_1408x1950.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6Lvc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffce23d89-c75d-4697-b17f-6316ea274097_1408x1950.png 424w, https://substackcdn.com/image/fetch/$s_!6Lvc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffce23d89-c75d-4697-b17f-6316ea274097_1408x1950.png 848w, https://substackcdn.com/image/fetch/$s_!6Lvc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffce23d89-c75d-4697-b17f-6316ea274097_1408x1950.png 1272w, https://substackcdn.com/image/fetch/$s_!6Lvc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffce23d89-c75d-4697-b17f-6316ea274097_1408x1950.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>There are many variants of this basic data structure for different types of objects, but they all look pretty similar. We&#8217;re basically just creating &#8220;buckets&#8221; with spatial hashes and filling them with any object that is contained within the cell represented by the spatial hash.</p><p>The reason spatial hashes aren&#8217;t as popular is you need to be careful about selecting your cell size- this is what makes it an informed algorithm. If your cell size isn&#8217;t calibrated well, you&#8217;ll end up paying high fixed costs per retrieval. In practice, it&#8217;s not that difficult to pick a reasonable cell size.</p><h2>4. Effective Spatial Partitioning + Caching is 1000x more important than algorithm performance</h2><p>A circuit board like the one inside an IPhone probably has somewhere between 10,000 and 20,000 traces and take a team several months to route with the best EDA tools in world. It can seem daunting to try to optimize such an incredibly complex task- but the truth is the entire industry is neglecting a very simple idea: <strong>everything that has been routed has been routed before.</strong></p><p>Game developers &#8220;pre-bake&#8221; navigation meshes into many gigabytes for their games. LLMs compress the entire internet into weights for search. The next generation of autorouters will spatially partition their problems, then call upon a massive cache for pre-solved solutions. The speed of the algorithm doesn&#8217;t matter when you have a massive cache with 99% of the autorouting problem pre-solved.</p><p>Most algorithms today do not focus on the effective cache-reusability or effective spatial partitioning, but a critical component of future autorouters will be caching inputs and outputs from each stage in a spatially partitioned way.</p><p>Moreover, the size of storage and caching seems to go down faster than the speed of computation goes up. It&#8217;s not a big deal to have a gigabyte cache to make your autorouter 50% faster.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!u0d-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c4bed3-2866-4ae0-8f11-7eaaf0307251_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!u0d-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c4bed3-2866-4ae0-8f11-7eaaf0307251_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!u0d-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c4bed3-2866-4ae0-8f11-7eaaf0307251_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!u0d-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c4bed3-2866-4ae0-8f11-7eaaf0307251_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!u0d-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c4bed3-2866-4ae0-8f11-7eaaf0307251_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!u0d-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c4bed3-2866-4ae0-8f11-7eaaf0307251_1024x1024.png" width="404" height="404" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/63c4bed3-2866-4ae0-8f11-7eaaf0307251_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:404,&quot;bytes&quot;:1579631,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/160020973?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c4bed3-2866-4ae0-8f11-7eaaf0307251_1024x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!u0d-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c4bed3-2866-4ae0-8f11-7eaaf0307251_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!u0d-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c4bed3-2866-4ae0-8f11-7eaaf0307251_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!u0d-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c4bed3-2866-4ae0-8f11-7eaaf0307251_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!u0d-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63c4bed3-2866-4ae0-8f11-7eaaf0307251_1024x1024.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">At the end of the day, the cache will win. Cacheable algorithms matter more than fast algorithms!</figcaption></figure></div><p></p><h2>5. If you do not have a visualization for a problem, you will never solve it</h2><p>If there is one thing I could have printed on a poster, it would be <strong>VISUALIZE THE PROBLEM. </strong>You can&#8217;t debug problems by staring at numbers.</p><p>For every tiny problem we solve, we have a visualization. We will often <em>start</em> with the visualization. Time and time again this enables us to debug and solve problems 10x faster than we could otherwise. Here&#8217;s a visualization we made of a subalgorithm for finding 45 degree paths, we use this in our &#8220;Path Simplification Phase&#8221;, an ~final phase of the autorouter.</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;0ec458ac-6cb6-4954-b708-7cfee1372fec&quot;,&quot;duration&quot;:null}"></div><p></p><p></p><h2>6. Javascript Profiling Is Amazing- Use it!</h2><p>Javascript profiling tools are incredibe, you can easily see the <em>exact total time in ms spend on each line of code</em>. You don&#8217;t need to use any performance framework, just execute your javascript in the browser and pull up the performance tab. There are also awesome features like flame charts and stuff for memory usage.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mrdR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a1d17a-917b-43c8-b0fa-ff0887181edc_2606x1508.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mrdR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a1d17a-917b-43c8-b0fa-ff0887181edc_2606x1508.png 424w, https://substackcdn.com/image/fetch/$s_!mrdR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a1d17a-917b-43c8-b0fa-ff0887181edc_2606x1508.png 848w, https://substackcdn.com/image/fetch/$s_!mrdR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a1d17a-917b-43c8-b0fa-ff0887181edc_2606x1508.png 1272w, https://substackcdn.com/image/fetch/$s_!mrdR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a1d17a-917b-43c8-b0fa-ff0887181edc_2606x1508.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mrdR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a1d17a-917b-43c8-b0fa-ff0887181edc_2606x1508.png" width="1456" height="843" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/77a1d17a-917b-43c8-b0fa-ff0887181edc_2606x1508.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:843,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:366683,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/160020973?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a1d17a-917b-43c8-b0fa-ff0887181edc_2606x1508.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mrdR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a1d17a-917b-43c8-b0fa-ff0887181edc_2606x1508.png 424w, https://substackcdn.com/image/fetch/$s_!mrdR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a1d17a-917b-43c8-b0fa-ff0887181edc_2606x1508.png 848w, https://substackcdn.com/image/fetch/$s_!mrdR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a1d17a-917b-43c8-b0fa-ff0887181edc_2606x1508.png 1272w, https://substackcdn.com/image/fetch/$s_!mrdR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77a1d17a-917b-43c8-b0fa-ff0887181edc_2606x1508.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Example flamechat for debugging performance in <a href="https://github.com/tscircuit/core">@tscircuit/core</a></figcaption></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Y6wX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3772274e-c1dc-46af-8fd3-c80fe6603418_2040x1424.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Y6wX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3772274e-c1dc-46af-8fd3-c80fe6603418_2040x1424.png 424w, https://substackcdn.com/image/fetch/$s_!Y6wX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3772274e-c1dc-46af-8fd3-c80fe6603418_2040x1424.png 848w, https://substackcdn.com/image/fetch/$s_!Y6wX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3772274e-c1dc-46af-8fd3-c80fe6603418_2040x1424.png 1272w, https://substackcdn.com/image/fetch/$s_!Y6wX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3772274e-c1dc-46af-8fd3-c80fe6603418_2040x1424.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Y6wX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3772274e-c1dc-46af-8fd3-c80fe6603418_2040x1424.png" width="1456" height="1016" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3772274e-c1dc-46af-8fd3-c80fe6603418_2040x1424.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1016,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:493490,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/160020973?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3772274e-c1dc-46af-8fd3-c80fe6603418_2040x1424.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Y6wX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3772274e-c1dc-46af-8fd3-c80fe6603418_2040x1424.png 424w, https://substackcdn.com/image/fetch/$s_!Y6wX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3772274e-c1dc-46af-8fd3-c80fe6603418_2040x1424.png 848w, https://substackcdn.com/image/fetch/$s_!Y6wX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3772274e-c1dc-46af-8fd3-c80fe6603418_2040x1424.png 1272w, https://substackcdn.com/image/fetch/$s_!Y6wX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3772274e-c1dc-46af-8fd3-c80fe6603418_2040x1424.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">You can easily see the time spent on each line of code inside Chrome&#8217;s performance tools!</figcaption></figure></div><p>Here&#8217;s a little <a href="https://youtube.com/shorts/xuBoiuK-VlU?si=b9lT9gPzXhbfQ9qc">youtube short</a> I made about it</p><h2>7. Never use recursive functions</h2><p>Recursive functions are bad for multiple reasons:</p><ul><li><p>They are almost always synchronous (can&#8217;t be broken out for animation)</p></li><li><p>They are inherently a Depth-First Search, and can&#8217;t be easily morphed to A*</p></li><li><p>You can&#8217;t easily track iterations</p></li><li><p>Mutability is often unnatural in recursive functions but critical to performance</p></li></ul><p>Here&#8217;s an example of an &#8220;obviously recursive&#8221; function converted to a non-recursive function:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Y0do!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4e5f886-732f-44a8-b9c2-a70ac502562e_6020x2957.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Y0do!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4e5f886-732f-44a8-b9c2-a70ac502562e_6020x2957.png 424w, https://substackcdn.com/image/fetch/$s_!Y0do!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4e5f886-732f-44a8-b9c2-a70ac502562e_6020x2957.png 848w, https://substackcdn.com/image/fetch/$s_!Y0do!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4e5f886-732f-44a8-b9c2-a70ac502562e_6020x2957.png 1272w, https://substackcdn.com/image/fetch/$s_!Y0do!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4e5f886-732f-44a8-b9c2-a70ac502562e_6020x2957.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Y0do!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4e5f886-732f-44a8-b9c2-a70ac502562e_6020x2957.png" width="1456" height="715" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e4e5f886-732f-44a8-b9c2-a70ac502562e_6020x2957.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:715,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:3554373,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/160020973?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4e5f886-732f-44a8-b9c2-a70ac502562e_6020x2957.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Y0do!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4e5f886-732f-44a8-b9c2-a70ac502562e_6020x2957.png 424w, https://substackcdn.com/image/fetch/$s_!Y0do!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4e5f886-732f-44a8-b9c2-a70ac502562e_6020x2957.png 848w, https://substackcdn.com/image/fetch/$s_!Y0do!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4e5f886-732f-44a8-b9c2-a70ac502562e_6020x2957.png 1272w, https://substackcdn.com/image/fetch/$s_!Y0do!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe4e5f886-732f-44a8-b9c2-a70ac502562e_6020x2957.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The iteration-based implementation is much faster because it keeps a set of <code>visitedNodes</code> and checks nodes prior to exploration. You can do this with recursive functions, but you have to pass around a mutable object and do other unnatural things. It&#8217;s just best to avoid recursive functions when writing performant code.</p><h2>8. Monte Carlo algorithms are hacks. AVOID</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7kf0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bd16ab-304d-4630-8c3d-a46057cbb8c9_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7kf0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bd16ab-304d-4630-8c3d-a46057cbb8c9_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!7kf0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bd16ab-304d-4630-8c3d-a46057cbb8c9_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!7kf0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bd16ab-304d-4630-8c3d-a46057cbb8c9_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!7kf0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bd16ab-304d-4630-8c3d-a46057cbb8c9_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7kf0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bd16ab-304d-4630-8c3d-a46057cbb8c9_1024x1024.png" width="439" height="439" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e6bd16ab-304d-4630-8c3d-a46057cbb8c9_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:439,&quot;bytes&quot;:1095069,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/160020973?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bd16ab-304d-4630-8c3d-a46057cbb8c9_1024x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!7kf0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bd16ab-304d-4630-8c3d-a46057cbb8c9_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!7kf0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bd16ab-304d-4630-8c3d-a46057cbb8c9_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!7kf0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bd16ab-304d-4630-8c3d-a46057cbb8c9_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!7kf0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bd16ab-304d-4630-8c3d-a46057cbb8c9_1024x1024.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p>Monte Carlo algorithms use randomness to iterate towards a solution. They are bad because:</p><ul><li><p>They lead to non-deterministic, hard-to-debug algorithms</p></li><li><p>They are basically never optimal relative to a heuristic</p></li></ul><p>I sometimes use Monte Carlo-style algorithms when I don&#8217;t yet know how the algorithm should get to the solution, but I know how to score a candidate. They can help give some basic intuition about how to solve a problem. Once you have something approximating a cost function, do something smarter than Monte Carlo or any other random technique like Simulated Annealing. If your algorithm is sensitive to local minimums, consider using hyper parameters or more complex cost functions. Almost any local minimum your human eye can see can be made into a component of a cost function.</p><p>Another way to think about it: How many PCB Designers randomly draw lines on their circuit board? None. Nobody does that. It&#8217;s just not a good technique for this domain. You&#8217;ll always be able to find a better heuristic.</p><h2>9. Keep intermediate algorithms grounded</h2><p>Our autorouter is currently a pipeline with 13 stages and something like 20 sub-algorithms that we measure the iteration count of for various things like determining spatial partitions or simplifying paths at the boundaries independently autorouted sections.</p><p>Being able to overlay different inputs/output visualizations of each stage of the algorithm helps you understand the context surrounding the problem you&#8217;re solving. I often ran into issues at downstream stages (often our &#8220;high density routing&#8221; stage) that could be solved by improving the output of previous stages.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1Jbq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce34df4d-9862-4dd1-8c31-97817a43cf01_1602x528.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1Jbq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce34df4d-9862-4dd1-8c31-97817a43cf01_1602x528.png 424w, https://substackcdn.com/image/fetch/$s_!1Jbq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce34df4d-9862-4dd1-8c31-97817a43cf01_1602x528.png 848w, https://substackcdn.com/image/fetch/$s_!1Jbq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce34df4d-9862-4dd1-8c31-97817a43cf01_1602x528.png 1272w, https://substackcdn.com/image/fetch/$s_!1Jbq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce34df4d-9862-4dd1-8c31-97817a43cf01_1602x528.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1Jbq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce34df4d-9862-4dd1-8c31-97817a43cf01_1602x528.png" width="1456" height="480" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ce34df4d-9862-4dd1-8c31-97817a43cf01_1602x528.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:480,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1187396,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/160020973?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce34df4d-9862-4dd1-8c31-97817a43cf01_1602x528.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1Jbq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce34df4d-9862-4dd1-8c31-97817a43cf01_1602x528.png 424w, https://substackcdn.com/image/fetch/$s_!1Jbq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce34df4d-9862-4dd1-8c31-97817a43cf01_1602x528.png 848w, https://substackcdn.com/image/fetch/$s_!1Jbq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce34df4d-9862-4dd1-8c31-97817a43cf01_1602x528.png 1272w, https://substackcdn.com/image/fetch/$s_!1Jbq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fce34df4d-9862-4dd1-8c31-97817a43cf01_1602x528.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The temptation when building sub-algorithms is to isolate the algorithm to its simplest form, maybe even normalizing around (0, 0). The danger with normalization or any complex transformation is it might impact the ability to quickly see consequences from early stages of the algorithm to later stages of the algorithm. To prevent this, just keep your coordinate space consistent throughout the lifecycle of the algorithm.</p><p>Here&#8217;s each stage of our algorithm one after another. We often zoom in on this to see what stage is the most guilty culprit for a failed Design Rule Check.</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;630d3867-3960-49a4-a9fd-c72518ae4da4&quot;,&quot;duration&quot;:null}"></div><p></p><h2>10. Animate your iterations to catch stupid behavior</h2><p>Remember how it&#8217;s super important to lower your iteration count?</p><p>Animating the iterations of your algorithm will show you how &#8220;dumb&#8221; it&#8217;s being by giving you an intuition for how many iterations are wasted exploring paths that don&#8217;t matter. This is particularly helpful when adjusting the greedy multiplier (discussed in 12)</p><p>This video is an animation of a simple trace failing to solve, but instead of failing outright attempting to solve endlessly outward. Without the animation, it would have been hard to tell what was going on!</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;ff646f1d-7d1e-4b44-9706-00e61bfdfe0f&quot;,&quot;duration&quot;:null}"></div><p></p><h2>11. Intersection math is fast, do you really need a grid?</h2><p>Consider two ways to determine if a trace A overlaps another trace B:</p><ol><li><p>Consider each segment of A and B, and check for intersections<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a></p></li><li><p>Create a binary grid that marks each square where trace B is present, then check all the squares where trace A is present to see if B is there</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zNzz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c9da8e1-4e35-4cf8-9b56-f6f1d7f7ed3f_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zNzz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c9da8e1-4e35-4cf8-9b56-f6f1d7f7ed3f_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!zNzz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c9da8e1-4e35-4cf8-9b56-f6f1d7f7ed3f_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!zNzz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c9da8e1-4e35-4cf8-9b56-f6f1d7f7ed3f_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!zNzz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c9da8e1-4e35-4cf8-9b56-f6f1d7f7ed3f_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zNzz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c9da8e1-4e35-4cf8-9b56-f6f1d7f7ed3f_1536x1024.png" width="712" height="474.8296703296703" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2c9da8e1-4e35-4cf8-9b56-f6f1d7f7ed3f_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:712,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Generated image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Generated image" title="Generated image" srcset="https://substackcdn.com/image/fetch/$s_!zNzz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c9da8e1-4e35-4cf8-9b56-f6f1d7f7ed3f_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!zNzz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c9da8e1-4e35-4cf8-9b56-f6f1d7f7ed3f_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!zNzz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c9da8e1-4e35-4cf8-9b56-f6f1d7f7ed3f_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!zNzz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c9da8e1-4e35-4cf8-9b56-f6f1d7f7ed3f_1536x1024.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Believe it or not, most people would choose to use Option 2 with a binary grid check, even though this can easily be 1000x slower. People do this because math is hard &#129318;</p><p>Luckily LLMs make this kind of intersection math trivial. Use fast vector math!! <strong>Checking a SINGLE grid square (memory access!) can literally be slower than doing a dot product to determine if two segments intersect!</strong></p><h2>12. Measure spatial probability of failure at each stage, prioritize solvability</h2><p>When doing spatial partitioning of the problem, you can measure the probability of solve failure of each stage with some leading indicators. For example, in the Unravel Autorouter we track the probability of failure for each &#8220;Capacity Node&#8221; at each major pipeline stage. Each stage focuses on reconfiguring adjacent nodes or rerouting to reduce the probability of failure.</p><p>The great thing about probability of failure as a metric is you can literally measure it and improve your prediction as your algorithm changes. Each stage can then do it&#8217;s best to minimize the chance of future stages failing.</p><p>I think generally prioritizing solvability is better than trying to incorporate too many constraints. Once a board is solved, it&#8217;s often easier to &#8220;work with that solution&#8221; than to generate optimal solution from scratch.</p><h2>13. The &#8220;Greedy Multiplier&#8221;, the secret hack to 100x A* performance at the cost of optimality </h2><p>Ok it&#8217;s not exactly a secret, maybe a &#8220;well-known secret&#8221;, but if you don&#8217;t know about it, you&#8217;re not using A* properly.</p><p>By default, A* is guaranteed to give you the optimal solution, but what if you care more about speed than about optimality? Make one tiny change to your <code>f(n)</code>and you have Weighted A*, a variant of A* that solves more greedily, and generally much, much faster!</p><div class="pullquote"><p>Normal A*:<code> f(n) = g(n) + h(n)<br></code>Weighted A*:<code> f(n) = g(n) + w * h(n)</code></p></div><p>You can read more about <a href="https://movingai.com/astar-var.html">weighted A* and other A* variants here</a>.</p><p>Game developers have a lot of the same problems as autorouting developers, so it&#8217;s not a bad idea to look for game development papers if you&#8217;re searching for related work!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xD2z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c88ad14-faf3-4d0b-afea-6875d3c558aa_697x500.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xD2z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c88ad14-faf3-4d0b-afea-6875d3c558aa_697x500.jpeg 424w, https://substackcdn.com/image/fetch/$s_!xD2z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c88ad14-faf3-4d0b-afea-6875d3c558aa_697x500.jpeg 848w, https://substackcdn.com/image/fetch/$s_!xD2z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c88ad14-faf3-4d0b-afea-6875d3c558aa_697x500.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!xD2z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c88ad14-faf3-4d0b-afea-6875d3c558aa_697x500.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xD2z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c88ad14-faf3-4d0b-afea-6875d3c558aa_697x500.jpeg" width="461" height="330.70301291248205" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7c88ad14-faf3-4d0b-afea-6875d3c558aa_697x500.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:697,&quot;resizeWidth&quot;:461,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xD2z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c88ad14-faf3-4d0b-afea-6875d3c558aa_697x500.jpeg 424w, https://substackcdn.com/image/fetch/$s_!xD2z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c88ad14-faf3-4d0b-afea-6875d3c558aa_697x500.jpeg 848w, https://substackcdn.com/image/fetch/$s_!xD2z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c88ad14-faf3-4d0b-afea-6875d3c558aa_697x500.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!xD2z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c88ad14-faf3-4d0b-afea-6875d3c558aa_697x500.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>We&#8217;re making an autorouter.</h2><p>If this was interesting to you, I&#8217;d love to show you our autorouter as it gets closer to release. I believe that solving autorouting will be a massive unlock for physical-world innovation and is a key piece to enable the &#8220;vibe-building&#8221; of electronics. All of our work is MIT-licensed open-source. You can also <a href="https://x.com/seveibar">follow me on twitter.</a></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.autorouting.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading autorouting! Subscribe to hear when we release our insanely fast autorouter!</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><p></p><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p>Technically, you should use &#8220;segment to segment&#8221; distance to ensure appropriate margins, which is slightly more complex than intersection, but not by much</p></div></div>]]></content:encoded></item><item><title><![CDATA[The Recursive Pattern Pathfinder]]></title><description><![CDATA[A fractal algorithm for finding paths by recursively applying line patterns, could this create hyper-fast autorouters?]]></description><link>https://blog.autorouting.com/p/the-recursive-pattern-pathfinder</link><guid isPermaLink="false">https://blog.autorouting.com/p/the-recursive-pattern-pathfinder</guid><dc:creator><![CDATA[Seve Ibarluzea]]></dc:creator><pubDate>Tue, 14 Jan 2025 01:05:43 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!m4J0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03b526ca-20b2-4870-b061-c07edd335913_1354x760.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!m4J0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03b526ca-20b2-4870-b061-c07edd335913_1354x760.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!m4J0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03b526ca-20b2-4870-b061-c07edd335913_1354x760.png 424w, https://substackcdn.com/image/fetch/$s_!m4J0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03b526ca-20b2-4870-b061-c07edd335913_1354x760.png 848w, https://substackcdn.com/image/fetch/$s_!m4J0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03b526ca-20b2-4870-b061-c07edd335913_1354x760.png 1272w, https://substackcdn.com/image/fetch/$s_!m4J0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03b526ca-20b2-4870-b061-c07edd335913_1354x760.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!m4J0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03b526ca-20b2-4870-b061-c07edd335913_1354x760.png" width="456" height="255.95273264401771" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/03b526ca-20b2-4870-b061-c07edd335913_1354x760.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:760,&quot;width&quot;:1354,&quot;resizeWidth&quot;:456,&quot;bytes&quot;:34796,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!m4J0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03b526ca-20b2-4870-b061-c07edd335913_1354x760.png 424w, https://substackcdn.com/image/fetch/$s_!m4J0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03b526ca-20b2-4870-b061-c07edd335913_1354x760.png 848w, https://substackcdn.com/image/fetch/$s_!m4J0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03b526ca-20b2-4870-b061-c07edd335913_1354x760.png 1272w, https://substackcdn.com/image/fetch/$s_!m4J0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03b526ca-20b2-4870-b061-c07edd335913_1354x760.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">An example of the recursive pathfinder, read on to see the animation!</figcaption></figure></div><p>There are a lot of benefits to using intersection calculations vs grids for fast autorouters, Grids take up a lot of memory and cause the algorithm to go slower as it routes across more real distance (I discuss this a bit in the <a href="https://blog.autorouting.com/p/the-intersection-jump-autorouter">intersection-jumping algorithm article</a>). This means that grid-based autorouting algorithms are not scale-invarant, a problem over 100mm will take 10x more compute than a problem over 10mm.</p><p>I was trying to think of ways to create an autorouting input/output data format that would be optimal for training machine learning algorithms when I realized that patterns are an incredibly useful way to represent scale-invariant autorouting results. What I mean is that if you could build a classifier that outputs a set of probabilities for a set of predefined routes. This is much easier to &#8220;learn&#8221; than outputting images or coordinate paths.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!L0N5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4052c8b8-0415-45dc-b2c9-9e27445eb929_3183x1120.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!L0N5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4052c8b8-0415-45dc-b2c9-9e27445eb929_3183x1120.png 424w, https://substackcdn.com/image/fetch/$s_!L0N5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4052c8b8-0415-45dc-b2c9-9e27445eb929_3183x1120.png 848w, https://substackcdn.com/image/fetch/$s_!L0N5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4052c8b8-0415-45dc-b2c9-9e27445eb929_3183x1120.png 1272w, https://substackcdn.com/image/fetch/$s_!L0N5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4052c8b8-0415-45dc-b2c9-9e27445eb929_3183x1120.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!L0N5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4052c8b8-0415-45dc-b2c9-9e27445eb929_3183x1120.png" width="1456" height="512" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4052c8b8-0415-45dc-b2c9-9e27445eb929_3183x1120.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:512,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:131845,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!L0N5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4052c8b8-0415-45dc-b2c9-9e27445eb929_3183x1120.png 424w, https://substackcdn.com/image/fetch/$s_!L0N5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4052c8b8-0415-45dc-b2c9-9e27445eb929_3183x1120.png 848w, https://substackcdn.com/image/fetch/$s_!L0N5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4052c8b8-0415-45dc-b2c9-9e27445eb929_3183x1120.png 1272w, https://substackcdn.com/image/fetch/$s_!L0N5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4052c8b8-0415-45dc-b2c9-9e27445eb929_3183x1120.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">3 outputs corresponding to the probability that 3 different paths are possible</figcaption></figure></div><p></p><p>There are a lot of benefits to having a constrained output space. The less options to choose from, the less ways to be wrong! I also realized I could now create a very simple algorithm that recursively attempts patterns for any region with a collision. </p><p>To do this, we just write an algorithm that says &#8220;whenever there is an intersection with an obstacle, take the segment that ran into the obstacle and try to replace it with any of the predefined patterns&#8221;</p><p>Check it out in the short video below!</p><p> </p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;183e17be-d72f-4747-96dd-c26e0038aafb&quot;,&quot;duration&quot;:null}"></div><p>Can you see what patterns were recursively applied above? There are only 4!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qDp-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb4a8fef-8e64-4f32-bf33-749ec79e7e4d_1980x652.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qDp-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb4a8fef-8e64-4f32-bf33-749ec79e7e4d_1980x652.png 424w, https://substackcdn.com/image/fetch/$s_!qDp-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb4a8fef-8e64-4f32-bf33-749ec79e7e4d_1980x652.png 848w, https://substackcdn.com/image/fetch/$s_!qDp-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb4a8fef-8e64-4f32-bf33-749ec79e7e4d_1980x652.png 1272w, https://substackcdn.com/image/fetch/$s_!qDp-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb4a8fef-8e64-4f32-bf33-749ec79e7e4d_1980x652.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qDp-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb4a8fef-8e64-4f32-bf33-749ec79e7e4d_1980x652.png" width="1456" height="479" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cb4a8fef-8e64-4f32-bf33-749ec79e7e4d_1980x652.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:479,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:91643,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qDp-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb4a8fef-8e64-4f32-bf33-749ec79e7e4d_1980x652.png 424w, https://substackcdn.com/image/fetch/$s_!qDp-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb4a8fef-8e64-4f32-bf33-749ec79e7e4d_1980x652.png 848w, https://substackcdn.com/image/fetch/$s_!qDp-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb4a8fef-8e64-4f32-bf33-749ec79e7e4d_1980x652.png 1272w, https://substackcdn.com/image/fetch/$s_!qDp-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcb4a8fef-8e64-4f32-bf33-749ec79e7e4d_1980x652.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Each of these patterns is applied to each segment that has collisions</figcaption></figure></div><p></p><p>This algorithm scales nearly perfectly with the complexity of the autorouting problem (the gray obstacles) so it&#8217;s a great choice for sparse problems! I also like how the depth of the recursion is a nice natural measurement for complexity.</p><p>It&#8217;s also kind of crazy to me that these patterns can actually allow the pathfinder to go backwards</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IIq6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d77ffaf-c8ca-441e-a6c9-1f6f1f01c16b_642x466.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IIq6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d77ffaf-c8ca-441e-a6c9-1f6f1f01c16b_642x466.png 424w, https://substackcdn.com/image/fetch/$s_!IIq6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d77ffaf-c8ca-441e-a6c9-1f6f1f01c16b_642x466.png 848w, https://substackcdn.com/image/fetch/$s_!IIq6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d77ffaf-c8ca-441e-a6c9-1f6f1f01c16b_642x466.png 1272w, https://substackcdn.com/image/fetch/$s_!IIq6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d77ffaf-c8ca-441e-a6c9-1f6f1f01c16b_642x466.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IIq6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d77ffaf-c8ca-441e-a6c9-1f6f1f01c16b_642x466.png" width="474" height="344.05607476635515" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6d77ffaf-c8ca-441e-a6c9-1f6f1f01c16b_642x466.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:466,&quot;width&quot;:642,&quot;resizeWidth&quot;:474,&quot;bytes&quot;:13787,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IIq6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d77ffaf-c8ca-441e-a6c9-1f6f1f01c16b_642x466.png 424w, https://substackcdn.com/image/fetch/$s_!IIq6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d77ffaf-c8ca-441e-a6c9-1f6f1f01c16b_642x466.png 848w, https://substackcdn.com/image/fetch/$s_!IIq6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d77ffaf-c8ca-441e-a6c9-1f6f1f01c16b_642x466.png 1272w, https://substackcdn.com/image/fetch/$s_!IIq6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d77ffaf-c8ca-441e-a6c9-1f6f1f01c16b_642x466.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">The sky is the limit if you&#8217;re recursive enough!</figcaption></figure></div><p></p><p>You can play with the algorithm and customize the patterns online in <a href="https://pattern-pathfinder.vercel.app/?fixtureId=%7B%22path%22%3A%22site%2Fexamples%2Fexample5-random-obstacles.fixture.tsx%22%7D">this sandbox</a></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HR4j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bcb6ffe-d1f5-47c5-840c-c1a8aeec665b_2230x1934.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HR4j!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bcb6ffe-d1f5-47c5-840c-c1a8aeec665b_2230x1934.png 424w, https://substackcdn.com/image/fetch/$s_!HR4j!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bcb6ffe-d1f5-47c5-840c-c1a8aeec665b_2230x1934.png 848w, https://substackcdn.com/image/fetch/$s_!HR4j!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bcb6ffe-d1f5-47c5-840c-c1a8aeec665b_2230x1934.png 1272w, https://substackcdn.com/image/fetch/$s_!HR4j!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bcb6ffe-d1f5-47c5-840c-c1a8aeec665b_2230x1934.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HR4j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bcb6ffe-d1f5-47c5-840c-c1a8aeec665b_2230x1934.png" width="521" height="451.9388736263736" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5bcb6ffe-d1f5-47c5-840c-c1a8aeec665b_2230x1934.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1263,&quot;width&quot;:1456,&quot;resizeWidth&quot;:521,&quot;bytes&quot;:275240,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://blog.autorouting.com/i/154793170?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bcb6ffe-d1f5-47c5-840c-c1a8aeec665b_2230x1934.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HR4j!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bcb6ffe-d1f5-47c5-840c-c1a8aeec665b_2230x1934.png 424w, https://substackcdn.com/image/fetch/$s_!HR4j!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bcb6ffe-d1f5-47c5-840c-c1a8aeec665b_2230x1934.png 848w, https://substackcdn.com/image/fetch/$s_!HR4j!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bcb6ffe-d1f5-47c5-840c-c1a8aeec665b_2230x1934.png 1272w, https://substackcdn.com/image/fetch/$s_!HR4j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5bcb6ffe-d1f5-47c5-840c-c1a8aeec665b_2230x1934.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://pattern-pathfinder.vercel.app/?fixtureId=%7B%22path%22%3A%22site%2Fexamples%2Fexample5-random-obstacles.fixture.tsx%22%7D">Sandbox </a>for recursive pattern autorouter</figcaption></figure></div><p></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.autorouting.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading autorouting! Subscribe to hear more about autorouting algorithms and datasets.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Why we're building autorouting.com]]></title><description><![CDATA[Open datasets and modern AI can solve autorouting once and for all!]]></description><link>https://blog.autorouting.com/p/why-were-building-autoroutingcom</link><guid isPermaLink="false">https://blog.autorouting.com/p/why-were-building-autoroutingcom</guid><dc:creator><![CDATA[Seve Ibarluzea]]></dc:creator><pubDate>Thu, 19 Dec 2024 23:32:27 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Cwtu!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc458374f-2a43-4c52-bbe7-823f9faf0fa2_200x200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We&#8217;re building <a href="https://autorouting.com">autorouting.com</a> as a central hub for open-source autorouting datasets and algorithms.</p><h2>The State of Autorouting in 2024</h2><p>In 2024 here&#8217;s where we&#8217;re at:</p><ul><li><p>There are very few people working in the public on autorouting algorithms, a notable exception being a single maintainer at <a href="https://github.com/freerouting/freerouting">freerouting</a></p></li><li><p>There is virtually no published work on building autorouters using modern AI techniques</p></li><li><p>There are very few, if any, large datasets of circuit boards with a corresponding fully-routed solution that can be used for training or tuning a modern algorithm</p></li></ul><h2>Why aren&#8217;t people working on autorouting?</h2><ul><li><p>Hardware expertise and machine-learning/AI expertise is uncommon</p></li><li><p>It currently takes hardware expertise just to understand the formats (such as Specctra DSN)</p></li><li><p>It is difficult to find a large repository of routed circuit boards for training</p></li></ul><h2>How we&#8217;re doing it</h2><p>We want to seed the ecosystem with large datasets that can be used to solve autorouting, as well as utilities to make it easy to parse and work with autorouting data, so that machine learning experts can jump in without needing to have hardware expertise.</p><p>More specifically:</p><ul><li><p>Develop datasets that can be used for evaluation and training of autorouters</p></li><li><p>Develops standards for benchmarking autorouters for comparison</p></li><li><p>Fund the development of open-source autorouting solutions</p></li><li><p>Showcase both closed and open-source autorouters</p></li><li><p>Develop open-source tooling and formats to make it easier to work with autorouters</p></li></ul><h2>Get Involved</h2><p>Please reach out to <a href="mailto:autorouting@tscircuit.com">autorouting@tscircuit.com</a> or join <a href="https://tscircuit.com/join">our discord</a> if you&#8217;re interested in working with us. We need help building datasets, utilities and autorouters themselves!</p><p>If you are someone who would be interested in purchasing an autorouting API, please reach out so we can connect you to great companies working on deploying autorouting solutions!</p><p>If you are an autorouting developer, we would love to benchmark or list your autorouter on <a href="https://autorouting.com">autorouting.com</a>, please reach out!</p><p></p>]]></content:encoded></item><item><title><![CDATA[How to start building an Autorouter (video tutorial)]]></title><description><![CDATA[Seve uses the tscircuit autorouting dataset to build a simple autorouter]]></description><link>https://blog.autorouting.com/p/how-to-start-building-an-autorouter</link><guid isPermaLink="false">https://blog.autorouting.com/p/how-to-start-building-an-autorouter</guid><dc:creator><![CDATA[Seve Ibarluzea]]></dc:creator><pubDate>Thu, 10 Oct 2024 19:17:38 GMT</pubDate><enclosure url="https://api.substack.com/feed/podcast/150066538/f79a45f8a65aacaee4d7b7270ec3dfd8.mp3" length="0" type="audio/mpeg"/><content:encoded><![CDATA[<p>Seve uses the tscircuit autorouting dataset to build a simple autorouter, shows how to create snapshot tests for an autorouter and how to run a development server for a custom algorithm.</p><p>These are the first critical steps for getting started. In a future tutorial we&#8217;ll show how to do this in other languages like Python.</p><p>Get started with this repo: <a href="https://github.com/tscircuit/autorouting">https://github.com/tscircuit/autorouting</a></p>]]></content:encoded></item><item><title><![CDATA[The Intersection-Jump Autorouter]]></title><description><![CDATA[I 100x'd my grid autorouter's performance using 3 iterative rules]]></description><link>https://blog.autorouting.com/p/the-intersection-jump-autorouter</link><guid isPermaLink="false">https://blog.autorouting.com/p/the-intersection-jump-autorouter</guid><dc:creator><![CDATA[Seve Ibarluzea]]></dc:creator><pubDate>Fri, 16 Aug 2024 22:03:07 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!aeqX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032d624-ede5-45d4-a59e-86f7474d4428_3898x1410.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The part 2 of this building autorouters series was supposed to be all about gridless autorouters and creating meshes to do autorouting, but while I was playing around with grid-based autorouters I discovered some interesting optimizations that blew the performance of everything I had done out of the water.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!aeqX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032d624-ede5-45d4-a59e-86f7474d4428_3898x1410.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!aeqX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032d624-ede5-45d4-a59e-86f7474d4428_3898x1410.png 424w, https://substackcdn.com/image/fetch/$s_!aeqX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032d624-ede5-45d4-a59e-86f7474d4428_3898x1410.png 848w, https://substackcdn.com/image/fetch/$s_!aeqX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032d624-ede5-45d4-a59e-86f7474d4428_3898x1410.png 1272w, https://substackcdn.com/image/fetch/$s_!aeqX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032d624-ede5-45d4-a59e-86f7474d4428_3898x1410.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!aeqX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032d624-ede5-45d4-a59e-86f7474d4428_3898x1410.png" width="1456" height="527" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c032d624-ede5-45d4-a59e-86f7474d4428_3898x1410.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:527,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:219920,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!aeqX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032d624-ede5-45d4-a59e-86f7474d4428_3898x1410.png 424w, https://substackcdn.com/image/fetch/$s_!aeqX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032d624-ede5-45d4-a59e-86f7474d4428_3898x1410.png 848w, https://substackcdn.com/image/fetch/$s_!aeqX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032d624-ede5-45d4-a59e-86f7474d4428_3898x1410.png 1272w, https://substackcdn.com/image/fetch/$s_!aeqX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc032d624-ede5-45d4-a59e-86f7474d4428_3898x1410.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Summarization of the three rules, don&#8217;t worry we&#8217;ll get into it below!</figcaption></figure></div><h2>Why I was mad at grid-based autorouters</h2><p>In <a href="https://blog.autorouting.com/p/building-a-grid-based-pcb-autorouter">Part 1</a> we built a grid-based autorouter and used the popular <a href="https://qiao.github.io/PathFinding.js/visual/">pathfinding.js</a> library, but the simple-grid was extremely slow for the &#8220;distant-single-trace&#8221; dataset, which is basically just where there&#8217;s a ton of empty space. The reason it&#8217;s so slow is it&#8217;s doing a bazillion checks in wide-open space.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MjoO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2819e1a4-b4a0-46bb-8784-179061966e24_1080x266.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MjoO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2819e1a4-b4a0-46bb-8784-179061966e24_1080x266.png 424w, https://substackcdn.com/image/fetch/$s_!MjoO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2819e1a4-b4a0-46bb-8784-179061966e24_1080x266.png 848w, https://substackcdn.com/image/fetch/$s_!MjoO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2819e1a4-b4a0-46bb-8784-179061966e24_1080x266.png 1272w, https://substackcdn.com/image/fetch/$s_!MjoO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2819e1a4-b4a0-46bb-8784-179061966e24_1080x266.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MjoO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2819e1a4-b4a0-46bb-8784-179061966e24_1080x266.png" width="1080" height="266" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2819e1a4-b4a0-46bb-8784-179061966e24_1080x266.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:266,&quot;width&quot;:1080,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:40501,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MjoO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2819e1a4-b4a0-46bb-8784-179061966e24_1080x266.png 424w, https://substackcdn.com/image/fetch/$s_!MjoO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2819e1a4-b4a0-46bb-8784-179061966e24_1080x266.png 848w, https://substackcdn.com/image/fetch/$s_!MjoO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2819e1a4-b4a0-46bb-8784-179061966e24_1080x266.png 1272w, https://substackcdn.com/image/fetch/$s_!MjoO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2819e1a4-b4a0-46bb-8784-179061966e24_1080x266.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><p>The benchmark showed that the simple-grid was extremely slow on "the &#8220;distant-single-trace&#8221; dataset, <strong>taking on average 70ms</strong>. Even the single-trace performance is a bit scary, taking 1ms for a single trace when circuit boards have thousands of traces completely dashes my dreams of having realtime-routed circuit boards.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_hBZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd09f9b1-ecae-4be8-9e47-fc472bbefd54_1112x860.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_hBZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd09f9b1-ecae-4be8-9e47-fc472bbefd54_1112x860.png 424w, https://substackcdn.com/image/fetch/$s_!_hBZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd09f9b1-ecae-4be8-9e47-fc472bbefd54_1112x860.png 848w, https://substackcdn.com/image/fetch/$s_!_hBZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd09f9b1-ecae-4be8-9e47-fc472bbefd54_1112x860.png 1272w, https://substackcdn.com/image/fetch/$s_!_hBZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd09f9b1-ecae-4be8-9e47-fc472bbefd54_1112x860.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_hBZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd09f9b1-ecae-4be8-9e47-fc472bbefd54_1112x860.png" width="470" height="363.48920863309354" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bd09f9b1-ecae-4be8-9e47-fc472bbefd54_1112x860.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:860,&quot;width&quot;:1112,&quot;resizeWidth&quot;:470,&quot;bytes&quot;:35081,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_hBZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd09f9b1-ecae-4be8-9e47-fc472bbefd54_1112x860.png 424w, https://substackcdn.com/image/fetch/$s_!_hBZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd09f9b1-ecae-4be8-9e47-fc472bbefd54_1112x860.png 848w, https://substackcdn.com/image/fetch/$s_!_hBZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd09f9b1-ecae-4be8-9e47-fc472bbefd54_1112x860.png 1272w, https://substackcdn.com/image/fetch/$s_!_hBZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd09f9b1-ecae-4be8-9e47-fc472bbefd54_1112x860.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">simple-grid is slower when there&#8217;s a ton of empty space between components- it&#8217;s doing checks in an empty area!</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_Act!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5395b4f-e932-4263-83cd-d0e880f607f6_1560x1166.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_Act!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5395b4f-e932-4263-83cd-d0e880f607f6_1560x1166.png 424w, https://substackcdn.com/image/fetch/$s_!_Act!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5395b4f-e932-4263-83cd-d0e880f607f6_1560x1166.png 848w, https://substackcdn.com/image/fetch/$s_!_Act!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5395b4f-e932-4263-83cd-d0e880f607f6_1560x1166.png 1272w, https://substackcdn.com/image/fetch/$s_!_Act!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5395b4f-e932-4263-83cd-d0e880f607f6_1560x1166.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_Act!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5395b4f-e932-4263-83cd-d0e880f607f6_1560x1166.png" width="478" height="357.1868131868132" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c5395b4f-e932-4263-83cd-d0e880f607f6_1560x1166.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1088,&quot;width&quot;:1456,&quot;resizeWidth&quot;:478,&quot;bytes&quot;:80928,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_Act!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5395b4f-e932-4263-83cd-d0e880f607f6_1560x1166.png 424w, https://substackcdn.com/image/fetch/$s_!_Act!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5395b4f-e932-4263-83cd-d0e880f607f6_1560x1166.png 848w, https://substackcdn.com/image/fetch/$s_!_Act!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5395b4f-e932-4263-83cd-d0e880f607f6_1560x1166.png 1272w, https://substackcdn.com/image/fetch/$s_!_Act!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5395b4f-e932-4263-83cd-d0e880f607f6_1560x1166.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">this problem took the simple-grid 91ms on my M3 macbook pro (UNBEARABLY SLOW)</figcaption></figure></div><h2>Generating Navmeshes</h2><p>Game engines will often throw out grid-based routing altogether and construct &#8220;navigation meshes&#8221; that contain all the points of interest for an autorouting problem.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MuZz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F462e2a26-780f-44bf-98f6-f4486f5cae34_587x473.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MuZz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F462e2a26-780f-44bf-98f6-f4486f5cae34_587x473.png 424w, https://substackcdn.com/image/fetch/$s_!MuZz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F462e2a26-780f-44bf-98f6-f4486f5cae34_587x473.png 848w, https://substackcdn.com/image/fetch/$s_!MuZz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F462e2a26-780f-44bf-98f6-f4486f5cae34_587x473.png 1272w, https://substackcdn.com/image/fetch/$s_!MuZz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F462e2a26-780f-44bf-98f6-f4486f5cae34_587x473.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MuZz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F462e2a26-780f-44bf-98f6-f4486f5cae34_587x473.png" width="587" height="473" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/462e2a26-780f-44bf-98f6-f4486f5cae34_587x473.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:473,&quot;width&quot;:587,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:123094,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MuZz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F462e2a26-780f-44bf-98f6-f4486f5cae34_587x473.png 424w, https://substackcdn.com/image/fetch/$s_!MuZz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F462e2a26-780f-44bf-98f6-f4486f5cae34_587x473.png 848w, https://substackcdn.com/image/fetch/$s_!MuZz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F462e2a26-780f-44bf-98f6-f4486f5cae34_587x473.png 1272w, https://substackcdn.com/image/fetch/$s_!MuZz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F462e2a26-780f-44bf-98f6-f4486f5cae34_587x473.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Example navmesh for two components</figcaption></figure></div><p>I have a lot to say on navmeshes, there are so many techniques and interesting decisions, but I&#8217;m going to table that for now because there is one big problem with navmeshes- especially how they&#8217;re done in game development: <strong>they&#8217;re pre-computed</strong>. In a game, it&#8217;s totally okay to spend some time pre-computing meshes, even &#8220;baking them overnight&#8221;, but for circuit boards that are being edited in realtime AND have dynamic adjustments due to other traces being routed or adjusted, that precomputation step is just too expensive. I have a lot more to say on this, but I&#8217;ll save it for a future article!</p><h2>Let&#8217;s talk about &#8220;infinite grid&#8221; autorouters</h2><p>With the grid-based approach we worked on in <a href="https://blog.autorouting.com/p/building-a-grid-based-pcb-autorouter">Part 1</a>, we iterated over each of our obstacles to compute a binary grid we would store in memory. Then you would know if there was an obstacle at a point by checking <code>grid[x][y]</code>, but as I mentioned above, I don&#8217;t like pre-computation, so what if we defined a method <code>isObstacleAt(x,y)</code> that iterated over our obstacles and checked in realtime? Now we don&#8217;t have to precompute, and as a bonus we don&#8217;t need to pick a size of the grid! </p><p>Allow me to introduce the <strong>Infinite Grid Autorouter</strong>. To reduce the possibility of mistakes in the algorithm, I&#8217;m moved all the A* logic into it&#8217;s own class. To define our autorouter, we just have to tell it out to get it&#8217;s neighbors!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3mZN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef042517-0c7e-4678-b93e-c3fc198e57c6_1854x1078.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3mZN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef042517-0c7e-4678-b93e-c3fc198e57c6_1854x1078.png 424w, https://substackcdn.com/image/fetch/$s_!3mZN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef042517-0c7e-4678-b93e-c3fc198e57c6_1854x1078.png 848w, https://substackcdn.com/image/fetch/$s_!3mZN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef042517-0c7e-4678-b93e-c3fc198e57c6_1854x1078.png 1272w, https://substackcdn.com/image/fetch/$s_!3mZN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef042517-0c7e-4678-b93e-c3fc198e57c6_1854x1078.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3mZN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef042517-0c7e-4678-b93e-c3fc198e57c6_1854x1078.png" width="548" height="318.78846153846155" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ef042517-0c7e-4678-b93e-c3fc198e57c6_1854x1078.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:847,&quot;width&quot;:1456,&quot;resizeWidth&quot;:548,&quot;bytes&quot;:200256,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3mZN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef042517-0c7e-4678-b93e-c3fc198e57c6_1854x1078.png 424w, https://substackcdn.com/image/fetch/$s_!3mZN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef042517-0c7e-4678-b93e-c3fc198e57c6_1854x1078.png 848w, https://substackcdn.com/image/fetch/$s_!3mZN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef042517-0c7e-4678-b93e-c3fc198e57c6_1854x1078.png 1272w, https://substackcdn.com/image/fetch/$s_!3mZN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef042517-0c7e-4678-b93e-c3fc198e57c6_1854x1078.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Code for the Infinite Grid Autorouter, pretty simple!</figcaption></figure></div><p>This algorithm has 3 basic steps:</p><ol><li><p>Define the four directions we want to go in, left, up, right, and down. Each of these directions is represented with a vector (-1, 0), (0, 1), (1, 0) and (0, -1)</p></li><li><p>Filter any neighbors that are inside an obstacle</p></li><li><p>Compute the neighbors position by adding the direction vector to the current node</p></li></ol><blockquote><p>Concerned about iterating over every obstacle inside of <code>isObstacleAt</code>? We&#8217;ll get to how we can do this efficiently using Quadtrees in a future article. It turns out this is a lot less important than the stuff I&#8217;m talking about today!</p></blockquote><h2>The critical insight: Optimal Neighbors = Massive Speedup</h2><p>The neighbors above are computed just by moving one <code>GRID_STEP</code> in all four possible directions. For a 0.1mm step, this means it would take a hundred steps to traverse a distance of 10mm. With A* exploring out in multiple directions, this can multiply and waste thousands of iterations. There&#8217;s got to be a better way!</p><p>I don&#8217;t think I&#8217;ve completely cracked the egg on optimal neighbor selection, but I did find three heuristics that generate nearly optimal points for most cases. Follow the direction for a <code>travelDistance</code> until one of the following happens:</p><ol><li><p>You hit a wall</p></li><li><p>You cross an axis that your goal is on</p></li><li><p>You overcome the obstacle that the parent node ran into</p></li></ol><p></p><h3>Heuristic 1: Hitting a wall</h3><p>This is really simple, you just project the direction outward and compute when it intersects an obstacle.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0lX8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa88f02b2-7cf3-4567-bfdb-b3e8b5afd68d_1055x374.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0lX8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa88f02b2-7cf3-4567-bfdb-b3e8b5afd68d_1055x374.png 424w, https://substackcdn.com/image/fetch/$s_!0lX8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa88f02b2-7cf3-4567-bfdb-b3e8b5afd68d_1055x374.png 848w, https://substackcdn.com/image/fetch/$s_!0lX8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa88f02b2-7cf3-4567-bfdb-b3e8b5afd68d_1055x374.png 1272w, https://substackcdn.com/image/fetch/$s_!0lX8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa88f02b2-7cf3-4567-bfdb-b3e8b5afd68d_1055x374.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0lX8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa88f02b2-7cf3-4567-bfdb-b3e8b5afd68d_1055x374.png" width="1055" height="374" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a88f02b2-7cf3-4567-bfdb-b3e8b5afd68d_1055x374.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:374,&quot;width&quot;:1055,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:23092,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0lX8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa88f02b2-7cf3-4567-bfdb-b3e8b5afd68d_1055x374.png 424w, https://substackcdn.com/image/fetch/$s_!0lX8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa88f02b2-7cf3-4567-bfdb-b3e8b5afd68d_1055x374.png 848w, https://substackcdn.com/image/fetch/$s_!0lX8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa88f02b2-7cf3-4567-bfdb-b3e8b5afd68d_1055x374.png 1272w, https://substackcdn.com/image/fetch/$s_!0lX8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa88f02b2-7cf3-4567-bfdb-b3e8b5afd68d_1055x374.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Rule 1: Travel until you hit a wall</figcaption></figure></div><p></p><p>Computing where two lines intersect is really fast, and rectangle obstacles are basically just 4 lines, so this is really easy!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LbCb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b1ccc77-f3d9-44f4-bc86-46f991e4807a_1706x1384.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LbCb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b1ccc77-f3d9-44f4-bc86-46f991e4807a_1706x1384.png 424w, https://substackcdn.com/image/fetch/$s_!LbCb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b1ccc77-f3d9-44f4-bc86-46f991e4807a_1706x1384.png 848w, https://substackcdn.com/image/fetch/$s_!LbCb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b1ccc77-f3d9-44f4-bc86-46f991e4807a_1706x1384.png 1272w, https://substackcdn.com/image/fetch/$s_!LbCb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b1ccc77-f3d9-44f4-bc86-46f991e4807a_1706x1384.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LbCb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b1ccc77-f3d9-44f4-bc86-46f991e4807a_1706x1384.png" width="1456" height="1181" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6b1ccc77-f3d9-44f4-bc86-46f991e4807a_1706x1384.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1181,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:264591,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LbCb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b1ccc77-f3d9-44f4-bc86-46f991e4807a_1706x1384.png 424w, https://substackcdn.com/image/fetch/$s_!LbCb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b1ccc77-f3d9-44f4-bc86-46f991e4807a_1706x1384.png 848w, https://substackcdn.com/image/fetch/$s_!LbCb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b1ccc77-f3d9-44f4-bc86-46f991e4807a_1706x1384.png 1272w, https://substackcdn.com/image/fetch/$s_!LbCb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b1ccc77-f3d9-44f4-bc86-46f991e4807a_1706x1384.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Yes it is very mathy, but once you have the function you don&#8217;t need to worry about how it works, all that matters is it returns the intersection!</figcaption></figure></div><h2></h2><h2>Heuristic 2: Crossing the Goal Axis</h2><p>Often times, there is no wall! We could travel on in a distance towards Infinity! To stop this, we add a heuristic where we stop along the &#8220;goal axis&#8221;, this means we&#8217;ll never pass by the goal without adding a new neighbor</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lDNy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3722e4b9-5cf2-453d-bca5-6d5bde7940f2_1321x771.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lDNy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3722e4b9-5cf2-453d-bca5-6d5bde7940f2_1321x771.png 424w, https://substackcdn.com/image/fetch/$s_!lDNy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3722e4b9-5cf2-453d-bca5-6d5bde7940f2_1321x771.png 848w, https://substackcdn.com/image/fetch/$s_!lDNy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3722e4b9-5cf2-453d-bca5-6d5bde7940f2_1321x771.png 1272w, https://substackcdn.com/image/fetch/$s_!lDNy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3722e4b9-5cf2-453d-bca5-6d5bde7940f2_1321x771.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lDNy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3722e4b9-5cf2-453d-bca5-6d5bde7940f2_1321x771.png" width="532" height="310.5011355034065" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3722e4b9-5cf2-453d-bca5-6d5bde7940f2_1321x771.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:771,&quot;width&quot;:1321,&quot;resizeWidth&quot;:532,&quot;bytes&quot;:37657,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lDNy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3722e4b9-5cf2-453d-bca5-6d5bde7940f2_1321x771.png 424w, https://substackcdn.com/image/fetch/$s_!lDNy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3722e4b9-5cf2-453d-bca5-6d5bde7940f2_1321x771.png 848w, https://substackcdn.com/image/fetch/$s_!lDNy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3722e4b9-5cf2-453d-bca5-6d5bde7940f2_1321x771.png 1272w, https://substackcdn.com/image/fetch/$s_!lDNy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3722e4b9-5cf2-453d-bca5-6d5bde7940f2_1321x771.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Rule 2: Travel until you pass the goal</figcaption></figure></div><p></p><h2>Heuristic 3: Overcoming an Obstacle</h2><p>This was definitely the most difficult heuristic to figure out, but it&#8217;s absolutely essential. With the Intersection Jump Autorouter we&#8217;re constantly running into walls, we want to place a neighbor whenever we hit a wall, change direction and overcome the wall. This allows us to &#8220;follow corners&#8221;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!187l!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80fdf3e2-58f0-4422-963c-7693c029f1e6_929x914.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!187l!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80fdf3e2-58f0-4422-963c-7693c029f1e6_929x914.png 424w, https://substackcdn.com/image/fetch/$s_!187l!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80fdf3e2-58f0-4422-963c-7693c029f1e6_929x914.png 848w, https://substackcdn.com/image/fetch/$s_!187l!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80fdf3e2-58f0-4422-963c-7693c029f1e6_929x914.png 1272w, https://substackcdn.com/image/fetch/$s_!187l!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80fdf3e2-58f0-4422-963c-7693c029f1e6_929x914.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!187l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80fdf3e2-58f0-4422-963c-7693c029f1e6_929x914.png" width="398" height="391.57373519913887" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/80fdf3e2-58f0-4422-963c-7693c029f1e6_929x914.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:914,&quot;width&quot;:929,&quot;resizeWidth&quot;:398,&quot;bytes&quot;:41188,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!187l!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80fdf3e2-58f0-4422-963c-7693c029f1e6_929x914.png 424w, https://substackcdn.com/image/fetch/$s_!187l!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80fdf3e2-58f0-4422-963c-7693c029f1e6_929x914.png 848w, https://substackcdn.com/image/fetch/$s_!187l!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80fdf3e2-58f0-4422-963c-7693c029f1e6_929x914.png 1272w, https://substackcdn.com/image/fetch/$s_!187l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80fdf3e2-58f0-4422-963c-7693c029f1e6_929x914.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Rule 3: Travel until you overcome an Obstacle</figcaption></figure></div><p></p><h2>Let&#8217;s look at an example</h2><p>The <a href="https://github.com/tscircuit/autorouting-dataset">autorouting-dataset repo</a> has a lot of tools for iterating over your autorouter to help you debug. Let&#8217;s walk step by step through an autorouting problem and look at the neighbors to understand how the IJump Autorouter works.</p><blockquote><p>To get debug information/graphs, we just run <code>export DEBUG=autorouting-dataset*</code> prior to running <code>bun start</code> to start the development server.</p></blockquote><p>Let&#8217;s take a look at this problem, we want to connect the two squares connected by a white line.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8FcC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99cb99d5-24e0-40ee-b85d-bbc2d930e424_1472x1116.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8FcC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99cb99d5-24e0-40ee-b85d-bbc2d930e424_1472x1116.png 424w, https://substackcdn.com/image/fetch/$s_!8FcC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99cb99d5-24e0-40ee-b85d-bbc2d930e424_1472x1116.png 848w, https://substackcdn.com/image/fetch/$s_!8FcC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99cb99d5-24e0-40ee-b85d-bbc2d930e424_1472x1116.png 1272w, https://substackcdn.com/image/fetch/$s_!8FcC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99cb99d5-24e0-40ee-b85d-bbc2d930e424_1472x1116.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8FcC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99cb99d5-24e0-40ee-b85d-bbc2d930e424_1472x1116.png" width="1456" height="1104" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/99cb99d5-24e0-40ee-b85d-bbc2d930e424_1472x1116.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1104,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:75958,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8FcC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99cb99d5-24e0-40ee-b85d-bbc2d930e424_1472x1116.png 424w, https://substackcdn.com/image/fetch/$s_!8FcC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99cb99d5-24e0-40ee-b85d-bbc2d930e424_1472x1116.png 848w, https://substackcdn.com/image/fetch/$s_!8FcC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99cb99d5-24e0-40ee-b85d-bbc2d930e424_1472x1116.png 1272w, https://substackcdn.com/image/fetch/$s_!8FcC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99cb99d5-24e0-40ee-b85d-bbc2d930e424_1472x1116.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Iteration 1: Hitting Walls on All Sides</h3><p>In iteration 1, we hit walls on every side. Each neighbor is numbered by it&#8217;s position in the A* open set. 0 means your next up! Let&#8217;s see what happens.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XM1m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9309845d-7d94-43e3-a745-fa2f352219a4_1476x1160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XM1m!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9309845d-7d94-43e3-a745-fa2f352219a4_1476x1160.png 424w, https://substackcdn.com/image/fetch/$s_!XM1m!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9309845d-7d94-43e3-a745-fa2f352219a4_1476x1160.png 848w, https://substackcdn.com/image/fetch/$s_!XM1m!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9309845d-7d94-43e3-a745-fa2f352219a4_1476x1160.png 1272w, https://substackcdn.com/image/fetch/$s_!XM1m!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9309845d-7d94-43e3-a745-fa2f352219a4_1476x1160.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XM1m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9309845d-7d94-43e3-a745-fa2f352219a4_1476x1160.png" width="1456" height="1144" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9309845d-7d94-43e3-a745-fa2f352219a4_1476x1160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1144,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:79511,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XM1m!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9309845d-7d94-43e3-a745-fa2f352219a4_1476x1160.png 424w, https://substackcdn.com/image/fetch/$s_!XM1m!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9309845d-7d94-43e3-a745-fa2f352219a4_1476x1160.png 848w, https://substackcdn.com/image/fetch/$s_!XM1m!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9309845d-7d94-43e3-a745-fa2f352219a4_1476x1160.png 1272w, https://substackcdn.com/image/fetch/$s_!XM1m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9309845d-7d94-43e3-a745-fa2f352219a4_1476x1160.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Iteration 2: Passing the Goal Line</h2><p>In this iteration, we explore to the right and left, because we&#8217;re blocked on an obstacle in the forward direction and we&#8217;re not allowed to backstep. The left neighbor goes until it overcomes the obstacle, the right neighbor goes until it crosses the goal axis. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Jo4D!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8927b34a-ade9-403b-a6d2-df85b66eb87a_1486x1144.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Jo4D!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8927b34a-ade9-403b-a6d2-df85b66eb87a_1486x1144.png 424w, https://substackcdn.com/image/fetch/$s_!Jo4D!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8927b34a-ade9-403b-a6d2-df85b66eb87a_1486x1144.png 848w, https://substackcdn.com/image/fetch/$s_!Jo4D!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8927b34a-ade9-403b-a6d2-df85b66eb87a_1486x1144.png 1272w, https://substackcdn.com/image/fetch/$s_!Jo4D!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8927b34a-ade9-403b-a6d2-df85b66eb87a_1486x1144.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Jo4D!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8927b34a-ade9-403b-a6d2-df85b66eb87a_1486x1144.png" width="1456" height="1121" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8927b34a-ade9-403b-a6d2-df85b66eb87a_1486x1144.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1121,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:83011,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Jo4D!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8927b34a-ade9-403b-a6d2-df85b66eb87a_1486x1144.png 424w, https://substackcdn.com/image/fetch/$s_!Jo4D!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8927b34a-ade9-403b-a6d2-df85b66eb87a_1486x1144.png 848w, https://substackcdn.com/image/fetch/$s_!Jo4D!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8927b34a-ade9-403b-a6d2-df85b66eb87a_1486x1144.png 1272w, https://substackcdn.com/image/fetch/$s_!Jo4D!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8927b34a-ade9-403b-a6d2-df85b66eb87a_1486x1144.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">On the left, we move until we overcome the obstacle. On the right, we move until we cross the goal axis</figcaption></figure></div><h3>Iteration 3: Going for Gold</h3><p>The last iteration we go up until we pass the goal axis, which this time happens at the goal! We did it! Only 3 iterations!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TGu2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F726d628f-b370-49fc-9e4f-6f2861bc94eb_1290x954.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TGu2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F726d628f-b370-49fc-9e4f-6f2861bc94eb_1290x954.png 424w, https://substackcdn.com/image/fetch/$s_!TGu2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F726d628f-b370-49fc-9e4f-6f2861bc94eb_1290x954.png 848w, https://substackcdn.com/image/fetch/$s_!TGu2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F726d628f-b370-49fc-9e4f-6f2861bc94eb_1290x954.png 1272w, https://substackcdn.com/image/fetch/$s_!TGu2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F726d628f-b370-49fc-9e4f-6f2861bc94eb_1290x954.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TGu2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F726d628f-b370-49fc-9e4f-6f2861bc94eb_1290x954.png" width="1290" height="954" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/726d628f-b370-49fc-9e4f-6f2861bc94eb_1290x954.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:954,&quot;width&quot;:1290,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:53999,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TGu2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F726d628f-b370-49fc-9e4f-6f2861bc94eb_1290x954.png 424w, https://substackcdn.com/image/fetch/$s_!TGu2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F726d628f-b370-49fc-9e4f-6f2861bc94eb_1290x954.png 848w, https://substackcdn.com/image/fetch/$s_!TGu2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F726d628f-b370-49fc-9e4f-6f2861bc94eb_1290x954.png 1272w, https://substackcdn.com/image/fetch/$s_!TGu2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F726d628f-b370-49fc-9e4f-6f2861bc94eb_1290x954.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>That&#8217;s it?</h2><p>Yes that&#8217;s it! Implementing this gives us a 100x+ speedup over our original grid-based autorouter, and no penalty for distant traces!</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!F4kY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f588045-097b-49e8-9440-58b8e0f8a060_1098x260.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!F4kY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f588045-097b-49e8-9440-58b8e0f8a060_1098x260.png 424w, https://substackcdn.com/image/fetch/$s_!F4kY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f588045-097b-49e8-9440-58b8e0f8a060_1098x260.png 848w, https://substackcdn.com/image/fetch/$s_!F4kY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f588045-097b-49e8-9440-58b8e0f8a060_1098x260.png 1272w, https://substackcdn.com/image/fetch/$s_!F4kY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f588045-097b-49e8-9440-58b8e0f8a060_1098x260.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!F4kY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f588045-097b-49e8-9440-58b8e0f8a060_1098x260.png" width="1098" height="260" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3f588045-097b-49e8-9440-58b8e0f8a060_1098x260.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:260,&quot;width&quot;:1098,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:41035,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!F4kY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f588045-097b-49e8-9440-58b8e0f8a060_1098x260.png 424w, https://substackcdn.com/image/fetch/$s_!F4kY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f588045-097b-49e8-9440-58b8e0f8a060_1098x260.png 848w, https://substackcdn.com/image/fetch/$s_!F4kY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f588045-097b-49e8-9440-58b8e0f8a060_1098x260.png 1272w, https://substackcdn.com/image/fetch/$s_!F4kY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f588045-097b-49e8-9440-58b8e0f8a060_1098x260.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Comparing this to the simple grid-base autorouter benchmark, we have a clear winner!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tTn3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe06516fa-0a2c-407f-b1df-3e4973bda1f6_1544x448.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tTn3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe06516fa-0a2c-407f-b1df-3e4973bda1f6_1544x448.png 424w, https://substackcdn.com/image/fetch/$s_!tTn3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe06516fa-0a2c-407f-b1df-3e4973bda1f6_1544x448.png 848w, https://substackcdn.com/image/fetch/$s_!tTn3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe06516fa-0a2c-407f-b1df-3e4973bda1f6_1544x448.png 1272w, https://substackcdn.com/image/fetch/$s_!tTn3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe06516fa-0a2c-407f-b1df-3e4973bda1f6_1544x448.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tTn3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe06516fa-0a2c-407f-b1df-3e4973bda1f6_1544x448.png" width="1456" height="422" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e06516fa-0a2c-407f-b1df-3e4973bda1f6_1544x448.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:422,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:78795,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tTn3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe06516fa-0a2c-407f-b1df-3e4973bda1f6_1544x448.png 424w, https://substackcdn.com/image/fetch/$s_!tTn3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe06516fa-0a2c-407f-b1df-3e4973bda1f6_1544x448.png 848w, https://substackcdn.com/image/fetch/$s_!tTn3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe06516fa-0a2c-407f-b1df-3e4973bda1f6_1544x448.png 1272w, https://substackcdn.com/image/fetch/$s_!tTn3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe06516fa-0a2c-407f-b1df-3e4973bda1f6_1544x448.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Why is it so fast?</h2><p>Where the simple-grid autorouter can take thousands of iterations, the ijump autorouter can take just 3-4. The main reason it&#8217;s better is it heuristics can be computed very quickly, and if the intersection is greater than 1 grid cell distance away, we&#8217;ve saved an iteration. In practice, this amounts to hundreds or thousands of iterations saved, making the cost of the intersection computation worth it.</p><p>It&#8217;s particularly good when the obstacles are sparse (like in the distant-trace dataset) but even with reasonably dense obstacles it tends to have many less iterations. The comparably low number of neighbors makes it easier for A* to select meaningfully different paths.</p><h2>Where it fails</h2><p>This autorouter is brand new, and I can&#8217;t find any literature on this technique (be sure to comment or <a href="https://x.com/seveibar">message me on twitter</a> if you find something), so there are a couple places where it doesn&#8217;t do so well.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BHg5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba7459b6-6c04-484b-9726-8f31a545f511_1238x992.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BHg5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba7459b6-6c04-484b-9726-8f31a545f511_1238x992.png 424w, https://substackcdn.com/image/fetch/$s_!BHg5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba7459b6-6c04-484b-9726-8f31a545f511_1238x992.png 848w, https://substackcdn.com/image/fetch/$s_!BHg5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba7459b6-6c04-484b-9726-8f31a545f511_1238x992.png 1272w, https://substackcdn.com/image/fetch/$s_!BHg5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba7459b6-6c04-484b-9726-8f31a545f511_1238x992.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BHg5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba7459b6-6c04-484b-9726-8f31a545f511_1238x992.png" width="1238" height="992" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ba7459b6-6c04-484b-9726-8f31a545f511_1238x992.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:992,&quot;width&quot;:1238,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:72463,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!BHg5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba7459b6-6c04-484b-9726-8f31a545f511_1238x992.png 424w, https://substackcdn.com/image/fetch/$s_!BHg5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba7459b6-6c04-484b-9726-8f31a545f511_1238x992.png 848w, https://substackcdn.com/image/fetch/$s_!BHg5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba7459b6-6c04-484b-9726-8f31a545f511_1238x992.png 1272w, https://substackcdn.com/image/fetch/$s_!BHg5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba7459b6-6c04-484b-9726-8f31a545f511_1238x992.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Especially with multi-trace datasets, weird lines are not unusual. Maybe some postprocessing would help?</figcaption></figure></div><h2>Want to build an autorouter?</h2><p>The <a href="https://github.com/tscircuit/autorouting-dataset">autorouting-dataset (github)</a> is a massive synthetic dataset of autorouting problems and a development environment for developing and benchmarking autorouters. I&#8217;d love to discuss and build autorouters together! There&#8217;s also a <a href="https://discord.gg/bQnACnZhBw">channel on our discord</a> where I&#8217;d love to help :) I&#8217;d also love to sponsor contributors to work on autorouting algorithms!</p><p>All the code for the IJump Autorouter is <a href="https://github.com/tscircuit/autorouting-dataset/blob/main/algos/infinite-grid-ijump-astar/v2/lib/IJumpAutorouter.ts">available on Github here</a>, you can <a href="https://dataset.autorouting.com/problem/traces/1/infgrid-ijump-astar">view it against datasets online too!</a></p><p>We&#8217;re just getting started in our adventures building autorouters, subscribe if you&#8217;re interested, we&#8217;ve got multi-layer autorouters, navmeshes, and new datasets coming soon!</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.autorouting.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">There&#8217;s so much more coming! Stay tuned for multi-layer autorouters, navmeshes and new datasets!</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><p></p>]]></content:encoded></item><item><title><![CDATA[Building a Grid-based PCB Autorouter]]></title><description><![CDATA[Build the best "getting started" autorouter, broken down step-by-step]]></description><link>https://blog.autorouting.com/p/building-a-grid-based-pcb-autorouter</link><guid isPermaLink="false">https://blog.autorouting.com/p/building-a-grid-based-pcb-autorouter</guid><dc:creator><![CDATA[Seve Ibarluzea]]></dc:creator><pubDate>Wed, 31 Jul 2024 05:35:03 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b5bb43f-595c-4019-a6c8-b4253e359f09_1560x948.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Autorouting is largely an unsolved problem</strong>. It&#8217;s the process of drawing all the little wires on a Printed Circuit Board that connect chips together. Believe it or not, this is still almost entirely done by humans today, people literally sit in front of a computer clicking and dragging to draw out each of the 1,000s of wires of a circuit. IMO it&#8217;s mostly unsolved because software engineers aren&#8217;t participating in the process of developing new autorouters, so in this post I hope to demystify some fundamental concepts.</p><blockquote><p>Before you even THINK about nerd-sniping me with <em>&#8220;actually, autorouting is a solved problem&#8221;</em> - I know if you set up your constraints you can get decent results. The problem is <em>even those results aren&#8217;t fast</em> and people still can&#8217;t agree on what foundational algorithms are ideal. Once there&#8217;s an open-source solution with wide adoption and real usage we can call it a solved problem.</p></blockquote><p>In this post, I&#8217;m going to show you how I quickly built the easiest of autorouters, a grid-based single layer autorouter. I&#8217;m also going to evaluate the autorouter on a new <a href="https://github.com/tscircuit/autorouting-dataset">dataset of thousands of autorouting problems</a> that you can play with or <a href="https://dataset.autorouting.com">view online here</a>.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WKlG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571dd81e-8f06-4d82-811f-352b8891a7f8_1042x755.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WKlG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571dd81e-8f06-4d82-811f-352b8891a7f8_1042x755.jpeg 424w, https://substackcdn.com/image/fetch/$s_!WKlG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571dd81e-8f06-4d82-811f-352b8891a7f8_1042x755.jpeg 848w, https://substackcdn.com/image/fetch/$s_!WKlG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571dd81e-8f06-4d82-811f-352b8891a7f8_1042x755.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!WKlG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571dd81e-8f06-4d82-811f-352b8891a7f8_1042x755.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WKlG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571dd81e-8f06-4d82-811f-352b8891a7f8_1042x755.jpeg" width="404" height="292.72552783109404" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/571dd81e-8f06-4d82-811f-352b8891a7f8_1042x755.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:755,&quot;width&quot;:1042,&quot;resizeWidth&quot;:404,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;From Arduino Prototype to Mass Production&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="From Arduino Prototype to Mass Production" title="From Arduino Prototype to Mass Production" srcset="https://substackcdn.com/image/fetch/$s_!WKlG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571dd81e-8f06-4d82-811f-352b8891a7f8_1042x755.jpeg 424w, https://substackcdn.com/image/fetch/$s_!WKlG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571dd81e-8f06-4d82-811f-352b8891a7f8_1042x755.jpeg 848w, https://substackcdn.com/image/fetch/$s_!WKlG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571dd81e-8f06-4d82-811f-352b8891a7f8_1042x755.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!WKlG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F571dd81e-8f06-4d82-811f-352b8891a7f8_1042x755.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">The Arduino Uno R3&#8217;s routing. How hard could it be to do that automatically?</figcaption></figure></div><p></p><p>This is <strong>Part 1</strong> of the <strong>Building Autorouters Series</strong> where we&#8217;ll build different types of autorouters, <strong>Part 2</strong> is about a gridless autorouting technique that uses line collisions, subscribe to stay tuned! </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.autorouting.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Subscribe to hear about <strong>Part 2 with a Gridless Autorouter</strong>, new autorouting datasets, new benchmarks and new algorithms!</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>A quick note on terminology</h2><p>For basic autorouting, you really only need to know a couple concepts</p><ul><li><p>Chips are glued (soldered) to a circuit board by placing them on &#8220;Copper Pads&#8221;</p></li><li><p>To connect two chips together, we draw traces between their Pads</p></li><li><p>When drawing a trace, other Pads become Obstacles</p></li></ul><p>That&#8217;s basically it! We&#8217;re just drawing lines.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EcB8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b5bb43f-595c-4019-a6c8-b4253e359f09_1560x948.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EcB8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b5bb43f-595c-4019-a6c8-b4253e359f09_1560x948.png 424w, https://substackcdn.com/image/fetch/$s_!EcB8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b5bb43f-595c-4019-a6c8-b4253e359f09_1560x948.png 848w, https://substackcdn.com/image/fetch/$s_!EcB8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b5bb43f-595c-4019-a6c8-b4253e359f09_1560x948.png 1272w, https://substackcdn.com/image/fetch/$s_!EcB8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b5bb43f-595c-4019-a6c8-b4253e359f09_1560x948.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EcB8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b5bb43f-595c-4019-a6c8-b4253e359f09_1560x948.png" width="1456" height="885" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8b5bb43f-595c-4019-a6c8-b4253e359f09_1560x948.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:885,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:83522,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EcB8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b5bb43f-595c-4019-a6c8-b4253e359f09_1560x948.png 424w, https://substackcdn.com/image/fetch/$s_!EcB8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b5bb43f-595c-4019-a6c8-b4253e359f09_1560x948.png 848w, https://substackcdn.com/image/fetch/$s_!EcB8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b5bb43f-595c-4019-a6c8-b4253e359f09_1560x948.png 1272w, https://substackcdn.com/image/fetch/$s_!EcB8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b5bb43f-595c-4019-a6c8-b4253e359f09_1560x948.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Grid-Based Autorouting</h2><p>Before we dive into the code (don't worry, it's coming), let's talk about why I chose a grid-based approach. </p><h4>Pros of Grid-based Autorouting</h4><ol><li><p><strong>It's Stupid Simple</strong>. Pathfinding on a 2d grid is incredibly common in game design, there&#8217;s almost certainly a library in your language that does it</p></li><li><p><strong>Fast</strong> for dense &#8220;maze-like&#8221; designs without a lot of area</p></li><li><p><strong>Consistent Clearance</strong>: Guaranteed clearance between traces. No awkward touching</p></li><li><p><strong>Layer Friendly</strong>: Multi-layer routing? Just add more grids.</p></li></ol><h4>Cons of Grid-Based Autorouting</h4><ol><li><p><strong>Limited Angles/Curves</strong>: Generally limits traces at 45 or 90 degrees (many EEs prefer this anyway)</p></li><li><p><strong>Resolution</strong>: Sometimes, you need more cells than the grid allows, and increasing the number of cells increasing computation time.</p></li><li><p><strong>Limited for Odd Pads</strong>: Funky pad shapes (and to a lesser extent circles) have trouble fitting onto a grid perfectly.</p></li><li><p><strong>Performance limited by size of grid</strong> <strong>- </strong>your memory usage is going to scale with the area of your circuit board, this can be pretty intense since you&#8217;ll typically want to have each cell less than 0.1mm x 0.1mm</p></li></ol><h2>Let's Get This Party Started: Implementing Our Grid-Based Autorouter</h2><p>Here's how we're going to structure this beast:</p><ol><li><p><strong>Grid Creation</strong>: We'll create our grid(s) based on the PCB dimensions.</p></li><li><p><strong>Mark Cells with Obstacles Unwalkable</strong>: We'll mark all the components as no-go zones on our grid</p></li><li><p><strong>Pathfinding and Routing</strong>: We'll set up our A* pathfinder and use it to route all our connections, avoiding any traces that have already been laid</p></li></ol><p>All of the code we write today takes in &#8220;<a href="https://github.com/tscircuit/autorouting-dataset?tab=readme-ov-file#usage">Simple Route JSON</a>&#8221; and spits out <a href="https://github.com/tscircuit/autorouting-dataset?tab=readme-ov-file#typescript-solvers">JSON &#8220;pcb_trace&#8221; objects</a>. In PCB land these simplified JSON formats are uncommon, most formats are in the form of s-expressions, deprecated XML files and hundred-page-spec binary formats.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4S5X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbf119e1-1379-48d6-a5b2-ec4f0d5c492a_2576x1316.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4S5X!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbf119e1-1379-48d6-a5b2-ec4f0d5c492a_2576x1316.png 424w, https://substackcdn.com/image/fetch/$s_!4S5X!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbf119e1-1379-48d6-a5b2-ec4f0d5c492a_2576x1316.png 848w, https://substackcdn.com/image/fetch/$s_!4S5X!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbf119e1-1379-48d6-a5b2-ec4f0d5c492a_2576x1316.png 1272w, https://substackcdn.com/image/fetch/$s_!4S5X!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbf119e1-1379-48d6-a5b2-ec4f0d5c492a_2576x1316.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4S5X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbf119e1-1379-48d6-a5b2-ec4f0d5c492a_2576x1316.png" width="1456" height="744" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bbf119e1-1379-48d6-a5b2-ec4f0d5c492a_2576x1316.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:744,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:247716,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4S5X!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbf119e1-1379-48d6-a5b2-ec4f0d5c492a_2576x1316.png 424w, https://substackcdn.com/image/fetch/$s_!4S5X!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbf119e1-1379-48d6-a5b2-ec4f0d5c492a_2576x1316.png 848w, https://substackcdn.com/image/fetch/$s_!4S5X!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbf119e1-1379-48d6-a5b2-ec4f0d5c492a_2576x1316.png 1272w, https://substackcdn.com/image/fetch/$s_!4S5X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbf119e1-1379-48d6-a5b2-ec4f0d5c492a_2576x1316.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><blockquote><p>Want to skip ahead? Here&#8217;s <a href="https://github.com/tscircuit/autorouting-dataset/tree/main/algos/simple-grid-based">the source</a></p></blockquote><h3>Making the Grid</h3><p>Let's construct a 2d binary grid with 0.1mm x 0.1mm cells.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fnPq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd07020de-020f-4fe7-81ab-21eb445cb24b_2856x1596.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fnPq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd07020de-020f-4fe7-81ab-21eb445cb24b_2856x1596.png 424w, https://substackcdn.com/image/fetch/$s_!fnPq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd07020de-020f-4fe7-81ab-21eb445cb24b_2856x1596.png 848w, https://substackcdn.com/image/fetch/$s_!fnPq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd07020de-020f-4fe7-81ab-21eb445cb24b_2856x1596.png 1272w, https://substackcdn.com/image/fetch/$s_!fnPq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd07020de-020f-4fe7-81ab-21eb445cb24b_2856x1596.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fnPq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd07020de-020f-4fe7-81ab-21eb445cb24b_2856x1596.png" width="1456" height="814" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d07020de-020f-4fe7-81ab-21eb445cb24b_2856x1596.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:814,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:412111,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fnPq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd07020de-020f-4fe7-81ab-21eb445cb24b_2856x1596.png 424w, https://substackcdn.com/image/fetch/$s_!fnPq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd07020de-020f-4fe7-81ab-21eb445cb24b_2856x1596.png 848w, https://substackcdn.com/image/fetch/$s_!fnPq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd07020de-020f-4fe7-81ab-21eb445cb24b_2856x1596.png 1272w, https://substackcdn.com/image/fetch/$s_!fnPq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd07020de-020f-4fe7-81ab-21eb445cb24b_2856x1596.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Now we&#8217;ll set the inside of each obstacle as &#8220;unwalkable&#8221; by iterating over each obstacle, then each cell inside each obstacle&#8217;s bounds.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ob8A!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda10edfc-c133-4daa-94b2-2e02a3551efc_2672x2156.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ob8A!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda10edfc-c133-4daa-94b2-2e02a3551efc_2672x2156.png 424w, https://substackcdn.com/image/fetch/$s_!Ob8A!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda10edfc-c133-4daa-94b2-2e02a3551efc_2672x2156.png 848w, https://substackcdn.com/image/fetch/$s_!Ob8A!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda10edfc-c133-4daa-94b2-2e02a3551efc_2672x2156.png 1272w, https://substackcdn.com/image/fetch/$s_!Ob8A!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda10edfc-c133-4daa-94b2-2e02a3551efc_2672x2156.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ob8A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda10edfc-c133-4daa-94b2-2e02a3551efc_2672x2156.png" width="1456" height="1175" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/da10edfc-c133-4daa-94b2-2e02a3551efc_2672x2156.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1175,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:496715,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Ob8A!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda10edfc-c133-4daa-94b2-2e02a3551efc_2672x2156.png 424w, https://substackcdn.com/image/fetch/$s_!Ob8A!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda10edfc-c133-4daa-94b2-2e02a3551efc_2672x2156.png 848w, https://substackcdn.com/image/fetch/$s_!Ob8A!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda10edfc-c133-4daa-94b2-2e02a3551efc_2672x2156.png 1272w, https://substackcdn.com/image/fetch/$s_!Ob8A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda10edfc-c133-4daa-94b2-2e02a3551efc_2672x2156.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Pathfinding and Routing: Where the Magic Happens</h3><p>Alright, this is where things get spicy. We're going to set up a A* pathfinder using the <strong><a href="https://www.npmjs.com/package/pathfinding">pathfinding</a></strong> module and use it to route all our connections.</p><ol><li><p>For each connection, look at each pair of points (A &amp; B) that make up the connection</p></li><li><p>Try to create a path from A to B using A*</p></li><li><p>If we find a path, add it to our array of pcbTraces</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yFr3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d4b4190-bdf8-4672-a679-280707112fad_2112x1476.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yFr3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d4b4190-bdf8-4672-a679-280707112fad_2112x1476.png 424w, https://substackcdn.com/image/fetch/$s_!yFr3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d4b4190-bdf8-4672-a679-280707112fad_2112x1476.png 848w, https://substackcdn.com/image/fetch/$s_!yFr3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d4b4190-bdf8-4672-a679-280707112fad_2112x1476.png 1272w, https://substackcdn.com/image/fetch/$s_!yFr3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d4b4190-bdf8-4672-a679-280707112fad_2112x1476.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yFr3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d4b4190-bdf8-4672-a679-280707112fad_2112x1476.png" width="1456" height="1018" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6d4b4190-bdf8-4672-a679-280707112fad_2112x1476.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1018,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:278887,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!yFr3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d4b4190-bdf8-4672-a679-280707112fad_2112x1476.png 424w, https://substackcdn.com/image/fetch/$s_!yFr3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d4b4190-bdf8-4672-a679-280707112fad_2112x1476.png 848w, https://substackcdn.com/image/fetch/$s_!yFr3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d4b4190-bdf8-4672-a679-280707112fad_2112x1476.png 1272w, https://substackcdn.com/image/fetch/$s_!yFr3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d4b4190-bdf8-4672-a679-280707112fad_2112x1476.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>And there you have it! It's finding paths, laying down traces, and respecting the personal space of components.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Gysk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60d97aee-24fe-45bb-92e6-0bb48510878b_1455x675.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Gysk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60d97aee-24fe-45bb-92e6-0bb48510878b_1455x675.png 424w, https://substackcdn.com/image/fetch/$s_!Gysk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60d97aee-24fe-45bb-92e6-0bb48510878b_1455x675.png 848w, https://substackcdn.com/image/fetch/$s_!Gysk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60d97aee-24fe-45bb-92e6-0bb48510878b_1455x675.png 1272w, https://substackcdn.com/image/fetch/$s_!Gysk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60d97aee-24fe-45bb-92e6-0bb48510878b_1455x675.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Gysk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60d97aee-24fe-45bb-92e6-0bb48510878b_1455x675.png" width="1455" height="675" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/60d97aee-24fe-45bb-92e6-0bb48510878b_1455x675.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:675,&quot;width&quot;:1455,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:67025,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Gysk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60d97aee-24fe-45bb-92e6-0bb48510878b_1455x675.png 424w, https://substackcdn.com/image/fetch/$s_!Gysk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60d97aee-24fe-45bb-92e6-0bb48510878b_1455x675.png 848w, https://substackcdn.com/image/fetch/$s_!Gysk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60d97aee-24fe-45bb-92e6-0bb48510878b_1455x675.png 1272w, https://substackcdn.com/image/fetch/$s_!Gysk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60d97aee-24fe-45bb-92e6-0bb48510878b_1455x675.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Before and after inside the autorouting-dataset dev server using our simple grid-based autrouter</figcaption></figure></div><p>This is basically the hello world of autorouters. For simple connections, it gets the job done, but as designs get more complex, you&#8217;ll want to implement algorithms on top of this like &#8220;rip and replace&#8221;, which is where you remove traces that are too often &#8220;in the way&#8221;. You&#8217;ll also notice that this autorouter is very order-dependent, the first trace is much more likely to get the shortest route.</p><h2>The kryptonite of grid-based autorouters</h2><p>The performance of this grid solver falls apart as soon as you have traces separated by any distance. <strong>Creating a huge grid and checking for collisions all over it isn&#8217;t cheap!</strong> If you run this solver against the the <strong><a href="https://dataset.autorouting.com/problem/distant-single-trace/1">distant-single-trace</a> dataset, </strong>it suddenly becomes <strong>94x slower</strong>, even though the complexity of the dataset in terms of pads and traces is identical to the <a href="https://dataset.autorouting.com/problem/single-trace/1">single-trace dataset</a>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WL99!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F725dfe9a-0575-4365-aa19-178aefbd2c25_1110x495.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WL99!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F725dfe9a-0575-4365-aa19-178aefbd2c25_1110x495.png 424w, https://substackcdn.com/image/fetch/$s_!WL99!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F725dfe9a-0575-4365-aa19-178aefbd2c25_1110x495.png 848w, https://substackcdn.com/image/fetch/$s_!WL99!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F725dfe9a-0575-4365-aa19-178aefbd2c25_1110x495.png 1272w, https://substackcdn.com/image/fetch/$s_!WL99!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F725dfe9a-0575-4365-aa19-178aefbd2c25_1110x495.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WL99!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F725dfe9a-0575-4365-aa19-178aefbd2c25_1110x495.png" width="1110" height="495" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/725dfe9a-0575-4365-aa19-178aefbd2c25_1110x495.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:495,&quot;width&quot;:1110,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:76836,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WL99!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F725dfe9a-0575-4365-aa19-178aefbd2c25_1110x495.png 424w, https://substackcdn.com/image/fetch/$s_!WL99!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F725dfe9a-0575-4365-aa19-178aefbd2c25_1110x495.png 848w, https://substackcdn.com/image/fetch/$s_!WL99!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F725dfe9a-0575-4365-aa19-178aefbd2c25_1110x495.png 1272w, https://substackcdn.com/image/fetch/$s_!WL99!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F725dfe9a-0575-4365-aa19-178aefbd2c25_1110x495.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">50x increase in time, despite having the same number of connections, pads and obstacles</figcaption></figure></div><p>Running a benchmark using the <code>npx autorouting-dataset benchmark </code>confirms the slowness.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MEmd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12ca1912-659a-4395-92da-af2a2b653581_966x364.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MEmd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12ca1912-659a-4395-92da-af2a2b653581_966x364.jpeg 424w, https://substackcdn.com/image/fetch/$s_!MEmd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12ca1912-659a-4395-92da-af2a2b653581_966x364.jpeg 848w, https://substackcdn.com/image/fetch/$s_!MEmd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12ca1912-659a-4395-92da-af2a2b653581_966x364.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!MEmd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12ca1912-659a-4395-92da-af2a2b653581_966x364.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MEmd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12ca1912-659a-4395-92da-af2a2b653581_966x364.jpeg" width="966" height="364" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/12ca1912-659a-4395-92da-af2a2b653581_966x364.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:364,&quot;width&quot;:966,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Image&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Image" title="Image" srcset="https://substackcdn.com/image/fetch/$s_!MEmd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12ca1912-659a-4395-92da-af2a2b653581_966x364.jpeg 424w, https://substackcdn.com/image/fetch/$s_!MEmd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12ca1912-659a-4395-92da-af2a2b653581_966x364.jpeg 848w, https://substackcdn.com/image/fetch/$s_!MEmd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12ca1912-659a-4395-92da-af2a2b653581_966x364.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!MEmd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12ca1912-659a-4395-92da-af2a2b653581_966x364.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Conclusion- What&#8217;s Next</h2><p>Grid-based autorouters definitely play their part, I think if you&#8217;re in a dense routing situation it can makes sense to whip out the grid, but we&#8217;re going to take a break from Grids in Part 2 and work on a totally different type of autorouter, one that uses line collisions and a BFS algorithm to quickly solve for autorouting paths regardless of the distance.</p><p>Can you think of what kinds of datasets stump a gridless autorouter? Want to make your own autorouter? Join the <a href="https://tscircuit.com/community/join-redirect">tscircuit discord</a>, <a href="https://github.com/tscircuit/autorouting-dataset">check out the Github</a>, or subscribe to follow along!</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.autorouting.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Subscribe for free to hear about new open-source autorouters, algorithms and datasets!</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Coming soon]]></title><description><![CDATA[This is autorouting.]]></description><link>https://blog.autorouting.com/p/coming-soon</link><guid isPermaLink="false">https://blog.autorouting.com/p/coming-soon</guid><dc:creator><![CDATA[Seve Ibarluzea]]></dc:creator><pubDate>Sat, 20 Jul 2024 18:22:32 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Cwtu!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc458374f-2a43-4c52-bbe7-823f9faf0fa2_200x200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This is autorouting.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://blog.autorouting.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://blog.autorouting.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item></channel></rss>