Marcus Daniels, Sept. 6, 2000

Here's an example using hdf5AppArchiver for saving simulation data to
a file.  HDF5 is good for logging data because it is fast and random-access.
If you prefer Lisp data files, simply replace "hdf5AppArchiver" with 
"lispAppArchiver". 

To load the HDF5 into R, you'd run:

$ R
> library(hdf5)
> hdf5load("TestArchiverSave.hdf")

Then you can do statistics on the saved data, e.g.:

> sum(agentList$ival)

import java.util.LinkedList;
import java.util.List;
import swarm.Globals;

public class TestArchiverSave {
    List agentList;

    class Agent {
        public int ival;
        public double dval;

        Agent (int ival, double dval) {
            super ();

            this.ival = ival;
            this.dval = dval;
        }
    }

    TestArchiverSave () {
        super ();
        agentList = new LinkedList ();

        for (int i = 0; i < 10; i++)
            agentList.add (new Agent (i + 1, i + 2));

        Globals.env.hdf5AppArchiver.putShallow$object ("agentList", agentList);
        Globals.env.hdf5AppArchiver.sync ();
    }

    static void main (String []args) {
        Globals.env.initSwarm ("TestArchiverSave",
                               "0.0",
                               "bug-swarm@swarm.org",
                               args);

        new TestArchiverSave ();
    }
    
}

