Python as an alternative to Matlab

We can also include Matlab in the results of the gridworld experiment benchmark. Certainly I guessed a different result, Matlab seems much faster than other interpreted languages. However, it is twice slower than Python.

LanguageRunning time%# lines
GCC 4.2.10.0041.00132
SBCL 1.0.360.0276.7577
Python 2.6.10.880220.0073
Matlab 7.8.01.636409.0080
Octave 3.2.320.9595249.7580

The main Matlab advantage is the important number and also quality of its toolboxes. Specifically, the Image Processing Toolbox is widely used by the Computer Vision and Image Processing community. But also the Artificial Neural Networks, Fuzzy Logic, and many other toolboxes. Recently I see some groups that used and promoted Matlab are starting to consider to Python as the new language for developing their work even in the Computer Vision and Image Processing context.

Date: 2010/09/06

Is Lisp fast enough?

The gridworld experiment shows interesting facts on the performance of several languages. The winner is Lisp. Lisp is faster than many other interpreted languages but general benchmark tests show many compiled languages run faster than Lisp. C, probably the fastest high-level programming language, achives the solution considerably faster.

LanguageRunning time%# lines
GCC 4.2.10.0041.00132
SBCL 1.0.360.0276.7577
Python 2.6.10.880220.0073
Octave 3.2.320.9595249.7580

The running time is important but it is not the only issue. For example, in no particular order, portability, number of available libraries, integration with different systems, integration with the code written by the others, time needed to develop a solution or check a new idea, documentation available, etc. are also important.

Lisp is a fast language and has many good things (it is very easy to code very complex algorithms and develop prototypes, there are lots of documentation available, etc.) but perhaps it is not well-situated for robot programming and systems integration. The job could be done but is it interesting?

Date: 2010/04/12

Gridworld

The gridworld problem is proposed in the book on Reinforcement Learning by Sutton and Barto (the book is freely available online). An agent or robot must move from a start state to a goal state. The four actions from every state are up, down, right and left. The movements that take the robot out the gridworld are not permitted. There is also a version with eight movements from each cell (like the king in the game of chess).

In the windy gridworld version there is a crosswind upward through the middle of the grid in such a way that the final cell is shifted upward by the wind. The strength of which varies from column to column.

Gridworld

The problem can be solved with a standard Q-learning algorithm. The robot is located in the same starting position for each episode (2000 episodes were considered for this experiment). The optimal path is usually achieved in the initial 30 or 40 episodes. It has been programmed in three different languages: Lisp, Octave and Python. The results are equivalent in all the three languages. And these are some benchmarking:

LanguageRunning time%# lines
SBCL 1.0.360.0271.0077
Python 2.6.10.88032.9773
Octave 3.2.320.959785.0180

It is amazing, Lisp is much more faster than Python! It is one of the oldest languages and probably it has a lot of good implementations. SBCL is one of the best and fastest ones. Octave is the slowest language, it is not optimized, it is a pitty but currently it can not be considered as a serious alternative to Matlab.

Date: 2010/04/04
$Date: 2010/09/06 12:12:13 $