Xholon - Stupid Model 8 - File Output

What is it

This is the 8th in a series of 16 "Stupid Models". It's intended as a starting point for learning how to develop grid and agent-based models using Xholon. It can also be used to compare Xholon with other agent-based modeling tools that have also implemented the Stupid Model series.

This model demonstrates how to write results to an output file. Each time step, it should write the minimum, mean, and maximum bug size to one line of an output file.

Xholon features

The easiest way to do this in Xholon is to enable the gnuplot line chart capability. Every time step it can write comma-separated data to an output file. Optionally, this data can be plotted later.

Specify details in StupidModel8_xhn.xml. The UseDataPlotter parameter should be set to "gnuplot". Also look at the DataPlotterParams parameter values.

StupidModel8_CompositeStructureHierarchy.xml includes four aggregators, which gather statistics about objects in the grid. The minimum, mean, and maximum values are each maintained in its own aggregator.

The shouldBePlotted() method in AppStupidModel8.java determines which objects will be written to the output file each time step. In this case it looks for any instance of Aggregator that is not just a simple count. This class, in its step() method, calls chartViewer.capture() each time step to record the current values of minimum, mean, and maximum.

The following is a sample of what the output file looks like (it's saved in the "statistics" directory in a file with a name like a1180389315357_sm8_Stats.csv):


Credits and references

Railsback, S., Lytinen, S., Grimm, V. (2005). StupidModel and Extensions: A Template and Teaching Tool for Agent-based Modeling Platforms.

Swarm page

Author's page