[Avida-SVN] r1967 - development/source/main
matt at myxo.css.msu.edu
matt at myxo.css.msu.edu
Mon Aug 20 17:44:13 PDT 2007
Author: matt
Date: 2007-08-20 20:44:13 -0400 (Mon, 20 Aug 2007)
New Revision: 1967
Removed:
development/source/main/cPlasticCPUTestInfo.cc
development/source/main/cPlasticCPUTestInfo.h
Modified:
development/source/main/cPhenPlastGenotype.cc
development/source/main/cPhenPlastGenotype.h
development/source/main/cPlasticPhenotype.cc
development/source/main/cPlasticPhenotype.h
Log:
Remove assert that doesn't work in Release mode
Modified: development/source/main/cPhenPlastGenotype.cc
===================================================================
--- development/source/main/cPhenPlastGenotype.cc 2007-08-20 19:50:58 UTC (rev 1966)
+++ development/source/main/cPhenPlastGenotype.cc 2007-08-21 00:44:13 UTC (rev 1967)
@@ -59,14 +59,16 @@
cTestCPU* test_cpu = m_world->GetHardwareManager().CreateTestCPU();
for (int k = 0; k < m_num_trials; k++){
test_cpu->TestGenome(ctx, test_info, m_genome);
-
//Is this a new phenotype?
UniquePhenotypes::iterator uit = m_unique.find(&test_info.GetTestPhenotype());
if (uit == m_unique.end()){ // Yes, make a new entry for it
cPlasticPhenotype* new_phen = new cPlasticPhenotype(test_info, m_num_trials);
m_unique.insert( static_cast<cPhenotype*>(new_phen) );
} else{ // No, add an observation to existing entry, make sure it is equivalent
- assert( static_cast<cPlasticPhenotype*>((*uit))->AddObservation(test_info) );
+ if (!static_cast<cPlasticPhenotype*>((*uit))->AddObservation(test_info)){
+ cerr << "Error with this plastic phenotype. Abort." << endl;
+ exit(3);
+ }
}
}
// Update statistics
Modified: development/source/main/cPhenPlastGenotype.h
===================================================================
--- development/source/main/cPhenPlastGenotype.h 2007-08-20 19:50:58 UTC (rev 1966)
+++ development/source/main/cPhenPlastGenotype.h 2007-08-21 00:44:13 UTC (rev 1967)
@@ -42,6 +42,12 @@
#ifndef cHardwareManager_h
#include "cHardwareManager.h"
#endif
+#ifndef cWorld_h
+#include "cWorld.h"
+#endif
+#ifndef cWorldDriver_h
+#include "cWorldDriver.h"
+#endif
class cAvidaContext;
class cTestCPU;
Deleted: development/source/main/cPlasticCPUTestInfo.cc
===================================================================
--- development/source/main/cPlasticCPUTestInfo.cc 2007-08-20 19:50:58 UTC (rev 1966)
+++ development/source/main/cPlasticCPUTestInfo.cc 2007-08-21 00:44:13 UTC (rev 1967)
@@ -1,56 +0,0 @@
-/*
- * cPlasticCPUTestInfo.cpp
- * Avida
- *
- * Created by Matthew Rupp on 7/27/07
- * Copyright 1999-2007 Michigan State University. All rights reserved.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "cPlasticPhenotype.h"
-
-
-bool cPlasticPhenotype::AddObservation( const cPhenotype& in_phen, const tArray<int>& env_inputs )
-{
- if (in_phen == *this){
- if (m_num_observations == 0)
- m_env_inputs.Resize(1, env_inputs.GetSize());
- else
- m_env_inputs.Resize(m_env_inputs.GetNumRows()+1, env_inputs.GetSize());
- m_env_inputs[m_env_inputs.GetNumRows()-1] = env_inputs;
- m_num_observations++;
- return true;
- }
- return false; //Wrong phenotype
-}
-
-bool cPlasticPhenotype::AddObservation( cCPUTestInfo& test_info )
-{
- tArray<int> env_inputs = test_info.GetTestCPUInputs();
- cPhenotype& test_phenotype = test_info.GetTestPhenotype();
- if (test_phenotype == *this ){
- if (m_num_observations == 0)
- m_env_inputs.Resize(1, env_inputs.GetSize());
- else
- m_env_inputs.Resize(m_env_inputs.GetNumRows()+1, env_inputs.GetSize());
- m_env_inputs[m_env_inputs.GetNumRows()-1] = env_inputs;
- m_num_observations++;
- return true;
- }
- return false; //Wrong phenotype
-}
Deleted: development/source/main/cPlasticCPUTestInfo.h
===================================================================
--- development/source/main/cPlasticCPUTestInfo.h 2007-08-20 19:50:58 UTC (rev 1966)
+++ development/source/main/cPlasticCPUTestInfo.h 2007-08-21 00:44:13 UTC (rev 1967)
@@ -1,74 +0,0 @@
-/*
- * cPlasticCPUTestInfo.h
- * Avida
- *
- * Created by Matthew Rupp on 7/27/07.
- * Copyright 1999-2007 Michigan State University. All rights reserved.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; version 2
- * of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef cPlasticCPUTestInfo
-#define cPlasticCPUTestInfo
-
-
-#include <cassert>
-
-#ifndef cCPUTestInfo_h
-#include "cCPUTestInfo.h"
-#endif
-
-#ifndef cPhenotype_h
-#include "cPhenotype.h"
-#endif
-
-#ifndef tMatrix_h
-#include "tMatrix.h"
-#endif
-
-
-#include <iostream>
-
-class cPlasticPhenotype : public cPhenotype{
-
- private:
- int m_num_observations;
- int m_num_trials;
- tMatrix<int> m_env_inputs;
-
- public:
- cPlasticPhenotype(cCPUTestInfo& test_info, int num_trials) :
- cPhenotype(test_info.GetTestPhenotype()), m_num_observations(1), m_num_trials(num_trials) { assert(m_num_trials > 0); }
-
- ~cPlasticPhenotype() { ; }
-
- //Modifiers
- bool AddObservation( const cPhenotype& in_phen, const tArray<int>& env_inputs );
- bool AddObservation( cCPUTestInfo& test_info );
-
- //Accessors
- int GetNumObservations() const { return m_num_observations; }
- int GetNumTrials() const { return m_num_trials; }
- double GetFrequency() const { return static_cast<double>(m_num_observations) / m_num_trials; }
- tMatrix<int> GetEnvInputs() const { return m_env_inputs; }
-
-
-
-};
-
-#endif
-
Modified: development/source/main/cPlasticPhenotype.cc
===================================================================
--- development/source/main/cPlasticPhenotype.cc 2007-08-20 19:50:58 UTC (rev 1966)
+++ development/source/main/cPlasticPhenotype.cc 2007-08-21 00:44:13 UTC (rev 1967)
@@ -42,6 +42,7 @@
m_num_observations++;
return true;
}
+
return false; //Wrong phenotype
}
Modified: development/source/main/cPlasticPhenotype.h
===================================================================
--- development/source/main/cPlasticPhenotype.h 2007-08-20 19:50:58 UTC (rev 1966)
+++ development/source/main/cPlasticPhenotype.h 2007-08-21 00:44:13 UTC (rev 1967)
@@ -64,7 +64,6 @@
~cPlasticPhenotype() { ; }
//Modifiers
- bool AddObservation( const cPhenotype& in_phen, const tArray<int>& env_inputs );
bool AddObservation( cCPUTestInfo& test_info );
//Accessors
More information about the Avida-cvs
mailing list