Skip to content

agent_State and agent_Sum Files

kalden edited this page Mar 20, 2013 · 5 revisions

4(A): agent_State and agent_Sum Files

agent_State Files

The agent_State files describe all the agents, sorted by species. The information included in the agent description depends on the species class (e.g. Bacterium, ParticulateEPS, etc.). A species mark-up provides the list of descriptors in the attribute header, followed by an array where each line represents a different agent and each column a different agent property.

agent_State

agent_Sum Files

The agent_Sum files are similar, but contain information about each species as a whole rather than information about each individual agent:

agent_Sum

Processing these Files in Matlab

There are some general Matlab routines provided that allow the result files to be read in for analysis. To use these files, you must first set the Matlab path as described early in this tutorial, and then change your working directory to where the result files are located. Then you may read in a particular agent state using the command:

a = loadAgents(nFile)

where nFile is the index of the file you want to load and analyze (i.e. its filename is agent_State(nFile).xml). If the file exists it will be loaded, and if it does not exist, the program will search into the zip file, decompress the file, and then load it. By using instead the syntax

a = loadAgents(nFile,true)

the program will delete the file it has decompressed after having loaded it into the Matlab workspace. The loadAgents routine returns an indexed structure (‘a’ in the above examples), which means that a(1) stores a structure describing the first species, a(2) a structure for the second species, and so on. Each structure includes several fields, including the name of the species in name, a header describing the saved data, and a data matrix that contains a description of all agents that belong to this species. For example, to extract the spatial coordinates of an agent of the first species, use the following command:

xyz = a(1).data(:,[10 11 12])

This routine copies from the data matrix all rows, but only columns 10, 11, and 12, which you can see in the agent_State mark-up above are the columns containing the location data (Matlab begins counting at 1 for indices, unlike Java which begins counting at 0). Note that you may easily access the last state by changing into the ‘lastIter’ directory and entering -1 for the nFile parameter.