Clever Algorithms in Python


Clever Algorithms in Python was born out of the need to understand and assimilate the original Clever Algorithms by Jason Brownlee. Please read about my motivations and goals here: Overview, Stochastic Algorithms – Part 1 & Part 2


Download source code. Unzip and import the attached folder in to your Eclipse workspace. It includes a test suite for exercising the algorithms.

I am using Python 2.7.2 with Eclipse IDE for Java Developers Version: Helios Service Release 2. I have the PyDev ver 2.1.0xxx plugin for eclipse to work in python.


Clever Algorithms are a collection of 45 algorithms divided in to 7 main categories: Stochastic Algorithms (10), Evolutionary Algorithms (10), Physical Algorithms (5), Probabilistic Algorithms (5), Swarm Algorithms (5), Immune Algorithms (5) and Neural Algorithms (5).

The source code download contains an eclipse workspace which can be opened in eclipse IDE. As and when I complete other algorithms, I will blog about it and upload the source.

The best way to assimilate this is to read and understand the algorithm strategy, heuristics and pseudo code, before attempting the code. To make it easier (easier than the original) I kept the code constructs like pseudo code and also commented the code extensively. It is a daunting task to take all of it at one go. I would recommend, starting with the basic searches like random search, adaptive random search etc and then build on those for others. Any suggestions, comments, improvements are always welcome.

Revision History

  • July 6th 2011 : Completed Stochastic Algorithms in Python: Random Search, Adaptive Random Search, Stochastic Hill Climbing, Iterated Local Search, Guided Local Search, Variable Neighborhood Search, Greedy Randomized Adaptive Search, Scatter Search,  Tabu Search and Reactive Tabu Search
  • July 7th 2011: Refactored the test suite to remove repetition in terms of inputs, result formatting etc. Added placeholder for  Swarm Algorithms and refactored helpers so that they can be accessed by other algorithm categories.

Leave a Reply

%d bloggers like this: