swarm-modeling
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ASM Patch 3 nearing completion; hdf5 question


From: Marcus G. Daniels
Subject: Re: ASM Patch 3 nearing completion; hdf5 question
Date: 01 Jul 2001 12:28:37 -0600
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.7

>>>>> "PJ" == pauljohn  <address@hidden> writes:

PJ> With hdf5 output from a swarm program, I hdf5load the file in R,
PJ> and I've got many objects, one for each time step. 

With an EZGraph setup for HDF5 output, you'll get an vector that
extends (and compresses) as the simulation runs.  It will have one
name and will look like a vector in R.  Although there isn't a way on
the Swarm side to create `compound types' of multiple sequences in a
graph, and have those load as data frames, it isn't a logistical
problem for doing statistics on the R side.  (It would probably have
some performance benefits, though..)

For example, in our market simulator there are EZGraph sequences that record
the positions taken by different kinds of traders, prices & value signals, and
many other things.  To construct a frame for doing statistics or 
transformations on this data is pretty easy in R.  Below, "default" refers
to the set of initial conditions that the simulation is using.  (It is
set by the "-m" option to Swarm.)  Here, the values inside of it are stored
to convenience variables and then combined into a data frame:

# store the position and price/value sequences in variables 
# (just for the sake of easy typing)
po <- default$position
pv <- default$priceValue

# Create a data frame using components of the values of these
# variables.  Specifically, the market maker positions, the
# fundamentalist positions and the price sequence.  Again, terse names
# are given the column names ("mm", "fn", "pv") for the sake of easy typing.
f <- data.frame(mm=po$MarketMaker,fn=po$Fundamentalist,pv=pv$price)

mean(f$mm)

PJ> Is there a typo in your commented-out line:
PJ>   #m <- hdf5load(hdf),load=FALSE)$m

Oops, the first ")" should not be there.  The last "$m" grabs the value
for the symbol "m" in the HDF5 file.  All the objects you save in an HDF5
file have names.  E.g. using hdf5save("foo.hdf","m"), given the `m'
from the read.table would have this form.

On another topic:

PJ> The keys I chose have
PJ> the timestep as part of the key, so I see objects with names that don't
PJ> even sort properly, as in

PJ> model0
PJ> model1
PJ> model10

Well, if you zero-pad them, the lexical and numeric sort will be the same..

The time-stamped keys can work, but it requires having some routines
on the R side to construct vectors and data frames.  It would make sense
to do this if it wasn't feasiable to load the whole time series for a field
into R memory at once.


                  ==================================
   Swarm-Modelling is for discussion of Simulation and Modelling techniques
   esp. using Swarm.  For list administration needs (esp. [un]subscribing),
   please send a message to <address@hidden> with "help" in the
   body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]