[Geneticd-devel] Command queuing in Environ done!
Status: Alpha
Brought to you by:
jonnymind
|
From: Jonny M. <jon...@ni...> - 2002-01-17 21:52:55
|
Ok. A complete command queuing is not the answer, but I found a fine
solution, and it is working (and on CVS). The spare population is now the
"working population".
1) If any command that could modify the population (from now on, P-Command)
reaches the engine, it is passed to the environment through a new method
called "alter". Alter locks the environment.
2) if there is not a turn evaluating when the alter command is called, the
enviroment calls immediately a private method called "exec_command", that
does the job.
3) At the beginning of the turn, the environment is locked and the population
is copied to the spare pop. This ensures that the population is coherent,
since the only method authorized to change it ("alter") is sync (locking with
the environment on the critical section).
4) spare pop is evolved; meanwhile any read-only command that reads the
population is directed to the "population" vector (that is unchanged), and
any "alter" invocation is cached.
5) at the end of the turn, the environ is locked again. Now, the spare pop is
copied in the population, and the turn counters are incremented. If there are
commands in queued from a preceding alter() call, they are applied to the new
population.
6) environment is unlocked and the turn ends.
This implies that any reading command should lock the environment: it won't
stop a turn from being evalued, but it will prevent fro inconsistent readings
(while population is being copied in or out, or while it is modified).
Allowed commands for "alter" are now:
- "add" a gene (from engine::loadgene())
- kill a gene (with a valid Genetic * that points to a gene in the population)
- kill an agent knowing it's id (numeric or integer)
- changing population parameters (add rate, del rate and same rate).
In the future they could be more.
All this "async" mechanism is now up, and seems to be working. Also, I have
removed some errors in the shutdown sequence.
Regards,
Giancarlo.
|