[Avida-SVN] r3585 - in branches/matt/InheritInstSet: . Avida.xcodeproj source/cpu source/main
ruppmatt at myxo.css.msu.edu
ruppmatt at myxo.css.msu.edu
Tue Jan 5 12:47:30 PST 2010
Author: ruppmatt
Date: 2010-01-05 15:47:29 -0500 (Tue, 05 Jan 2010)
New Revision: 3585
Added:
branches/matt/InheritInstSet/source/main/cInheritedInstSet.cc
Removed:
branches/matt/InheritInstSet/source/main/cInheritedInstSet.cpp
Modified:
branches/matt/InheritInstSet/Avida.xcodeproj/project.pbxproj
branches/matt/InheritInstSet/CMakeLists.txt
branches/matt/InheritInstSet/source/cpu/cHardwareBase.cc
Log:
Changing filename from cpp to cc.
Modified: branches/matt/InheritInstSet/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/matt/InheritInstSet/Avida.xcodeproj/project.pbxproj 2010-01-05 20:45:03 UTC (rev 3584)
+++ branches/matt/InheritInstSet/Avida.xcodeproj/project.pbxproj 2010-01-05 20:47:29 UTC (rev 3585)
@@ -174,6 +174,7 @@
70B6514F0BEA6FCC002472ED /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 701EF27E0BEA5D2300DAE168 /* main.cc */; };
70B651B70BEA9AEC002472ED /* unit-tests in CopyFiles */ = {isa = PBXBuildFile; fileRef = 70B6514C0BEA6FAD002472ED /* unit-tests */; };
70DCAC9C097AF7C0002F8733 /* primitive.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70DCAC9B097AF7C0002F8733 /* primitive.cc */; };
+ B4480DDF10F3DE4E00FC179B /* cInheritedInstSet.cc in Sources */ = {isa = PBXBuildFile; fileRef = B4480DDE10F3DE4E00FC179B /* cInheritedInstSet.cc */; };
B4DA5DBE10F289170052C0A5 /* cInheritedInstSet.h in Headers */ = {isa = PBXBuildFile; fileRef = B4DA5DBC10F289170052C0A5 /* cInheritedInstSet.h */; };
B4DA5DBF10F289170052C0A5 /* cInheritedInstSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B4DA5DBD10F289170052C0A5 /* cInheritedInstSet.cpp */; };
B4FA258A0C5EB65E0086D4B5 /* cPlasticPhenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = B4FA25810C5EB6510086D4B5 /* cPlasticPhenotype.cc */; };
@@ -715,7 +716,8 @@
70F7DE76092967A8009E311D /* cGenotypeBatch.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cGenotypeBatch.h; sourceTree = "<group>"; };
70F9FD990C4E89C40083B788 /* tAutoRelease.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tAutoRelease.h; sourceTree = "<group>"; };
70FB86A908BFAFEC00BDF589 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
- B4DA5DBC10F289170052C0A5 /* cInheritedInstSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cInheritedInstSet.h; path = source/main/cInheritedInstSet.h; sourceTree = SOURCE_ROOT; };
+ B4480DDE10F3DE4E00FC179B /* cInheritedInstSet.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cInheritedInstSet.cc; sourceTree = "<group>"; };
+ B4DA5DBC10F289170052C0A5 /* cInheritedInstSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cInheritedInstSet.h; sourceTree = "<group>"; };
B4DA5DBD10F289170052C0A5 /* cInheritedInstSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cInheritedInstSet.cpp; path = source/main/cInheritedInstSet.cpp; sourceTree = SOURCE_ROOT; };
B4FA25800C5EB6510086D4B5 /* cPhenPlastGenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cPhenPlastGenotype.h; sourceTree = "<group>"; };
B4FA25810C5EB6510086D4B5 /* cPlasticPhenotype.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cPlasticPhenotype.cc; sourceTree = "<group>"; };
@@ -1143,7 +1145,6 @@
DCC30F7C0762539D008F7A48 /* cpu */ = {
isa = PBXGroup;
children = (
- B4DA5DBC10F289170052C0A5 /* cInheritedInstSet.h */,
B4DA5DBD10F289170052C0A5 /* cInheritedInstSet.cpp */,
705261050B87AF5C0007426F /* cInstLib.h */,
706C703E0B83FB95003174C1 /* tInstLibEntry.h */,
@@ -1193,6 +1194,8 @@
DCC310040762539D008F7A48 /* main */ = {
isa = PBXGroup;
children = (
+ B4DA5DBC10F289170052C0A5 /* cInheritedInstSet.h */,
+ B4480DDE10F3DE4E00FC179B /* cInheritedInstSet.cc */,
B4FA259E0C5EB7600086D4B5 /* cPhenPlastGenotype.cc */,
B4FA25800C5EB6510086D4B5 /* cPhenPlastGenotype.h */,
B4FA25810C5EB6510086D4B5 /* cPlasticPhenotype.cc */,
@@ -1737,6 +1740,7 @@
B4FA25A90C5EB7880086D4B5 /* cPhenPlastGenotype.cc in Sources */,
B516AF840C91E2D400023D53 /* cDemeCellEvent.cc in Sources */,
B4DA5DBF10F289170052C0A5 /* cInheritedInstSet.cpp in Sources */,
+ B4480DDF10F3DE4E00FC179B /* cInheritedInstSet.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: branches/matt/InheritInstSet/CMakeLists.txt
===================================================================
--- branches/matt/InheritInstSet/CMakeLists.txt 2010-01-05 20:45:03 UTC (rev 3584)
+++ branches/matt/InheritInstSet/CMakeLists.txt 2010-01-05 20:47:29 UTC (rev 3585)
@@ -208,6 +208,7 @@
${MAIN_DIR}/cFitnessMatrix.cc
${MAIN_DIR}/cGenome.cc
${MAIN_DIR}/cGenomeUtil.cc
+ ${MAIN_DIR}/cInheritedInstSet.cc
${MAIN_DIR}/cInstruction.cc
${MAIN_DIR}/cLandscape.cc
${MAIN_DIR}/cLocalMutations.cc
Modified: branches/matt/InheritInstSet/source/cpu/cHardwareBase.cc
===================================================================
--- branches/matt/InheritInstSet/source/cpu/cHardwareBase.cc 2010-01-05 20:45:03 UTC (rev 3584)
+++ branches/matt/InheritInstSet/source/cpu/cHardwareBase.cc 2010-01-05 20:47:29 UTC (rev 3585)
@@ -50,7 +50,7 @@
cHardwareBase::~cHardwareBase(){
if (m_inherited_instset)
- delete static_cast<cInheritedInstSet*>(m_inst_set);
+ delete m_inst_set;
}
Copied: branches/matt/InheritInstSet/source/main/cInheritedInstSet.cc (from rev 3584, branches/matt/InheritInstSet/source/main/cInheritedInstSet.cpp)
===================================================================
--- branches/matt/InheritInstSet/source/main/cInheritedInstSet.cc (rev 0)
+++ branches/matt/InheritInstSet/source/main/cInheritedInstSet.cc 2010-01-05 20:47:29 UTC (rev 3585)
@@ -0,0 +1,117 @@
+/*
+ * cInheritedInstSet.cpp
+ * Avida
+ *
+ * Created by Matthew Rupp on 1/4/10.
+ * Copyright 2010 Michigan State University. All rights reserved.
+ *
+ */
+
+#include "cInheritedInstSet.h"
+#include "cInstSet.h"
+#include "cRandom.h"
+#include "cWorld.h"
+#include <cassert>
+
+
+cInheritedInstSet::cInheritedInstSet(const cInheritedInstSet* in) : cInstSet(*in)
+{
+ m_allowed_redundancies = in->m_allowed_redundancies;
+}
+
+
+
+cInheritedInstSet::cInheritedInstSet(const cInstSet* in, int init_val, const tArray< tArray<int> >& allowed_redundancies) : cInstSet(*in)
+{
+ m_allowed_redundancies = allowed_redundancies;
+ if (init_val == 0)
+ InitRedRandomly();
+ else if (init_val > 0)
+ InitRedByValue(init_val);
+ Sync();
+}
+
+
+
+void cInheritedInstSet::InitRedRandomly()
+{
+ for (int x = 0; x < m_lib_name_map.GetSize(); x++)
+ m_lib_name_map[x].redundancy = GetRandomRedundancy(x);
+ return;
+}
+
+
+
+void cInheritedInstSet::InitRedByValue(int val)
+{
+ for (int x = 0; x < m_lib_name_map.GetSize(); x++){
+ m_lib_name_map[x].redundancy = GetRandomRedundancy(x);
+ }
+ return;
+}
+
+
+
+void cInheritedInstSet::DoMutation(eIIS_MUT_TYPE type, double p)
+{
+ bool did_mutate = false;
+ if (type == PER_INST){
+ did_mutate = MutateAllInsts(p);
+ } else if (type == PER_INSTSET){
+ if (RandProceed(p))
+ did_mutate = MutateSingleInst();
+ }
+ if (did_mutate)
+ Sync();
+ return;
+}
+
+
+bool cInheritedInstSet::MutateAllInsts(double p)
+{
+ bool did_mutate = false;
+ for (int id = 0; id < m_lib_name_map.GetSize(); id++)
+ if (RandProceed(p)){
+ m_lib_name_map[id].redundancy = GetRandomRedundancy(id);
+ did_mutate = true;
+ }
+ return did_mutate;
+}
+
+
+bool cInheritedInstSet::MutateSingleInst()
+{
+ int id = m_world->GetRandom().GetUInt(0,m_lib_name_map.GetSize());
+ m_lib_name_map[id].redundancy = GetRandomRedundancy(id);
+ return true;
+}
+
+
+
+void cInheritedInstSet::Sync()
+{
+ int sum = 0;
+ for (int x = 0; x < m_lib_name_map.GetSize(); x++)
+ sum += m_lib_name_map[x].redundancy;
+ assert(sum <= 255);
+ m_mutation_chart = tArray<int>(sum, -1);
+ int ndx = 0;
+ for (int id = 0; id < m_lib_name_map.GetSize(); id++)
+ for (int n = 0; n < m_lib_name_map[id].redundancy; n++)
+ m_mutation_chart[ndx++] = id;
+}
+
+
+
+inline bool cInheritedInstSet::RandProceed(double p){
+ return (m_world->GetRandom().GetDouble(0,1) < p);
+}
+
+
+
+inline int cInheritedInstSet::GetRandomRedundancy(int id){
+ return m_allowed_redundancies[id][m_world->GetRandom().GetUInt(0,m_allowed_redundancies[id].GetSize())];
+}
+
+
+
Deleted: branches/matt/InheritInstSet/source/main/cInheritedInstSet.cpp
===================================================================
--- branches/matt/InheritInstSet/source/main/cInheritedInstSet.cpp 2010-01-05 20:45:03 UTC (rev 3584)
+++ branches/matt/InheritInstSet/source/main/cInheritedInstSet.cpp 2010-01-05 20:47:29 UTC (rev 3585)
@@ -1,117 +0,0 @@
-/*
- * cInheritedInstSet.cpp
- * Avida
- *
- * Created by Matthew Rupp on 1/4/10.
- * Copyright 2010 Michigan State University. All rights reserved.
- *
- */
-
-#include "cInheritedInstSet.h"
-#include "cInstSet.h"
-#include "cRandom.h"
-#include "cWorld.h"
-#include <cassert>
-
-
-cInheritedInstSet::cInheritedInstSet(const cInheritedInstSet* in) : cInstSet(*in)
-{
- m_allowed_redundancies = in->m_allowed_redundancies;
-}
-
-
-
-cInheritedInstSet::cInheritedInstSet(const cInstSet* in, int init_val, const tArray< tArray<int> >& allowed_redundancies) : cInstSet(*in)
-{
- m_allowed_redundancies = allowed_redundancies;
- if (init_val == 0)
- InitRedRandomly();
- else if (init_val > 0)
- InitRedByValue(init_val);
- Sync();
-}
-
-
-
-void cInheritedInstSet::InitRedRandomly()
-{
- for (int x = 0; x < m_lib_name_map.GetSize(); x++)
- m_lib_name_map[x].redundancy = GetRandomRedundancy(x);
- return;
-}
-
-
-
-void cInheritedInstSet::InitRedByValue(int val)
-{
- for (int x = 0; x < m_lib_name_map.GetSize(); x++){
- m_lib_name_map[x].redundancy = GetRandomRedundancy(x);
- }
- return;
-}
-
-
-
-void cInheritedInstSet::DoMutation(eIIS_MUT_TYPE type, double p)
-{
- bool did_mutate = false;
- if (type == PER_INST){
- did_mutate = MutateAllInsts(p);
- } else if (type == PER_INSTSET){
- if (RandProceed(p))
- did_mutate = MutateSingleInst();
- }
- if (did_mutate)
- Sync();
- return;
-}
-
-
-bool cInheritedInstSet::MutateAllInsts(double p)
-{
- bool did_mutate = false;
- for (int id = 0; id < m_lib_name_map.GetSize(); id++)
- if (RandProceed(p)){
- m_lib_name_map[id].redundancy = GetRandomRedundancy(id);
- did_mutate = true;
- }
- return did_mutate;
-}
-
-
-bool cInheritedInstSet::MutateSingleInst()
-{
- int id = m_world->GetRandom().GetUInt(0,m_lib_name_map.GetSize());
- m_lib_name_map[id].redundancy = GetRandomRedundancy(id);
- return true;
-}
-
-
-
-void cInheritedInstSet::Sync()
-{
- int sum = 0;
- for (int x = 0; x < m_lib_name_map.GetSize(); x++)
- sum += m_lib_name_map[x].redundancy;
- assert(sum <= 255);
- m_mutation_chart = tArray<int>(sum, -1);
- int ndx = 0;
- for (int id = 0; id < m_lib_name_map.GetSize(); id++)
- for (int n = 0; n < m_lib_name_map[id].redundancy; n++)
- m_mutation_chart[ndx++] = id;
-}
-
-
-
-inline bool cInheritedInstSet::RandProceed(double p){
- return (m_world->GetRandom().GetDouble(0,1) < p);
-}
-
-
-
-inline int cInheritedInstSet::GetRandomRedundancy(int id){
- return m_allowed_redundancies[id][m_world->GetRandom().GetUInt(0,m_allowed_redundancies[id].GetSize())];
-}
-
-
-
More information about the Avida-cvs
mailing list