[Avida-cvs] [avida-svn] r775 - in development: source/cpu source/main support/config
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Sun Jun 25 15:30:42 PDT 2006
Author: brysonda
Date: 2006-06-25 18:30:42 -0400 (Sun, 25 Jun 2006)
New Revision: 775
Modified:
development/source/cpu/cHardwareSMT.cc
development/source/main/cAvidaConfig.h
development/source/main/cEnvironment.h
development/source/main/cMutationRates.cc
development/source/main/cMutationRates.h
development/source/main/cOrganism.h
development/source/main/cPopulation.cc
development/source/main/cPopulationCell.cc
development/support/config/avida-smt.cfg
development/support/config/avida.cfg
Log:
Add inject specific mutations. These are all per-site, applied on inject. Also, as with all current parasite work, this is only honored by SMT.
Modified: development/source/cpu/cHardwareSMT.cc
===================================================================
--- development/source/cpu/cHardwareSMT.cc 2006-06-23 22:31:24 UTC (rev 774)
+++ development/source/cpu/cHardwareSMT.cc 2006-06-25 22:30:42 UTC (rev 775)
@@ -939,32 +939,14 @@
return copied_size;
}
-void cHardwareSMT::Inject_DoMutations(cAvidaContext& ctx, double mut_multiplier, cCPUMemory & injected_code)
+void cHardwareSMT::Inject_DoMutations(cAvidaContext& ctx, double mut_multiplier, cCPUMemory& injected_code)
{
organism->GetPhenotype().SetDivType(mut_multiplier);
- // Divide Mutations
- if (organism->TestDivideMut(ctx)) {
- const unsigned int mut_line = ctx.GetRandom().GetUInt(injected_code.GetSize());
- injected_code[mut_line] = m_inst_set->GetRandomInst(ctx);
- }
-
- // Divide Insertions
- if (organism->TestDivideIns(ctx) && injected_code.GetSize() < MAX_CREATURE_SIZE){
- const unsigned int mut_line = ctx.GetRandom().GetUInt(injected_code.GetSize() + 1);
- injected_code.Insert(mut_line, m_inst_set->GetRandomInst(ctx));
- }
-
- // Divide Deletions
- if (organism->TestDivideDel(ctx) && injected_code.GetSize() > MIN_CREATURE_SIZE){
- const unsigned int mut_line = ctx.GetRandom().GetUInt(injected_code.GetSize());
- injected_code.Remove(mut_line);
- }
-
// Divide Mutations (per site)
if(organism->GetDivMutProb() > 0){
int num_mut = ctx.GetRandom().GetRandBinomial(injected_code.GetSize(),
- organism->GetDivMutProb() / mut_multiplier);
+ organism->GetInjectMutProb() / mut_multiplier);
// If we have lines to mutate...
if( num_mut > 0 ){
for (int i = 0; i < num_mut; i++) {
@@ -978,7 +960,7 @@
// Insert Mutations (per site)
if(organism->GetInsMutProb() > 0){
int num_mut = ctx.GetRandom().GetRandBinomial(injected_code.GetSize(),
- organism->GetInsMutProb());
+ organism->GetInjectInsProb());
// If would make creature to big, insert up to MAX_CREATURE_SIZE
if( num_mut + injected_code.GetSize() > MAX_CREATURE_SIZE ){
num_mut = MAX_CREATURE_SIZE - injected_code.GetSize();
@@ -1003,7 +985,7 @@
// Delete Mutations (per site)
if( organism->GetDelMutProb() > 0 ){
int num_mut = ctx.GetRandom().GetRandBinomial(injected_code.GetSize(),
- organism->GetDelMutProb());
+ organism->GetInjectDelProb());
// If would make creature too small, delete down to MIN_CREATURE_SIZE
if (injected_code.GetSize() - num_mut < MIN_CREATURE_SIZE) {
num_mut = injected_code.GetSize() - MIN_CREATURE_SIZE;
Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h 2006-06-23 22:31:24 UTC (rev 774)
+++ development/source/main/cAvidaConfig.h 2006-06-25 22:30:42 UTC (rev 775)
@@ -215,6 +215,9 @@
CONFIG_ADD_VAR(DIVIDE_DEL_PROB, double, 0.05, "Deletion rate (per divide)");
CONFIG_ADD_VAR(PARENT_MUT_PROB, double, 0.0, "Per-site, in parent, on divide");
CONFIG_ADD_VAR(SPECIAL_MUT_LINE, int, -1, "If this is >= 0, ONLY this line is mutated");
+ CONFIG_ADD_VAR(INJECT_INS_PROB, double, 0.0, "Insertion rate (per site, applied on inject)");
+ CONFIG_ADD_VAR(INJECT_DEL_PROB, double, 0.0, "Deletion rate (per site, applied on inject)");
+ CONFIG_ADD_VAR(INJECT_MUT_PROB, double, 0.0, "Mutation rate (per site, applied on inject)");
CONFIG_ADD_GROUP(REVERSION_GROUP, "Mutation Reversion\nThese slow down avida a lot, and should be set to 0.0 normally.");
CONFIG_ADD_VAR(REVERT_FATAL, double, 0.0, "Should any mutations be reverted on birth?");
Modified: development/source/main/cEnvironment.h
===================================================================
--- development/source/main/cEnvironment.h 2006-06-23 22:31:24 UTC (rev 774)
+++ development/source/main/cEnvironment.h 2006-06-25 22:30:42 UTC (rev 775)
@@ -81,7 +81,7 @@
cEnvironment& operator=(const cEnvironment&); // @not_implemented
public:
- cEnvironment(cWorld* world) : m_world(world), inst_set(world) { ; }
+ cEnvironment(cWorld* world) : m_world(world), inst_set(world) { mut_rates.Setup(world); }
~cEnvironment() { ; }
/**
Modified: development/source/main/cMutationRates.cc
===================================================================
--- development/source/main/cMutationRates.cc 2006-06-23 22:31:24 UTC (rev 774)
+++ development/source/main/cMutationRates.cc 2006-06-25 22:30:42 UTC (rev 775)
@@ -10,33 +10,54 @@
#include "cMutationRates.h"
+#include "cWorld.h"
+#include "cAvidaConfig.h"
+
+void cMutationRates::Setup(cWorld* world)
+{
+ exec.point_mut_prob = world->GetConfig().POINT_MUT_PROB.Get();
+ copy.mut_prob = world->GetConfig().COPY_MUT_PROB.Get();
+ divide.ins_prob = world->GetConfig().INS_MUT_PROB.Get();
+ divide.del_prob = world->GetConfig().DEL_MUT_PROB.Get();
+ divide.mut_prob = world->GetConfig().DIV_MUT_PROB.Get();
+ divide.divide_mut_prob = world->GetConfig().DIVIDE_MUT_PROB.Get();
+ divide.divide_ins_prob = world->GetConfig().DIVIDE_INS_PROB.Get();
+ divide.divide_del_prob = world->GetConfig().DIVIDE_DEL_PROB.Get();
+ divide.parent_mut_prob = world->GetConfig().PARENT_MUT_PROB.Get();
+ inject.ins_prob = world->GetConfig().INJECT_INS_PROB.Get();
+ inject.del_prob = world->GetConfig().INJECT_DEL_PROB.Get();
+ inject.mut_prob = world->GetConfig().INJECT_MUT_PROB.Get();
+}
+
void cMutationRates::Clear()
{
exec.point_mut_prob = 0.0;
- copy.copy_mut_prob = 0.0;
- divide.ins_mut_prob = 0.0;
- divide.del_mut_prob = 0.0;
- divide.div_mut_prob = 0.0;
+ copy.mut_prob = 0.0;
+ divide.ins_prob = 0.0;
+ divide.del_prob = 0.0;
+ divide.mut_prob = 0.0;
divide.divide_mut_prob = 0.0;
divide.divide_ins_prob = 0.0;
divide.divide_del_prob = 0.0;
divide.parent_mut_prob = 0.0;
- divide.crossover_prob = 0.0;
- divide.aligned_cross_prob = 0.0;
+ inject.ins_prob = 0.0;
+ inject.del_prob = 0.0;
+ inject.mut_prob = 0.0;
}
-void cMutationRates::Copy(const cMutationRates & in_muts)
+void cMutationRates::Copy(const cMutationRates& in_muts)
{
exec.point_mut_prob = in_muts.exec.point_mut_prob;
- copy.copy_mut_prob = in_muts.copy.copy_mut_prob;
- divide.ins_mut_prob = in_muts.divide.ins_mut_prob;
- divide.del_mut_prob = in_muts.divide.del_mut_prob;
- divide.div_mut_prob = in_muts.divide.div_mut_prob;
+ copy.mut_prob = in_muts.copy.mut_prob;
+ divide.ins_prob = in_muts.divide.ins_prob;
+ divide.del_prob = in_muts.divide.del_prob;
+ divide.mut_prob = in_muts.divide.mut_prob;
divide.divide_mut_prob = in_muts.divide.divide_mut_prob;
divide.divide_ins_prob = in_muts.divide.divide_ins_prob;
divide.divide_del_prob = in_muts.divide.divide_del_prob;
divide.parent_mut_prob = in_muts.divide.parent_mut_prob;
- divide.crossover_prob = in_muts.divide.crossover_prob;
- divide.aligned_cross_prob = in_muts.divide.aligned_cross_prob;
+ inject.ins_prob = in_muts.inject.ins_prob;
+ inject.del_prob = in_muts.inject.del_prob;
+ inject.mut_prob = in_muts.inject.mut_prob;
}
Modified: development/source/main/cMutationRates.h
===================================================================
--- development/source/main/cMutationRates.h 2006-06-23 22:31:24 UTC (rev 774)
+++ development/source/main/cMutationRates.h 2006-06-25 22:30:42 UTC (rev 775)
@@ -18,6 +18,7 @@
#include "cRandom.h"
#endif
+class cWorld;
class cMutationRates
{
@@ -32,25 +33,31 @@
// ...during an instruction copy...
struct sCopyMuts {
- double copy_mut_prob;
+ double mut_prob;
};
sCopyMuts copy;
// ...at the divide...
struct sDivideMuts {
- double ins_mut_prob; // Per site
- double del_mut_prob; // Per site
- double div_mut_prob; // Per site
+ double ins_prob; // Per site
+ double del_prob; // Per site
+ double mut_prob; // Per site
double divide_mut_prob; // Max one per divide
double divide_ins_prob; // Max one per divide
double divide_del_prob; // Max one per divide
- double crossover_prob;
- double aligned_cross_prob;
double parent_mut_prob;
};
sDivideMuts divide;
+ // ...at inject...
+ struct sInjectMuts {
+ double ins_prob; // Per site
+ double del_prob; // Per site
+ double mut_prob; // Per site
+ };
+ sInjectMuts inject;
+
cMutationRates& operator=(const cMutationRates&); // @not_implemented
public:
@@ -58,41 +65,42 @@
cMutationRates(const cMutationRates& in_muts) { Copy(in_muts); }
~cMutationRates() { ; }
+ void Setup(cWorld* world);
void Clear();
- void Copy(const cMutationRates & in_muts);
+ void Copy(const cMutationRates& in_muts);
bool TestPointMut(cAvidaContext& ctx) const { return ctx.GetRandom().P(exec.point_mut_prob); }
- bool TestCopyMut(cAvidaContext& ctx) const { return ctx.GetRandom().P(copy.copy_mut_prob); }
+ bool TestCopyMut(cAvidaContext& ctx) const { return ctx.GetRandom().P(copy.mut_prob); }
bool TestDivideMut(cAvidaContext& ctx) const { return ctx.GetRandom().P(divide.divide_mut_prob); }
bool TestDivideIns(cAvidaContext& ctx) const { return ctx.GetRandom().P(divide.divide_ins_prob); }
bool TestDivideDel(cAvidaContext& ctx) const { return ctx.GetRandom().P(divide.divide_del_prob); }
bool TestParentMut(cAvidaContext& ctx) const { return ctx.GetRandom().P(divide.parent_mut_prob); }
- bool TestCrossover(cAvidaContext& ctx) const { return ctx.GetRandom().P(divide.crossover_prob); }
- bool TestAlignedCrossover(cAvidaContext& ctx) const { return ctx.GetRandom().P(divide.aligned_cross_prob); }
double GetPointMutProb() const { return exec.point_mut_prob; }
- double GetCopyMutProb() const { return copy.copy_mut_prob; }
- double GetInsMutProb() const { return divide.ins_mut_prob; }
- double GetDelMutProb() const { return divide.del_mut_prob; }
- double GetDivMutProb() const { return divide.div_mut_prob; }
+ double GetCopyMutProb() const { return copy.mut_prob; }
+ double GetInsMutProb() const { return divide.ins_prob; }
+ double GetDelMutProb() const { return divide.del_prob; }
+ double GetDivMutProb() const { return divide.mut_prob; }
double GetDivideMutProb() const { return divide.divide_mut_prob; }
double GetDivideInsProb() const { return divide.divide_ins_prob; }
double GetDivideDelProb() const { return divide.divide_del_prob; }
double GetParentMutProb() const { return divide.parent_mut_prob; }
- double GetCrossoverProb() const { return divide.crossover_prob; }
- double GetAlignedCrossProb() const { return divide.aligned_cross_prob; }
-
- void SetPointMutProb(double in_prob) { exec.point_mut_prob = in_prob; }
- void SetCopyMutProb(double in_prob) { copy.copy_mut_prob = in_prob; }
- void SetInsMutProb(double in_prob) { divide.ins_mut_prob = in_prob; }
- void SetDelMutProb(double in_prob) { divide.del_mut_prob = in_prob; }
- void SetDivMutProb(double in_prob) { divide.div_mut_prob = in_prob; }
+ double GetInjectInsProb() const { return inject.ins_prob; }
+ double GetInjectDelProb() const { return inject.del_prob; }
+ double GetInjectMutProb() const { return inject.mut_prob; }
+
+ void SetPointMutProb(double in_prob) { exec.point_mut_prob = in_prob; }
+ void SetCopyMutProb(double in_prob) { copy.mut_prob = in_prob; }
+ void SetInsMutProb(double in_prob) { divide.ins_prob = in_prob; }
+ void SetDelMutProb(double in_prob) { divide.del_prob = in_prob; }
+ void SetDivMutProb(double in_prob) { divide.mut_prob = in_prob; }
void SetDivideMutProb(double in_prob) { divide.divide_mut_prob = in_prob; }
void SetDivideInsProb(double in_prob) { divide.divide_ins_prob = in_prob; }
void SetDivideDelProb(double in_prob) { divide.divide_del_prob = in_prob; }
void SetParentMutProb(double in_prob) { divide.parent_mut_prob = in_prob; }
- void SetCrossoverProb(double in_prob) { divide.crossover_prob = in_prob; }
- void SetAlignedCrossProb(double in) { divide.aligned_cross_prob = in; }
+ void SetInjectInsProb(double in_prob) { inject.ins_prob = in_prob; }
+ void SetInjectDelProb(double in_prob) { inject.del_prob = in_prob; }
+ void SetInjectMutProb(double in_prob) { inject.mut_prob = in_prob; }
};
Modified: development/source/main/cOrganism.h
===================================================================
--- development/source/main/cOrganism.h 2006-06-23 22:31:24 UTC (rev 774)
+++ development/source/main/cOrganism.h 2006-06-25 22:30:42 UTC (rev 775)
@@ -190,8 +190,6 @@
bool TestDivideIns(cAvidaContext& ctx) const { return MutationRates().TestDivideIns(ctx); }
bool TestDivideDel(cAvidaContext& ctx) const { return MutationRates().TestDivideDel(ctx); }
bool TestParentMut(cAvidaContext& ctx) const { return MutationRates().TestParentMut(ctx); }
- bool TestCrossover(cAvidaContext& ctx) const { return MutationRates().TestCrossover(ctx); }
- bool TestAlignedCrossover(cAvidaContext& ctx) const { return MutationRates().TestAlignedCrossover(ctx); }
double GetCopyMutProb() const { return MutationRates().GetCopyMutProb(); }
void SetCopyMutProb(double _p) { return MutationRates().SetCopyMutProb(_p); }
@@ -202,6 +200,10 @@
double GetDivMutProb() const { return MutationRates().GetDivMutProb(); }
double GetParentMutProb() const { return MutationRates().GetParentMutProb();}
+ double GetInjectInsProb() const { return MutationRates().GetInjectInsProb(); }
+ double GetInjectDelProb() const { return MutationRates().GetInjectDelProb(); }
+ double GetInjectMutProb() const { return MutationRates().GetInjectMutProb(); }
+
bool GetTestOnDivide() const;
bool GetFailImplicit() const;
@@ -229,10 +231,10 @@
void SetGenotype(cGenotype * in_genotype) { genotype = in_genotype; }
cGenotype * GetGenotype() const { return genotype; }
- const cMutationRates & MutationRates() const { return mut_rates; }
- cMutationRates & MutationRates() { return mut_rates; }
- const cLocalMutations & GetLocalMutations() const { return mut_info; }
- cLocalMutations & GetLocalMutations() { return mut_info; }
+ const cMutationRates& MutationRates() const { return mut_rates; }
+ cMutationRates& MutationRates() { return mut_rates; }
+ const cLocalMutations& GetLocalMutations() const { return mut_info; }
+ cLocalMutations& GetLocalMutations() { return mut_info; }
const cOrgInterface& GetOrgInterface() const { assert(m_interface); return *m_interface; }
cOrgInterface& GetOrgInterface() { assert(m_interface); return *m_interface; }
Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc 2006-06-23 22:31:24 UTC (rev 774)
+++ development/source/main/cPopulation.cc 2006-06-25 22:30:42 UTC (rev 775)
@@ -57,18 +57,6 @@
, num_organisms(0)
, sync_events(false)
{
- // Setup the default mutation rates...
- cMutationRates& default_mut_rates = environment.GetMutRates();
- default_mut_rates.SetCopyMutProb ( world->GetConfig().COPY_MUT_PROB.Get() );
- default_mut_rates.SetInsMutProb ( world->GetConfig().INS_MUT_PROB.Get() );
- default_mut_rates.SetDelMutProb ( world->GetConfig().DEL_MUT_PROB.Get() );
- default_mut_rates.SetDivMutProb ( world->GetConfig().DIV_MUT_PROB.Get() );
- default_mut_rates.SetPointMutProb ( world->GetConfig().POINT_MUT_PROB.Get() );
- default_mut_rates.SetDivideMutProb( world->GetConfig().DIVIDE_MUT_PROB.Get() );
- default_mut_rates.SetDivideInsProb( world->GetConfig().DIVIDE_INS_PROB.Get() );
- default_mut_rates.SetDivideDelProb( world->GetConfig().DIVIDE_DEL_PROB.Get() );
- default_mut_rates.SetParentMutProb( world->GetConfig().PARENT_MUT_PROB.Get() );
-
// Avida specific information.
world_x = world->GetConfig().WORLD_X.Get();
world_y = world->GetConfig().WORLD_Y.Get();
@@ -95,7 +83,7 @@
for (int cell_id = 0; cell_id < num_cells; cell_id++) {
int x = cell_id % world_x;
int y = cell_id / world_x;
- cell_array[cell_id].Setup(world, cell_id, default_mut_rates);
+ cell_array[cell_id].Setup(world, cell_id, environment.GetMutRates());
if ((y == 0) && (geometry == nGeometry::GRID)) {
Modified: development/source/main/cPopulationCell.cc
===================================================================
--- development/source/main/cPopulationCell.cc 2006-06-23 22:31:24 UTC (rev 774)
+++ development/source/main/cPopulationCell.cc 2006-06-25 22:30:42 UTC (rev 775)
@@ -26,7 +26,7 @@
{
}
-cPopulationCell::cPopulationCell(const cPopulationCell & in_cell)
+cPopulationCell::cPopulationCell(const cPopulationCell& in_cell)
: m_world(in_cell.m_world)
, organism(in_cell.organism)
, cur_input(in_cell.cur_input)
@@ -34,8 +34,7 @@
, organism_count(in_cell.organism_count)
{
for (int i = 0; i < nHardware::IO_SIZE; i++) input_array[i] = in_cell.input_array[i];
- mutation_rates = new cMutationRates();
- mutation_rates->Copy(*in_cell.mutation_rates);
+ mutation_rates = new cMutationRates(*in_cell.mutation_rates);
tConstListIterator<cPopulationCell> conn_it(in_cell.connection_list);
cPopulationCell * test_cell;
while ( (test_cell = (cPopulationCell *) conn_it.Next()) != NULL) {
@@ -43,7 +42,7 @@
}
}
-void cPopulationCell::operator=(const cPopulationCell & in_cell)
+void cPopulationCell::operator=(const cPopulationCell& in_cell)
{
m_world = in_cell.m_world;
organism = in_cell.organism;
@@ -51,8 +50,10 @@
cur_input = in_cell.cur_input;
cell_id = in_cell.cell_id;
organism_count = in_cell.organism_count;
- if (mutation_rates == NULL) mutation_rates = new cMutationRates();
- mutation_rates->Copy(*in_cell.mutation_rates);
+ if (mutation_rates == NULL)
+ mutation_rates = new cMutationRates(*in_cell.mutation_rates);
+ else
+ mutation_rates->Copy(*in_cell.mutation_rates);
tConstListIterator<cPopulationCell> conn_it(in_cell.connection_list);
cPopulationCell * test_cell;
while ( (test_cell = (cPopulationCell *) conn_it.Next()) != NULL) {
@@ -60,13 +61,14 @@
}
}
-void cPopulationCell::Setup(cWorld* world, int in_id, const cMutationRates & in_rates)
+void cPopulationCell::Setup(cWorld* world, int in_id, const cMutationRates& in_rates)
{
m_world = world;
cell_id = in_id;
- if (mutation_rates == NULL)
- mutation_rates = new cMutationRates();
- mutation_rates->Copy(in_rates);
+ if (mutation_rates == NULL)
+ mutation_rates = new cMutationRates(in_rates);
+ else
+ mutation_rates->Copy(in_rates);
}
void cPopulationCell::Rotate(cPopulationCell & new_facing)
Modified: development/support/config/avida-smt.cfg
===================================================================
--- development/support/config/avida-smt.cfg 2006-06-23 22:31:24 UTC (rev 774)
+++ development/support/config/avida-smt.cfg 2006-06-25 22:30:42 UTC (rev 775)
@@ -103,6 +103,9 @@
DIVIDE_DEL_PROB 0.05 # Deletion rate (per divide)
PARENT_MUT_PROB 0.0 # Per-site, in parent, on divide
SPECIAL_MUT_LINE -1 # If this is >= 0, ONLY this line is mutated
+INJECT_INS_PROB 0.0 # Insertion rate (per site, applied on inject)
+INJECT_DEL_PROB 0.0 # Deletion rate (per site, applied on inject)
+INJECT_MUT_PROB 0.0 # Mutation rate (per site, applied on inject)
### REVERSION_GROUP ###
# Mutation Reversion
Modified: development/support/config/avida.cfg
===================================================================
--- development/support/config/avida.cfg 2006-06-23 22:31:24 UTC (rev 774)
+++ development/support/config/avida.cfg 2006-06-25 22:30:42 UTC (rev 775)
@@ -103,6 +103,9 @@
DIVIDE_DEL_PROB 0.05 # Deletion rate (per divide)
PARENT_MUT_PROB 0.0 # Per-site, in parent, on divide
SPECIAL_MUT_LINE -1 # If this is >= 0, ONLY this line is mutated
+INJECT_INS_PROB 0.0 # Insertion rate (per site, applied on inject)
+INJECT_DEL_PROB 0.0 # Deletion rate (per site, applied on inject)
+INJECT_MUT_PROB 0.0 # Mutation rate (per site, applied on inject)
### REVERSION_GROUP ###
# Mutation Reversion
More information about the Avida-cvs
mailing list