[avida-cvs] avida(Sherri) CVS commits: /current/source/main inject_genebank.cc inject_genebank.hh inject_genotype.cc inject_genotype.hh primitive.pch primitive.pdb /current/source/qt-viewer qt-viewer.pch qt-viewer.pdb /current/source/support genesis.4stack inst_set.4stack /current/source/support/preset_organisms organism.4stack organism.parasite /current/source/viewers ncurses-viewer.pch ncurses-viewer.pdb
goingssh
avida-cvs at alife.org
Tue Aug 19 20:38:02 PDT 2003
goingssh Tue Aug 19 12:38:02 2003 EDT
Added files: (Branch: Sherri)
/avida/current/source/viewers ncurses-viewer.pch ncurses-viewer.pdb
/avida/current/source/main inject_genebank.cc inject_genebank.hh
inject_genotype.cc inject_genotype.hh
primitive.pch primitive.pdb
/avida/current/source/qt-viewer qt-viewer.pch qt-viewer.pdb
/avida/current/source/support genesis.4stack inst_set.4stack
/avida/current/source/support/preset_organisms organism.4stack
organism.parasite
Log:
updating my branch again
-------------- next part --------------
Index: avida/current/source/viewers/ncurses-viewer.pch
+++ avida/current/source/viewers/ncurses-viewer.pch
Index: avida/current/source/viewers/ncurses-viewer.pdb
+++ avida/current/source/viewers/ncurses-viewer.pdb
Index: avida/current/source/main/inject_genebank.cc
+++ avida/current/source/main/inject_genebank.cc
//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1993 - 2003 California Institute of Technology //
// //
// Read the COPYING and README files, or contact 'avida at alife.org', //
// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
//////////////////////////////////////////////////////////////////////////////
#include <fstream>
#include "inject_genebank.hh"
#include "inject_genotype.hh"
#include "config.hh"
#include "stats.hh"
#include "../cpu/test_util.hh"
using namespace std;
/////////////////////
// cInjectGenotypeQueue
/////////////////////
cInjectGenotypeQueue::cInjectGenotypeQueue()
{
size = 0;
root.SetNext(&root);
root.SetPrev(&root);
}
cInjectGenotypeQueue::~cInjectGenotypeQueue()
{
while (root.GetNext() != &root) {
Remove(root.GetNext());
}
}
bool cInjectGenotypeQueue::OK()
{
bool result = true;
int count = 0;
for (cInjectGenotypeElement * temp_element = root.GetNext();
temp_element != &root;
temp_element = temp_element->GetNext()) {
assert (temp_element->GetNext()->GetPrev() == temp_element);
assert (temp_element->GetInjectGenotype()->GetID() >= 0);
count++;
assert (count <= size);
}
assert (count == size);
return result;
}
void cInjectGenotypeQueue::Insert(cInjectGenotype & in_inject_genotype)
{
cInjectGenotypeElement * new_element = new cInjectGenotypeElement(&in_inject_genotype);
new_element->SetNext(root.GetNext());
new_element->SetPrev(&root);
root.GetNext()->SetPrev(new_element);
root.SetNext(new_element);
size++;
}
void cInjectGenotypeQueue::Remove(cInjectGenotype & in_inject_genotype)
{
cInjectGenotypeElement * cur_element;
for (cur_element = root.GetNext();
cur_element != &root;
cur_element = cur_element->GetNext()) {
if (cur_element->GetInjectGenotype() == &in_inject_genotype) break;
}
assert (cur_element != &root);
Remove(cur_element);
}
void cInjectGenotypeQueue::Remove(cInjectGenotypeElement * in_element)
{
in_element->GetPrev()->SetNext(in_element->GetNext());
in_element->GetNext()->SetPrev(in_element->GetPrev());
in_element->SetNext(NULL);
in_element->SetPrev(NULL);
delete(in_element);
size--;
}
cInjectGenotype * cInjectGenotypeQueue::Find(const cGenome & in_genome) const
{
for (cInjectGenotypeElement * cur_element = root.GetNext();
cur_element != &root;
cur_element = cur_element->GetNext()) {
if (cur_element->GetInjectGenotype()->GetGenome() == in_genome) {
return cur_element->GetInjectGenotype();
}
}
return NULL;
}
////////////////////////////
// cInjectGenotypeControl
////////////////////////////
cInjectGenotypeControl::cInjectGenotypeControl(cInjectGenebank & in_gb) : genebank(in_gb)
{
size = 0;
best = NULL;
coalescent = NULL;
for (int i = 0; i < INJECTGENOTYPE_THREADS; i++) threads[i] = NULL;
historic_list = NULL;
historic_count = 0;
}
cInjectGenotypeControl::~cInjectGenotypeControl()
{
}
bool cInjectGenotypeControl::OK()
{
int ret_value = true;
// Cycle through the list, making sure all connections are proper, size
// is correct, and all genotypes are OK().
cInjectGenotype * cur_pos = best;
for (int i = 0; i < size; i++) {
if (!cur_pos->OK()) ret_value = false;
assert (cur_pos->GetNext()->GetPrev() == cur_pos);
cur_pos = cur_pos->GetNext();
}
assert (cur_pos == best);
return ret_value;
}
void cInjectGenotypeControl::Insert(cInjectGenotype & in_inject_genotype, cInjectGenotype * prev_genotype)
{
if (prev_genotype == NULL) {
assert(size == 0); // Destroying a full genotype queue...
best = &in_inject_genotype;
best->SetNext(best);
best->SetPrev(best);
}
else {
in_inject_genotype.SetPrev(prev_genotype);
in_inject_genotype.SetNext(prev_genotype->GetNext());
prev_genotype->SetNext(&in_inject_genotype);
in_inject_genotype.GetNext()->SetPrev(&in_inject_genotype);
}
size++;
}
void cInjectGenotypeControl::Remove(cInjectGenotype & in_inject_genotype)
{
if (size == 1) {
best = NULL;
}
if (&in_inject_genotype == best) {
best = best->GetNext();
}
in_inject_genotype.GetNext()->SetPrev(in_inject_genotype.GetPrev());
in_inject_genotype.GetPrev()->SetNext(in_inject_genotype.GetNext());
in_inject_genotype.SetNext(NULL);
in_inject_genotype.SetPrev(NULL);
size--;
}
void cInjectGenotypeControl::RemoveHistoric(cInjectGenotype & in_inject_genotype)
{
if (historic_count == 1) {
historic_list = NULL;
}
if (&in_inject_genotype == historic_list) {
historic_list = historic_list->GetNext();
}
in_inject_genotype.GetNext()->SetPrev(in_inject_genotype.GetPrev());
in_inject_genotype.GetPrev()->SetNext(in_inject_genotype.GetNext());
in_inject_genotype.SetNext(NULL);
in_inject_genotype.SetPrev(NULL);
historic_count--;
}
void cInjectGenotypeControl::InsertHistoric(cInjectGenotype & in_inject_genotype)
{
if (historic_count == 0) {
in_inject_genotype.SetNext(&in_inject_genotype);
in_inject_genotype.SetPrev(&in_inject_genotype);
}
else {
in_inject_genotype.SetPrev(historic_list->GetPrev());
in_inject_genotype.SetNext(historic_list);
historic_list->GetPrev()->SetNext(&in_inject_genotype);
historic_list->SetPrev(&in_inject_genotype);
}
historic_list = &in_inject_genotype;
historic_count++;
}
/*int cInjectGenotypeControl::UpdateCoalescent()
{
// Test to see if any updating needs to be done...
// Don't update active coalescent genotype, or if there is more than
// one offspring.
if (coalescent != NULL &&
(coalescent->GetNumInjected() > 0) ||
coalescent->GetNumOffspringGenotypes() > 1) ) {
return coalescent->GetDepth();
}
// If there is no best, there is nothing to search through...
if (best == NULL) return -1;
// Find the new point...
cInjectGenotype * test_gen = best;
cInjectGenotype * found_gen = best;
cInjectGenotype * parent_gen = best->GetParentGenotype();
while (parent_gen != NULL) {
// See if this genotype should be the new found genotype...
if (test_gen->GetNumOrganisms() > 0 ||
test_gen->GetNumOffspringGenotypes() > 1) {
found_gen = test_gen;
}
// Move to the next genotype...
test_gen = parent_gen;
parent_gen = test_gen->GetParentGenotype();
}
coalescent = found_gen;
return coalescent->GetDepth();
}*/
bool cInjectGenotypeControl::CheckPos(cInjectGenotype & in_inject_genotype)
{
int next_OK = false;
int prev_OK = false;
if (in_inject_genotype.GetNumInjected() >= in_inject_genotype.GetNext()->GetNumInjected()) {
next_OK =true;
}
if (in_inject_genotype.GetNumInjected() <= in_inject_genotype.GetPrev()->GetNumInjected()) {
prev_OK =true;
}
if ((&in_inject_genotype == best && next_OK) ||
(next_OK && prev_OK) ||
(&in_inject_genotype == best->GetPrev() && prev_OK)) {
return true;
}
return false;
}
void cInjectGenotypeControl::Insert(cInjectGenotype & new_genotype)
{
// If there is nothing in the list, add this.
if (size == 0) {
Insert(new_genotype, NULL);
}
// Otherwise tack it on the end.
else {
Insert(new_genotype, best->GetPrev());
}
}
bool cInjectGenotypeControl::Adjust(cInjectGenotype & in_inject_genotype)
{
//if (in_inject_genotype.GetDeferAdjust() == true) return true;
cInjectGenotype * cur_inject_genotype = in_inject_genotype.GetPrev();
// Check to see if this genotype should be removed completely.
if (in_inject_genotype.GetNumInjected() == 0) {
genebank.RemoveInjectGenotype(in_inject_genotype);
return false;
}
// Do not adjust if this was and still is the best genotype, or is
// otherwise in the proper spot...
if (CheckPos(in_inject_genotype)) {
return true;
}
// Otherwise, remove it from the queue for just the moment.
Remove(in_inject_genotype);
// Also, if this genotype is the best, put it there.
if (in_inject_genotype.GetNumInjected() > best->GetNumInjected()) {
Insert(in_inject_genotype, best->GetPrev());
best = &in_inject_genotype;
return true;
}
// Finally, find out where this genotype *does* go.
while (cur_inject_genotype->GetNumInjected() >= in_inject_genotype.GetNumInjected() &&
cur_inject_genotype != best->GetPrev()) {
cur_inject_genotype = cur_inject_genotype->GetNext();
}
while (cur_inject_genotype->GetNumInjected() < in_inject_genotype.GetNumInjected() &&
cur_inject_genotype != best) {
cur_inject_genotype = cur_inject_genotype->GetPrev();
}
Insert(in_inject_genotype, cur_inject_genotype);
return true;
}
cInjectGenotype * cInjectGenotypeControl::Find(const cGenome & in_genome) const
{
int i;
cInjectGenotype * cur_inject_genotype = best;
for (i = 0; i < size; i++) {
if (in_genome == cur_inject_genotype->GetGenome()) {
return cur_inject_genotype;
}
cur_inject_genotype = cur_inject_genotype->GetNext();
}
return NULL;
}
int cInjectGenotypeControl::FindPos(cInjectGenotype & in_inject_genotype, int max_depth)
{
cInjectGenotype * temp_genotype = best;
if (max_depth < 0 || max_depth > size) max_depth = size;
for (int i = 0; i < max_depth; i++) {
if (temp_genotype == &in_inject_genotype) return i;
temp_genotype = temp_genotype->GetNext();
}
return -1;
}
cInjectGenotype * cInjectGenotypeControl::Next(int thread)
{
return threads[thread] = threads[thread]->GetNext();
}
cInjectGenotype * cInjectGenotypeControl::Prev(int thread)
{
return threads[thread] = threads[thread]->GetPrev();
}
////////////////////
// cInjectGenebank
////////////////////
cInjectGenebank::cInjectGenebank(cStats & in_stats)
: stats(in_stats)
{
for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
inject_genotype_count[i] = 0;
}
inject_genotype_control = new cInjectGenotypeControl(*this);
}
cInjectGenebank::~cInjectGenebank()
{
delete inject_genotype_control;
}
void cInjectGenebank::UpdateReset()
{
static int genotype_dom_time = 0;
static int prev_dom = -1;
cInjectGenotype * best_inject_genotype = GetBestInjectGenotype();
if (best_inject_genotype && best_inject_genotype->GetID() != prev_dom) {
genotype_dom_time = 0;
prev_dom = best_inject_genotype->GetID();
}
else {
genotype_dom_time++;
if (genotype_dom_time == cConfig::GetGenotypePrintDom()) {
cString filename;
filename.Set("genebank/%s", best_inject_genotype->GetName()());
cTestUtil::PrintGenome(best_inject_genotype, best_inject_genotype->GetGenome(),
filename, stats.GetUpdate());
}
}
}
cString cInjectGenebank::GetLabel(int in_size, int in_num)
{
char alpha[6];
char full_name[12];
int i;
for (i = 4; i >= 0; i--) {
alpha[i] = (in_num % 26) + 'a';
in_num /= 26;
}
alpha[5] = '\0';
sprintf(full_name, "p%03d-%s", in_size, alpha);
return full_name;
}
void cInjectGenebank::AddInjectGenotype(cInjectGenotype * in_inject_genotype, int in_list_num)
{
assert( in_inject_genotype != 0 );
if ( in_list_num < 0 )
in_list_num = FindCRC(in_inject_genotype->GetGenome()) % INJECTGENOTYPE_HASH_SIZE;
active_inject_genotypes[in_list_num].Insert(*in_inject_genotype);
inject_genotype_control->Insert(*in_inject_genotype);
//stats.AddGenotype(in_inject_genotype->GetID());
}
cInjectGenotype * cInjectGenebank::AddInjectGenotype(const cGenome & in_genome,
cInjectGenotype * parent_genotype)
{
int list_num = FindCRC(in_genome) % INJECTGENOTYPE_HASH_SIZE;
cInjectGenotype * found_genotype;
found_genotype = active_inject_genotypes[list_num].Find(in_genome);
if (!found_genotype) {
found_genotype = new cInjectGenotype();
found_genotype->SetGenome(in_genome);
found_genotype->SetParent(parent_genotype);
AddInjectGenotype( found_genotype, list_num );
}
return found_genotype;
}
cInjectGenotype * cInjectGenebank::FindInjectGenotype(const cGenome & in_genome) const
{
int list_num = FindCRC(in_genome) % INJECTGENOTYPE_HASH_SIZE;
return active_inject_genotypes[list_num].Find(in_genome);
}
void cInjectGenebank::RemoveInjectGenotype(cInjectGenotype & in_inject_genotype)
{
// If this genotype is still active, mark it no longer active and
// take it out of the hash table so it doesn't have any new organisms
// assigned to it.
if (in_inject_genotype.GetActive() == true) {
int list_num = FindCRC(in_inject_genotype.GetGenome()) % INJECTGENOTYPE_HASH_SIZE;
active_inject_genotypes[list_num].Remove(in_inject_genotype);
inject_genotype_control->Remove(in_inject_genotype);
//in_inject_genotype.Deactivate(stats.GetUpdate());
if (cConfig::GetTrackMainLineage()) {
inject_genotype_control->InsertHistoric(in_inject_genotype);
}
}
// If we are tracking the main lineage, we only want to delete a
// genotype when all of its decendents have also died out.
/*if (cConfig::GetTrackMainLineage()) {
// If there are more offspring genotypes, hold off on deletion...
if (in_inject_genotype.GetNumOffspringGenotypes() != 0) return;
// If this is a dead end, delete it and recurse up...
cInjectGenotype * parent = in_inject_genotype.GetParentGenotype();
if (parent != NULL) {
parent->RemoveOffspringGenotype();
// Test to see if we need to update the coalescent genotype.
const int new_coal = inject_genotype_control->UpdateCoalescent();
stats.SetCoalescentGenotypeDepth(new_coal);
// cout << "Set coalescent to " << found_gen->GetDepth() << endl;
if (parent->GetNumInjected() == 0) {
// Regardless, run RemoveGenotype on the parent.
RemoveGenotype(*parent);
}
}
inject_genotype_control->RemoveHistoric(in_inject_genotype);
}
// Handle the relevent statistics...
stats.RemoveGenotype(in_inject_genotype.GetID(),
in_inject_genotype.GetParentID(), in_inject_genotype.GetParentDistance(),
in_inject_genotype.GetDepth(), in_inject_genotype.GetTotalOrganisms(),
in_inject_genotype.GetTotalParasites(),
stats.GetUpdate() - in_inject_genotype.GetUpdateBorn(),
in_inject_genotype.GetLength());
if (in_inject_genotype.GetThreshold()) {
stats.RemoveThreshold(in_inject_genotype.GetID());
}*/
delete &in_inject_genotype;
}
void cInjectGenebank::ThresholdInjectGenotype(cInjectGenotype & in_inject_genotype)
{
in_inject_genotype.SetName( GetLabel(in_inject_genotype.GetLength(),
inject_genotype_count[in_inject_genotype.GetLength()]++) );
in_inject_genotype.SetThreshold();
//stats.AddThreshold(in_inject_genotype.GetID(), in_inject_genotype.GetName()());
// Print the genotype?
if (cConfig::GetGenotypePrint()) {
cString filename;
filename.Set("genebank/%s", in_inject_genotype.GetName()());
//cTestUtil::PrintGenome(in_inject_genotype.GetGenome(), filename,
// &in_inject_genotype, stats.GetUpdate());
}
}
bool cInjectGenebank::AdjustInjectGenotype(cInjectGenotype & in_inject_genotype)
{
if (!inject_genotype_control->Adjust(in_inject_genotype)) return false;
if ((in_inject_genotype.GetNumInjected() >= cConfig::GetThreshold() ||
&in_inject_genotype == inject_genotype_control->GetBest()) &&
!(in_inject_genotype.GetThreshold())) {
ThresholdInjectGenotype(in_inject_genotype);
}
return true;
}
bool cInjectGenebank::SaveClone(ofstream & fp)
{
// This method just save the counts at each size-class of genotypes.
// The rest is reconstructable.
// Save the numbers of organisms we're up to at each size.
fp << MAX_CREATURE_SIZE << " ";
for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
fp << inject_genotype_count[i] << " ";
}
return true;
}
bool cInjectGenebank::LoadClone(ifstream & fp)
{
// This method just restores the counts at each size-class of genotypes.
// The rest of the loading process should be handled elsewhere.
// Load the numbers of organisms we're up to at each size.
int max_size;
fp >> max_size;
assert (max_size <= MAX_CREATURE_SIZE); // MAX_CREATURE_SIZE too small
for (int i = 0; i < max_size && i < MAX_CREATURE_SIZE; i++) {
fp >> inject_genotype_count[i];
}
return true;
}
bool cInjectGenebank::DumpTextSummary(ofstream & fp)
{
inject_genotype_control->Reset(0);
for (int i = 0; i < inject_genotype_control->GetSize(); i++) {
cInjectGenotype * genotype = inject_genotype_control->Get(0);
fp << genotype->GetGenome().AsString() << " "
<< genotype->GetNumInjected() << " "
<< genotype->GetID() << endl;
inject_genotype_control->Next(0);
}
return true;
}
bool cInjectGenebank::DumpDetailedSummary(const cString & file, int update)
{
inject_genotype_control->Reset(0);
for (int i = 0; i < inject_genotype_control->GetSize(); i++) {
DumpDetailedEntry(inject_genotype_control->Get(0), file, update);
inject_genotype_control->Next(0);
}
return true;
}
/*bool cInjectGenebank::DumpHistoricSummary(ofstream & fp)
{
inject_genotype_control->ResetHistoric(0);
for (int i = 0; i < inject_genotype_control->GetHistoricCount(); i++) {
DumpDetailedEntry(inject_genotype_control->Get(0), fp);
inject_genotype_control->Next(0);
}
return true;
}*/
void cInjectGenebank::DumpDetailedEntry(cInjectGenotype * genotype, const cString & filename, int update)
{
/*fp << genotype->GetID() << " " // 1
<< genotype->GetParentID() << " " // 2
// << genotype->GetParentDistance() << " " // 3
<< genotype->GetNumInjected() << " " // 4
<< genotype->GetTotalInjected() << " " // 5
<< genotype->GetLength() << " " // 6
// << genotype->GetMerit() << " " // 7
// << genotype->GetGestationTime() << " " // 8
// << genotype->GetFitness() << " " // 9
<< genotype->GetUpdateBorn() << " " // 10
<< genotype->GetUpdateDeactivated() << " " // 11
<< genotype->GetDepth() << " " // 12
<< genotype->GetGenome().AsString() << " " // 13
<< endl;*/
cDataFile & df = stats.GetDataFile(filename);
df.WriteComment( "Avida parasite dump data" );
df.WriteComment( "UPDATE " + update);
df.WriteTimeStamp();
//df.Write( update, "update");
df.Write( genotype->GetID(), "parasite genotype ID");
df.Write( genotype->GetName(), "parasite genotype name");
df.Write( genotype->GetParentID(), "parasite parent ID");
df.Write( genotype->GetNumInjected(), "current number of injected creatures with this genotype");
df.Write( genotype->GetTotalInjected(), "total number of injected creatures with this genotype");
df.Write( genotype->GetLength(), "genotype length");
df.Write( genotype->GetUpdateBorn(), "update this genotype was born");
df.Write( genotype->GetUpdateDeactivated(), "update this genotype was deactivated");
df.Write( genotype->GetDepth(), "genotype depth");
df.Write( genotype->GetGenome().AsString(), "genome of this genotype");
df.Endl();
}
bool cInjectGenebank::OK()
{
bool ret_value = true;
int i;
// Check components...
if (!inject_genotype_control->OK()) {
ret_value = false;
}
// Loop through all of the reference lists for matching genotypes...
for (i = 0; i < INJECTGENOTYPE_HASH_SIZE; i++) {
assert (active_inject_genotypes[i].OK());
}
assert (ret_value == true);
return ret_value;
}
int cInjectGenebank::CountNumCreatures()
{
int i;
int total = 0;
inject_genotype_control->Reset(0);
for (i = 0; i < inject_genotype_control->GetSize(); i++) {
total += inject_genotype_control->Get(0)->GetNumInjected();
inject_genotype_control->Next(0);
}
return total;
}
unsigned int cInjectGenebank::FindCRC(const cGenome & in_genome) const
{
unsigned int total = 13;
int i;
for (i = 0; i < in_genome.GetSize(); i++) {
total *= in_genome[i].GetOp() + 10 + i << 6;
total += 3;
}
return total;
}
Index: avida/current/source/main/inject_genebank.hh
+++ avida/current/source/main/inject_genebank.hh
//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1993 - 2003 California Institute of Technology //
// //
// Read the COPYING and README files, or contact 'avida at alife.org', //
// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
//////////////////////////////////////////////////////////////////////////////
#ifndef INJECT_GENEBANK_HH
#define INJECT_GENEBANK_HH
#include "../tools/string.hh"
#include "../defs.hh"
// porting to gcc 3.1 -- k
//class std::ofstream;
//class std::ifstream;
class cInjectGenebank;
class cInjectGenotype;
class cGenome;
class cSpecies;
class cStats;
#define INJECTGENOTYPE_HASH_SIZE 307 // @CAO Is this an optimal number?
#define SPECIES_HASH_SIZE 101
#define INJECTGENOTYPE_THREADS 2
#define SPECIES_RECORD_OFF 0
#define SPECIES_RECORD_FULL 1
#define SPECIES_RECORD_LIMITED 2
class cInjectGenotypeElement {
private:
cInjectGenotype * inject_genotype;
cInjectGenotypeElement * next;
cInjectGenotypeElement * prev;
public:
inline cInjectGenotypeElement(cInjectGenotype * in_gen=NULL) : inject_genotype(in_gen) {
next = NULL; prev = NULL;
}
inline ~cInjectGenotypeElement() { ; }
inline cInjectGenotype * GetInjectGenotype() const { return inject_genotype; }
inline cInjectGenotypeElement * GetNext() const { return next; }
inline cInjectGenotypeElement * GetPrev() const { return prev; }
inline void SetNext(cInjectGenotypeElement * in_next) { next = in_next; }
inline void SetPrev(cInjectGenotypeElement * in_prev) { prev = in_prev; }
};
class cInjectGenotypeQueue {
private:
int size;
cInjectGenotypeElement root;
void Remove(cInjectGenotypeElement * in_element);
public:
cInjectGenotypeQueue();
~cInjectGenotypeQueue();
bool OK();
void Insert(cInjectGenotype & in_inject_genotype);
void Remove(cInjectGenotype & in_inject_genotype);
cInjectGenotype * Find(const cGenome & in_genome) const;
};
class cInjectGenotypeControl {
private:
int size;
cInjectGenotype * best;
cInjectGenotype * coalescent;
cInjectGenotype * threads[INJECTGENOTYPE_THREADS];
cInjectGenebank & genebank;
cInjectGenotype * historic_list;
int historic_count;
void Insert(cInjectGenotype & in_inject_genotype, cInjectGenotype * prev_inject_genotype);
bool CheckPos(cInjectGenotype & in_inject_genotype);
public:
cInjectGenotypeControl(cInjectGenebank & in_gb);
~cInjectGenotypeControl();
bool OK();
void Remove(cInjectGenotype & in_inject_genotype);
void Insert(cInjectGenotype & new_inject_genotype);
bool Adjust(cInjectGenotype & in_inject_genotype);
void RemoveHistoric(cInjectGenotype & in_inject_genotype);
void InsertHistoric(cInjectGenotype & in_inject_genotype);
int GetHistoricCount() { return historic_count; }
int UpdateCoalescent();
inline int GetSize() const { return size; }
inline cInjectGenotype * GetBest() const { return best; }
inline cInjectGenotype * GetCoalescent() const { return coalescent; }
cInjectGenotype * Find(const cGenome & in_genome) const;
int FindPos(cInjectGenotype & in_inject_genotype, int max_depth = -1);
inline cInjectGenotype * Get(int thread) const { return threads[thread]; }
inline cInjectGenotype * Reset(int thread)
{ return threads[thread] = best; }
inline cInjectGenotype * ResetHistoric(int thread)
{ return threads[thread] = historic_list; }
cInjectGenotype * Next(int thread);
cInjectGenotype * Prev(int thread);
};
class cInjectGenebank {
private:
unsigned int inject_genotype_count[MAX_CREATURE_SIZE];
cInjectGenotypeQueue active_inject_genotypes[INJECTGENOTYPE_HASH_SIZE];
cInjectGenotypeControl * inject_genotype_control;
cStats & stats;
private:
cString GetLabel(int in_size, int in_num);
public:
cInjectGenebank(cStats & stats);
~cInjectGenebank();
void UpdateReset();
/**
* This function can be used to add a injectgenotype that was created
* outside the genebank. In this case, the parameter in_list_num
* should not be given. Normally, injectgenotypes are added through the
* function AddInjectGenotype(const cGenome & in_genome,
* cInjectGenotype * parent_injectgenotype = NULL), which then calls this one.
**/
void AddInjectGenotype(cInjectGenotype *in_inject_genotype, int in_list_num = -1 );
cInjectGenotype * AddInjectGenotype(const cGenome & in_genome,
cInjectGenotype * parent_inject_genotype = NULL);
cInjectGenotype * FindInjectGenotype(const cGenome & in_genome) const;
void RemoveInjectGenotype(cInjectGenotype & in_inject_genotype);
void ThresholdInjectGenotype(cInjectGenotype & in_inject_genotype);
bool AdjustInjectGenotype(cInjectGenotype & in_inject_genotype);
bool SaveClone(std::ofstream & fp);
bool LoadClone(std::ifstream & fp);
bool DumpTextSummary(std::ofstream & fp);
//bool DumpDetailedSummary(std::ofstream & fp);
bool DumpDetailedSummary(const cString & file, int update);
bool DumpHistoricSummary(std::ofstream & fp);
//void DumpDetailedEntry(cInjectGenotype * inject_genotype, std::ofstream & fp);
void DumpDetailedEntry(cInjectGenotype * inject_genotype, const cString & file, int update);
bool OK();
inline int GetSize() const { return inject_genotype_control->GetSize(); }
inline cInjectGenotype * GetBestInjectGenotype() const
{ return inject_genotype_control->GetBest(); }
inline cInjectGenotype * GetCoalescentInjectGenotype() const
{ return inject_genotype_control->GetCoalescent(); }
inline cInjectGenotype * GetInjectGenotype(int thread) const
{ return inject_genotype_control->Get(thread); }
inline cInjectGenotype * NextInjectGenotype(int thread) {
cInjectGenotype * next = inject_genotype_control->Next(thread);
return (next == inject_genotype_control->GetBest()) ? (cInjectGenotype*)NULL : next;
}
inline cInjectGenotype * ResetThread(int thread)
{ return inject_genotype_control->Reset(thread); }
int CountNumCreatures();
inline int FindPos(cInjectGenotype & in_inject_genotype, int max_depth = -1)
{ return inject_genotype_control->FindPos(in_inject_genotype, max_depth); }
unsigned int FindCRC(const cGenome & in_genome) const;
};
#endif
Index: avida/current/source/main/inject_genotype.cc
+++ avida/current/source/main/inject_genotype.cc
//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1993 - 2003 California Institute of Technology //
// //
// Read the COPYING and README files, or contact 'avida at alife.org', //
// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
//////////////////////////////////////////////////////////////////////////////
#include <fstream>
#include "inject_genotype.hh"
#include "../tools/tools.hh"
#include "../tools/merit.hh"
#include "stats.hh"
#include "config.hh"
#include "genome_util.hh"
#include "../cpu/hardware_method.hh"
#include "organism.hh"
#include "phenotype.hh"
#include "../cpu/test_cpu.hh"
using namespace std;
/////////////////////////
// cInjectGenotype_BirthData
/////////////////////////
cInjectGenotype_BirthData::cInjectGenotype_BirthData(int in_update_born)
: update_born(in_update_born)
, parent_id(-1)
, gene_depth(0)
, update_deactivated(-1)
, parent_genotype(NULL)
, num_offspring_genotypes(0)
{
}
cInjectGenotype_BirthData::~cInjectGenotype_BirthData()
{
}
///////////////////////////
// cInjectGenotype
///////////////////////////
cInjectGenotype::cInjectGenotype(int in_update_born, int in_id)
: genome(1)
, name("p001-no_name")
, flag_threshold(false)
, is_active(true)
, defer_adjust(0)
, symbol(0)
, birth_data(in_update_born)
, num_injected(0)
, last_num_injected(0)
, total_injected(0)
, next(NULL)
, prev(NULL)
{
static int next_id = 1;
if ( in_id >= 0 )
next_id = in_id;
id_num = next_id++;
}
cInjectGenotype::~cInjectGenotype()
{
// Reset some of the variables to make sure program will crash if a deleted
// cell is read!
symbol = '!';
num_injected = -1;
total_injected = -1;
next = NULL;
prev = NULL;
}
bool cInjectGenotype::SaveClone(ofstream & fp)
{
fp << id_num << " ";
fp << genome.GetSize() << " ";
for (int i = 0; i < genome.GetSize(); i++) {
fp << ((int) genome[i].GetOp()) << " ";
}
return true;
}
bool cInjectGenotype::LoadClone(ifstream & fp)
{
int genome_size = 0;
fp >> id_num;
fp >> genome_size;
genome = cGenome(genome_size);
for (int i = 0; i < genome_size; i++) {
cInstruction temp_inst;
int inst_op;
fp >> inst_op;
temp_inst.SetOp((UCHAR) inst_op);
genome[i] = temp_inst;
// @CAO add something here to load arguments for instructions.
}
return true;
}
bool cInjectGenotype::OK()
{
bool ret_value = true;
// Check the components...
if (!genome.OK()) ret_value = false;
// And the statistics
assert( id_num >= 0 && num_injected >= 0 && total_injected >= 0 );
assert( birth_data.update_born >= -1);
return ret_value;
};
void cInjectGenotype::SetParent(cInjectGenotype * parent)
{
birth_data.parent_genotype = parent;
// If we have a real parent genotype, collect other data about parent.
if (parent == NULL) return;
birth_data.parent_id = parent->GetID();
birth_data.gene_depth = parent->GetDepth() + 1;
parent->AddOffspringGenotype();
}
void cInjectGenotype::Mutate() // Check each location to be mutated.
{
int i;
for (i = 0; i < genome.GetSize(); i++) {
genome[i].SetOp(g_random.GetUInt(cConfig::GetNumInstructions()));
}
}
void cInjectGenotype::UpdateReset()
{
last_num_injected = num_injected;
birth_data.birth_track.Next();
birth_data.death_track.Next();
}
void cInjectGenotype::SetGenome(const cGenome & in_genome)
{
genome = in_genome;
name.Set("p%03d-no_name", genome.GetSize());
}
void cInjectGenotype::Deactivate(int update)
{
is_active = false;
birth_data.update_deactivated = update;
}
int cInjectGenotype::AddParasite()
{
total_injected++;
return num_injected++;
}
int cInjectGenotype::RemoveParasite()
{
//birth_data.death_track.Inc();
return num_injected--;
}
Index: avida/current/source/main/inject_genotype.hh
+++ avida/current/source/main/inject_genotype.hh
//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1993 - 2003 California Institute of Technology //
// //
// Read the COPYING and README files, or contact 'avida at alife.org', //
// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
//////////////////////////////////////////////////////////////////////////////
#ifndef INJECT_GENOTYPE_HH
#define INJECT_GENOTYPE_HH
#include "../tools/string.hh"
#include "../tools/stat.hh"
#include "genome.hh"
// porting to gcc 3.1 -- k
//class ofstream;
//class ifstream;
class cSpecies;
class cMerit;
class cInjectGenotype;
/*class cInjectGenotype_TestData {
public:
cGenotype_TestData();
~cGenotype_TestData();
bool is_viable;
double fitness;
double merit;
int gestation_time;
int executed_size;
int copied_size;
double colony_fitness;
int generations;
};*/
class cInjectGenotype_BirthData {
public:
cInjectGenotype_BirthData(int in_update_born);
~cInjectGenotype_BirthData();
cCountTracker birth_track;
cCountTracker death_track;
//cCountTracker breed_in_track;
//cCountTracker breed_true_track;
//cCountTracker breed_out_track;
int update_born; // Update genotype was first created
int parent_id; // ID of parent genotype
//int parent_distance; // Genetic distance from parent genotype
int gene_depth; // depth in the phylogenetic tree from ancestor
int update_deactivated; // If not, when did it get deactivated?
cInjectGenotype * parent_genotype; // Pointer to parent genotype...
//cSpecies * parent_species;
int num_offspring_genotypes; // Num offspring genotypes still in memory.
};
class cInjectGenotype {
private:
cGenome genome;
cString name;
bool flag_threshold;
bool is_active; // Is this genotype still alive?
int defer_adjust; // Don't adjust in the genebank until all are cleared.
int id_num;
char symbol;
//mutable cGenotype_TestData test_data;
cInjectGenotype_BirthData birth_data;
// Statistical info
int num_injected;
int last_num_injected;
int total_injected;
//int total_parasites;
//cSpecies * species;
// Data Structure stuff...
cInjectGenotype * next;
cInjectGenotype * prev;
////// Statistical info //////
// Collected on Divides
//cDoubleSum sum_copied_size;
//cDoubleSum sum_exe_size;
//cDoubleSum sum_gestation_time;
//cDoubleSum sum_repro_rate; // should make gestation obsolete (not new)
//cDoubleSum sum_merit;
//cDoubleSum sum_fitness;
// Temporary (Approx stats used before any divides done)
// Set in "SetParent"
//cDoubleSum tmp_sum_copied_size;
//cDoubleSum tmp_sum_exe_size;
//cDoubleSum tmp_sum_gestation_time;
//cDoubleSum tmp_sum_repro_rate;
//cDoubleSum tmp_sum_merit;
//cDoubleSum tmp_sum_fitness;
void CalcTestStats() const;
public:
/**
* Constructs an empty genotype. Normally, in_id should not specified as
* parameter, because cGenotype keeps track of the last id given out, and
* choses a new one based on that. However, in some cases it is necessary
* to specify an id (e.g., when loading a history file from disk). Note
* that in this case, cGenotype does not check if the id has already been
* used before.
**/
cInjectGenotype(int in_update_born = 0, int in_id = -1);
~cInjectGenotype();
bool SaveClone(std::ofstream & fp);
bool LoadClone(std::ifstream & fp);
bool OK();
void Mutate();
void UpdateReset();
void SetGenome(const cGenome & in_genome);
//void SetSpecies(cSpecies * in_species);
// Test CPU info -- only used with limited options on.
//bool GetTestViable() const;
//double GetTestFitness() const;
//double GetTestMerit() const;
//int GetTestGestationTime() const;
//int GetTestExecutedSize() const;
//int GetTestCopiedSize() const;
//double GetTestColonyFitness() const;
//int GetTestGenerations() const;
void SetParent(cInjectGenotype * parent);
void SetName(cString in_name) { name = in_name; }
void SetNext(cInjectGenotype * in_next) { next = in_next; }
void SetPrev(cInjectGenotype * in_prev) { prev = in_prev; }
void SetSymbol(char in_symbol) { symbol = in_symbol; }
inline void SetThreshold();
void IncDeferAdjust() { defer_adjust++; }
void DecDeferAdjust() { defer_adjust--; assert(defer_adjust >= 0); }
// Setting New Stats
//void AddCopiedSize (int in) { sum_copied_size.Add(in); }
//void AddExecutedSize (int in) { sum_exe_size.Add(in); }
//void AddGestationTime (int in) { sum_gestation_time.Add(in);
// sum_repro_rate.Add(1/(double)in); }
//void AddMerit (const cMerit & in);
//void RemoveMerit (const cMerit & in);
//void AddFitness (double in){
// assert(in >= 0.0);
// sum_fitness.Add(in);
//}
//void RemoveFitness (double in){
// assert(in >= 0.0);
// sum_fitness.Subtract(in);
//}
//// Properties Native to Genotype ////
cGenome & GetGenome() { return genome; }
const cGenome & GetGenome() const { return genome; }
int GetLength() const { return genome.GetSize(); }
//int GetBirths() const { return birth_data.birth_track.GetTotal(); }
//int GetBreedOut() const { return birth_data.breed_out_track.GetTotal(); }
//int GetBreedTrue() const { return birth_data.breed_true_track.GetTotal(); }
//int GetBreedIn() const { return birth_data.breed_in_track.GetTotal(); }
//int GetThisBirths() const { return birth_data.birth_track.GetCur(); }
//int GetThisBreedOut() const { return birth_data.breed_out_track.GetCur(); }
//int GetThisBreedTrue() const { return birth_data.breed_true_track.GetCur(); }
//int GetThisBreedIn() const { return birth_data.breed_in_track.GetCur(); }
//int GetThisDeaths() const { return birth_data.death_track.GetCur(); }
//int GetLastNumOrganisms() const { return last_num_organisms; }
//int GetLastBirths() const { return birth_data.birth_track.GetLast(); }
//int GetLastBreedOut() const { return birth_data.breed_out_track.GetLast(); }
//int GetLastBreedTrue() const { return birth_data.breed_true_track.GetLast();}
//int GetLastBreedIn() const { return birth_data.breed_in_track.GetLast(); }
//inline void SetBreedStats(cGenotype & daughter); // called by ActivateChild
//// Properties Averaged Over Creatues ////
//double GetCopiedSize() const { return (sum_copied_size.Count()>0) ?
// sum_copied_size.Average() : tmp_sum_copied_size.Average(); }
//double GetExecutedSize() const { return (sum_exe_size.Count()>0) ?
// sum_exe_size.Average() : tmp_sum_exe_size.Average(); }
//double GetGestationTime() const { return (sum_gestation_time.Count()>0) ?
// sum_gestation_time.Average() : tmp_sum_gestation_time.Average(); }
//double GetReproRate() const { return (sum_repro_rate.Count()>0) ?
// sum_repro_rate.Average() : tmp_sum_repro_rate.Average(); }
//double GetMerit() const { return (sum_merit.Count()>0) ?
// sum_merit.Average() : tmp_sum_merit.Average(); }
//double GetFitness() const { return (sum_fitness.Count()>0) ?
// sum_fitness.Average() : tmp_sum_fitness.Average(); }
// For tracking the genotype line back to the ancestor...
cInjectGenotype * GetParentGenotype() { return birth_data.parent_genotype; }
int GetNumOffspringGenotypes() const
{ return birth_data.num_offspring_genotypes; }
void AddOffspringGenotype() { birth_data.num_offspring_genotypes++; }
void RemoveOffspringGenotype() { birth_data.num_offspring_genotypes--; }
bool GetActive() const { return is_active; }
// bool GetDeferAdjust() const { return defer_adjust > 0; }
int GetUpdateDeactivated() { return birth_data.update_deactivated; }
void Deactivate(int update);
int GetUpdateBorn() { return birth_data.update_born; }
int GetParentID() { return birth_data.parent_id; }
//int GetParentDistance() { return birth_data.parent_distance; }
int GetDepth() { return birth_data.gene_depth; }
cString & GetName() { return name; }
cInjectGenotype * GetNext() { return next; }
cInjectGenotype * GetPrev() { return prev; }
bool GetThreshold() const { return flag_threshold; }
int GetID() const { return id_num; }
char GetSymbol() const { return symbol; }
int AddParasite();
int RemoveParasite();
//int AddParasite() { return ++total_parasites; }
//void SwapOrganism() { total_organisms++; }
int GetNumInjected() { return num_injected; }
int GetTotalInjected() { return total_injected; }
//int GetTotalParasites() { return total_parasites; }
};
// The genotype pointer template...
// All the inline stuff...
////////////////
// cGenotype //
////////////////
inline void cInjectGenotype::SetThreshold()
{
flag_threshold = true;
if (symbol == '.') symbol = '+';
}
/*
inline void cGenotype::SetBreedStats(cGenotype & daughter)
{
birth_data.birth_track.Inc();
if (daughter.id_num == id_num) {
birth_data.breed_true_track.Inc();
} else {
birth_data.breed_out_track.Inc();
daughter.birth_data.breed_in_track.Inc();
}
}*/
#endif
Index: avida/current/source/main/primitive.pch
+++ avida/current/source/main/primitive.pch
Index: avida/current/source/main/primitive.pdb
+++ avida/current/source/main/primitive.pdb
Index: avida/current/source/qt-viewer/qt-viewer.pch
+++ avida/current/source/qt-viewer/qt-viewer.pch
Index: avida/current/source/qt-viewer/qt-viewer.pdb
+++ avida/current/source/qt-viewer/qt-viewer.pdb
Index: avida/current/source/support/genesis.4stack
+++ avida/current/source/support/genesis.4stack
#############################################################################
# This file includes all the basic run-time defines for avida.
# For more information, see doc/genesis.html
#############################################################################
VERSION_ID 2.0b1 # Do not change this value!
### Architecture Variables ###
MAX_UPDATES -1 # Maximum updates to run simulation (-1 = no limit)
MAX_GENERATIONS -1 # Maximum generations to run simulation (-1 = no limit)
END_CONDITION_MODE 0 # End run when ...
# 0 = MAX_UPDATES _OR_ MAX_GENERATIONS is reached
# 1 = MAX_UPDATES _AND_ MAX_GENERATIONS is reached
WORLD-X 60 # Width of the world in Avida mode.
WORLD-Y 60 # Height of the world in Avida mode.
RANDOM_SEED 0 # Random number seed. (0 for based on time)
HARDWARE_TYPE 1 # 0 = Original CPUs
# 1 = New, Stack-based CPUs
MAX_CPU_THREADS 1 # Number of Threads CPUs can spawn
### Configuration Files ###
DEFAULT_DIR ../work/ # Directory in which config files are found
INST_SET inst_set.4stack # File containing instruction set
EVENT_FILE events.cfg # File containing list of events during run
ANALYZE_FILE analyze.cfg # File used for analysis mode
ENVIRONMENT_FILE environment.cfg # File that describes the environment
START_CREATURE organism.4stack # Organism to seed the soup
### Reproduction ###
BIRTH_METHOD 4 # 0 = Replace random organism in neighborhood
# 1 = Replace oldest organism in neighborhood
# 2 = Replace largest Age/Merit in neighborhood
# 3 = Place only in empty cells in neighborhood
# 4 = Replace random from entire population (Mass Action)
# 5 = Replace oldest in entire population (like Tierra)
DEATH_METHOD 0 # 0 = Never die of old age.
# 1 = Die when inst executed = AGE_LIMIT (with deviation)
# 2 = Die when inst executed = length * AGE_LIMIT (+ dev.)
AGE_LIMIT 5000 # Modifies DEATH_METHOD
AGE_DEVIATION 0 # Modified DEATH_METHOD
ALLOC_METHOD 0 # 0 = Allocated space is set to default instruction.
# 1 = Set to section of dead genome (Necrophilia)
# 2 = Allocated space is set to random instruction.
DIVIDE_METHOD 2 # 0 = Divide leaves state of mother untouched.
# 1 = Divide resets state of mother
# (after the divide, we have 2 children)
# 2 = Divide resets only the current thread of the mother
# (useful in 4-stack CPU w/ parasites)
GENERATION_INC_METHOD 0 # 0 = Only the generation of the child is
# increased on divide.
# 1 = Both the generation of the mother and child are
# increased on divide (good with DIVIDE_METHOD 1).
### Divide Restrictions ####
CHILD_SIZE_RANGE 2.0 # Maximal differential between child and parent sizes.
MIN_COPIED_LINES 0.5 # Code fraction which must be copied before divide.
MIN_EXE_LINES 0.5 # Code fraction which must be executed before divide.
REQUIRE_ALLOCATE 1 # Is a an allocate required before a divide? (0/1)
REQUIRED_TASK -1 # Number of task required for successful divide.
### Mutations ###
# mutations that occur during execution..
POINT_MUT_PROB 0.0 # Mutation rate (per-location per update)
COPY_MUT_PROB 0.0075 # Mutation rate (per copy).
# mutations that occur on divide...
INS_MUT_PROB 0.0 # Insertion rate (per site, applied on divide).
DEL_MUT_PROB 0.0 # Deletion rate (per site, applied on divide).
DIV_MUT_PROB 0.0 # Mutation rate (per site, applied on divide).
DIVIDE_MUT_PROB 0.0 # Mutation rate (per divide).
DIVIDE_INS_PROB 0.05 # Insertion rate (per divide).
DIVIDE_DEL_PROB 0.05 # Deletion rate (per divide).
PARENT_MUT_PROB 0.0 # Per-site, in parent, on divide
# heads based mutations
# READ_SHIFT_PROB 0.0
# READ INS_PROB 0.0
# READ_DEL_PROB 0.0
# WRITE_SHIFT_PROB 0.0
# WRITE_INS_PROB 0.0
# WRITE_DEL_PROB 0.0
### Mutation reversions ###
# these slow down avida a lot, and should be set to 0 normally.
REVERT_FATAL 0.0 # Should any mutations be reverted on birth?
REVERT_DETRIMENTAL 0.0 # 0.0 to 1.0; Probability of reversion.
REVERT_NEUTRAL 0.0
REVERT_BENEFICIAL 0.0
STERILIZE_FATAL 0.0 # Should any mutations clear (kill) the organism?
STERILIZE_DETRIMENTAL 0.0 # 0.0 to 1.0; Probability of reset.
STERILIZE_NEUTRAL 0.0
STERILIZE_BENEFICIAL 0.0
FAIL_IMPLICIT 0 # Should copies that failed *not* due to mutations
# be eliminated?
### Time Slicing ###
AVE_TIME_SLICE 30
SLICING_METHOD 2 # 0 = CONSTANT: all organisms get default...
# 1 = PROBABILISTIC: Run _prob_ proportional to merit.
# 2 = INTEGRATED: Perfectly integrated deterministic.
SIZE_MERIT_METHOD 4 # 0 = off (merit is independent of size)
# 1 = Merit proportional to copied size
# 2 = Merit prop. to executed size
# 3 = Merit prop. to full size
# 4 = Merit prop. to min of executed or copied size
# 5 = Merit prop. to sqrt of the minimum size
TASK_MERIT_METHOD 1 # 0 = No task bonuses
# 1 = Bonus just equals the task bonus
THREAD_SLICING_METHOD 1 # 0 = One thread executed per time slice.
# 1 = All threads executed each time slice.
# Formula for an organism's thread slicing:
# 1 + (num_organism_threads-1) * THREAD_SLICING_METHOD
MAX_LABEL_EXE_SIZE 1 # Max nops marked as executed when labels are used
MERIT_TIME 1 # 0 = Merit Calculated when task completed
# 1 = Merit Calculated on Divide
MAX_NUM_TASKS_REWARDED -1 # -1 = Unlimited
### Genotype Info ###
THRESHOLD 3 # Number of organisms in a genotype needed for it
# to be considered viable.
GENOTYPE_PRINT 0 # 0/1 (off/on) Print out all threshold genotypes?
GENOTYPE_PRINT_DOM 0 # Print out a genotype if it stays dominant for
# this many updates. (0 = off)
SPECIES_THRESHOLD 2 # max failure count for organisms to be same species
SPECIES_RECORDING 0 # 1 = full, 2 = limited search (parent only)
SPECIES_PRINT 0 # 0/1 (off/on) Print out all species?
TEST_CPU_TIME_MOD 20 # Time allocated in test CPUs (multiple of length)
TRACK_MAIN_LINEAGE 1 # Track primary lineage leading to final population?
### Log Files ###
LOG_CREATURES 0 # 0/1 (off/on) toggle to print file.
LOG_GENOTYPES 0 # 0 = off, 1 = print ALL, 2 = print threshold ONLY.
LOG_THRESHOLD 0 # 0/1 (off/on) toggle to print file.
LOG_SPECIES 0 # 0/1 (off/on) toggle to print file.
LOG_LANDSCAPE 0 # 0/1 (off/on) toggle to print file.
LOG_LINEAGES 0 # 0/1 (off/on) to log advantageous mutations
# This one can slow down avida a lot. It is used to get an idea of how
# often an advantageous mutation arises, and where it goes afterwards.
# See also LINEAGE_CREATION_METHOD.
LINEAGE_CREATION_METHOD 0
# Lineage creation options are. Works only when LOG_LINEAGES is set to 1.
# 0 = manual creation (on inject, use successive integers as lineage labels).
# 1 = when a child's (potential) fitness is higher than that of its parent.
# 2 = when a child's (potential) fitness is higher than max in population.
# 3 = when a child's (potential) fitness is higher than max in dom. lineage
# *and* the child is in the dominant lineage, or (2)
# 4 = when a child's (potential) fitness is higher than max in dom. lineage
# (and that of its own lineage)
# 5 = same as child's (potential) fitness is higher than that of the
# currently dominant organism, and also than that of any organism
# currently in the same lineage.
# 6 = when a child's (potential) fitness is higher than any organism
# currently in the same lineage.
# 7 = when a child's (potential) fitness is higher than that of any
# organism in its line of descent
### END ###
Index: avida/current/source/support/inst_set.4stack
+++ avida/current/source/support/inst_set.4stack
Nop-A 1 #1 (a)
Nop-B 1 #2 (b)
Nop-C 1 #3 (c)
Nop-D 1 #4 (d)
#Nop-X 1 #
Val-Shift-R 1 #5 (e)
Val-Shift-L 1 #6 (f)
Val-Nand 1 #7 (g)
Val-Add 1 #8 (h)
Val-Sub 1 #9 (i)
Val-Mult 1 #10 (j)
Val-Div 1 #11 (k)
SetMemory 1 #12 (l)
Divide 1 #13 (m)
Inst-Read 1 #14 (n)
Inst-Write 1 #15 (o)
#Inst-Copy 1 ()
If-Equal 1 #16 (p)
If-Not-Equal 1 #17 (q)
If-Less 1 #18 (r)
If-Greater 1 #19 (s)
Head-Push 1 #20 (t)
Head-Pop 1 #21 (u)
Head-Move 1 #22 (v)
Search 1 #23 (w)
Push-Next 1 #24 (x)
Push-Prev 1 #25 (y)
Push-Comp 1 #26 (z)
Val-Delete 1 #27 (A)
Val-Copy 1 #28 (B)
#ThreadFork 1 #29 ()
#if-label 1 ()
Val-Inc 1 #30 (C)
Val-Dec 1 #31 (D)
Val-Mod 1 #32 (E)
#ThreadKill 1 #33 ()
IO 1 #34 (F)
Inject 1 #35 (G)
Index: avida/current/source/support/preset_organisms/organism.4stack
+++ avida/current/source/support/preset_organisms/organism.4stack
# SAMPLE ORGANISM:
#
Search # 1: Find organism end.
Nop-C # 2: - Match CD:AB
Nop-D
#ThreadFork # 3:
#Nop-D # 4:
Push-Prev # 5: Move end position to Stack-A
SetMemory # 6: Place FLOW-head in memory space for offspring
Head-Move # 7: Move Write head to flow head position
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
Search # 9: Drop flow head at start of copy loop
Inst-Read # 10:
Inst-Write # 11:
Head-Push # 12: Get current position of...
Nop-C # 13: - Read-Head
If-Equal # 14: Test if we are done copying...
Divide # 15: ...If so, divide.
Head-Move # 16: ...If not, continue with loop.
Nop-A # 17:
Nop-B
Index: avida/current/source/support/preset_organisms/organism.parasite
+++ avida/current/source/support/preset_organisms/organism.parasite
Search # 1: Find organism end.
Nop-D # 2: - Match A:A
Push-Prev # 5: Move end position to Stack-A
SetMemory # 6: Place FLOW-head in memory space for offspring
Head-Move # 7: Move Write head to flow head position
Nop-C # 8:
Search # 9: Drop flow head at start of copy loop
Inst-Read # 10:
Inst-Write # 11:
Head-Push # 12: Get current position of...
Nop-C # 13: - Read-Head
If-Equal # 14: Test if we are done copying...
Inject # 15: ...If so, inject.
Head-Move # 16: ...If not, continue with loop.
Nop-A # 17:
Nop-B # 18:
More information about the Avida-cvs
mailing list