Popular recipes tagged "optimization" but not "math"http://code.activestate.com/recipes/tags/optimization-math/2016-10-29T20:22:27-07:00ActiveState Code RecipesPDF wrapper for FileOptimizer (Python)
2016-10-29T20:22:27-07:00Harald Liederhttp://code.activestate.com/recipes/users/4191581/http://code.activestate.com/recipes/580711-pdf-wrapper-for-fileoptimizer/
<p style="color: grey">
Python
recipe 580711
by <a href="/recipes/users/4191581/">Harald Lieder</a>
(<a href="/recipes/tags/fileoptimizer/">fileoptimizer</a>, <a href="/recipes/tags/fitz/">fitz</a>, <a href="/recipes/tags/mupdf/">mupdf</a>, <a href="/recipes/tags/optimization/">optimization</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pymupdf/">pymupdf</a>).
</p>
<p>Among dozens of other filetypes, FileOptimizer also compresses PDFs - often significantly.
The issue is that the used plugin <em>smpdf</em> is free for non-commercial use only and it annoyingly <strong>also overwrites metadata</strong> information to state this.</p>
<p>The following tool remedies these metadata changes (but not the license situation!).</p>
Finding sets in the card game SET! (Python)
2013-04-05T12:49:36-07:00Sander Evershttp://code.activestate.com/recipes/users/4173111/http://code.activestate.com/recipes/578508-finding-sets-in-the-card-game-set/
<p style="color: grey">
Python
recipe 578508
by <a href="/recipes/users/4173111/">Sander Evers</a>
(<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/optimization/">optimization</a>, <a href="/recipes/tags/search/">search</a>, <a href="/recipes/tags/setgame/">setgame</a>).
Revision 2.
</p>
<p>In the card game <a href="http://en.wikipedia.org/wiki/Set_%28game%29">SET!</a>, players are shown an array of 12 (or more) symbol cards and try to identify a so-called 3-card <strong>set</strong> among these cards as quickly as possible.</p>
<p>A card has four attributes (number, shape, color and shading), each of which can take 3 possible values. In a <strong>set</strong>, for each attribute, all three cards should have either the same value, or the three different values.</p>
<p>This recipe solves the problem of finding <em>all</em> sets within an array of an arbitrary number of cards, showing some clever optimizations and celebrating the clarity of Python in expressing the algorithms.</p>
Compare speeds of different kinds of access to variables (Python)
2011-08-10T23:54:12-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577834-compare-speeds-of-different-kinds-of-access-to-var/
<p style="color: grey">
Python
recipe 577834
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/optimization/">optimization</a>).
Revision 5.
</p>
<p>Compare speeds of locals, nested scopes, global, builtins, instance variables, and class variables.</p>
Dijkstra shortest path implementation (Python)
2011-10-05T09:06:50-07:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/577892-dijkstra-shortest-path-implementation/
<p style="color: grey">
Python
recipe 577892
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/dijkstra/">dijkstra</a>, <a href="/recipes/tags/optimization/">optimization</a>, <a href="/recipes/tags/shortest/">shortest</a>).
</p>
<p>This code snippet is the implementation of Dijkstra's algorithm.</p>
Flatten a list (or list of lists, etc.) (Python)
2011-03-01T03:46:26-08:00Sunjay Varmahttp://code.activestate.com/recipes/users/4174115/http://code.activestate.com/recipes/577255-flatten-a-list-or-list-of-lists-etc/
<p style="color: grey">
Python
recipe 577255
by <a href="/recipes/users/4174115/">Sunjay Varma</a>
(<a href="/recipes/tags/extend/">extend</a>, <a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/list/">list</a>, <a href="/recipes/tags/optimization/">optimization</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/smart/">smart</a>).
Revision 2.
</p>
<p>I created this function sometime ago for my own purposes. It simply flattens a list.</p>
<p>Check out the first comment for another version of someone else's design.</p>
Decorator for BindingConstants at compile time (Python)
2009-09-15T00:34:37-07:00Gabriel Genellinahttp://code.activestate.com/recipes/users/924636/http://code.activestate.com/recipes/576904-decorator-for-bindingconstants-at-compile-time/
<p style="color: grey">
Python
recipe 576904
by <a href="/recipes/users/924636/">Gabriel Genellina</a>
(<a href="/recipes/tags/optimisation/">optimisation</a>, <a href="/recipes/tags/optimization/">optimization</a>, <a href="/recipes/tags/programs/">programs</a>).
</p>
<p>Decorator for automatic code optimization. If a global is known at compile time, replace it with a constant. Fold tuples of constants into a single constant. Fold constant attribute lookups into a single constant.</p>
<p>This is only an update of <a href="http://code.activestate.com/recipes/277940/">Recipe 277940</a>, making it compatible with Python 3. All credit must go to the original author, Raymond Hettinger.</p>
Evolution optimization strategy (Python)
2009-04-20T06:31:13-07:00Agnius Vasiliauskashttp://code.activestate.com/recipes/users/4169134/http://code.activestate.com/recipes/576645-evolution-optimization-strategy/
<p style="color: grey">
Python
recipe 576645
by <a href="/recipes/users/4169134/">Agnius Vasiliauskas</a>
(<a href="/recipes/tags/ai/">ai</a>, <a href="/recipes/tags/evolution/">evolution</a>, <a href="/recipes/tags/evolution_strategy/">evolution_strategy</a>, <a href="/recipes/tags/gene/">gene</a>, <a href="/recipes/tags/genetic_algorithm/">genetic_algorithm</a>, <a href="/recipes/tags/np_complete/">np_complete</a>, <a href="/recipes/tags/optimization/">optimization</a>).
Revision 6.
</p>
<p>Algorithm for solving search and optimization problems.</p>