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.
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):
#time,minimum:aggregator_3,mean:aggregator_4,maximum:aggregator_5, 0.0,0.0,0.0,0.0, 1.0,1.0,1.0019910208472986,1.0097022650519742, 2.0,1.0004643268652638,1.0095674153157645,1.0262259489733176, 3.0,1.0060119053314747,1.0217061437540778,1.0427319696020914, 4.0,1.0123960316227099,1.0376411151187632,1.0694676191541803, 5.0,1.0347474119967652,1.0603441700026108,1.095720861915768,