Saturday, March 21, 2009

Look mom, no hands! Automating experiments.

This week I devoted most of the time to improve the modeling framework to make easier the realization of experiments and the gathering and analysis of of results. Now I'm doing and planning some serious experiments and have a clearer idea of what it will take to produce "paper ready" results. I prefer to invest time doing this for once that doing it by hand every time I need some results.

First I added some new features to obtain not only raw counters from models (for example, number or messages sent and dropped) both also calculated (the ratio of the dropped with respect of the total) and time series of those values along the execution of the experiment. I had all the pieces already, but now they fit nicely and also with the charting tools.

I'm now working on the controlling the execution of multiple runs of the same experimental setup and gathering both the information from each experiment and a summary. I've found that thanks to the data analysis features I already have implemented in the simulation engine, this will be quite easy.

Sometimes I wonder if it had been a better idea to go further with Repast, a widely used agent based simulation framework. However, when I see how clean my code is, all doubts disappear. Repast's model (or lack or, thereof) leads to very messy, hardly reusable code. I will post in the near future about that makes my framework different.

I also made some modifications is the Jung based topology display, to accommodate different display layouts like force based, which will be important to reflect how the nodes of the topology actually reorganize. I notice that I need some way to change the zoom level of the display if I want to work with more than some hundreds of nodes.

This is the good thing about frameworks: they serve to purposes you didn't even considered while you were designing it. The hard part is to keep working on the framework without evident progress (just a bunch of classes and interfaces) .

It is "easier" to take a short cut, do a dirty implementation and have something to show. But the problems came later, when you need to make changes in the simulation and start patching the code with the risk of introducing errors in the simulation. I personally prefer clean code because it gives me more confidence.

The next big change I need to implement is to improve the efficiency of the code. Because I use reflection a lot, the simulation time grows almost exponentially with the number of agents. I haven't made a profiling of the simulator (even when this would be a good idea), but from what I read in the Internet, most of the overhead of reflection is in the "discovery" part. That is, in locating the right method to call. Therefore. I'll try with a cache of the reflection information.

No comments:

Post a Comment