Algorithms

Spring 2011
course
navigation

Apr 28

So now that we're at the end of the term, I thought we could discuss general approaches the underlying theme of the course: how do you write code to solve a given problem that will run fast?

python Lin-Kernighan Traveling Salesman code and analysis from last term and last night.

making it faster

0a. choose algorithm 0b. get it to work at all, and understand run time 1. profiling loop: test it profile it, find out which parts are slow rewrite slowest parts 2. memoization I give a simple example; 3. C for slow bits: details vary with language you're embedding in; from python one typically creates a "setup.py" file and let python itself compile the C code. Usually you end up writing a "wrapper" around the C. Or you can use PyInline (!) (Though it's old.) 4. can this problem run concurrently ? a) Will the problem let you do that? b) If so, what do you have access to? multiple cpus? machines? See e.g. http://wiki.python.org/moin/ParallelProcessing 5. more cpu/memory help ? See e.g. www.picloud.com Also: Has someone else done the problem (or part of it) for you? http://nodebox.net/code/index.php/Graph Locality : in memory (don't thrash!), in access time (caches!) ... particularly in C code.

physical units

N-body example
http://cs.marlboro.edu/ courses/ spring2011/algorithms/ notes/ Apr_28
last modified Thursday April 28 2011 11:36 am EDT