|
RePast v. 2.0 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--uchicago.src.sim.engine.SimModelImpl
|
+--uchicago.src.sim.engine.SimpleModel
Encapsulates some simple model behavoir and hides the scheduling mechansim. Every time step of the simulation, SimpleModel will executes its preStep(), step() and postStep() methods. Classes that extends this class can provide the appropriate implementation of these methods. In addition, SimpleModel will execute the atPause and atEnd methods at a pause in or at the end of a simulation run.
If the protected ivar autoStep is true, then SimpleModel will executes
preStep(), autoStep(), and postStep(). SimpleModel defines autoStep and
child classes need only implement preStep() and postStep() if desired.
autoStep() will optionaly shuffle the list of agents, and then call
step() on each agent. Note that in the auto-step case, agents
must implement the Stepable interface.
Child classes can make use of the following protected instance variables:
| Field Summary | |
protected ArrayList |
agentList
|
protected boolean |
autoStep
|
protected boolean |
isGui
|
protected String |
name
|
protected String[] |
params
|
protected Schedule |
schedule
|
protected long |
seed
|
protected boolean |
shuffle
|
protected long |
startAt
|
| Fields inherited from class uchicago.src.sim.engine.SimModelImpl |
descriptors, modelManipulator |
| Constructor Summary | |
SimpleModel()
|
|
| Method Summary | |
void |
atEnd()
|
void |
atPause()
|
void |
begin()
Begins a simulation run. |
void |
buildModel()
|
void |
buildSchedule()
|
String[] |
getInitParam()
Gets the names of the initial model parameters to set. |
String |
getName()
Gets the name of this model. |
double |
getNextDoubleFromTo(double from,
double to)
Returns the next random double between from and to, exclusive of from and to. |
int |
getNextIntFromTo(int from,
int to)
Returns the next random integer between from and to, inclusive of from and to. |
Schedule |
getSchedule()
Gets the Schedule created by the model. |
protected void |
postStep()
|
protected void |
preStep()
|
void |
run()
|
void |
runAutoStep()
|
void |
setRngSeed(long seed)
Sets the random number seed for this model, and recreates a uniform distribution with that seed. |
void |
setStoppingTime(double time)
Sets the tick at which this model will stop. |
void |
setStoppingTime(long time)
Sets the tick at which this model will stop. |
void |
setup()
Prepares a model for a new run, typically by deallocating objects or setting them to some reasonable default. |
protected void |
step()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Schedule schedule
protected ArrayList agentList
protected String name
protected String[] params
protected boolean autoStep
protected boolean shuffle
protected long seed
protected boolean isGui
protected long startAt
| Constructor Detail |
public SimpleModel()
| Method Detail |
public void setStoppingTime(long time)
public void setStoppingTime(double time)
public void setup()
SimModel
public void setRngSeed(long seed)
setRngSeed in interface SimModelsetRngSeed in class SimModelImplseed - the new rng seedRandom
public int getNextIntFromTo(int from,
int to)
public double getNextDoubleFromTo(double from,
double to)
public void begin()
SimModel
public String getName()
public Schedule getSchedule()
SimModel
public String[] getInitParam()
SimModel
public void buildModel()
public void buildSchedule()
public void atPause()
public void atEnd()
public void runAutoStep()
public void run()
protected void preStep()
protected void step()
protected void postStep()
|
RePast v. 2.0 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||