Planet Sagehttp://planet.sagemath.org/atom.xml2020-01-26T18:27:32+00:00Planet/2.0 +http://www.planetplanet.orgShould I Resign from My Full Professor Job to Work Fulltime on Cocalc?tag:blogger.com,1999:blog-6365588202025292315.post-81211311172219914642019-05-09T14:21:33+00:00<div><span>Nearly 3 years ago, I gave <a href="https://wstein.org/talks/2016-06-sage-bp/">a talk</a> at a Harvard mathematics conference announcing that “I am leaving academia to build a company”. What I really did is go on <em>unpaid leave</em> for three years from my tenured Full Professor position. No further extensions of that leave is possible, so I finally have to decide whether or not to go back to academia or resign.</span></div><h2 id="how-did-i-get-here"><span><span>How did I get here?</span></span></h2><div><span>Nearly two decades ago, as a recently minted Berkeley math Ph.D., I was hired as a non-tenure-track faculty member in the mathematics department at Harvard. I spent five years at Harvard, then I applied for jobs, and accepted a tenured Associate Professor position in the mathematics department at UC San Diego. The mathematics community was very supportive of my number theory research; I skipped tenure track, and landed a tier-1 tenured position by the time I was 30 years old. In 2006, I moved from UCSD to a tenured Associate Professor position at the University of Washington (UW) mathematics department, primarily because my wife was a graduate student there, UW has strong research in number theory and algebraic geometry, and they have a good culture supporting undergraduate research.</span></div><div><span><br /></span></div><div><span>Before I left Harvard, I started the <a href="https://sagemath.org/">SageMath open source software project</a>, initially with the longterm goal of creating a free open source viable alternative to Mathematica, Maple, Matlab and Magma. As a result, in addition to publishing <a href="https://wstein.org/papers/">dozens of research mathematics papers</a> and <a href="https://wstein.org/books/">some books</a>, I also started spending a lot of my time writing software, and organizing <a href="https://wiki.sagemath.org/Workshops#Past_Workshops">Sage Days workshops</a>.</span></div><h2 id="recruiting-at-uw-mathematics"><span><span>Recruiting at UW Mathematics</span></span></h2><div><span>At UW, I recruited an amazing team of undergraduates and grad students who had a major impact on the development of Sage. I was blown away by the quality of the students (both undergrad and grad) that I was able to get involved in Sage development. I fully expected that in the next few years I would have the resources to hire some of these students to work fulltime on Sage. They had written the first versions of much of the core functionality of Sage (e.g., graph theory, symbolic calculus, matrices, and much more).</span></div><div><span><br /></span></div><div><span>I was surprised when my application for Full Professor at UW was delayed for one year because – I was told – I wasn’t publishing enough research papers. This was because I was working very hard on building Sage, which was going extremely well at the time. I took the feedback seriously, and put more time into traditional research and publishing; this was the first time in my life that I did research mathematics for reasons other than just because I loved doing it.</span></div><div><span><br /></span></div><div><span>I tried very hard to hire <a href="http://wbhart.blogspot.com/">Bill Hart</a> as a tenure-track faculty member at UW. However, I was told that his publication count was <em>“a bit light”</em>, and I did not succeed at hiring him. If you printed out the source code of software he has written, it would be a tall stack of paper. In any case, I totally failed at the politics needed to make his case and was left dispirited, realizing my personal shortcomings at department politics meant I probably could not hire the sort of colleagues I desperately needed.</span></div><div><span>UW was also very supportive of me teaching an undergrad course on open source math software (it evolved into <a href="https://github.com/kedlaya/math157">this</a>). I taught a similar course at the graduate level once, and it went extremely well, and was in my mind the best course I ever taught at UW. I was extremely surprised when my application to teach that grad course again was denied, and I was told that grad students should just go to my undergraduate course. I thought, “this is really strange”, instead of lobbying to teach the course and better presenting my case.</span></div><div><span><br /></span></div><div><span>To be clear, I do not mean to criticize the mathematics department. The UW math department has thought very hard and systematically about their priorities and how they fit into UW. They are a traditional <em>pure</em> mathematics departments that is generally ranked around 25 in the country, with a particular set of strengths. There is a separate applied math department on campus, several stats departments, and a massive School of Computer Science. Maybe I was in the wrong place to try to hire somebody whose main qualification is being world class at writing mathematical software. This blog post is about the question of whether the UW math department is the right place for me or not.</span></div><h2 id="outside-grant-support"><span><span>Outside Grant Support?</span></span></h2><div><span>My number theory research received incredible support from the NSF, with me being the PI on <a href="https://wstein.org/grants/">six NSF grants</a>. Also, <a href="https://magma.maths.usyd.edu.au/">Magma</a> (which is similar to Sage, but closed source) had managed to find sufficient government funding, so I remained optimistic. Maybe I could fund people to build Sage via grants, and even start an institute! I applied for grants to support work on SageMath at a larger scale, and had some initial success (half of a postdoc, and some workshops, etc.).</span></div><div><span><br /></span></div><div><span>Why is grant funding so important for Sage? The goal of the SageMath project is to create free open source software that is a viable alternative to Mathematica, Maple, Matlab, and Magma – software produced by companies with a combined thousands of fulltime employees. Though initial progress was encouraging, it was clear that I desperately needed significant money to genuinely compete. For example, one Sage developer had a fantastic Sage development project he wanted about 20K to work fulltime on during a summer, and I could not find the money; as a result he quit working on Sage. This project involved implementing some deep algorithms that are needed to more directly compete with Mathematica for solving symbolic inequalities. This sort of thing happened over and over again, and it began to really frustrate me. I could get plenty of funding for 1-week workshops (just travel expenses – everybody works for free), but there’s only so much you can do at such sprints.</span></div><div><span><br /></span></div><div><span>I kept hearing that there would be a big one-in-10-years NSF institutes competition sometime in the “next year or two”. People hinted to me that this would be a good thing to watch out for, and I dreamed that I could found such an institute, with the mission to make it so the mathematics community finally owned the deep software on which teaching and research are based. This institute would bring the same openness and robustness to computational mathematics that rigorous proof had brought to mathematics itself a century earlier.</span></div><div><span><br /></span></div><div><span>Alas, this did not happen. I remember the moment I found out about the actual NSF institutes competition. <a href="http://www.math.brown.edu/~jhs/">Joe Silverman</a> was standing behind me at a coffee break at <a href="http://swc.math.arizona.edu/aws/2010/index.html">The Arizona Winter School 2010</a> telling people about how <a href="https://icerm.brown.edu/">his proposal for ICERM</a> had just won the NSF institutes competition. I spun around and congratulated him as I listened to how much work it was to put together the application during the last year; internally, my heart sunk. Not only did I not win, I didn’t even know the competition had happened! I guess I was too busy working on Sage. In any case, my fantasy of creating an NSF-funded institute died at that moment. Of course, ICERM has turned out to be a fantastic institute, and it has hosted several workshops that support the development of open source math software.</span></div><div><span><br /></span></div><div><span>Around this time, I also started <a href="https://wstein.org/grants/">having my grant proposals denied</a> for reasons I do not understand. This was confusing to me, after having received so many NSF grants before. In 2012, the Simons Foundation put out a call for something that potentially addressed what I had hoped to accomplish via an NSF-funded institute. I was very excited again, but that <a href="http://sagemath.blogspot.com/2015/09/the-simons-foundation-and-open-source.html">did not turn out as I had hoped</a>. So next I tried something I never thought I would ever do in a million years…</span></div><h2 id="commercialization-at-uw"><span><span>Commercialization at UW</span></span></h2><div><span>For various reasons, I failed to get the NSF or other foundations to fund Sage at the level I needed, so in 2013, I decided to try to sell a commercial product, and use the profits to fund Sage development. I first tried to do this at University of Washington, by working with <a href="https://comotion.uw.edu/">the commercialization office (C4C)</a> to sell access to Sage online. As long as the business and product were merely abstract ideas (e.g., let’s make up a name and trademark it! let’s write some terms of service!) things went fine. However, when things became much more concrete, working with C4C got strange and frustrating for me. I was clearly missing something.</span></div><div><span><br /></span></div><div><span>For example, the first thing C4C told me on the very first day we sat down together was they would not work with me if I made the software I wrote for this open source, and that the university would own the software. Given there was no software at all yet, and I imagined I would just whip out a quick modern web-based frontend to Sage and make boatloads of money that would go straight into a UW account to be used to fund Sage, this seemed fine to me. However, I had a nagging feeling that a pure closed-source approach to this problem was impossible, and not having that flexibility would come back to haunt me.</span></div><div><span><br /></span></div><div><span>Naively optimistic, I found myself working fulltime at UW and at the same time trying to get a sophisticated web application off the ground by myself, with many important early users depending on it for their classes. This was stressful and took an enormous amount of time and attention. I felt like I was just part of the software, often getting warnings that things were broken or breaking, and manually fixing them. The toil was high, and only got worse as more people used the software. I would get woken up all night. I couldn’t travel since things were constantly breaking.</span></div><div><span><br /></span></div><blockquote><em>Every time I fought through some really difficult problem with the web application instead of just giving up, I came out far more determined not to quit.</em></blockquote><br /><div><span>The web application described above evolved over 6 years into what is now <a class="vglnk" href="https://cocalc.com/" rel="nofollow">https://CoCalc.com</a>; the functionality was pretty similar from day 1, but quality and scalability have come a long ways. CoCalc lets you collaboratively use LaTeX, Sage, Terminals, Jupyter Notebooks, etc., for teaching and research.</span></div><div><span><br /></span></div><div><span>In 2014, I went on sabbatical and worked fulltime developing this web application and the feedback loop I described above only grew more intense: fix things, fight through difficult problems, be even more determined not to give up. Fortunately, I had some leftover NSF grant funds, and was able to use them to hire several students to help with development. I failed to find students who I could hire to do the backend work (and be available any time day or night), which meant that much of the stress of keeping the site running continued to fall squarely on my shoulders. And as the site grew in popularity (and functionality), the stress from it got worse.</span></div><div><span><br /></span></div><div><span>My Sabbatical ended, and I was required to return to UW fulltime for one year, or return all the money I was paid during my sabbatical. So far, CoCalc had grown in popularity, but I had not been allowed by the “commercialization office” to actually commercialize it, so it was still a free site.</span></div><div><span>I taught at UW at the same time as being the main person trying to run this very complicated and painful production web application. Based on user feedback, I was also highly motivated to improve CoCalc. I would typically sleep a few hours, get up at 3am and write code until 8am, then prepare to teach, hope not to have any site issues right before class, and so on. One day CoCalc got hit by a massive DDoS attack minutes before a class I was teaching, while I was talking with a prospective donor to the math department.</span></div><div><span><br /></span></div><div><span>I am the sort of person who does well focusing on exactly one thing at a time. Given the chance to fully focus on one thing for extended periods of time, I sometimes even do things that really matter and have an impact. I am not great at doing many different things at once.</span></div><div><span><br /></span></div><div><span>In the meantime, Sage itself was growing and receiving funding, though this had nothing to do with me. For example, Gregg Musiker was putting together a <a href="https://www.ima.umn.edu/2017-2018.2/W8.21-25.17">big program at IMA</a>, in the form of a ton of Sage Days workshops. Also, the <a href="https://opendreamkit.org/">huge ODK project</a>, which was a European Union grant proposal to support open source math software would be fully funded. And closer to home, Moore and Sloane funded a <a href="https://escience.washington.edu/">major new initiative</a> that could potentially have also supported work on Sage. I was invited to go to workshops and events involving these and other grants, but often I either said no or canceled at the last minute due to the toil needed just to keep CoCalc running. Also, I believed if I could start charging customers, then I would have a lot more money, and could hire more help.</span></div><div><span>I met with more senior people at UW’s C4C to finally actually charge people to use CoCalc. They wanted me to do some integration with their license management system, and sell “express” software licenses. It didn’t make any sense to me, and we went around in circles. I then asked about actually starting a separate company (a legal entity) that the university would have some ownership in, so that the company could take payments, etc. This is when things got really weird. They would not talk with me about creating the company due to “conflict of interest”.</span></div><div><span><br /></span></div><div><span>I searched for other UW faculty that had commercialized remotely similar products, and found one. He told me how it went, and said it was the worst experience of his life. UW owned 50% of the company, and all of the software of the company, which they licensed under onerous terms. They refused to negotiate anything with him, instead requiring his spinoff company to hire an outside negotiator. As a result of all this, I educated myself as much as possible about relevant rules and laws, and consulted with a lawyer.</span></div><div><span><br /></span></div><div><span>It turns out that the NSF grants I used to fund work on CoCalc explicitly stipulated that code funded by those grants had to be GPL licensed. <a href="https://news.ycombinator.com/item?id=8967094">This meant all the code for CoCalc had to be open sourced.</a> Later the university even agreed in writing to release a snapshot of all the CoCalc code under the BSD license, and I haven’t been paid a penny by UW since the date of that release, so there is no possible claim that the company can’t use the code.</span></div><h2 id="building-a-company"><span><span>Building a company</span></span></h2><div><span>A colleague of mine from when I was at Harvard was in town for a day, and we met for coffee. He expected we would talk about Sage and number theory, but instead I told him about CoCalc and my attempts at commercialization and starting a company. He immediately suggested a solution to my problems, which was to talk with a friend of his who had both extensive experience working with companies and deep connections with mathematics. I was confident that in the worst case I could quit my job at UW and rewrite all the software from scratch, so I took him up on the offer.</span></div><div><span>In 2015 I formed a corporation, and received some outside investment, and used that (and dramatically cutting my already-small academic income) to “leave academia”. More precisely, in 2016 (after working fulltime for a year at UW), I finally went on 100% unpaid leave from UW in order to completely focus on CoCalc development and getting a business off the ground. Also, there was no good reason to quit a tenured Full Professor job when you can go on leave; also CoCalc supports teaching in math departments, so it is closely related to my academic job. The only academic responsibilities I had were to my two Ph.D. students, who I meet with one-on-one at least once a week. At the end of two years, I requested a third year of unpaid leave, which UW granted (this is not routine). Throughout all this, the UW mathematics department was very supportive.</span></div><div><span>During these three years on unpaid leave, I’ve hired <a href="http://blog.sagemath.com/cocalc/2018/09/10/where-is-cocalc-from.html">three other people</a> who work fulltime on CoCalc. Together we have massively improved the software, and built a business with thousands of paying customers. The company is still not profitable, though the future is clearly very bright if we continue what we are currently doing. CoCalc has become a platform that an increasing number of scalable products (such as <a href="https://wit.io/portfolio/minerva-active-learning-forum">this</a>) are being built with, and there is enormous growth potential in the next year.</span></div><div><span><br /></span></div><div><span>At this point, <a href="https://github.com/sagemath/website/pull/162#issue-248232293">it rightfully appears to the community</a> that I have left SageMath development to focus fulltime on building CoCalc as an independent business. Indeed, I do not spend any significant time contributing to Sage, and I even switched to getting daily digests of <a href="https://groups.google.com/forum/#!forum/sage-devel">the sage-devel mailing list</a>.</span></div><div><span>On the other hand, as mentioned above, CoCalc is going well by many metrics (in terms of quality, feature development, customer love, market position, etc.). Most importantly, me and the other three people who work fulltime on CoCalc really, really love this job, and the potential to have a significant impact. I still don’t know if CoCalc will ever be wildly profitable and massively fund Sage development. If I were to obsess over only that goal, I would have to quit working on CoCalc (since it is taking way too long) and pursue other opportunities for funding Sage.</span></div><div><span><br /></span></div><blockquote><em>In retrospect, my idea from 7 years ago to start a web-based software company from scratch and build it into a successful profitable business has so far completely failed to fund Sage.</em></blockquote><br /><div><span>It would be far easier to work fulltime writing grants to foundations, and leveraging the <a href="http://www.sigsam.org/awards/jenks/awardees/2013/">acknowledged success</a> of Sage so far. I made the wrong move, given my original goal. The surprise is that I really enjoy what I’m doing right now!</span></div><h2 id="my-unpaid-leave-is-up--what-am-i-going-to-do"><span><span>My unpaid leave is up – what am I going to do?</span></span></h2><div><span>My third year of unpaid leave from UW is up. I have to decide whether to return to UW or resign. If I return, it turns out that I would have to have <a href="https://ap.washington.edu/ahr/academic-titles-ranks/professor/">at least a 50% appointment</a>. I currently have 50% of one year of teaching in “credits”, which means I wouldn’t be required to teach for the first year I go back as a 50% appointment. Moreover, the current department chair (John Palmieri) understands and appreciates Sage – he is among the <a href="https://github.com/sagemath/sage/graphs/contributors">top 10 all time contributors to the source code of Sage</a>!</span></div><div><span><br /></span></div><div><span>I have decided to resign. I’m worried about issues of intellectual property; it would be extremely unfair to my employees, investors and customers if I took a 50% UW position, and then later got sued by UW as a result. Having a 50% paid appointment at UW subjects one to a lot of legal jeopardy, which is precisely why I have been on 100% unpaid leave for the last three years. But more importantly, I feel very good about continuing to focus 100% on the development of CoCalc, which is going to have an incredible year going forward. I genuinely love building this (non-VC funded) company, and feel very good about it.</span></div>William Steinnoreply@blogger.comhttp://sagemath.blogspot.com/Comment installer et utiliser RISE, une extension du notebook Jupyter pour faire des présentationshttp://www.slabbe.org/blogue/2019/01/comment-installer-et-utiliser-rise-une-extension-du-notebook-jupyter-pour-faire-des-presentations2019-01-24T10:37:00+00:00<div class="document">
<p>La semaine dernière, Jeroen Demeyer a fait une présentation lors de l'<a class="reference external" href="https://pari.math.u-bordeaux.fr/Events/PARI2019/">Atelier
PARI/GP 2019</a> au sujet de <a class="reference external" href="https://pypi.org/project/cypari2/">cypari2</a>.</p>
<p>La présentation de Jeroen consistait en des diapositives HTML où les calculs
sont faits en direct (avec Jupyter) et où on peut les modifier en direct dans
les diapositives. Impressionant! Tout cela grâce au package Python <a class="reference external" href="https://pypi.org/project/rise/">RISE</a>.</p>
<p>Pour installer et utiliser RISE, une extension du Jupyter Notebook pour faire
des présentations éditables, il ne suffit pas de l'installer il faut aussi
recopier les css au bon endroit. Pour l'installer dans Sage, il suffit de
faire:</p>
<div class="pygments_manni"><pre>sage -pip install rise
sage -sh
jupyter-nbextension install rise --py --sys-prefix
</pre></div>
<p>Après on peut consulter ce <a class="reference external" href="https://youtu.be/sXyFa_r1nxA">démo</a> sur youtube et la <a class="reference external" href="https://rise.readthedocs.io/en/docs_hot_fixes/index.html">documentation de RISE est ici</a>.</p>
</div>Sébastien Labbéhttp://www.slabbe.org/blogue/Comparison of Wang tiling solvershttp://www.slabbe.org/blogue/2018/12/comparison-of-wang-tiling-solvers2018-12-12T15:24:00+00:00<div class="document">
<p>During the last year, I have written a <a class="reference external" href="https://github.com/seblabbe/slabbe/blob/develop/slabbe/wang_tiles.py">Python module</a> to deal with Wang
tiles containing about 4K lines of code including doctests and documentation.</p>
<p>It can be installed like this:</p>
<div class="pygments_manni"><pre>sage -pip install slabbe
</pre></div>
<p>It can be used like this:</p>
<div class="pygments_manni"><pre><span class="n">sage</span><span class="p">:</span> <span class="kn">from</span> <span class="nn">slabbe</span> <span class="kn">import</span> <span class="n">WangTileSet</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">tiles</span> <span class="o">=</span> <span class="p">[(</span><span class="mi">2</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">),</span>
<span class="o">....</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">4</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">)]</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">T0</span> <span class="o">=</span> <span class="n">WangTileSet</span><span class="p">([</span><span class="nb">map</span><span class="p">(</span><span class="nb">str</span><span class="p">,</span><span class="n">t</span><span class="p">)</span> <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">tiles</span><span class="p">])</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">T0</span><span class="o">.</span><span class="n">tikz</span><span class="p">(</span><span class="n">ncolumns</span><span class="o">=</span><span class="mi">11</span><span class="p">)</span><span class="o">.</span><span class="n">pdf</span><span class="p">()</span>
</pre></div>
/Files/2018/T0_tiles.svg
<p>The module on wang tiles contains a class <tt class="docutils literal">WangTileSolver</tt> which contains
three reductions of the Wang tiling problem the first using <a class="reference external" href="http://doc.sagemath.org/html/en/reference/numerical/sage/numerical/mip.html">MILP solvers</a>,
the second using <a class="reference external" href="http://doc.sagemath.org/html/en/reference/sat/index.html">SAT solvers</a> and the third using <a class="reference external" href="http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/matrices/dancing_links.html">Knuth's dancing links</a>.</p>
<p>Here is one example of a tiling found using the dancing links reduction:</p>
<div class="pygments_manni"><pre><span class="n">sage</span><span class="p">:</span> <span class="o">%</span><span class="n">time</span> <span class="n">tiling</span> <span class="o">=</span> <span class="n">T0</span><span class="o">.</span><span class="n">solver</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span><span class="mi">10</span><span class="p">)</span><span class="o">.</span><span class="n">solve</span><span class="p">(</span><span class="n">solver</span><span class="o">=</span><span class="s1">'dancing_links'</span><span class="p">)</span>
<span class="n">CPU</span> <span class="n">times</span><span class="p">:</span> <span class="n">user</span> <span class="mi">36</span> <span class="n">ms</span><span class="p">,</span> <span class="n">sys</span><span class="p">:</span> <span class="mi">12</span> <span class="n">ms</span><span class="p">,</span> <span class="n">total</span><span class="p">:</span> <span class="mi">48</span> <span class="n">ms</span>
<span class="n">Wall</span> <span class="n">time</span><span class="p">:</span> <span class="mf">65.5</span> <span class="n">ms</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">tiling</span><span class="o">.</span><span class="n">tikz</span><span class="p">()</span><span class="o">.</span><span class="n">pdf</span><span class="p">()</span>
</pre></div>
/Files/2018/T0_10x10tiling.svg
<p>All these reductions now allow me to compare the efficiency of various types of
solvers restricted to the Wang tiling type of problems. Here is the list of
solvers that I often use.</p>
<table border="1" class="docutils">
<caption>List of solvers</caption>
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Solver</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="docutils literal">'Gurobi'</tt></td>
<td>MILP solver</td>
</tr>
<tr><td><tt class="docutils literal">'GLPK'</tt></td>
<td>MILP solver</td>
</tr>
<tr><td><tt class="docutils literal">'PPL'</tt></td>
<td>MILP solver</td>
</tr>
<tr><td><tt class="docutils literal">'LP'</tt></td>
<td>a SAT solver using a reduction to LP</td>
</tr>
<tr><td><tt class="docutils literal">'cryptominisat'</tt></td>
<td>SAT solver</td>
</tr>
<tr><td><tt class="docutils literal">'picosat'</tt></td>
<td>SAT solver</td>
</tr>
<tr><td><tt class="docutils literal">'glucose'</tt></td>
<td>SAT solver</td>
</tr>
<tr><td><tt class="docutils literal">'dancing_links'</tt></td>
<td>Knuth's algorihm</td>
</tr>
</tbody>
</table>
<p>In this <a class="reference external" href="https://arxiv.org/abs/1808.07768">recent work</a> on the substitutive structure of Jeandel-Rao tilings, I
introduced various Wang tile sets \(T_i\) for \(i\in\{0,1,\dots,12\}\).
In this blog post, we will concentrate on the 11 Wang tile set \(T_0\)
introduced by <a class="reference external" href="https://arxiv.org/abs/1506.06492">Jeandel and Rao</a> as well as \(T_2\) containing 20 tiles and
\(T_3\) containing 24 tiles.</p>
<p><strong>Tiling a n x n square</strong></p>
<p>The most natural question to ask is to find valid Wang tilings of \(n\times
n\) square with given Wang tiles. Below is the time spent by each mentionned
solvers to find a valid tiling of a \(n\times n\) square in less than 10
seconds for each of the three wang tile sets \(T_0\), \(T_2\) and
\(T_3\).</p>
/Files/2018/T0_square_tilings.svg
/Files/2018/T2_square_tilings.svg
/Files/2018/T3_square_tilings.svg
<p>We remark that MILP solvers are slower. Dancing links can solve 20x20 squares
with Jeandel Rao tiles \(T_0\) and SAT solvers are performing very well with
Glucose being the best as it can find a 55x55 tiling with Jeandel-Rao tiles
\(T_0\) in less than 10 seconds.</p>
<p><strong>Finding all dominoes allowing a surrounding of given radius</strong></p>
<p>One thing that is often needed in my research is to enumerate all horizontal
and vertical dominoes that allow a given surrounding radius. This is a
difficult question in general as deciding if a given tile set admits a tiling
of the infinite plane is undecidable. But in some cases, the information we get
from the dominoes admitting a surrounding of radius 1, 2, 3 or 4 is enough to
conclude that the tiling can be desubstituted for instance. This is why we need
to answer this question as fast as possible.</p>
<p>Below is the comparison in the time taken by each solver to compute all
vertical and horizontal dominoes allowing a surrounding of radius 1, 2 and 3
(in less than 1000 seconds for each execution).</p>
/Files/2018/T0_dominoes_surrounding.svg
/Files/2018/T2_dominoes_surrounding.svg
/Files/2018/T3_dominoes_surrounding.svg
<p>What is surprising at first is that the solvers that performed well in the
first \(n\times n\) square experience are not the best in the second
experiment computing valid dominoes. Dancing links and the MILP solver Gurobi
are now the best algorithms to compute all dominoes. They are followed by
picosat and cryptominisat and then glucose.</p>
<p><strong>The source code of the above comparisons</strong></p>
<p>The source code of the above comparison can be found in this <a class="reference external" href="https://nbviewer.jupyter.org/url/www.slabbe.org/Files/2018/Comparison-of-Wang-tile-solvers.ipynb">Jupyter
notebook</a>. Note that it depends on the <a class="reference external" href="https://trac.sagemath.org/ticket/26361">use of Glucose as a Sage optional
package (#26361)</a> and on the most recent development version of <a class="reference external" href="https://pypi.python.org/pypi/slabbe">slabbe</a>
optional Sage Package.</p>
</div>Sébastien Labbéhttp://www.slabbe.org/blogue/Wooden laser-cut Jeandel-Rao tileshttp://www.slabbe.org/blogue/2018/09/wooden-laser-cut-jeandel-rao-tiles2018-09-07T09:16:00+00:00<div class="document">
<p>I have been working on Jeandel-Rao tiles <a class="reference external" href="https://arxiv.org/abs/1808.07768">lately</a>.</p>
<a class="reference external image-reference" href="http://www.slabbe.org/Files/2018/article2_T0_tiles.svg">/Files/2018/article2_T0_tiles.svg</a>
<p>Before the conference <a class="reference external" href="https://sites.google.com/view/modelsets/home">Model Sets and Aperiodic Order</a> held in Durham UK (Sep
3-7 2018), I thought it would be a good idea to bring some real tiles at the
conference. So I first decided of some conventions to represent the above tiles
as topologically closed disk basically using the representation of integers in
base 1:</p>
<a class="reference external image-reference" href="http://www.slabbe.org/Files/2018/T0_shapes.svg">/Files/2018/T0_shapes.svg</a>
<p>With these shapes, I created a 33 x 19 patch. With 3cm on each side, the patch
takes 99cm x 57cm just within the capacity of the laser cut machine (1m x 60
cm):</p>
<a class="reference external image-reference" href="http://www.slabbe.org/Files/2018/33x19_A_scale3.svg">/Files/2018/33x19_A_scale3.svg</a>
<p>With the help of David Renault from LaBRI, we went at <a class="reference external" href="https://www.iut.u-bordeaux.fr/cohabit/">Coh@bit</a>, the FabLab
of Bordeaux University and we laser cut two 3mm thick plywood for a total of
1282 Wang tiles. This is the result:</p>
<a class="reference external image-reference" href="http://www.slabbe.org/Files/2018/laser_cut_8x8.jpg"><img alt="/Files/2018/laser_cut_8x8.jpg" src="http://www.slabbe.org/Files/2018/laser_cut_8x8.jpg" /></a>
<p>One may recreate the 33 x 19 tiling as follows (note that I am using
Cartesian-like coordinates, so the first list <tt class="docutils literal">data[0]</tt> actually is the first
column from bottom to top):</p>
<div class="pygments_manni"><pre><span class="n">sage</span><span class="p">:</span> <span class="n">data</span> <span class="o">=</span> <span class="p">[[</span><span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">8</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">8</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">8</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">8</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">8</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">8</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span>
<span class="o">....</span><span class="p">:</span> <span class="p">[</span><span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">]]</span>
</pre></div>
<p>The above patch have been chosen among 1000 other randomly generated as the
closest to the asymptotic frequencies of the tiles in Jeandel-Rao tilings (or
at least in the minimal subshift that I describe in the preprint):</p>
<div class="pygments_manni"><pre><span class="n">sage</span><span class="p">:</span> <span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">Counter</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">c</span> <span class="o">=</span> <span class="n">Counter</span><span class="p">(</span><span class="n">flatten</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">tile_count</span> <span class="o">=</span> <span class="p">[</span><span class="n">c</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">11</span><span class="p">)]</span>
</pre></div>
<p>The asymptotic frequencies:</p>
<div class="pygments_manni"><pre><span class="n">sage</span><span class="p">:</span> <span class="n">phi</span> <span class="o">=</span> <span class="n">golden_ratio</span><span class="o">.</span><span class="n">n</span><span class="p">()</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">Linv</span> <span class="o">=</span> <span class="p">[</span><span class="mi">2</span><span class="o">*</span><span class="n">phi</span> <span class="o">+</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">phi</span> <span class="o">+</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">18</span><span class="o">*</span><span class="n">phi</span> <span class="o">+</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">phi</span> <span class="o">+</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">8</span><span class="o">*</span><span class="n">phi</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span>
<span class="o">....</span><span class="p">:</span> <span class="mi">5</span><span class="o">*</span><span class="n">phi</span> <span class="o">+</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">phi</span> <span class="o">+</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">12</span><span class="o">/</span><span class="mi">5</span><span class="o">*</span><span class="n">phi</span> <span class="o">+</span> <span class="mi">14</span><span class="o">/</span><span class="mi">5</span><span class="p">,</span> <span class="mi">8</span><span class="o">*</span><span class="n">phi</span> <span class="o">+</span> <span class="mi">2</span><span class="p">,</span>
<span class="o">....</span><span class="p">:</span> <span class="mi">2</span><span class="o">*</span><span class="n">phi</span> <span class="o">+</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">8</span><span class="o">*</span><span class="n">phi</span> <span class="o">+</span> <span class="mi">2</span><span class="p">]</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">perfect_proportions</span> <span class="o">=</span> <span class="n">vector</span><span class="p">([</span><span class="mi">1</span><span class="o">/</span><span class="n">a</span> <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">Linv</span><span class="p">])</span>
</pre></div>
<p>Comparison of the number of tiles of each type with the expected frequency:</p>
<div class="pygments_manni"><pre><span class="n">sage</span><span class="p">:</span> <span class="n">header_row</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'tile id'</span><span class="p">,</span> <span class="s1">'Asymptotic frequency'</span><span class="p">,</span> <span class="s1">'Expected nb of copies'</span><span class="p">,</span>
<span class="o">....</span><span class="p">:</span> <span class="s1">'Nb copies in the 33x19 patch'</span><span class="p">]</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">columns</span> <span class="o">=</span> <span class="p">[</span><span class="nb">range</span><span class="p">(</span><span class="mi">11</span><span class="p">),</span> <span class="n">perfect_proportions</span><span class="p">,</span> <span class="n">vector</span><span class="p">(</span><span class="n">perfect_proportions</span><span class="p">)</span><span class="o">*</span><span class="mi">33</span><span class="o">*</span><span class="mi">19</span><span class="p">,</span> <span class="n">tile_count</span><span class="p">]</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">table</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">,</span> <span class="n">header_row</span><span class="o">=</span><span class="n">header_row</span><span class="p">)</span>
<span class="n">tile</span> <span class="nb">id</span> <span class="n">Asymptotic</span> <span class="n">frequency</span> <span class="n">Expected</span> <span class="n">nb</span> <span class="n">of</span> <span class="n">copies</span> <span class="n">Nb</span> <span class="n">copies</span> <span class="ow">in</span> <span class="n">the</span> <span class="mi">33</span><span class="n">x19</span> <span class="n">patch</span>
<span class="o">+---------+----------------------+-----------------------+------------------------------+</span>
<span class="mi">0</span> <span class="mf">0.108271182329550</span> <span class="mf">67.8860313206280</span> <span class="mi">67</span>
<span class="mi">1</span> <span class="mf">0.108271182329550</span> <span class="mf">67.8860313206280</span> <span class="mi">65</span>
<span class="mi">2</span> <span class="mf">0.0255593590340479</span> <span class="mf">16.0257181143480</span> <span class="mi">16</span>
<span class="mi">3</span> <span class="mf">0.108271182329550</span> <span class="mf">67.8860313206280</span> <span class="mi">71</span>
<span class="mi">4</span> <span class="mf">0.0669152706817991</span> <span class="mf">41.9558747174880</span> <span class="mi">42</span>
<span class="mi">5</span> <span class="mf">0.0827118232955023</span> <span class="mf">51.8603132062800</span> <span class="mi">51</span>
<span class="mi">6</span> <span class="mf">0.108271182329550</span> <span class="mf">67.8860313206280</span> <span class="mi">65</span>
<span class="mi">7</span> <span class="mf">0.149627093977301</span> <span class="mf">93.8161879237680</span> <span class="mi">95</span>
<span class="mi">8</span> <span class="mf">0.0669152706817991</span> <span class="mf">41.9558747174880</span> <span class="mi">44</span>
<span class="mi">9</span> <span class="mf">0.108271182329550</span> <span class="mf">67.8860313206280</span> <span class="mi">67</span>
<span class="mi">10</span> <span class="mf">0.0669152706817991</span> <span class="mf">41.9558747174880</span> <span class="mi">44</span>
</pre></div>
<p>I brought the \(33\times19=641\) tiles at the conference and offered to the
first 7 persons to find a \(7\times 7\) tiling the opportunity to keep the
49 tiles they used. 49 is a good number since the frequency of the lowest tile
(with id 2) is about 2% which allows to have at least one copy of each tile in
a subset of 49 tiles allowing a solution.</p>
<p>A natural question to ask is how many such \(7\times 7\) tilings does there
exist? With ticket <a class="reference external" href="https://trac.sagemath.org/ticket/25125">#25125</a> that was merged in Sage 8.3 this Spring, it is
possible to enumerate and count solutions in parallel with Knuth dancing links
algorithm. After the installation of the Sage Optional package <a class="reference external" href="https://pypi.python.org/pypi/slabbe/">slabbe</a> (<tt class="docutils literal">sage
<span class="pre">-pip</span> install slabbe</tt>), one may compute that there are 152244 solutions.</p>
<div class="pygments_manni"><pre><span class="n">sage</span><span class="p">:</span> <span class="kn">from</span> <span class="nn">slabbe</span> <span class="kn">import</span> <span class="n">WangTileSet</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">tiles</span> <span class="o">=</span> <span class="p">[(</span><span class="mi">2</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">),</span>
<span class="o">....</span><span class="p">:</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">4</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">)]</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">T0</span> <span class="o">=</span> <span class="n">WangTileSet</span><span class="p">(</span><span class="n">tiles</span><span class="p">)</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">T0_solver</span> <span class="o">=</span> <span class="n">T0</span><span class="o">.</span><span class="n">solver</span><span class="p">(</span><span class="mi">7</span><span class="p">,</span><span class="mi">7</span><span class="p">)</span>
<span class="n">sage</span><span class="p">:</span> <span class="o">%</span><span class="n">time</span> <span class="n">T0_solver</span><span class="o">.</span><span class="n">number_of_solutions</span><span class="p">(</span><span class="n">ncpus</span><span class="o">=</span><span class="mi">8</span><span class="p">)</span>
<span class="n">CPU</span> <span class="n">times</span><span class="p">:</span> <span class="n">user</span> <span class="mi">16</span> <span class="n">ms</span><span class="p">,</span> <span class="n">sys</span><span class="p">:</span> <span class="mf">82.3</span> <span class="n">ms</span><span class="p">,</span> <span class="n">total</span><span class="p">:</span> <span class="mf">98.3</span> <span class="n">ms</span>
<span class="n">Wall</span> <span class="n">time</span><span class="p">:</span> <span class="mi">388</span> <span class="n">ms</span>
<span class="mi">152244</span>
</pre></div>
<p>One may also get the list of all solutions and print one of them:</p>
<div class="pygments_manni"><pre><span class="n">sage</span><span class="p">:</span> <span class="o">%</span><span class="n">time</span> <span class="n">L</span> <span class="o">=</span> <span class="n">T0_solver</span><span class="o">.</span><span class="n">all_solutions</span><span class="p">();</span> <span class="k">print</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">L</span><span class="p">))</span>
<span class="mi">152244</span>
<span class="n">CPU</span> <span class="n">times</span><span class="p">:</span> <span class="n">user</span> <span class="mf">6.46</span> <span class="n">s</span><span class="p">,</span> <span class="n">sys</span><span class="p">:</span> <span class="mi">344</span> <span class="n">ms</span><span class="p">,</span> <span class="n">total</span><span class="p">:</span> <span class="mf">6.8</span> <span class="n">s</span>
<span class="n">Wall</span> <span class="n">time</span><span class="p">:</span> <span class="mf">6.82</span> <span class="n">s</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">L</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">A</span> <span class="n">wang</span> <span class="n">tiling</span> <span class="n">of</span> <span class="n">a</span> <span class="mi">7</span> <span class="n">x</span> <span class="mi">7</span> <span class="n">rectangle</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">L</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">table</span><span class="p">()</span> <span class="c1"># warning: the output is in Cartesian-like coordinates</span>
<span class="p">[[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">],</span>
<span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">],</span>
<span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span>
<span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">],</span>
<span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">],</span>
<span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">]]</span>
</pre></div>
<p>This is the number of distinct sets of 49 tiles which admits a 7x7 solution:</p>
<div class="pygments_manni"><pre><span class="n">sage</span><span class="p">:</span> <span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">Counter</span>
<span class="n">sage</span><span class="p">:</span> <span class="k">def</span> <span class="nf">count_tiles</span><span class="p">(</span><span class="n">tiling</span><span class="p">):</span>
<span class="o">....</span><span class="p">:</span> <span class="n">C</span> <span class="o">=</span> <span class="n">Counter</span><span class="p">(</span><span class="n">flatten</span><span class="p">(</span><span class="n">tiling</span><span class="o">.</span><span class="n">table</span><span class="p">()))</span>
<span class="o">....</span><span class="p">:</span> <span class="k">return</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">C</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span> <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">11</span><span class="p">))</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">Lfreq</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="n">count_tiles</span><span class="p">,</span> <span class="n">L</span><span class="p">)</span>
<span class="n">sage</span><span class="p">:</span> <span class="n">Lfreq_count</span> <span class="o">=</span> <span class="n">Counter</span><span class="p">(</span><span class="n">Lfreq</span><span class="p">)</span>
<span class="n">sage</span><span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="n">Lfreq_count</span><span class="p">)</span>
<span class="mi">83258</span>
</pre></div>
<p>Number of other solutions with the same set of 49 tiles:</p>
<div class="pygments_manni"><pre><span class="n">sage</span><span class="p">:</span> <span class="n">Counter</span><span class="p">(</span><span class="n">Lfreq_count</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
<span class="n">Counter</span><span class="p">({</span><span class="mi">1</span><span class="p">:</span> <span class="mi">49076</span><span class="p">,</span> <span class="mi">2</span><span class="p">:</span> <span class="mi">19849</span><span class="p">,</span> <span class="mi">3</span><span class="p">:</span> <span class="mi">6313</span><span class="p">,</span> <span class="mi">4</span><span class="p">:</span> <span class="mi">3664</span><span class="p">,</span> <span class="mi">6</span><span class="p">:</span> <span class="mi">1410</span><span class="p">,</span> <span class="mi">5</span><span class="p">:</span> <span class="mi">1341</span><span class="p">,</span> <span class="mi">7</span><span class="p">:</span> <span class="mi">705</span><span class="p">,</span> <span class="mi">8</span><span class="p">:</span>
<span class="mi">293</span><span class="p">,</span> <span class="mi">9</span><span class="p">:</span> <span class="mi">159</span><span class="p">,</span> <span class="mi">14</span><span class="p">:</span> <span class="mi">116</span><span class="p">,</span> <span class="mi">10</span><span class="p">:</span> <span class="mi">104</span><span class="p">,</span> <span class="mi">12</span><span class="p">:</span> <span class="mi">97</span><span class="p">,</span> <span class="mi">18</span><span class="p">:</span> <span class="mi">44</span><span class="p">,</span> <span class="mi">11</span><span class="p">:</span> <span class="mi">26</span><span class="p">,</span> <span class="mi">15</span><span class="p">:</span> <span class="mi">24</span><span class="p">,</span> <span class="mi">13</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">17</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span>
<span class="mi">22</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">32</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">16</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">28</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">19</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">21</span><span class="p">:</span> <span class="mi">1</span><span class="p">})</span>
</pre></div>
<p>How the number of \(k\times k\)-solutions grows for <cite>k</cite> from 0 to 9:</p>
<div class="pygments_manni"><pre><span class="n">sage</span><span class="p">:</span> <span class="p">[</span><span class="n">T0</span><span class="o">.</span><span class="n">solver</span><span class="p">(</span><span class="n">k</span><span class="p">,</span><span class="n">k</span><span class="p">)</span><span class="o">.</span><span class="n">number_of_solutions</span><span class="p">()</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">)]</span>
<span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">85</span><span class="p">,</span> <span class="mi">444</span><span class="p">,</span> <span class="mi">1723</span><span class="p">,</span> <span class="mi">9172</span><span class="p">,</span> <span class="mi">50638</span><span class="p">,</span> <span class="mi">152244</span><span class="p">,</span> <span class="mi">262019</span><span class="p">,</span> <span class="mi">1641695</span><span class="p">]</span>
</pre></div>
<p>Unfortunately, most of those \(k\times k\)-solutions are not extendable to a
tiling of the whole plane. Indeed the number of \(k\times k\) patches in
the language of the minimal aperiodic subshift that I am able to describe and
which is a proper subset of Jeandel-Rao tilings seems, according to some
heuristic, to be something like:</p>
<div class="pygments_manni"><pre><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">49</span><span class="p">,</span> <span class="mi">108</span><span class="p">,</span> <span class="mi">184</span><span class="p">,</span> <span class="mi">268</span><span class="p">,</span> <span class="mi">367</span><span class="p">,</span> <span class="mi">483</span><span class="p">]</span>
</pre></div>
<p>I do not share my (ugly) code for this computation yet, as I will rather share
clean code soon when times come. So among the 152244 about only 483 (0.32%) of
them are prolongable into a uniformly recurrent tiling of the plane.</p>
</div>Sébastien Labbéhttp://www.slabbe.org/blogue/