[avida-cvs] avida CVS commits: /current/source/cpu hardware_cpu.cc /current/source/main config.cc config.hh phenotype.hh
mercere99
avida-cvs at alife.org
Fri Jun 6 20:46:23 PDT 2003
mercere99 Fri Jun 6 12:46:23 2003 EDT
Modified files:
/avida/current/source/cpu hardware_cpu.cc
/avida/current/source/main config.cc config.hh phenotype.hh
Log:
Fixed "sterilize" genesis options. They no longer require test CPUs
(they work right inside the population) and seem to finally actually
be preventing any evolution from occuring.
Index: avida/current/source/cpu/hardware_cpu.cc
diff -u avida/current/source/cpu/hardware_cpu.cc:1.49 avida/current/source/cpu/hardware_cpu.cc:1.50
--- avida/current/source/cpu/hardware_cpu.cc:1.49 Tue May 27 18:08:18 2003
+++ avida/current/source/cpu/hardware_cpu.cc Fri Jun 6 12:46:22 2003
@@ -1721,8 +1721,47 @@
}
// Save the information we collected here...
- organism->GetPhenotype().SetLinesExecuted(executed_size);
- organism->GetPhenotype().SetLinesCopied(copied_size);
+ cPhenotype & phenotype = organism->GetPhenotype();
+ phenotype.SetLinesExecuted(executed_size);
+ phenotype.SetLinesCopied(copied_size);
+
+ // Determine the fitness of this organism as compared to its parent...
+ if (cConfig::GetTestSterilize() == true &&
+ phenotype.IsInjected() == false) {
+ const int merit_base =
+ cPhenotype::CalcSizeMerit(genome_size, copied_size, executed_size);
+ const double cur_fitness =
+ merit_base * phenotype.GetCurBonus() / phenotype.GetTimeUsed();
+ const double fitness_ratio = cur_fitness / phenotype.GetLastFitness();
+
+
+ // const double neut_min = parent_fitness * FITNESS_NEUTRAL_MIN;
+ // const double neut_max = parent_fitness * FITNESS_NEUTRAL_MAX;
+
+ bool sterilize = false;
+
+ if (fitness_ratio < FITNESS_NEUTRAL_MIN) {
+ if (g_random.P(organism->GetSterilizeNeg())) sterilize = true;
+ } else if (fitness_ratio <= FITNESS_NEUTRAL_MAX) {
+ if (g_random.P(organism->GetSterilizeNeut())) sterilize = true;
+ } else {
+ if (g_random.P(organism->GetSterilizePos())) sterilize = true;
+ }
+
+// cout << "[ min(" << genome_size
+// << "," << copied_size
+// << "," << executed_size
+// << ") * " << phenotype.GetCurBonus()
+// << " / " << phenotype.GetTimeUsed()
+// << "] / " << phenotype.GetLastFitness()
+// << " == " << fitness_ratio;
+
+ if (sterilize == true) {
+ //Don't let this organism have this or any more children!
+ phenotype.IsFertile() = false;
+ return false;
+ }
+ }
return true; // (divide succeeds!)
}
Index: avida/current/source/main/config.cc
diff -u avida/current/source/main/config.cc:1.57 avida/current/source/main/config.cc:1.58
--- avida/current/source/main/config.cc:1.57 Mon May 26 00:53:37 2003
+++ avida/current/source/main/config.cc Fri Jun 6 12:46:23 2003
@@ -70,6 +70,7 @@
double cConfig::min_exe_lines;
int cConfig::require_allocate;
bool cConfig::test_on_divide;
+bool cConfig::test_sterilize;
double cConfig::revert_fatal;
double cConfig::revert_neg;
double cConfig::revert_neut;
@@ -330,9 +331,17 @@
// Determine if any variables were set that require test CPUs to be run
// at every divide.
- test_on_divide = (revert_fatal > 0.0) || (revert_neg > 0.0) ||
- (revert_neut > 0.0) || (revert_pos > 0.0) || (sterilize_fatal > 0.0) ||
- (sterilize_neg > 0.0) || (sterilize_neut > 0.0) || (sterilize_pos > 0.0);
+ test_on_divide = false;
+ if ((revert_fatal > 0.0) || (revert_neg > 0.0) || (revert_neut > 0.0) ||
+ (revert_pos > 0.0) || (fail_implicit > 0)) {
+ test_on_divide = true;
+ }
+
+ test_sterilize = false;
+ if ((sterilize_fatal > 0.0) || (sterilize_neg > 0.0) ||
+ (sterilize_neut > 0.0) || (sterilize_pos > 0.0)) {
+ test_sterilize = true;
+ }
// Determine if we are only logging threshold genotypes...
log_threshold_only = false;
Index: avida/current/source/main/config.hh
diff -u avida/current/source/main/config.hh:1.50 avida/current/source/main/config.hh:1.51
--- avida/current/source/main/config.hh:1.50 Tue May 27 14:30:11 2003
+++ avida/current/source/main/config.hh Fri Jun 6 12:46:23 2003
@@ -221,6 +221,7 @@
// For specialized experiments -- mutation reversion.
static bool test_on_divide;
+ static bool test_sterilize;
static double revert_fatal;
static double revert_neg;
static double revert_neut;
@@ -336,6 +337,7 @@
static int GetRequireAllocate() { return require_allocate; }
static bool GetTestOnDivide() { return test_on_divide; }
+ static bool GetTestSterilize() { return test_sterilize; }
static double GetRevertFatal() { return revert_fatal; }
static double GetRevertNeg() { return revert_neg; }
static double GetRevertNeut() { return revert_neut; }
Index: avida/current/source/main/phenotype.hh
diff -u avida/current/source/main/phenotype.hh:1.34 avida/current/source/main/phenotype.hh:1.35
--- avida/current/source/main/phenotype.hh:1.34 Sat May 17 12:33:53 2003
+++ avida/current/source/main/phenotype.hh Fri Jun 6 12:46:23 2003
@@ -98,9 +98,6 @@
bool last_child_fertile; // Was the child being born to be fertile?
int child_copied_size; // Instruction copied into child.
-private:
- static int CalcSizeMerit(int full_size, int copied_size, int exe_size);
-
public:
cPhenotype(const cEnvironment & environment);
~cPhenotype();
@@ -129,6 +126,14 @@
bool LoadState(std::ifstream & fp);
void PrintStatus(std::ostream & fp);
+ // Some useful methods...
+ static int CalcSizeMerit(int full_size, int copied_size, int exe_size);
+ double CalcFitnessRatio() {
+ const int merit_base =
+ CalcSizeMerit(genome_length,copied_size,executed_size);
+ const double cur_fitness = merit_base * cur_bonus / time_used;
+ return cur_fitness / last_fitness;
+ }
///////////////////// Accessors -- Retrieving ////////////////////
const cEnvironment & GetEnvironment() const { return environment; };
More information about the Avida-cvs
mailing list