[Avida-SVN] r2214 - in branches/uml/source: actions cpu main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Thu Nov 29 12:54:06 PST 2007
Author: hjg
Date: 2007-11-29 15:54:06 -0500 (Thu, 29 Nov 2007)
New Revision: 2214
Modified:
branches/uml/source/actions/PrintActions.cc
branches/uml/source/cpu/cHardwareCPU.cc
branches/uml/source/cpu/cHardwareCPU.h
branches/uml/source/main/cMDEAbsenceProperty.cc
branches/uml/source/main/cMDEProperty.cc
branches/uml/source/main/cMDEUniversalProperty.cc
branches/uml/source/main/cPopulation.cc
branches/uml/source/main/cPopulation.h
branches/uml/source/main/cStats.cc
branches/uml/source/main/cStats.h
branches/uml/source/main/cTaskLib.cc
branches/uml/source/main/cTaskLib.h
branches/uml/source/main/cUMLModel.cc
branches/uml/source/main/cUMLModel.h
Log:
Modified: branches/uml/source/actions/PrintActions.cc
===================================================================
--- branches/uml/source/actions/PrintActions.cc 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/actions/PrintActions.cc 2007-11-29 20:54:06 UTC (rev 2214)
@@ -88,9 +88,11 @@
STATS_OUT_FILE(PrintSenseData, sense.dat );
STATS_OUT_FILE(PrintSenseExeData, sense_exe.dat );
STATS_OUT_FILE(PrintUMLData, uml.dat );
+STATS_OUT_FILE(PrintPropertyData, property.dat );
+
#define POP_OUT_FILE(METHOD, DEFAULT) /* 1 */ \
class cAction ## METHOD : public cAction { /* 2 */ \
private: /* 3 */ \
@@ -2452,6 +2454,7 @@
// UML
action_lib->Register<cActionPrintUMLData>("PrintUMLData");
+ action_lib->Register<cActionPrintPropertyData>("PrintPropertyData");
action_lib->Register<cActionSetVerbose>("VERBOSE");
Modified: branches/uml/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.cc 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/cpu/cHardwareCPU.cc 2007-11-29 20:54:06 UTC (rev 2214)
@@ -5061,7 +5061,8 @@
if (s != "<null>" ) {
// std::string n = organism->getStateDiagram()->getName();
// s = n + "." + s;
- val = organism->getUMLModel()->addAbsenceProperty(s);
+// val = organism->getUMLModel()->addAbsenceProperty(s);
+ val = m_world->GetPopulation().getUMLModel()->addAbsenceProperty(s);
}
return val;
}
@@ -5075,7 +5076,8 @@
if (s != "<null>" ) {
// std::string n = organism->getStateDiagram()->getName();
// s = n + "." + s;
- val = organism->getUMLModel()->addUniversalProperty(s);
+// val = organism->getUMLModel()->addUniversalProperty(s);
+ val = m_world->GetPopulation().getUMLModel()->addUniversalProperty(s);
}
return val;
}
@@ -5089,7 +5091,8 @@
if (s != "<null>" ) {
// std::string n = organism->getStateDiagram()->getName();
// s = n + "." + s;
- val = organism->getUMLModel()->addExistenceProperty(s);
+// val = organism->getUMLModel()->addExistenceProperty(s);
+ val = m_world->GetPopulation().getUMLModel()->addExistenceProperty(s);
}
return val;
}
Modified: branches/uml/source/cpu/cHardwareCPU.h
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.h 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/cpu/cHardwareCPU.h 2007-11-29 20:54:06 UTC (rev 2214)
@@ -56,6 +56,9 @@
#ifndef tInstLib_h
#include "tInstLib.h"
#endif
+#ifndef cPopulation_h
+#include "cPopulation.h"
+#endif
#ifndef defs_h
#include "defs.h"
Modified: branches/uml/source/main/cMDEAbsenceProperty.cc
===================================================================
--- branches/uml/source/main/cMDEAbsenceProperty.cc 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/main/cMDEAbsenceProperty.cc 2007-11-29 20:54:06 UTC (rev 2214)
@@ -64,5 +64,12 @@
// print the property
print();
verify_reward = verify();
+
+ // if this property passed, then save it to a file
+ if (verify_reward) {
+ cmd = "cat " + _name + " >> " + work_prop;
+ system(cmd.c_str());
+ }
+
_reward = verify_reward;
}
Modified: branches/uml/source/main/cMDEProperty.cc
===================================================================
--- branches/uml/source/main/cMDEProperty.cc 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/main/cMDEProperty.cc 2007-11-29 20:54:06 UTC (rev 2214)
@@ -60,6 +60,9 @@
void cMDEProperty::evaluate() {
float wit_reward = 0;
float verify_reward = 0;
+ std::string cmd;
+ std::string work_prop = "properties_that_passed";
+
// print the witness property
printWitness();
@@ -72,6 +75,13 @@
print();
verify_reward = verify();
}
+
+ // if this property passed, then save it to a file
+ if (verify_reward) {
+ cmd = "cat " + _name + " >> " + work_prop;
+ system(cmd.c_str());
+ }
+
_reward = wit_reward + verify_reward;
}
Modified: branches/uml/source/main/cMDEUniversalProperty.cc
===================================================================
--- branches/uml/source/main/cMDEUniversalProperty.cc 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/main/cMDEUniversalProperty.cc 2007-11-29 20:54:06 UTC (rev 2214)
@@ -60,6 +60,13 @@
// print the property
print();
verify_reward = verify();
+
+ // if this property passed, then save it to a file
+ if (verify_reward) {
+ cmd = "cat " + _name + " >> " + work_prop;
+ system(cmd.c_str());
+ }
+
_reward = verify_reward;
}
Modified: branches/uml/source/main/cPopulation.cc
===================================================================
--- branches/uml/source/main/cPopulation.cc 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/main/cPopulation.cc 2007-11-29 20:54:06 UTC (rev 2214)
@@ -77,6 +77,7 @@
, environment(world->GetEnvironment())
, num_organisms(0)
, sync_events(false)
+, m_model((const char*)world->GetConfig().SEED_MODEL.Get())
{
// Avida specific information.
world_x = world->GetConfig().WORLD_X.Get();
Modified: branches/uml/source/main/cPopulation.h
===================================================================
--- branches/uml/source/main/cPopulation.h 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/main/cPopulation.h 2007-11-29 20:54:06 UTC (rev 2214)
@@ -113,7 +113,7 @@
tArray<cDeme> deme_array; // Deme structure of the population.
// UML branch -- for property generation
- cUMLModel* m_model;
+ cUMLModel m_model;
// Outside interactions...
bool sync_events; // Do we need to sync up the event list with population?
@@ -255,7 +255,7 @@
// UML branch -- get the UML model
- cUMLModel* getUMLModel() { return m_model; }
+ cUMLModel* getUMLModel() { return &m_model; }
};
Modified: branches/uml/source/main/cStats.cc
===================================================================
--- branches/uml/source/main/cStats.cc 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/main/cStats.cc 2007-11-29 20:54:06 UTC (rev 2214)
@@ -1008,6 +1008,15 @@
}
+void cStats::PrintPropertyData(const cString& filename)
+{
+ cDataFile& df = m_world->GetDataFile(filename);
+ df.Write( m_propertySuccess.Sum(), "total number of properties that passed" );
+ df.Write( m_propertyFailure.Sum(), "total number of properties that failed" );
+ df.Endl();
+
+}
+
void cStats::PrintUMLData(const cString& filename)
{
cDataFile& df = m_world->GetDataFile(filename);
Modified: branches/uml/source/main/cStats.h
===================================================================
--- branches/uml/source/main/cStats.h 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/main/cStats.h 2007-11-29 20:54:06 UTC (rev 2214)
@@ -271,6 +271,11 @@
cDoubleSum m_W2Attempt;
cDoubleSum m_W2Passed;
cDoubleSum m_N1andN2Passed;
+ cDoubleSum m_propertySuccess;
+ cDoubleSum m_propertyFailure;
+
+
+
/*
cDoubleSum m_scenario5;
cDoubleSum m_scenario6;
@@ -640,6 +645,7 @@
void PrintSenseData(const cString& filename);
void PrintSenseExeData(const cString& filename);
void PrintUMLData(const cString& filename);
+ void PrintPropertyData(const cString& filename);
// UML Data Function
@@ -662,6 +668,8 @@
void W2Attempt() { m_W2Attempt.Add(1); }
void W2Passed() { m_W2Passed.Add(1); }
void N1andN2Passed() { m_N1andN2Passed.Add(1); }
+ void propSuccess(int x) {m_propertySuccess.Add(x); }
+ void propFailure(int x) {m_propertyFailure.Add(x); }
/* void scenario5Complete() { m_scenario5.Add(1); }
void scenario6Complete() { m_scenario6.Add(1); }
void scenario7Complete() { m_scenario7.Add(1); }
Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/main/cTaskLib.cc 2007-11-29 20:54:06 UTC (rev 2214)
@@ -2963,10 +2963,13 @@
double cTaskLib::Task_Properties(cTaskContext& ctx) const
{
double bonus = 0.0;
- cOrganism* org = ctx.getOrganism();
+ //cOrganism* org = ctx.getOrganism();
+ cPopulation* pop = (&m_world->GetPopulation());
// call some sort of check properties function for the model.
- bonus = org->getUMLModel()->checkProperties();
+ bonus = pop->getUMLModel()->checkProperties();
+ m_world->GetStats().propSuccess(pop->getUMLModel()->numSuccess());
+ m_world->GetStats().propFailure(pop->getUMLModel()->numFailure());
return bonus;
Modified: branches/uml/source/main/cTaskLib.h
===================================================================
--- branches/uml/source/main/cTaskLib.h 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/main/cTaskLib.h 2007-11-29 20:54:06 UTC (rev 2214)
@@ -41,6 +41,9 @@
#ifndef cStats_h
#include "cStats.h"
#endif
+#ifndef cPopulation_h
+#include "cPopulation.h"
+#endif
class cEnvReqs;
Modified: branches/uml/source/main/cUMLModel.cc
===================================================================
--- branches/uml/source/main/cUMLModel.cc 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/main/cUMLModel.cc 2007-11-29 20:54:06 UTC (rev 2214)
@@ -193,8 +193,17 @@
cUMLModel::~cUMLModel()
-{}
+{
+ for( std::set<cMDEProperty*, ltcMDEProperty>::iterator it = mdeprops.begin(),
+ e = mdeprops.end(); it != e; )
+ {
+ cMDEProperty *p = *it;
+ mdeprops.erase(it++);
+ delete p;
+ }
+}
+
float cUMLModel::getBonusInfo (std::string s)
{
float val;
@@ -337,7 +346,7 @@
bool cUMLModel::readyForHydra()
{
// options: (0) ALL_COMPLETE, (1) ONE_COMPLETE, (2) ONE_NON_EMPTY, (3) ALL_NON_EMPTY
- // (4) ALL COMPLETE && DETERMINISTIC
+ // (4) ALL COMPLETE && DETERMINISTIC, (5) NONE
// check which option was selected in the seed-model.cfg
// check to see if this condition is true. If so, return 1; otherwise, return 0.
@@ -406,8 +415,8 @@
std::set<cMDEProperty*>::iterator prop_ptr;
float total = 0;
float temp_val = 0;
- int success = 0;
- int failure = 0;
+ m_property_success = 0;
+ m_property_failure = 0;
for (prop_ptr=mdeprops.begin(); prop_ptr!=mdeprops.end(); prop_ptr++)
{
@@ -416,14 +425,19 @@
(*prop_ptr)->evaluate();
temp_val = (*prop_ptr)->getEvaluationInformation();
// increment the temp_val by 1 more, since this is a new property
- if (temp_val >0) temp_val += 1;
+ if (temp_val >0) {
+ temp_val += 1;
+ m_property_success++;
+ } else {
+ m_property_failure++;
+ }
}
- if (temp_val == 0) {
- failure++;
+ /*if (temp_val == 0) {
+ m_property_failure++;
} else {
- success++;
- }
+ m_property_success++;
+ }*/
total += temp_val;
Modified: branches/uml/source/main/cUMLModel.h
===================================================================
--- branches/uml/source/main/cUMLModel.h 2007-11-29 13:56:39 UTC (rev 2213)
+++ branches/uml/source/main/cUMLModel.h 2007-11-29 20:54:06 UTC (rev 2214)
@@ -65,16 +65,20 @@
int numActions();
int numSDs();
int numSCs();
+ int numSuccess() { return m_property_success; }
+ int numFailure() { return m_property_failure; }
// Properties
bool addExistenceProperty(std::string);
bool addAbsenceProperty(std::string);
bool addUniversalProperty(std::string);
+
// check if the model is ready for hydra
bool readyForHydra();
bool getWitnessMode() {return witnessMode; }
float checkProperties();
+
protected:
static xmi_info xi;
@@ -89,6 +93,8 @@
// set of properties.
std::set<cMDEProperty*, ltcMDEProperty> mdeprops;
+ int m_property_success;
+ int m_property_failure;
// The following are set once per Avida experiment, when the first cUMLModel is constructed:
More information about the Avida-cvs
mailing list