Author: Christian S. Perone

Genetic Algorithms, Pyevolve, Python

Rosenbrock’s banana function and friends

This post is a report of an optimization test suite applied to Pyevolve GA Core.

I’m writing a paper about Pyevolve and I’ve done some tests on the GA quality of Pyevolve with must common optimization test functions: Schaffer, Rastringin, Sphere, Ackley and the absolute GA-hard Rosenbrock. Follows in the end of the post, the results of the trials, I’ve exported the latex formulae as images.

The only function that the GA had some trouble (it failed to find the global minima in 3 of 10 trials, the “fail” term means that it had not found an optimal solution for 5.000 generations) was the Rosenbrock’s function with 20 variables, also known as Rosenbrock’s banana function due the dinstinctive shape of the contour lines, here is the 3D plot with 2 variables.

As Wikipedia says,

This function is often used to test performance of optimization algorithms. The global minimum is inside a long, narrow, parabolic shaped flat valley. To find the valley is trivial, however to converge to the global minimum is difficult.

However, this behavior was not unexpected, since we can note the same on the research of [1], [2], [3] and [4], among other many papers.

I think this trial results brings more reliability to the framework, when the Pyevolve paper was published, I’ll post it here.

[1] Seredynski, Franciszek, et. al. (2003). “Function Optimization with Coevolutionary Algorithms”, in International Intelligent Information Processing and Web Mining Conference.

[2] Hiroyasu, Tomoyuki, et. al. (1999). “Distributed Genetic Algorithms with Randomized Migration Rate”, IEEE Proceedings of Systems, Man and Cybernetics Conference SMC’99, Vol. 1, pp. 689-694.

[3] Bouvry, Pascal, et. al. (1997). “Distributed evolutionary optimization in Manifold: the Rosenbrock’s function case study”, Duke University.

[4] Panait, Liviu (2002). “A comparison of two competitive fitness functions”, in GECCO 2002: Proceedings of the Genetic and Evolutionary Computation Conference.

Article, Genetic Algorithms, News, Philosophy, Science

Considerations regarding Karl Popper’s philosophy of science and Evolutionary Algorithms

There is a portuguese version of this post here.

I am a big fan of the Karl Popper’s philosophy of science, so I decided to write something about what I find interesting in his philosophy, especially in relation to rational criticism, to talk later a little bit of what I think about this in relation to Evolutionary Algorithms (EAs).

karlpopper

Popper, in his book “In Search of a Better World” (the original title is “Auf der Suche nach einer besseren Welt“), cites the importance of rational criticism in science and combat the dogmatism of belief in the scientific authority. For me, this idea, despite intrinsic in the thoughts of many philosophers, was not so clearly exposed as Popper did, the clarity with how Popper gives us the insight about how the science grows and improves through rational criticism is remarkable, and I’ll try to summarize here what he tried to explain for almost whole life.

(more…)

Genetic Algorithms, Pyevolve, Python

Pyevolve on Sony PSP ! (genetic algorithms on PSP)

Sony PSP can be more interesting than funny sometimes. Few people know about the potential of the PSP port of Stackless Python 2.5.2. This great port of python was done by Carlos E. and you can find more information about the progress of the port on his blog.

Well, I’ve tested the Pyevolve GA framework on the Stackless Python for PSP and for my surprise, it worked without changing one single line of code on the framework due the fact of Pyevolve has been written in pure Python (except the platform specific issue like the Interactive Mode, but this issue is automaticly disabled on unsupported platforms).

So now, we have Genetic Algorithms on PSP.

Follow some screenshots (click to enlarge):

psp2psp1

The GA running on the PSP screenshot is the minimization of the Sphere function.

Here is the steps to install Pyevolve on PSP:

PSP Stackless Python Installation

1) First, create a directory called “python” on your PSP under the “/PSP/GAME” and the directory structure “/python/site-packages/” on the root of your memory stick (this last directory will be used to put Pyevolve later).
2) Copy the EBOOT.PBP and the python.zip files to this created directory;

Pyevolve Installation

3) Download the Pyevolve source and copy the directory called “pyevolve” to the created directory “/python/site-packages/”, the final directory structure will be: “/python/site-packages/pyevolve”

Ready ! Now you can import Pyevolve modules inside scripts on your PSP, of course you can’t use the graphical plotting tool or some DB Adapters of Pyevolve, but the GA Core it’s working very well.

Here is some basic usage of PSP Stackless Python port. I’ve used the psp2d module to show the information on screen. When I got more time, I’ll port the visualization of the TSP problem to use the psp2d, it will be nice to see Traveling Salesperson Problem running with real-time visualization on PSP =)

Related Links

Google Code Project of PSP Stackless Python

Genetic Algorithms, Pyevolve, Python

Pyevolve: the effect of Linear Scaling

There’s an interesting graph in Pyevolve which is a heat-like graph of the population raw and fitness scores. In this graph you can note the effect of Linear Scaling over the scores, the raw scores graph is in left and the fitness scaled scores is in the right, this plot uses the Gaussian interpolation method.

linear

This graph feature is very interesting to study the effects of selections and scaling schemes and even to see the propagation of best individuals on the population while evolving, I think this graph should be more explored.

News, Python, Time Waste

Python: 3D real-time debugging and function call structure

Here is two videos of a small script (python and xmlrpc calls to ubigraph visualization server) created to show a 3D graph of  the function call structure of a python application, the first shows only the structure created while running the application and the next video shows a debugging-like tool, it changes the node color to red when the function is called, and the labels shows: function name, python file name and the line on the python file where the code is.

Update (26/02): download here the script source-code.

To use the script, start the Ubigraph visualization server and add the profile module to your python application, it will looks like this:

import prof3d

def run_main():
   # your code

if __name__ == "__main__":
   prof3d.profile_me()
   run_main()

News, Python, Time Waste

Twitter in 3D !

I was doing some tests on the Ubigraph dynamic graph visualization tool and I have this idea to use the Ubigraph tool to render 3D graphs of Twitter friends on real-time. Follows the video of the scripting utility I’ve created, it starts with a red node of your twitter and when you click, it shows your friends, when you click on your friends, it shows their  friends, and so on. I think it is interesting those social network graphs, when I got more time I’ll put more ideas on the pratice =)

Update (26/02): download here the script source-code.
To use it, you must install python-twitter, use the easy_install:

easy_install python-twitter

I’ve tested with Python 2.5, but it should works on 2.4 and 2.6 too.

Start the Ubigraph visualization server and run the script. The syntax for the script is like this:

python twitter3d.py -u username

You can get a help using:

python twitter3d.py –help

Genetic Algorithms, News, Science

Genetic Algorithms help us to understand how we see

There is a very interesting article on the insciences.org, it talks about the use of a Genetic Algorithm to create images used to test people brain performance:

The team developed a ‘genetic algorithm’, based on a simple model of evolution, that can breed a range of images and visual stimuli which were then used to test people’s brain performance. By using artificial intelligence to design the test patterns, the team removed any likelihood of predetermining the results which could have occurred if researchers had designed the test pictures themselves.

Read the full article or see the created images.

Pyevolve, Python

Good news: IronPython and Jython compatibility !

Good news, I’ve tested Pyevolve 0.5 with the IronPython 2.0.1 and Jython 2.5b1, and the framework is working perfect (besides the performance loss when comparing with CPython 2.5 and 2.6). The only feature that do not worked is the dump of statistics with the sqlite3, sine there is no sqlite3 on the default install of Jython and IronPython. To Pyevolve work on IronPython, you must install the zlib module for IronPython and import your Python modules like this:

import sys
sys.path.append(r"c:\python25\lib")

With this compatibility issue, you can use Pyevolve on your .NET platform or in your Java applications.

I'm starting a new course "Machine Learning: Foundations and Engineering" for 2024.