<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" >
  <generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator>
  <link href="https://www.shubhamjha.com/sympy_feed.xml" rel="self" type="application/atom+xml" />
  <link href="https://www.shubhamjha.com/" rel="alternate" type="text/html" />
  <updated>2024-09-19T04:31:47+05:30</updated>
  <id>https://www.shubhamjha.com/sympy_feed.xml</id>

  <title type="html">Shubham’s Blog</title>

  
    <subtitle>My Corner on Internet</subtitle>
  

  
    <author>
        <name>Shubham Kumar Jha</name>
      
      
    </author>
  

  
    <entry>
      <title type="html">GSoC 2019: Week 12 (The Final Week)</title>
      <link href="https://www.shubhamjha.com/posts/GSoC-Week-12-(The-Final-Week)/" rel="alternate" type="text/html" title="GSoC 2019: Week 12 (The Final Week)" />
      <published>2019-08-21T00:00:00+05:30</published>
      <updated>2019-08-21T00:00:00+05:30</updated>
      <id>https://www.shubhamjha.com/posts/GSoC-Week-12-(The-Final-Week)</id>
      <content type="html" xml:base="https://www.shubhamjha.com/posts/GSoC-Week-12-(The-Final-Week)/">&lt;p&gt;The last week of coding period is officially over. A summary of the work done during this week is:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/sympy/sympy/pull/17379&quot;&gt;#17379&lt;/a&gt; is now complete and currently under review. I will try to get it merged within this week.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/sympy/sympy/pull/17392&quot;&gt;#17392&lt;/a&gt; still needs work. I will try to put a closure to this by the end of week.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/sympy/sympy/pull/17440&quot;&gt;#17440&lt;/a&gt; was started. It attempts to add a powerful (but optional) SAT solving engine to SymPy (&lt;a href=&quot;https://pypi.org/project/pycosat/&quot;&gt;pycosat&lt;/a&gt;). The performance gain for SAT solver is also subtle here: Using this
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;from sympy import *
from sympy.abc import x
r = random_poly(x, 100, -100, 100)
ans = ask(Q.positive(r), Q.positive(x))
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;The performance is like&lt;/p&gt;
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;# In master
 |  `- 0.631 check_satisfiability  sympy/assumptions/satask.py:30
 |     `- 0.607 satisfiable  sympy/logic/inference.py:38
 |        `- 0.607 dpll_satisfiable  sympy/logic/algorithms/dpll2.py:21
# With pycosat
 |  `- 0.122 check_satisfiability  sympy/assumptions/satask.py:30
 |     `- 0.098 satisfiable  sympy/logic/inference.py:39
 |        `- 0.096 pycosat_satisfiable  sympy/logic/algorithms/pycosat_wrapper.py:11
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;It is finished and under review now.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also, with the end of GSoC 2019, final evaluations have started. I will be writing a final report to the whole project by the end of this week.&lt;/p&gt;

&lt;p&gt;So far it has been a great and enriching experience for me. It was my first attempt at GSoC and I am lucky to get such an exposure. I acknowledge that I started with an abstract idea of the project but I now understand both the need and the code of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;New Assumptions&lt;/code&gt; pretty well (thanks to &lt;a href=&quot;https://github.com/asmeurer&quot;&gt;Aaron&lt;/a&gt; who wrote the most of it). The system is still in its early phases and needs a lot more work. I am happy to be a part of it and I will be available to work on it.&lt;/p&gt;

&lt;p&gt;This is the last weekly report but I will still be contributing to SymPy and open source in general. I will try to write more of such experiences through this portal. Till then, Good bye and thank you!&lt;/p&gt;</content>
      <author>
          <name></name>
        
        
      </author>


      
        <category term="gsoc" />
      
        <category term="sympy" />
      
    </entry>
  
    <entry>
      <title type="html">GSoC 2019: Week 10 and 11</title>
      <link href="https://www.shubhamjha.com/posts/GSoC-Week-10-and-11/" rel="alternate" type="text/html" title="GSoC 2019: Week 10 and 11" />
      <published>2019-08-13T00:00:00+05:30</published>
      <updated>2019-08-13T00:00:00+05:30</updated>
      <id>https://www.shubhamjha.com/posts/GSoC-Week-10-and-11</id>
      <content type="html" xml:base="https://www.shubhamjha.com/posts/GSoC-Week-10-and-11/">&lt;p&gt;So, the second last week of the official coding period is over now. During the last two weeks, I was mostly occupied with on-campus placement drives, hence I couldn’t put up a blog earlier. A summary of my work during these weeks is as follows:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;First of all, &lt;a href=&quot;https://github.com/sympy/sympy/pull/17144&quot;&gt;#17144&lt;/a&gt; is merged 😄. This was a large PR and hence took time to get fully reviewed. With this, the performance of New assumptions comes closer to that of the old system. Currently, queries are evaluated about &lt;strong&gt;20X&lt;/strong&gt; faster than before.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/sympy/sympy/pull/17379&quot;&gt;#17379&lt;/a&gt; attempts to remove SymPy’s costly &lt;strong&gt;rcall()&lt;/strong&gt; from the whole assumptions mechanism. It’s a follow-up from &lt;a href=&quot;https://github.com/sympy/sympy/pull/17144&quot;&gt;#17144&lt;/a&gt; and the performance gain is subtle for large queries. E.g.
    &lt;div class=&quot;language-py highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sympy&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_poly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;positive&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;positive&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;In the master it takes &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;4.292 s&lt;/code&gt;, out of this &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2.483 s&lt;/code&gt; is spent in &lt;strong&gt;rcall&lt;/strong&gt;. With this, the time spent is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1.929 s&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0.539 s&lt;/code&gt; respectively.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/sympy/sympy/pull/17392&quot;&gt;#17392&lt;/a&gt; attempts to make the New Assumptions able to handle queries which involve Relationals. Currently, it works only with simple queries (e.g. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ask(x&amp;gt;y, Q.positive(x) &amp;amp; Q.negative(y))&lt;/code&gt; now evaluates &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;True&lt;/code&gt;) just like the way old system works. This is a much-awaited functionality for the new system. Also, during this I realized that sathandlers lack many necessary facts. This PR also adds many new facts to the system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the last week of coding, my attempt would be to complete both of these PRs and get them merged. Also, I will try to add new facts to sathandlers.&lt;/p&gt;</content>
      <author>
          <name></name>
        
        
      </author>


      
        <category term="gsoc" />
      
        <category term="sympy" />
      
    </entry>
  
    <entry>
      <title type="html">GSoC 2019: Week 9</title>
      <link href="https://www.shubhamjha.com/posts/GSoC-Week-9/" rel="alternate" type="text/html" title="GSoC 2019: Week 9" />
      <published>2019-07-31T00:00:00+05:30</published>
      <updated>2019-07-31T00:00:00+05:30</updated>
      <id>https://www.shubhamjha.com/posts/GSoC-Week-9</id>
      <content type="html" xml:base="https://www.shubhamjha.com/posts/GSoC-Week-9/">&lt;p&gt;I spent most of this week getting &lt;a href=&quot;https://github.com/sympy/sympy/pull/17144&quot;&gt;#17144&lt;/a&gt; ready to be merged. I had to change a lot of things from the last attempt. One of such was an attempt on &lt;strong&gt;early encoding&lt;/strong&gt;, I had tried it on &lt;strong&gt;Literals&lt;/strong&gt;. They were eventually going to be encoded so I tried to do this when &lt;strong&gt;Literals&lt;/strong&gt; were created only. But as Aaron suggested, my approach had left encodings in the global space and hence could leak memory. During the week, I tried to attach encoding to the &lt;strong&gt;CNF&lt;/strong&gt; object itself but it would have needed a lot of refactoring, since &lt;strong&gt;CNF&lt;/strong&gt; objects interacted with other such objects. So, after some attempts, at the end I left the encoding to be done at last in &lt;strong&gt;EncodedCNF&lt;/strong&gt; object. Currently, this is ready to be merged.&lt;/p&gt;

&lt;p&gt;For the coming weeks, I would try to improve over this.&lt;/p&gt;

&lt;p&gt;This was also the week for second monthly evaluation and I feel happy to announce that I passed it. From this week my college has also started but I am still able to give the required time to this project and complete it.&lt;/p&gt;

&lt;p&gt;Will keep you updated. Thank you !&lt;/p&gt;</content>
      <author>
          <name></name>
        
        
      </author>


      
        <category term="gsoc" />
      
        <category term="sympy" />
      
    </entry>
  
    <entry>
      <title type="html">GSoC 2019: Week 8</title>
      <link href="https://www.shubhamjha.com/posts/GSoC-Week-8/" rel="alternate" type="text/html" title="GSoC 2019: Week 8" />
      <published>2019-07-23T00:00:00+05:30</published>
      <updated>2019-07-23T00:00:00+05:30</updated>
      <id>https://www.shubhamjha.com/posts/GSoC-Week-8</id>
      <content type="html" xml:base="https://www.shubhamjha.com/posts/GSoC-Week-8/">&lt;p&gt;Now, the eighth week of official coding period has ended. I would give you a summary of my work during this week.&lt;/p&gt;

&lt;p&gt;I spent most of this week polishing and finishing my work on &lt;a href=&quot;https://github.com/sympy/sympy/pull/17144&quot;&gt;#17144&lt;/a&gt;. The performance gain from this PR was very subtle but I had tested this only on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/assumptions/tests&lt;/code&gt; of SymPy. During this week’s meeting, Aaron suggested an example that had become slower than before:&lt;/p&gt;
&lt;div class=&quot;language-py highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_poly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;positive&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;positive&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This made me realize that my strategy had a flaw. I had converted the smallest expressions into &lt;strong&gt;CNF&lt;/strong&gt; objects and applied Boolean functions (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;or&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;and&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;not&lt;/code&gt;) on them keeping the CNF structure intact. The performance regression was coming from operations &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;or&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;not&lt;/code&gt;. In case of CNF structures, the number of expressions increased exponentially for these operations. Since the test suite didn’t have such examples, all the tests passed without any visible performance issue.&lt;/p&gt;

&lt;p&gt;With some research, I found that the best approach to handle this (without any kind of pruning) was to convert these expression into &lt;a href=&quot;https://en.wikipedia.org/wiki/Negation_normal_form&quot;&gt;&lt;strong&gt;NNF&lt;/strong&gt;&lt;/a&gt; form first. So, I implemented a function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;to_NNF&lt;/code&gt; which works with low-level constructs (SymPy’s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;to_nnf&lt;/code&gt; would have been too costly) and converts an expression into NNF. This is then converted into &lt;strong&gt;CNF&lt;/strong&gt; with ease. It keeps the number of clauses in check and hence also increases the performance outcome. The results are such: the above example now takes about &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0.4 s&lt;/code&gt; on this PR while it takes about &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;6 s&lt;/code&gt; in master.&lt;/p&gt;

&lt;p&gt;Currently, the work on this PR is almost complete and it is under review.&lt;/p&gt;

&lt;p&gt;For the next week,&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;My first priority is to get &lt;a href=&quot;https://github.com/sympy/sympy/pull/17144&quot;&gt;#17144&lt;/a&gt; merged.&lt;/li&gt;
  &lt;li&gt;Then, work on optimizing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rcall&lt;/code&gt;. This is an extension for the above work.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Will keep you updated. Thank you !&lt;/p&gt;</content>
      <author>
          <name></name>
        
        
      </author>


      
        <category term="gsoc" />
      
        <category term="sympy" />
      
    </entry>
  
    <entry>
      <title type="html">GSoC 2019: Week 6 and 7</title>
      <link href="https://www.shubhamjha.com/posts/GSoC-2019-Week-6-and-7/" rel="alternate" type="text/html" title="GSoC 2019: Week 6 and 7" />
      <published>2019-07-15T00:00:00+05:30</published>
      <updated>2019-07-15T00:00:00+05:30</updated>
      <id>https://www.shubhamjha.com/posts/GSoC-2019-Week-6-and-7</id>
      <content type="html" xml:base="https://www.shubhamjha.com/posts/GSoC-2019-Week-6-and-7/">&lt;p&gt;With this ends the seventh week of the official coding period. During the end of 6th week and the beginning of 7th week, I was mostly travelling, so I was not able to write a blog for the sixth week. Instead, I will try to summarize my work during the last two weeks here.&lt;/p&gt;

&lt;p&gt;For the last few weeks, I have been focused on optimizing the code of new assumptions to enhance its performance. Most of my work has been exploratory, as Aaron says 😅. Indeed I have dry-run, backtracked, profiled, and ran the same code with a debugger too many times to understand the slow parts and the improvements I can make here and there. Mostly the code is optimized given the class structure of SymPy. But it is also the class structure that is adding up to the performance issues. Already noted in my last blog, classes like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;And&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Or&lt;/code&gt; sorts their &lt;em&gt;args&lt;/em&gt;, hence take a great amount of time. But other SymPy class constructors also take significant time.&lt;/p&gt;

&lt;p&gt;With the success of fifth week’s attempt, I have been desperate to bring down the execution time 😅. Some of the attempts I have made, which are included in &lt;a href=&quot;https://github.com/sympy/sympy/pull/17144&quot;&gt;#17144&lt;/a&gt;, are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;I have modified &lt;strong&gt;CNF&lt;/strong&gt; class, which essentially is a low-level implementation for the &lt;a href=&quot;https://en.wikipedia.org/wiki/Conjunctive_normal_form&quot;&gt;cnf&lt;/a&gt; of any boolean expression. &lt;strong&gt;CNF&lt;/strong&gt; object holds a set of clauses. These clauses are themselves &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frozenset&lt;/code&gt; of &lt;strong&gt;Literal&lt;/strong&gt; objects. &lt;strong&gt;Literal&lt;/strong&gt; class is being implemented just to reduce the unnecessary creation of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Not&lt;/code&gt; objects (It takes significant execution time and is called many times).&lt;/li&gt;
  &lt;li&gt;I have also modified the code of &lt;em&gt;sympify()&lt;/em&gt;, it appeared to take more time than expected when the argument is a SymPy object already. Consider this, almost one-third execution time.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;In&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Symbol&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&apos;x&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;In&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeit&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sympify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# before change
&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;601&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ns&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;±&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;14.6&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ns&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;per&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loop&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mean&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;±&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dev&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;of&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;runs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000000&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loops&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;In&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeit&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sympify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# after change
&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;239&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ns&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;±&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;11.8&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ns&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;per&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loop&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mean&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;±&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dev&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;of&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;runs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000000&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loops&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;Finally, I rewrote &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;to_cnf()&lt;/code&gt; for &lt;strong&gt;CNF&lt;/strong&gt; objects. By using mostly Python’s built-ins and removing any SymPy object construction during its execution. The performance gain is quite subtle 😎.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;rouge-gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;rouge-code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;In&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sympy&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;In&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sympy.abc&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;In&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;In&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sympy.logic.boolalg&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CNF&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Before
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;In&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeit&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CNF&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;from_prop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# It is using to_cnf()
&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.41&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ms&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;±&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;18&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;µs&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;per&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loop&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mean&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;±&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dev&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;of&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;runs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loops&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# after
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;In&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeit&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CNF&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;from_prop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# It is using the new to_CNF()
&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;31.5&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;µs&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;±&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.48&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;µs&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;per&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loop&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mean&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;±&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dev&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;of&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;runs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10000&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loops&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There is definitely a limit to performance we can get with Python. But implementing most of the things in Python built-ins we can definitely make things much faster.&lt;/p&gt;

&lt;p&gt;For the upcoming week, I will try to complete the following:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;The CNF objects are still not simplified. I have to implement simplification to reduce the number of clauses. These have to be fed into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;satisfiable&lt;/code&gt; at the end, which can benefit from lesser number of clauses.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rcall&lt;/code&gt; used with &lt;strong&gt;sathandlers&lt;/strong&gt; is another major portion having high execution time. I will try to work it out.&lt;/li&gt;
  &lt;li&gt;Clean up the code and make it ready for reviewing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Apart from that, I will also try to shift my focus towards the other part of my project and write some theory solvers. After all, I need to enhance the assumptions not just make it faster 😎.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Peace&lt;/em&gt;&lt;/p&gt;</content>
      <author>
          <name></name>
        
        
      </author>


      
        <category term="gsoc" />
      
        <category term="sympy" />
      
    </entry>
  
    <entry>
      <title type="html">GSoC 2019: Week 5</title>
      <link href="https://www.shubhamjha.com/posts/GSoC-2019-Week-5/" rel="alternate" type="text/html" title="GSoC 2019: Week 5" />
      <published>2019-07-03T00:00:00+05:30</published>
      <updated>2019-07-03T00:00:00+05:30</updated>
      <id>https://www.shubhamjha.com/posts/GSoC-2019-Week-5</id>
      <content type="html" xml:base="https://www.shubhamjha.com/posts/GSoC-2019-Week-5/">&lt;p&gt;With this the fifth week of the official coding period has ended. I will try to give a brief summary of my work during this week.&lt;/p&gt;

&lt;p&gt;I spent most of this week learning the inner working of &lt;strong&gt;satask&lt;/strong&gt; module. It took a lot of debugging to understand the on-going processes efficiently 😅 . My major job was to reduce the unwanted slowing portions in the code. I had  &lt;a href=&quot;https://github.com/sympy/sympy/pull/11789&quot;&gt;#11789&lt;/a&gt; for reference. Some of such performance reducing portions of code were:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;A major segment of code was creating &lt;strong&gt;And&lt;/strong&gt; objects unnecessarily. As suggested in &lt;a href=&quot;https://github.com/sympy/sympy/issues/17087&quot;&gt;#17087&lt;/a&gt; the sorting in the &lt;strong&gt;And&lt;/strong&gt; constructor takes up a significant amount of time. These have to be reduced.&lt;/li&gt;
  &lt;li&gt;Using SymPy objects is itself a bottleneck for performance. Having a system built over SymPy objects slows things down. Python’s built-in types should be used as much as possible.&lt;/li&gt;
  &lt;li&gt;A specific segment (used many times in the code) calls &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rcall&lt;/code&gt; over propositions. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rcall&lt;/code&gt; which is a recursive process also takes a significant of time.&lt;/li&gt;
  &lt;li&gt;Also, I have tried to pre-compile results as much as possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the above and some other changes, the overall performance of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;satask&lt;/code&gt; has improved much. I have made a PR over this &lt;a href=&quot;https://github.com/sympy/sympy/pull/17144&quot;&gt;#17144&lt;/a&gt;. For an instance,&lt;/p&gt;
&lt;table style=&quot;padding:15px;&quot;&gt;
    &lt;thead&gt;
        &lt;th&gt;Tests&lt;/th&gt;
        &lt;th&gt;After this PR&lt;/th&gt;
        &lt;th&gt;In master&lt;/th&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;test_satask&lt;/td&gt;
            &lt;td&gt;2.39 s&lt;/td&gt;
            &lt;td&gt;36.26 s&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;assumptions/tests&lt;/td&gt;
            &lt;td&gt;16.74 s&lt;/td&gt;
            &lt;td&gt;127.21 s&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;br /&gt;
There is still scope for improvement in performance. In the coming week, I will try to work these out. I will also try to improve the performance of &lt;strong&gt;ask&lt;/strong&gt; module.&lt;/p&gt;

&lt;p&gt;Also, the first evaluations are over now and I feel happy to announce that I passed it. During the first phase I learnt a lot. In last few weeks I got to explore profiling and got to understand how small segments can influence performance. Before this I felt that I already know the codebase, but in reality I had much to explore. My mentors always gave me a good starting point and a direction over the course of this phase. With the hope to work much better in the coming phases, I take your leave now 😄 .&lt;/p&gt;</content>
      <author>
          <name></name>
        
        
      </author>


      
        <category term="gsoc" />
      
        <category term="sympy" />
      
    </entry>
  
    <entry>
      <title type="html">GSoC 2019: Week 4</title>
      <link href="https://www.shubhamjha.com/posts/GSoC-2019-Week-4/" rel="alternate" type="text/html" title="GSoC 2019: Week 4" />
      <published>2019-06-24T00:00:00+05:30</published>
      <updated>2019-06-24T00:00:00+05:30</updated>
      <id>https://www.shubhamjha.com/posts/GSoC-2019-Week-4</id>
      <content type="html" xml:base="https://www.shubhamjha.com/posts/GSoC-2019-Week-4/">&lt;p&gt;With this the fourth week and the first phase of GSoC 2019 is over. Here I will give you a brief summary of my progress this week.&lt;/p&gt;

&lt;p&gt;I started this week by setting up my workspace for profiling the code related to new assumptions. I am using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pyinstrument&lt;/code&gt; for that. The results of profiler suggests that a significant amount of time is spent in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;to_cnf()&lt;/code&gt; function which converts the logical expression into their CNF counterparts, to be used by the SAT solver. Also, since this system is built over the SymPy core, a large amount of this time is spent in the core itself (See the graph &lt;a href=&quot;https://github.com/sympy/sympy/issues/17066#issuecomment-504774120&quot;&gt;here&lt;/a&gt;). A possible solution to this is to use constructs at a level lower than the SymPy objects, hence removing the overheads.&lt;/p&gt;

&lt;p&gt;Also, as suggested in the last blog, there are various ideas proposed for improving the new assumptions mechanism. Some of them have been implemented to some extent in some PRs. Before proceeding for any new strategies, I need to look into these ideas first. I have started an &lt;a href=&quot;https://github.com/sympy/sympy/issues/17066&quot;&gt;issue-tree&lt;/a&gt; to gather them.&lt;/p&gt;

&lt;p&gt;Over the end of the week, I also pushed my work on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;First Order Logic&lt;/code&gt; module at &lt;a href=&quot;https://github.com/sympy/sympy/pull/17069&quot;&gt;#17069&lt;/a&gt;. This work is based on &lt;a href=&quot;https://github.com/sympy/sympy/pull/7608&quot;&gt;#7608&lt;/a&gt; and extends it by adding &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Equality&lt;/code&gt; to it. Currently, there are test failures and some points to decide. I will try to get it done within this week.&lt;/p&gt;

&lt;p&gt;I spent most of this week exploring the profiling and benchmarking of code, and I learnt a lot during this. For the coming week, I will focus on speeding up the code in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;to_cnf&lt;/code&gt;. As suggested by Aaron, &lt;a href=&quot;https://github.com/sympy/sympy/pull/11789&quot;&gt;this&lt;/a&gt; seems a good point to start with. Also, I will be working on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FOL&lt;/code&gt; module.&lt;/p&gt;</content>
      <author>
          <name></name>
        
        
      </author>


      
        <category term="gsoc" />
      
        <category term="sympy" />
      
    </entry>
  
    <entry>
      <title type="html">GSoC 2019: Week 3</title>
      <link href="https://www.shubhamjha.com/posts/GSoC-2019-Week-3/" rel="alternate" type="text/html" title="GSoC 2019: Week 3" />
      <published>2019-06-17T00:00:00+05:30</published>
      <updated>2019-06-17T00:00:00+05:30</updated>
      <id>https://www.shubhamjha.com/posts/GSoC-2019-Week-3</id>
      <content type="html" xml:base="https://www.shubhamjha.com/posts/GSoC-2019-Week-3/">&lt;p&gt;The third week of coding period has ended and as I already stated in the last blog, I couldn’t be much productive this week. Nevertheless, I tried to wrap-up some unfinished works. PR &lt;a href=&quot;https://github.com/sympy/sympy/pull/16956&quot;&gt;#16956&lt;/a&gt; is ready to merge, just waiting for some last reviews. This PR needs to be supplemented with some fixes in the code of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Add&lt;/code&gt; class to handle all the issues over &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Relationals&lt;/code&gt;. PR &lt;a href=&quot;https://github.com/sympy/sympy/pull/16978&quot;&gt;#16978&lt;/a&gt; had one major failing test from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stats&lt;/code&gt; module. I tried to debug it ,but due to my unfamiliarity with that part of code I took help from &lt;a href=&quot;https://github.com/czgdp1807&quot;&gt;Gagandeep&lt;/a&gt; and as his &lt;a href=&quot;https://github.com/sympy/sympy/pull/16978#discussion_r294039337&quot;&gt;comment&lt;/a&gt; suggests, the result this PR is giving is correct and more intuitive. At least, one less issue to handle 😌.&lt;/p&gt;

&lt;p&gt;Over the end of the week, I shifted my focus towards &lt;em&gt;New Assumptions&lt;/em&gt;. One of my major tasks for this summer is to speed up the &lt;em&gt;satask&lt;/em&gt; module. As suggested by Aaron, I searched the repository for issues and PRs over this, and I found a number of such unfinished work. I would need to study these ideas and profile the results before working ahead. I would create a issue-tree over it connecting all such PRs and there respective benchmarks.&lt;/p&gt;

&lt;p&gt;For this week, I would focus on the above mentioned task only. Since the first phase is about to end, I would have to speed things up.&lt;/p&gt;</content>
      <author>
          <name></name>
        
        
      </author>


      
        <category term="gsoc" />
      
        <category term="sympy" />
      
    </entry>
  
    <entry>
      <title type="html">GSoC 2019: Week 2</title>
      <link href="https://www.shubhamjha.com/posts/GSoC-2019-Week-2/" rel="alternate" type="text/html" title="GSoC 2019: Week 2" />
      <published>2019-06-13T00:00:00+05:30</published>
      <updated>2019-06-13T00:00:00+05:30</updated>
      <id>https://www.shubhamjha.com/posts/GSoC-2019-Week-2</id>
      <content type="html" xml:base="https://www.shubhamjha.com/posts/GSoC-2019-Week-2/">&lt;p&gt;The second week of official coding period has concluded. I will give you a brief summary of the week’s work.&lt;/p&gt;

&lt;p&gt;I started this week with working on PR &lt;a href=&quot;https://github.com/sympy/sympy/pull/16956&quot;&gt;#16956&lt;/a&gt;, the PR is now passing tests. I will try to get it merged soon. Later this week, I tried to include &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complex -&amp;gt; finite&lt;/code&gt; in the assumptions system. I started PR &lt;a href=&quot;https://github.com/sympy/sympy/pull/16978&quot;&gt;#16978&lt;/a&gt; over this. This PR changes the assumptions system to work over the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complex -&amp;gt; finite&lt;/code&gt; clause. All the instances of use of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;is_complex&lt;/code&gt; call has to be modified. As suggested by Aaron, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;is_complex&lt;/code&gt; call was changed with a disjunction of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;is_complex&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;is_infinite&lt;/code&gt; calls. Luckily for me, the usage of complex assumption was not much in the codebase 😌. Though it meant less test failures to handle, the core assumptions system (in the old system) is quite complex to understand and debug, and hence handling all the failing tests proved quite difficult. Also, I tried to work on it without including any new assumptions to the system. One important result of this is, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zoo.is_complex&lt;/code&gt; returns &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;False&lt;/code&gt; now.&lt;/p&gt;

&lt;p&gt;Apart from that I have worked on to sync these changes in the new assumptions system as well and I will be sending PR over it soon.&lt;/p&gt;

&lt;p&gt;For the coming week,&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;I will start to work on SAT solver and to speed it up. As suggested by Aaron, I will first look into the other unfinished PRs over this.&lt;/li&gt;
  &lt;li&gt;I will sync the new assumptions with the recent developments in the old system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With enough said, these PRs made me realize how much the codebase can break with small changes in the assumptions. Also, I know this post is a little bit late(because of bad health). I have some pending work over from the last week and I will try to catch speed as soon as possible.&lt;/p&gt;</content>
      <author>
          <name></name>
        
        
      </author>


      
        <category term="gsoc" />
      
        <category term="sympy" />
      
    </entry>
  
    <entry>
      <title type="html">GSoC 2019: Week 1</title>
      <link href="https://www.shubhamjha.com/posts/GSoC-2019-Week-1/" rel="alternate" type="text/html" title="GSoC 2019: Week 1" />
      <published>2019-06-04T00:00:00+05:30</published>
      <updated>2019-06-04T00:00:00+05:30</updated>
      <id>https://www.shubhamjha.com/posts/GSoC-2019-Week-1</id>
      <content type="html" xml:base="https://www.shubhamjha.com/posts/GSoC-2019-Week-1/">&lt;p&gt;The first week of official Coding Period is over and it went well 😄.&lt;/p&gt;

&lt;p&gt;As proposed, I created a branch over &lt;a href=&quot;https://github.com/sympy/sympy/pull/7608&quot;&gt;#7608&lt;/a&gt; and went through it locally. I have made certain improvements and I will create appropriate PR for them this week. I intend to get that merged in this week only, if everything goes well. Also, as suggested by Aaron, I looked for profiling tools for optimizing slow parts in the codebase. I will be using &lt;a href=&quot;https://pypi.org/project/pyinstrument/&quot;&gt;&lt;strong&gt;pyinstrument&lt;/strong&gt;&lt;/a&gt; and the profiler of PyCharm for this purpose.&lt;/p&gt;

&lt;p&gt;Later in this week, I started the PR &lt;a href=&quot;https://github.com/sympy/sympy/pull/16956&quot;&gt;#16956&lt;/a&gt; which fixes issues &lt;a href=&quot;https://github.com/sympy/sympy/issues/16915&quot;&gt;#16915&lt;/a&gt; and &lt;a href=&quot;https://github.com/sympy/sympy/issues/16582&quot;&gt;#16582&lt;/a&gt;. Both these issues are related to assumptions handling in Relationals. It broke more code than expected 😅. This shows how embedded the old assumptions are in the codebase. I will try to fix them ASAP.&lt;/p&gt;

&lt;p&gt;With the first week wrapped up, in the next week :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;I will create an experimental PR to include &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complex -&amp;gt; finite&lt;/code&gt; in the old assumptions. This is going to break &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zoo.is_complex&lt;/code&gt; overall. I will try to do it without including new facts. &lt;a href=&quot;https://github.com/sympy/sympy/pull/16666&quot;&gt;#16666&lt;/a&gt; shows how difficult such proceedings can be.&lt;/li&gt;
  &lt;li&gt;I will also create a PR to include &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complex -&amp;gt; finite&lt;/code&gt; in the new assumptions. This should be easier than the former. The new assumptions is still not used much in the codebase 😌.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I will try to shift my focus more towards the new assumptions. But I will also look for any major inconsistency between the assumptions systems.&lt;/p&gt;

&lt;p&gt;With this, sign out for the next week.&lt;/p&gt;</content>
      <author>
          <name></name>
        
        
      </author>


      
        <category term="gsoc" />
      
        <category term="sympy" />
      
    </entry>
  
    <entry>
      <title type="html">Community Bonding Period</title>
      <link href="https://www.shubhamjha.com/posts/Community-bonding-period/" rel="alternate" type="text/html" title="Community Bonding Period" />
      <published>2019-05-29T00:00:00+05:30</published>
      <updated>2019-05-29T00:00:00+05:30</updated>
      <id>https://www.shubhamjha.com/posts/Community-bonding-period</id>
      <content type="html" xml:base="https://www.shubhamjha.com/posts/Community-bonding-period/">&lt;p&gt;Community bonding period has concluded. Due to my exams and travelling, I was not able to devote much of my time over this. But I managed to review PR &lt;a href=&quot;https://github.com/sympy/sympy/pull/16666&quot;&gt;#16666&lt;/a&gt; and helped it get merged. With this PR, SymPy comes one step closer to unifying both the Assumption systems. Also, with this I realized how difficult reviewing can be 😅.&lt;/p&gt;

&lt;p&gt;I had my first meeting with my mentors, Aaron and Kalevi, on Monday where we decided about the timings of weekly meetings. It was also decided to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gitter&lt;/code&gt; as a medium for these meetings. Aaron also gave me some directions about the overall project.&lt;/p&gt;

&lt;p&gt;Since the official coding period has begun, I will try to stick to my proposal. These are my plans for the coming week:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;As per my proposal, I have to include First Order Logic into SymPy. There is already a PR on this ( &lt;a href=&quot;https://github.com/sympy/sympy/pull/7608&quot;&gt;#7608&lt;/a&gt;). During this week I will work on to improve over it.&lt;/li&gt;
  &lt;li&gt;Also as suggested by Aaron, I will look into some known performance issues with assumptions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Along with this, I will also be looking for inconsistencies between the two Assumptions systems.&lt;/p&gt;

&lt;p&gt;Sign out for the next week 😄&lt;/p&gt;</content>
      <author>
          <name></name>
        
        
      </author>


      
        <category term="gsoc" />
      
        <category term="sympy" />
      
    </entry>
  
    <entry>
      <title type="html">Beginning GSoC 2019: with SymPy</title>
      <link href="https://www.shubhamjha.com/posts/Beginning-GSoC-2019/" rel="alternate" type="text/html" title="Beginning GSoC 2019: with SymPy" />
      <published>2019-05-12T00:00:00+05:30</published>
      <updated>2019-05-12T00:00:00+05:30</updated>
      <id>https://www.shubhamjha.com/posts/Beginning-GSoC-2019</id>
      <content type="html" xml:base="https://www.shubhamjha.com/posts/Beginning-GSoC-2019/">&lt;p&gt;&lt;a href=&quot;https://summerofcode.withgoogle.com/&quot;&gt;
  &lt;img src=&quot;/assets/img/gsoc.jpg&quot; style=&quot;width:30%;height:30%;float:left;&quot; /&gt;
&lt;/a&gt;
&lt;a href=&quot;https://www.sympy.org/en/index.html&quot;&gt;
  &lt;img src=&quot;/assets/img/sympy.png&quot; style=&quot;width:25%;height:25%;float:right;margin-right:100px;&quot; /&gt;
&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
Finally, the result of GSoC-2019 came on 6&lt;sup&gt;th&lt;/sup&gt; of May, 2019. I am very happy to inform that my &lt;a href=&quot;https://github.com/sympy/sympy/wiki/GSoC-2019-Proposal-Shubham-Kumar-Jha-:-Improving-Assumptions&quot;&gt;proposal&lt;/a&gt; on improving the assumptions mechanism has been accepted by SymPy for this year’s GSoC. For those who don’t know, SymPy is an open-sourced Computer Algebra System(&lt;a href=&quot;https://en.wikipedia.org/wiki/Computer_algebra_system&quot;&gt;CAS&lt;/a&gt;) written in Python. It was started by Ondrej Cetrik(&lt;a href=&quot;https://github.com/cetrik&quot;&gt;@cetrik&lt;/a&gt;) in 2006, as a project. Since 2007, SymPy has participated in Google Summer of Code every year. GSoC has given much boost to the development of SymPy’s codebase.&lt;/p&gt;

&lt;p&gt;My official mentors will be Aaron Meurer(&lt;a href=&quot;https://github.com/asmeurer&quot;&gt;@asmeurer&lt;/a&gt;) and Kelevi Suominen(&lt;a href=&quot;https://github.com/jksuom&quot;&gt;@jksuom&lt;/a&gt;). Aaron(who joined from GSoC) is also the lead developer of SymPy. For the next three months, I will be working on my project under their guidance.&lt;/p&gt;

&lt;p&gt;GSoC happens in phases. The official coding period will begin from 27&lt;sup&gt;th&lt;/sup&gt; of May, 2019. Before that, the first phase is the &lt;em&gt;Community Bonding Period&lt;/em&gt;. My plans for this period include:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Setting up a blog and synchronizing it with &lt;a href=&quot;https://planet.sympy.org/&quot;&gt;planet.sympy.org&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Discussing with my mentors about the possible means of communication and weekly meetings.&lt;/li&gt;
  &lt;li&gt;Planning about the implementation of the project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have been contributing to SymPy for the past four months. I am very happy to be a part of it.&lt;/p&gt;

&lt;p&gt;Looking forward to a great summer with SymPy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;:There will be a lot of posts after this 😄&lt;/p&gt;</content>
      <author>
          <name></name>
        
        
      </author>


      
        <category term="gsoc" />
      
        <category term="sympy" />
      
    </entry>
  
</feed>
