Document: SCL: An Artificial Chemistry in Swarm

next 6.7 Access to Random State?
up 6 SCL Design Notes
gif 6.5 Agent Update Order

6.6 Persistent Storage

An essential part of the requirement for SCL was to support persistent storage of a model--i.e. being able to save a model into a disk file, and reload it later. This is not supported by any of the current Swarm example applications, and there is little support for it built into Swarm.

Swarm does provide object classes ObjectSaver and ObjectLoader intended to take an arbitrary object and save it or reload it. I experimented with these, but eventually found them too cumbersome. They operate by exploiting the Swarm probe machinery. Thus, in order to control exactly what instance variables are processed, it is necessary to establish appropriate probeMaps. Further it is difficult to use these methods in a way which easily respects the class inheritance hierarchy. Finally, in some cases, instance variables cannot be meaningfully saved to disk in their normal form--because they are actually pointers, and the same object will not generally be guaranteed to be at the same location when the model is reloaded (indeed, it would generally be highly unlikely). In these cases it is necessary to ``re-code'' these variables in some sense. To do this within the ObjectSaver and ObjectLoader framework would mean developing special ``proxy'' objects, to which ObjectSaver and ObjectLoader could be applied, but which would contain the ``re-coded'' instance variables. Given all these complications, I abandoned this approach.

The strategy I adopted was to provide all relevant objects with methods, saveTo: and loadFrom:, which will save to or load from a given disk file (implemented as a Swarm OutFile or InFile object as appropriate). The sclModelSwarm then provides methods to get a file name, open the file, and invoke the required saveTo: and loadFrom: methods, in order, on all required objects. This finally worked satisfactorily, but there were various problems along the way:



next 6.7 Access to Random State?
up 6 SCL Design Notes
gif 6.5 Agent Update Order

Document: SCL: An Artificial Chemistry in Swarm

Copyright © 1997 All Rights Reserved.
Timestamp: Tue Dec 31 19:40:38 GMT 1996

mcmullin@eeng.dcu.ie