[Avida-cvs] [avida-svn] r954 - in development/source: cpu utils/task_events

covertar at myxo.css.msu.edu covertar at myxo.css.msu.edu
Wed Sep 13 18:20:35 PDT 2006


Author: covertar
Date: 2006-09-13 21:20:34 -0400 (Wed, 13 Sep 2006)
New Revision: 954

Modified:
   development/source/cpu/cHardwareBase.cc
   development/source/cpu/cHardwareBase.h
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/cHardwareCPU.h
   development/source/utils/task_events/Makefile
Log:
Fixed resampling, added extra divide commands to resample specific mutatoins


Modified: development/source/cpu/cHardwareBase.cc
===================================================================
--- development/source/cpu/cHardwareBase.cc	2006-09-14 01:02:44 UTC (rev 953)
+++ development/source/cpu/cHardwareBase.cc	2006-09-14 01:20:34 UTC (rev 954)
@@ -1,7 +1,7 @@
 /*
  *  cHardwareBase.cc
  *  Avida
- *
+ *../RSDN_FI_25ku_basemut_org50_1dist_fixlen_32205
  *  Called "hardware_base.cc" prior to 11/17/05.
  *  Copyright 2005-2006 Michigan State University. All rights reserved.
  *  Copyright 1999-2003 California Institute of Technology.
@@ -115,57 +115,198 @@
 
 /*
   Return the number of mutations that occur on divide.  AWC 06/29/06
+  Limit the number of mutations that occur to be less than or equat to maxmut (defaults to INT_MAX)
 */
-unsigned cHardwareBase::Divide_DoMutations(cAvidaContext& ctx, double mut_multiplier)
+unsigned cHardwareBase::Divide_DoMutations(cAvidaContext& ctx, double mut_multiplier, const int maxmut)
 {
-  unsigned totalMutations = 0;
-
+  int totalMutations = 0;
+  //cerr << "Maxmut: " << maxmut << endl;
   sCPUStats& cpu_stats = organism->CPUStats();
   cCPUMemory& child_genome = organism->ChildGenome();
   
   organism->GetPhenotype().SetDivType(mut_multiplier);
   
   // Divide Mutations
-  if (organism->TestDivideMut(ctx)) {
+  if (organism->TestDivideMut(ctx) && totalMutations < maxmut) {
     const unsigned int mut_line = ctx.GetRandom().GetUInt(child_genome.GetSize());
     child_genome[mut_line] = m_inst_set->GetRandomInst(ctx);
-    totalMutations += ++cpu_stats.mut_stats.divide_mut_count;
+    ++cpu_stats.mut_stats.divide_mut_count;
+    totalMutations++;
+    //cerr << "Mutating HERE!!!! BAD!!!!!" << endl;
   }
   
   // Divide Insertions
-  if (organism->TestDivideIns(ctx) && child_genome.GetSize() < MAX_CREATURE_SIZE) {
+  if (organism->TestDivideIns(ctx) && child_genome.GetSize() < MAX_CREATURE_SIZE && totalMutations < maxmut) {
     const unsigned int mut_line = ctx.GetRandom().GetUInt(child_genome.GetSize() + 1);
     child_genome.Insert(mut_line, m_inst_set->GetRandomInst(ctx));
-    totalMutations += ++cpu_stats.mut_stats.divide_insert_mut_count;
+    ++cpu_stats.mut_stats.divide_insert_mut_count;
+    totalMutations++;
   }
   
   // Divide Deletions
-  if (organism->TestDivideDel(ctx) && child_genome.GetSize() > MIN_CREATURE_SIZE) {
+  if (organism->TestDivideDel(ctx) && child_genome.GetSize() > MIN_CREATURE_SIZE && totalMutations < maxmut) {
     const unsigned int mut_line = ctx.GetRandom().GetUInt(child_genome.GetSize());
     child_genome.Remove(mut_line);
-    totalMutations += ++cpu_stats.mut_stats.divide_delete_mut_count;
+    ++cpu_stats.mut_stats.divide_delete_mut_count;
+    totalMutations++;
   }
   
   // Divide Mutations (per site)
-  if (organism->GetDivMutProb() > 0) {
+  if (organism->GetDivMutProb() > 0 && totalMutations < maxmut) {
     int num_mut = ctx.GetRandom().GetRandBinomial(child_genome.GetSize(), 
                                                   organism->GetDivMutProb() / mut_multiplier);
     // If we have lines to mutate...
+    if (num_mut > 0 && totalMutations < maxmut) {
+      for (int i = 0; i < num_mut && totalMutations < maxmut; i++) {
+        int site = ctx.GetRandom().GetUInt(child_genome.GetSize());
+        child_genome[site] = m_inst_set->GetRandomInst(ctx);
+        ++cpu_stats.mut_stats.div_mut_count;
+	totalMutations++;
+	//cerr << "OK to mutate here " << totalMutations << endl;
+      }
+    }
+  }
+  
+  
+
+  // Need to come back and fix tese last two - per site instructions
+  // Insert Mutations (per site)
+  if (organism->GetInsMutProb() > 0 && totalMutations < maxmut) {
+    int num_mut = ctx.GetRandom().GetRandBinomial(child_genome.GetSize(),
+                                                  organism->GetInsMutProb());
+    // If would make creature to big, insert up to MAX_CREATURE_SIZE
+    if (num_mut + child_genome.GetSize() > MAX_CREATURE_SIZE) {
+      num_mut = MAX_CREATURE_SIZE - child_genome.GetSize();
+    }
+    // If we have lines to insert...
     if (num_mut > 0) {
+      // Build a list of the sites where mutations occured
+      static int mut_sites[MAX_CREATURE_SIZE];
       for (int i = 0; i < num_mut; i++) {
+        mut_sites[i] = ctx.GetRandom().GetUInt(child_genome.GetSize() + 1);
+      }
+      // Sort the list
+      qsort( (void*)mut_sites, num_mut, sizeof(int), &IntCompareFunction );
+      // Actually do the mutations (in reverse sort order)
+      for (int i = num_mut-1; i >= 0; i--) {
+        child_genome.Insert(mut_sites[i], m_inst_set->GetRandomInst(ctx));
+        cpu_stats.mut_stats.insert_mut_count++;
+	totalMutations++; //Unlike the others we can't be sure this was done only on divide -- AWC 06/29/06
+      }
+    }
+  }
+  
+  
+  // Delete Mutations (per site)
+  if (organism->GetDelMutProb() > 0 && totalMutations < maxmut) {
+    int num_mut = ctx.GetRandom().GetRandBinomial(child_genome.GetSize(),
+                                                  organism->GetDelMutProb());
+    // If would make creature too small, delete down to MIN_CREATURE_SIZE
+    if (child_genome.GetSize() - num_mut < MIN_CREATURE_SIZE) {
+      num_mut = child_genome.GetSize() - MIN_CREATURE_SIZE;
+    }
+    
+    // If we have lines to delete...
+    for (int i = 0; i < num_mut; i++) {
+      int site = ctx.GetRandom().GetUInt(child_genome.GetSize());
+      child_genome.Remove(site);
+      cpu_stats.mut_stats.delete_mut_count++;
+      totalMutations++;
+    }
+  }
+  
+  // Mutations in the parent's genome
+  if (organism->GetParentMutProb() > 0 && totalMutations < maxmut) {
+    for (int i = 0; i < GetMemory().GetSize(); i++) {
+      if (organism->TestParentMut(ctx)) {
+        GetMemory()[i] = m_inst_set->GetRandomInst(ctx);
+        cpu_stats.mut_stats.parent_mut_line_count++;
+	totalMutations++; //Unlike the others we can't be sure this was done only on divide -- AWC 06/29/06
+
+      }
+    }
+  }
+  
+  
+  // Count up mutated lines
+  for (int i = 0; i < GetMemory().GetSize(); i++) {
+    if (GetMemory().FlagPointMut(i)) {
+      cpu_stats.mut_stats.point_mut_line_count++;
+    }
+  }
+  for (int i = 0; i < child_genome.GetSize(); i++) {
+    if (child_genome.FlagCopyMut(i)) {
+      cpu_stats.mut_stats.copy_mut_line_count++;
+    }
+  }
+
+  return totalMutations;
+}
+
+/*
+  Return the number of mutations that occur on divide.  AWC 06/29/06
+  Limit the number of mutations that occur to be less than or equat to maxmut (defaults to INT_MAX)
+*/
+unsigned cHardwareBase::Divide_DoExactMutations(cAvidaContext& ctx, double mut_multiplier, const int pointmut)
+{
+  int maxmut = pointmut;
+  int totalMutations = 0;
+  //cerr << "Maxmut: " << maxmut << endl;
+  sCPUStats& cpu_stats = organism->CPUStats();
+  cCPUMemory& child_genome = organism->ChildGenome();
+  
+  organism->GetPhenotype().SetDivType(mut_multiplier);
+  
+  // Divide Mutations
+  if (organism->TestDivideMut(ctx) && totalMutations < maxmut) {
+    const unsigned int mut_line = ctx.GetRandom().GetUInt(child_genome.GetSize());
+    child_genome[mut_line] = m_inst_set->GetRandomInst(ctx);
+    ++cpu_stats.mut_stats.divide_mut_count;
+    totalMutations++;
+    //cerr << "Mutating HERE!!!! BAD!!!!!" << endl;
+  }
+  
+  // Divide Insertions
+  if (organism->TestDivideIns(ctx) && child_genome.GetSize() < MAX_CREATURE_SIZE && totalMutations < maxmut) {
+    const unsigned int mut_line = ctx.GetRandom().GetUInt(child_genome.GetSize() + 1);
+    child_genome.Insert(mut_line, m_inst_set->GetRandomInst(ctx));
+    ++cpu_stats.mut_stats.divide_insert_mut_count;
+    totalMutations++;
+  }
+  
+  // Divide Deletions
+  if (organism->TestDivideDel(ctx) && child_genome.GetSize() > MIN_CREATURE_SIZE && totalMutations < maxmut) {
+    const unsigned int mut_line = ctx.GetRandom().GetUInt(child_genome.GetSize());
+    child_genome.Remove(mut_line);
+    ++cpu_stats.mut_stats.divide_delete_mut_count;
+    totalMutations++;
+  }
+  
+  // Divide Mutations (per site)
+  if (organism->GetDivMutProb() > 0 && totalMutations < maxmut) {
+    //int num_mut = ctx.GetRandom().GetRandBinomial(child_genome.GetSize(), 
+    //                                              organism->GetDivMutProb() / mut_multiplier);
+    int num_mut = pointmut;
+    // If we have lines to mutate...
+    if (num_mut > 0 && totalMutations < maxmut) {
+      for (int i = 0; i < num_mut && totalMutations < maxmut; i++) {
         int site = ctx.GetRandom().GetUInt(child_genome.GetSize());
         child_genome[site] = m_inst_set->GetRandomInst(ctx);
-        cpu_stats.mut_stats.div_mut_count++;
+        ++cpu_stats.mut_stats.div_mut_count;
+	totalMutations++;
+	//cerr << "OK to mutate here " << totalMutations << endl;
       }
     }
-    totalMutations += cpu_stats.mut_stats.div_mut_count;
   }
   
   
+
+  // Need to come back and fix tese last two - per site instructions
   // Insert Mutations (per site)
-  if (organism->GetInsMutProb() > 0) {
+  if (organism->GetInsMutProb() > 0 && totalMutations < maxmut) {
     int num_mut = ctx.GetRandom().GetRandBinomial(child_genome.GetSize(),
-                                                  organism->GetInsMutProb());
+						  organism->GetInsMutProb());
+    
     // If would make creature to big, insert up to MAX_CREATURE_SIZE
     if (num_mut + child_genome.GetSize() > MAX_CREATURE_SIZE) {
       num_mut = MAX_CREATURE_SIZE - child_genome.GetSize();
@@ -183,14 +324,14 @@
       for (int i = num_mut-1; i >= 0; i--) {
         child_genome.Insert(mut_sites[i], m_inst_set->GetRandomInst(ctx));
         cpu_stats.mut_stats.insert_mut_count++;
-	totalMutations++; //Unline the others we can't be sure this was done only on divide -- AWC 06/29/06
+	totalMutations++; //Unlike the others we can't be sure this was done only on divide -- AWC 06/29/06
       }
     }
   }
   
   
   // Delete Mutations (per site)
-  if (organism->GetDelMutProb() > 0) {
+  if (organism->GetDelMutProb() > 0 && totalMutations < maxmut) {
     int num_mut = ctx.GetRandom().GetRandBinomial(child_genome.GetSize(),
                                                   organism->GetDelMutProb());
     // If would make creature too small, delete down to MIN_CREATURE_SIZE
@@ -203,16 +344,17 @@
       int site = ctx.GetRandom().GetUInt(child_genome.GetSize());
       child_genome.Remove(site);
       cpu_stats.mut_stats.delete_mut_count++;
+      totalMutations++;
     }
   }
   
   // Mutations in the parent's genome
-  if (organism->GetParentMutProb() > 0) {
+  if (organism->GetParentMutProb() > 0 && totalMutations < maxmut) {
     for (int i = 0; i < GetMemory().GetSize(); i++) {
       if (organism->TestParentMut(ctx)) {
         GetMemory()[i] = m_inst_set->GetRandomInst(ctx);
         cpu_stats.mut_stats.parent_mut_line_count++;
-	totalMutations++; //Unline the others we can't be sure this was done only on divide -- AWC 06/29/06
+	totalMutations++; //Unlike the others we can't be sure this was done only on divide -- AWC 06/29/06
 
       }
     }

Modified: development/source/cpu/cHardwareBase.h
===================================================================
--- development/source/cpu/cHardwareBase.h	2006-09-14 01:02:44 UTC (rev 953)
+++ development/source/cpu/cHardwareBase.h	2006-09-14 01:20:34 UTC (rev 954)
@@ -43,7 +43,8 @@
   virtual int GetCopiedSize(const int parent_size, const int child_size) = 0;  
   
   bool Divide_CheckViable(cAvidaContext& ctx, const int parent_size, const int child_size);
-  unsigned Divide_DoMutations(cAvidaContext& ctx, double mut_multiplier = 1.0);
+  unsigned Divide_DoMutations(cAvidaContext& ctx, double mut_multiplier = 1.0, const int maxmut = INT_MAX);
+  unsigned Divide_DoExactMutations(cAvidaContext& ctx, double mut_multiplier = 1.0, const int pointmut = INT_MAX);
   bool Divide_TestFitnessMeasures(cAvidaContext& ctx);
   
   void TriggerMutations_Body(cAvidaContext& ctx, int type, cCPUMemory& target_memory, cHeadCPU& cur_head);

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2006-09-14 01:02:44 UTC (rev 953)
+++ development/source/cpu/cHardwareCPU.cc	2006-09-14 01:20:34 UTC (rev 954)
@@ -240,8 +240,12 @@
                   "Allocate maximum allowed space"),
     cInstEntryCPU("h-divide",  &cHardwareCPU::Inst_HeadDivide, true,
                   "Divide code between read and write heads."),
+    cInstEntryCPU("h-divide1RS",  &cHardwareCPU::Inst_HeadDivide1RS, true,
+		  "Divide code between read and write heads, at most one mutation on divide, resample if reverted."),
+    cInstEntryCPU("h-divide2RS",  &cHardwareCPU::Inst_HeadDivide2RS, true,
+                  "Divide code between read and write heads, at most two mutations on divide, resample if reverted."),
     cInstEntryCPU("h-divideRS",  &cHardwareCPU::Inst_HeadDivideRS, true,
-                  "Divide code between read and write heads, resample reversions."),
+                  "Divide code between read and write heads, resample if reverted."),
     cInstEntryCPU("h-read",    &cHardwareCPU::Inst_HeadRead),
     cInstEntryCPU("h-write",   &cHardwareCPU::Inst_HeadWrite),
     cInstEntryCPU("h-copy",    &cHardwareCPU::Inst_HeadCopy, true,
@@ -1257,10 +1261,12 @@
   
   unsigned 
     totalMutations = 0,
-    mutations = 0,
-    RScount = 0;
+    mutations = 0;
+    //RScount = 0;
 
 
+  bool
+    fitTest = false;
 
   // Handle Divide Mutations...
   /*
@@ -1270,8 +1276,8 @@
       that is not reverted
      the parent is steralized (usually means an implicit mutation)
   */
-  do{
-    if(!RScount){
+  for(unsigned i = 0; i <= 100; i++){
+    if(i == 0){
       mutations = totalMutations = Divide_DoMutations(ctx, mut_multiplier);
     }
     else{
@@ -1279,16 +1285,18 @@
       m_world->GetStats().IncResamplings();
     }
 
+    fitTest = Divide_TestFitnessMeasures(ctx);
     
-    
-  }while (RScount++ < 10 && mutations >= totalMutations && Divide_TestFitnessMeasures(ctx)); 
+    if(!fitTest && mutations >= totalMutations) break;
+
+  } 
   // think about making this mutations == totalMuations - though this may be too hard...
   /*
   if(RScount > 2)
     cerr << "Resampled " << RScount << endl;
   */
   //org could not be resampled beneath the hard cap -- it is then steraalized
-  if(RScount == 10) {
+  if(fitTest/*RScount == 11*/) {
     organism->GetPhenotype().ChildFertile() = false;
     m_world->GetStats().IncFailedResamplings();
   }
@@ -1315,7 +1323,189 @@
   return true;
 }
 
+/*
+  Almost the same as Divide_Main, but only allows for one mutation 
+    on divde and resamples reverted offspring.
 
+  RESAMPLING ONLY WORKS CORRECTLY WHEN ALL MUTIONS OCCUR ON DIVIDE!!
+
+  AWC - 07/28/06
+*/
+bool cHardwareCPU::Divide_Main1RS(cAvidaContext& ctx, const int div_point,
+                               const int extra_lines, double mut_multiplier)
+{
+
+  //cStats stats = m_world->GetStats();
+  const int child_size = GetMemory().GetSize() - div_point - extra_lines;
+  
+  // Make sure this divide will produce a viable offspring.
+  const bool viable = Divide_CheckViable(ctx, div_point, child_size);
+  if (viable == false) return false;
+  
+  // Since the divide will now succeed, set up the information to be sent
+  // to the new organism
+  cGenome & child_genome = organism->ChildGenome();
+  child_genome = cGenomeUtil::Crop(m_memory, div_point, div_point+child_size);
+  
+  // Cut off everything in this memory past the divide point.
+  GetMemory().Resize(div_point);
+  
+  unsigned 
+    totalMutations = 0,
+    mutations = 0;
+  //    RScount = 0;
+
+  bool
+    fitTest = false;
+
+
+  // Handle Divide Mutations...
+  /*
+    Do mutations until one of these conditions are satisified:
+     we have resampled X times
+     we have an offspring with the same number of muations as the first offspring
+      that is not reverted
+     the parent is steralized (usually means an implicit mutation)
+  */
+  for(unsigned i = 0; i < 100; i++){
+    if(!i){
+      mutations = totalMutations = Divide_DoMutations(ctx, mut_multiplier,1);
+    }
+    else{
+      mutations = Divide_DoExactMutations(ctx, mut_multiplier,1);
+      m_world->GetStats().IncResamplings();
+    }
+
+    fitTest = Divide_TestFitnessMeasures(ctx);
+    //if(mutations > 1 ) cerr << "Too Many mutations!!!!!!!!!!!!!!!" << endl;
+    if(!fitTest && mutations >= totalMutations) break;
+
+  } 
+  // think about making this mutations == totalMuations - though this may be too hard...
+  /*
+  if(RScount > 2)
+    cerr << "Resampled " << RScount << endl;
+  */
+  //org could not be resampled beneath the hard cap -- it is then steraalized
+  if(fitTest/*RScount == 11*/) {
+    organism->GetPhenotype().ChildFertile() = false;
+    m_world->GetStats().IncFailedResamplings();
+  }
+
+#if INSTRUCTION_COSTS
+  // reset first time instruction costs
+  for (int i = 0; i < inst_ft_cost.GetSize(); i++) {
+    inst_ft_cost[i] = m_inst_set->GetFTCost(cInstruction(i));
+  }
+#endif
+  
+  m_mal_active = false;
+  if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) {
+    m_advance_ip = false;
+  }
+  
+  // Activate the child, and do more work if the parent lives through the
+  // birth.
+  bool parent_alive = organism->ActivateDivide(ctx);
+  if (parent_alive) {
+    if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) Reset();
+  }
+  
+  return true;
+}
+
+/*
+  Almost the same as Divide_Main, but only allows for one mutation 
+    on divde and resamples reverted offspring.
+
+  RESAMPLING ONLY WORKS CORRECTLY WHEN ALL MUTIONS OCCUR ON DIVIDE!!
+
+  AWC - 07/28/06
+*/
+bool cHardwareCPU::Divide_Main2RS(cAvidaContext& ctx, const int div_point,
+                               const int extra_lines, double mut_multiplier)
+{
+
+  //cStats stats = m_world->GetStats();
+  const int child_size = GetMemory().GetSize() - div_point - extra_lines;
+  
+  // Make sure this divide will produce a viable offspring.
+  const bool viable = Divide_CheckViable(ctx, div_point, child_size);
+  if (viable == false) return false;
+  
+  // Since the divide will now succeed, set up the information to be sent
+  // to the new organism
+  cGenome & child_genome = organism->ChildGenome();
+  child_genome = cGenomeUtil::Crop(m_memory, div_point, div_point+child_size);
+  
+  // Cut off everything in this memory past the divide point.
+  GetMemory().Resize(div_point);
+  
+  unsigned 
+    totalMutations = 0,
+    mutations = 0;
+  //    RScount = 0;
+
+  bool
+    fitTest = false;
+
+
+  // Handle Divide Mutations...
+  /*
+    Do mutations until one of these conditions are satisified:
+     we have resampled X times
+     we have an offspring with the same number of muations as the first offspring
+      that is not reverted
+     the parent is steralized (usually means an implicit mutation)
+  */
+  for(unsigned i = 0; i < 100; i++){
+    if(!i){
+      mutations = totalMutations = Divide_DoMutations(ctx, mut_multiplier,2);
+    }
+    else{
+      Divide_DoExactMutations(ctx, mut_multiplier,mutations);
+      m_world->GetStats().IncResamplings();
+    }
+
+    fitTest = Divide_TestFitnessMeasures(ctx);
+    //if(mutations > 1 ) cerr << "Too Many mutations!!!!!!!!!!!!!!!" << endl;
+    if(!fitTest && mutations >= totalMutations) break;
+
+  } 
+  // think about making this mutations == totalMuations - though this may be too hard...
+  /*
+  if(RScount > 2)
+    cerr << "Resampled " << RScount << endl;
+  */
+  //org could not be resampled beneath the hard cap -- it is then steraalized
+  if(fitTest/*RScount == 11*/) {
+    organism->GetPhenotype().ChildFertile() = false;
+    m_world->GetStats().IncFailedResamplings();
+  }
+
+#if INSTRUCTION_COSTS
+  // reset first time instruction costs
+  for (int i = 0; i < inst_ft_cost.GetSize(); i++) {
+    inst_ft_cost[i] = m_inst_set->GetFTCost(cInstruction(i));
+  }
+#endif
+  
+  m_mal_active = false;
+  if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) {
+    m_advance_ip = false;
+  }
+  
+  // Activate the child, and do more work if the parent lives through the
+  // birth.
+  bool parent_alive = organism->ActivateDivide(ctx);
+  if (parent_alive) {
+    if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) Reset();
+  }
+  
+  return true;
+}
+
+
 //////////////////////////
 // And the instructions...
 //////////////////////////
@@ -2929,6 +3119,41 @@
   return ret_val; 
 }
 
+/*
+  Resample Divide -- single mut on divide-- AWC 07/28/06
+*/
+
+bool cHardwareCPU::Inst_HeadDivide1RS(cAvidaContext& ctx)
+{
+  AdjustHeads();
+  const int divide_pos = GetHead(nHardware::HEAD_READ).GetPosition();
+  int child_end =  GetHead(nHardware::HEAD_WRITE).GetPosition();
+  if (child_end == 0) child_end = GetMemory().GetSize();
+  const int extra_lines = GetMemory().GetSize() - child_end;
+  bool ret_val = Divide_Main1RS(ctx, divide_pos, extra_lines, 1);
+  // Re-adjust heads.
+  AdjustHeads();
+  return ret_val; 
+}
+
+/*
+  Resample Divide -- double mut on divide-- AWC 08/29/06
+*/
+
+bool cHardwareCPU::Inst_HeadDivide2RS(cAvidaContext& ctx)
+{
+  AdjustHeads();
+  const int divide_pos = GetHead(nHardware::HEAD_READ).GetPosition();
+  int child_end =  GetHead(nHardware::HEAD_WRITE).GetPosition();
+  if (child_end == 0) child_end = GetMemory().GetSize();
+  const int extra_lines = GetMemory().GetSize() - child_end;
+  bool ret_val = Divide_Main2RS(ctx, divide_pos, extra_lines, 1);
+  // Re-adjust heads.
+  AdjustHeads();
+  return ret_val; 
+}
+
+
 bool cHardwareCPU::Inst_HeadDivideSex(cAvidaContext& ctx)  
 { 
   organism->GetPhenotype().SetDivideSex(true);

Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h	2006-09-14 01:02:44 UTC (rev 953)
+++ development/source/cpu/cHardwareCPU.h	2006-09-14 01:20:34 UTC (rev 954)
@@ -172,6 +172,8 @@
   
   bool Divide_Main(cAvidaContext& ctx, const int divide_point, const int extra_lines=0, double mut_multiplier=1);
   bool Divide_MainRS(cAvidaContext& ctx, const int divide_point, const int extra_lines=0, double mut_multiplier=1); //AWC 06/29/06
+  bool Divide_Main1RS(cAvidaContext& ctx, const int divide_point, const int extra_lines=0, double mut_multiplier=1); //AWC 07/28/06
+  bool Divide_Main2RS(cAvidaContext& ctx, const int divide_point, const int extra_lines=0, double mut_multiplier=1); //AWC 07/28/06
 
   
   void InjectCode(const cGenome& injection, const int line_num);
@@ -418,6 +420,8 @@
   bool Inst_IfLabel2(cAvidaContext& ctx);
   bool Inst_HeadDivide(cAvidaContext& ctx);
   bool Inst_HeadDivideRS(cAvidaContext& ctx); //AWC 06/29/06
+  bool Inst_HeadDivide1RS(cAvidaContext& ctx); //AWC 07/28/06
+  bool Inst_HeadDivide2RS(cAvidaContext& ctx); //AWC 08/29/06
   bool Inst_HeadRead(cAvidaContext& ctx);
   bool Inst_HeadWrite(cAvidaContext& ctx);
   bool Inst_HeadCopy(cAvidaContext& ctx);

Modified: development/source/utils/task_events/Makefile
===================================================================
--- development/source/utils/task_events/Makefile	2006-09-14 01:02:44 UTC (rev 953)
+++ development/source/utils/task_events/Makefile	2006-09-14 01:20:34 UTC (rev 954)
@@ -1,168 +1,125 @@
-# CMAKE generated Makefile, DO NOT EDIT!
-# Generated by "Unix Makefiles" Generator, CMake Version 2.0
-# Generated from the following files:
-# /home/covertar/source/development_52205/CMakeCache.txt
-# /home/covertar/source/development_52205/CMakeCCompiler.cmake
-# /home/covertar/source/development_52205/CMakeCXXCompiler.cmake
-# /home/covertar/source/development_52205/CMakeLists.txt
-# /home/covertar/source/development_52205/CMakeSystem.cmake
-# /home/covertar/source/development_52205/source/CMakeLists.txt
-# /home/covertar/source/development_52205/source/utils/task_events/CMakeLists.txt
-# /usr/local/share/CMake/Modules/CMakeDefaultMakeRuleVariables.cmake
-# /usr/local/share/CMake/Modules/CMakeSystemSpecificInformation.cmake
-# /usr/local/share/CMake/Modules/Dart.cmake
-# /usr/local/share/CMake/Modules/FindDart.cmake
-# /usr/local/share/CMake/Modules/FindTclsh.cmake
-# /usr/local/share/CMake/Modules/Platform/Linux.cmake
-# /usr/local/share/CMake/Modules/Platform/gcc.cmake
+# Include the progress variables for this target.
+include progress.make
 
+# CMAKE generated file: DO NOT EDIT!
+# Generated by "Unix Makefiles" Generator, CMake Version 2.4
 
-# disable some common implicit rules to speed things up
-.SUFFIXES:
-.SUFFIXES:.hpuxmakemusthaverule
-CMAKE_MAKEFILE_SOURCES =  /home/covertar/source/development_52205/CMakeCCompiler.cmake /home/covertar/source/development_52205/CMakeCXXCompiler.cmake /home/covertar/source/development_52205/CMakeLists.txt /home/covertar/source/development_52205/CMakeSystem.cmake /home/covertar/source/development_52205/source/CMakeLists.txt /home/covertar/source/development_52205/source/utils/task_events/CMakeLists.txt /usr/local/share/CMake/Modules/CMakeDefaultMakeRuleVariables.cmake /usr/local/share/CMake/Modules/CMakeSystemSpecificInformation.cmake /usr/local/share/CMake/Modules/Dart.cmake /usr/local/share/CMake/Modules/FindDart.cmake /usr/local/share/CMake/Modules/FindTclsh.cmake /usr/local/share/CMake/Modules/Platform/Linux.cmake /usr/local/share/CMake/Modules/Platform/gcc.cmake /home/covertar/source/development_52205/CMakeCache.txt
+#=============================================================================
+# Set environment variables for the build.
 
-
-# the standard shell for make
+# The shell in which to execute make rules.
 SHELL = /bin/sh
 
+# The CMake executable.
 CMAKE_COMMAND = /usr/local/bin/cmake
+
+# The command to remove a file.
 RM = /usr/local/bin/cmake -E remove -f
+
+# The program to use to edit the cache.
 CMAKE_EDIT_COMMAND = /usr/local/bin/ccmake
-CMAKE_CURRENT_SOURCE = /home/covertar/source/development_52205/source/utils/task_events
-CMAKE_CURRENT_BINARY = /home/covertar/source/development_52205/source/utils/task_events
-CMAKE_SOURCE_DIR = /home/covertar/source/development_52205
-CMAKE_BINARY_DIR = /home/covertar/source/development_52205
-INCLUDE_FLAGS = -I/home/covertar/source/development_52205/source/tools -I/home/covertar/source/development_52205/source/actions -I/home/covertar/source/development_52205/source/analyze -I/home/covertar/source/development_52205/source/archive -I/home/covertar/source/development_52205/source/third-party/boost -I/home/covertar/source/development_52205/source/classification -I/home/covertar/source/development_52205/source/cpu -I/home/covertar/source/development_52205/source/drivers -I/home/covertar/source/development_52205/source/event -I/home/covertar/source/development_52205/source/main -I/home/covertar/source/development_52205/source  
 
-#---------------------------------------------------------
-# Default target executed when no arguments are given to make, first make sure cmake.depends exists, cmake.check_depends is up-to-date, check the sources, then build the all target
-#
+# The top-level source directory on which CMake was run.
+CMAKE_SOURCE_DIR = /home/covertar/source/development_72806/development
 
-default_target: /home/covertar/source/development_52205/cmake.check_cache
-	$(MAKE) $(MAKESILENT) cmake.depends
-	$(MAKE) $(MAKESILENT) cmake.check_depends
-	$(MAKE) $(MAKESILENT) -f cmake.check_depends
-	$(MAKE) $(MAKESILENT) all
+# The top-level build directory on which CMake was run.
+CMAKE_BINARY_DIR = /home/covertar/source/development_72806/development
 
-# Suppresses display of executed commands
-$(VERBOSE).SILENT:
+# Default target executed when no arguments are given to make.
+default_target: all
 
-help:
-	@echo "The following are some of the valid targets for this Makefile:"
-	@echo "... all (the default if no target is provided)"
-	@echo "... clean"
-	@echo "... depend"
-	@echo "... install"
-	@echo "... rebuild_cache"
+# Special rule for the target edit_cache
+edit_cache:
+	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
+	cd /home/covertar/source/development_72806/development/source/utils/task_events && /usr/local/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
 
+# Special rule for the target edit_cache
+edit_cache/fast: edit_cache
 
-TARGETS = 
+# Special rule for the target install
+install: preinstall
+	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
+	cd /home/covertar/source/development_72806/development/source/utils/task_events && /usr/local/bin/cmake -P cmake_install.cmake
 
-TARGET_EXTRAS = 
+# Special rule for the target install
+install/fast: preinstall/fast
+	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
+	cd /home/covertar/source/development_72806/development/source/utils/task_events && /usr/local/bin/cmake -P cmake_install.cmake
 
-CLEAN_OBJECT_FILES = 
+# Special rule for the target rebuild_cache
+rebuild_cache:
+	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
+	cd /home/covertar/source/development_72806/development/source/utils/task_events && /usr/local/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
 
+# Special rule for the target rebuild_cache
+rebuild_cache/fast: rebuild_cache
 
-#---------------------------------------------------------
-# default build rule
-#
+# Special rule for the target test
+test:
+	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..."
+	cd /home/covertar/source/development_72806/development/source/utils/task_events && /usr/local/bin/ctest --force-new-ctest-process
 
-all: cmake.depends $(SUBDIR_PREORDER_BUILD) $(TARGETS) $(SUBDIR_BUILD)
+# Special rule for the target test
+test/fast: test
 
-#---------------------------------------------------------
-# clean generated files
-#
+#=============================================================================
+# Special targets provided by cmake.
 
-clean: $(SUBDIR_CLEAN)
-	-@ $(RM) $(CLEAN_OBJECT_FILES)  $(TARGETS) $(TARGET_EXTRAS) $(GENERATED_QT_FILES) $(GENERATED_FLTK_FILES) $(ADDITIONAL_MAKE_CLEAN_FILES)
+# Produce verbose output by default.
+VERBOSE = 1
 
-#---------------------------------------------------------
-# dependencies.
-#
+# Suppress display of executed commands.
+$(VERBOSE).SILENT:
 
-cmake.depends: $(CMAKE_MAKEFILE_SOURCES)
-	@echo "Building dependencies. cmake.depends..."
-	$(CMAKE_COMMAND) -S$(CMAKE_CURRENT_SOURCE) -O$(CMAKE_CURRENT_BINARY) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
+# Disable implicit rules so canoncical targets will work.
+.SUFFIXES:
 
-#---------------------------------------------------------
-# dependencies
-#
+.SUFFIXES: .hpux_make_needs_suffix_list
 
-cmake.check_depends:
-	@echo "Building dependencies cmake.check_depends..."
-	$(CMAKE_COMMAND) -S$(CMAKE_CURRENT_SOURCE) -O$(CMAKE_CURRENT_BINARY) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
+# The main all target
+all: cmake_check_build_system
+	cd /home/covertar/source/development_72806/development && $(CMAKE_COMMAND) -E cmake_progress_start /home/covertar/source/development_72806/development/CMakeFiles $(CMAKE_ALL_PROGRESS)
+	cd /home/covertar/source/development_72806/development && $(MAKE) -f CMakeFiles/Makefile2 source/utils/task_events/all
+	$(CMAKE_COMMAND) -E cmake_progress_start /home/covertar/source/development_72806/development/CMakeFiles 0
 
-#---------------------------------------------------------
-# dependencies
-#
+# The main clean target
+clean:
+	cd /home/covertar/source/development_72806/development && $(MAKE) -f CMakeFiles/Makefile2 source/utils/task_events/clean
 
-depend: $(SUBDIR_DEPEND)
-	@echo "Building dependencies depend..."
-	$(CMAKE_COMMAND) -S$(CMAKE_CURRENT_SOURCE) -O$(CMAKE_CURRENT_BINARY) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
+# The main clean target
+clean/fast: clean
 
-#---------------------------------------------------------
-# dependencies
-#
+# Prepare targets for installation.
+preinstall: all
+	cd /home/covertar/source/development_72806/development && $(MAKE) -f CMakeFiles/Makefile2 source/utils/task_events/preinstall
 
-dependlocal:
-	@echo "Building dependencies dependlocal..."
-	$(CMAKE_COMMAND) -S$(CMAKE_CURRENT_SOURCE) -O$(CMAKE_CURRENT_BINARY) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
+# Prepare targets for installation.
+preinstall/fast:
+	cd /home/covertar/source/development_72806/development && $(MAKE) -f CMakeFiles/Makefile2 source/utils/task_events/preinstall
 
-#---------------------------------------------------------
-# CMakeCache.txt
-#
+# clear depends
+depend:
+	$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
 
-rebuild_cache:
-	@echo "Building CMakeCache.txt rebuild_cache..."
-	$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
+# Help Target
+help::
+	@echo "The following are some of the valid targets for this Makefile:"
+	@echo "... all (the default if no target is provided)"
+	@echo "... clean"
+	@echo "... depend"
+	@echo "... edit_cache"
+	@echo "... install"
+	@echo "... rebuild_cache"
+	@echo "... test"
 
-#---------------------------------------------------------
-# CMakeCache.txt because out-of-date:
-#
 
-/home/covertar/source/development_52205/cmake.check_cache: $(CMAKE_MAKEFILE_SOURCES)
-	@echo "Building CMakeCache.txt because out-of-date: /home/covertar/source/development_52205/cmake.check_cache..."
-	$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
 
-#---------------------------------------------------------
-# edit CMakeCache.txt
-#
+#=============================================================================
+# Special targets to cleanup operation of make.
 
-edit_cache:
-	@echo "Building edit CMakeCache.txt edit_cache..."
-	$(CMAKE_EDIT_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
+# Special rule to run CMake to check the build system integrity.
+# No rule that depends on this can have commands that come from listfiles
+# because they might be regenerated.
+cmake_check_build_system:
+	cd /home/covertar/source/development_72806/development && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
 
-#---------------------------------------------------------
-# CMakeCache.txt
-#
-
-/home/covertar/source/development_52205/CMakeCache.txt:
-	@echo "Building CMakeCache.txt /home/covertar/source/development_52205/CMakeCache.txt..."
-	$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
-
-#---------------------------------------------------------
-# Rule to keep make from removing Makefiles if control-C is hit during a run of cmake.
-#
-
-.PRECIOUS: Makefile cmake.depends
-
-# Rules to build .o files from their sources:
-ARGS=
-#---------------------------------------------------------
-# tests
-#
-
-test: 
-	@echo "Building tests test..."
-	/usr/local/bin/ctest $(ARGS)
-
-#---------------------------------------------------------
-# installation
-#
-
-install: 
-	@echo "Building installation install..."
-	$(CMAKE_COMMAND) -P cmake_install.cmake
-
-include cmake.depends




More information about the Avida-cvs mailing list