<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/1354" rel="nofollow">http://projects.scipy.org/scipy/ticket/1354</a> on 2011-01-12 by trac user bubla, assigned to unknown.</em></p>
<p dir="auto">Hello, as stated in the summary, something needs to be done with the Scipy FFT implementation.</p>
<p dir="auto">Consider this example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import scipy as sp
import scipy.fftpack
import numpy as np
import numpy.fft

# Now watch the system's resource usage
a = sp.rand(300,300,300)
sp.fftpack.fftn(a)
# Still lots of memory occupied
np.fft.fftn(a)
# Almost no additional memory occupied"><pre class="notranslate"><code class="notranslate">import scipy as sp
import scipy.fftpack
import numpy as np
import numpy.fft

# Now watch the system's resource usage
a = sp.rand(300,300,300)
sp.fftpack.fftn(a)
# Still lots of memory occupied
np.fft.fftn(a)
# Almost no additional memory occupied
</code></pre></div>
<p dir="auto">The point is that scipy uses much more resources and frees little, numpy is much better here.</p>
<h2 dir="auto">Problem</h2>
<p dir="auto"><code class="notranslate">_linprog.py</code> solves linear programming problems, originally via the simplex method. An implementation of the interior-point method was later added via <code class="notranslate">_linprog_ip.py</code> using the original <code class="notranslate">_linprog.py</code> as the top-level interface. The simplex and interior-point implementations duplicate similar behaviour and arguments especially to:</p>
<ul dir="auto">
<li>Clean user input.</li>
<li>Convert problem to standard equality form.</li>
<li>Call-back functions (not (yet) implemented in IP)</li>
</ul>
<p dir="auto">Further <code class="notranslate">_linprog_ip.py</code> implements the <code class="notranslate">_presolve(...)</code> and <code class="notranslate">_postprocess(...)</code>, which may also improve the simplex method.</p>
<h2 dir="auto">Proposed changes</h2>
<p dir="auto">I'm proposing to refactor <code class="notranslate">_linprog.py</code> and <code class="notranslate">_linprog_ip.py</code> into three new files <code class="notranslate">_linprog.py</code>, <code class="notranslate">_linprog_ip.py</code> and <code class="notranslate">_linprog_simplex.py</code></p>
<p dir="auto"><code class="notranslate">_linprog.py</code> to be the top level linear programming interface and handle behaviour common to all linear programming methods:</p>
<ul dir="auto">
<li>Validating and cleaning input.</li>
<li>Conversion to standard form.</li>
<li>Call-back functions.</li>
<li>Pre-solving and post-processing.</li>
</ul>
<p dir="auto"><code class="notranslate">_linprog_ip.py</code> and <code class="notranslate">_linprog_simplex.py</code> to implement the specific methods.</p>
<h2 dir="auto">Benefits</h2>
<ul dir="auto">
<li>Remove code implementing similar behaviour.</li>
<li>Avoid calling more complex solvers if problem is trivially solved.</li>
<li>Supply problem in standard equality form to all solvers.</li>
<li>Reduce the complexity of <code class="notranslate">_linprog_simplex(...)</code> by reusing <code class="notranslate">_clean_inputs(...)</code>  and <code class="notranslate">_get_Abc(...)</code> from the interior point method.</li>
<li>Improve simplex method implementation by pre-solving and post-processing.</li>
</ul>
<p dir="auto">Would this be worth refactoring or are there any other suggestions? <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/rgommers/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/rgommers">@rgommers</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mdhaber/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mdhaber">@mdhaber</a></p>