[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Swarm, sub-swarms, sub-sub-swarms, and sub-sub-sub-swarms
From: |
Andrew Boyd |
Subject: |
Swarm, sub-swarms, sub-sub-swarms, and sub-sub-sub-swarms |
Date: |
Tue, 10 Aug 1999 19:22:14 -0500 |
Hi,
Back a few months ago someone asked if you could have more than level of
objects stepping throughout a simulation, for example a population object
having all of the people objects, and allowing the population object step
as well as the People. I have gotten a similar program to work.
I was writing a simulation of a cell for development. Each cell needed
compartments (comp), and with in each compartment I need objects of Gene
Product or concentration of protein. I don't think any one has posted
pseudo code for a hierachial structure such as this within swarm, I could
be mistaken if so ignore this email. So the full order of the code would be
main -> ObserverSwarm -> ModelSwarm -> Cell -> Comp -> GeneProducts
Where ModelSwarm has a list of Cells, and each Cell has a list of
Compartments, and each Compartment has a List of GeneProducts.
At the implementation the only Swarm Object is GeneProducts.
Cell and Comp are Swarms, however since Cell and Comp are a mixture between
Model Swarms and SwarmObjects, I called them Swarm Object Binders. You
need the header file for both Swarm and SwarmObject to get both abilities of
building objects and stepping.
This project is not in the final stages of development so whether or not the
probes completely work has not been tested, Some of the function calls to a
super class are due to mimicking SwarmModel and may not be needed. I have
taken out much of the stuff still in development so I think I left
everything in that is needed for hierachial layers of objects. You also
have to add the new objects and files to the MAKEFILE as well.
Sincerely
Andy Boyd
UT Southwestern Medical Center
Here is the code
The one change you need to make to Model Swarm is
during the creation of Cell you need the command
[cell buildObjects];
This allows each cell to build it compartments and geneproducts as
necessary.
Cell
#import <objectbase/Swarm.h>
#import <objectbase/SwarmObject.h>
#import <activity.h>
#import <space.h>
#import "Comp.h"
@interface Cell: Swarm
{
int numComp;
Comp *cmp; // Comp object
id compList;
}
+ createBegin: aZone; // extra methods you
- createEnd; // provide for Swarms
- buildObjects;
- step;
@end
@implementation Cell
+ createBegin: aZone
{
Cell *obj;
id <ProbeMap> probeMap;
printf("Cell createBegin\n");
obj = [super createBegin: aZone];
obj->numComp = 10;
probeMap = [EmptyProbeMap createBegin: aZone];
[probeMap setProbedClass: [self class]];
probeMap = [probeMap createEnd];
[probeLibrary setProbeMap: probeMap For: [self class]];
return obj;
}
- createEnd
{
return [super createEnd];
}
- buildObjects
{
int i; // a loop counter
// allow our parent class to build anything.
[super buildObjects];
compList = [List create: self];
for (i = 0; i < numComp; i++)
{
cmp = [Comp create: self];
cmp = [Comp createEnd];
[cmp buildObjects];
[compList addLast: cmp];
}
return self;
}
-step
{
[compList forEach: M(step): cmp];
return self;
}
@end
Here is the code for Comp.
#import <objectbase/Swarm.h>
#import <objectbase/SwarmObject.h>
#import <activity.h>
#import <space.h>
#import "GeneProduct.h"
@interface Comp: Swarm
{
int numGeneProducts;
GeneProduct * gnprdct; // GeneProduct object
id geneProductList;
}
- step;
+ createBegin: aZone; // extra methods you
- createEnd; // provide for Swarms
- buildObjects;
@end
@implementation Comp
+ createBegin: aZone
{
Comp *obj;
id <ProbeMap> probeMap;
// First, call our superclass createBegin - the return value is the
// allocated Cell object.
obj = [super createBegin: aZone];
obj->numGeneProducts = 200;
probeMap = [EmptyProbeMap createBegin: aZone];
[probeMap setProbedClass: [self class]];
probeMap = [probeMap createEnd];
[probeMap addProbe: [probeLibrary getProbeForVariable: "numGenes"
inClass: [self class]]];
[probeLibrary setProbeMap: probeMap For: [self class]];
return obj;
}
-createEnd
{
return [super createEnd];
}
- buildObjects
{
int i;
[super buildObjects];
geneProductList = [List create: self];
for (i = 0; i < numGeneProducts; i++)
{
gnprdct = [GeneProduct createBegin: self];
gnprdct = [GeneProduct createEnd];
[geneProductList addLast: gnprdct];
}
return self;
}
-step
{
[geneProductList forEach: M(step): gnprdct ];
return self;
}
@end
GeneProduct is a normal Swarm Object
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Swarm, sub-swarms, sub-sub-swarms, and sub-sub-sub-swarms,
Andrew Boyd <=