[Avida-SVN] r2213 - branches/uml/source/main

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Thu Nov 29 05:56:39 PST 2007


Author: hjg
Date: 2007-11-29 08:56:39 -0500 (Thu, 29 Nov 2007)
New Revision: 2213

Modified:
   branches/uml/source/main/cMDEProperty.cc
   branches/uml/source/main/cMDEProperty.h
   branches/uml/source/main/cPopulation.h
   branches/uml/source/main/cTaskLib.cc
   branches/uml/source/main/cUMLModel.cc
   branches/uml/source/main/cUMLModel.h
   branches/uml/source/main/cUMLStateDiagram.h
Log:
Fixed insertion of properties into set. 




Modified: branches/uml/source/main/cMDEProperty.cc
===================================================================
--- branches/uml/source/main/cMDEProperty.cc	2007-11-28 12:21:58 UTC (rev 2212)
+++ branches/uml/source/main/cMDEProperty.cc	2007-11-29 13:56:39 UTC (rev 2213)
@@ -9,13 +9,20 @@
 
 #include "cMDEProperty.h"
 
+#include <cstdlib>
+#include <cmath>
+#include <climits>
+#include <iomanip>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <errno.h>
+
 float cMDEProperty::numWitnesses() {
 	
-	float num_witness = 0;
-	//	const int max_witness = 1;
-	
 	std::string file_name = "tmp-witness" + _name + ".pr";
 	std::string cmd = "cp tmp.pr "+ file_name;
+	int num_witness = 0;
 	
 	if(system(cmd.c_str())!=0) return 0.0;
 	
@@ -25,8 +32,11 @@
 	if(system("/usr/bin/gcc -DMEMLIM=512 pan.c -o pan &> /dev/null")!=0) return 0.0;
 	if(system("./pan -e -n -a -w19  -m100000 -c1 &> ./pan.out")!=0) return 0.0;
 	num_witness = (system("cat pan.out | perl -e 'while(<STDIN>) { if(/errors:\\s(\\d+)/) {exit($1);}}'"));
+	if (num_witness != 0) {
+		num_witness = 1;
+	}
 	
-	return num_witness; 
+	return num_witness;
 }
 
 
@@ -41,7 +51,8 @@
 	
 	if(system("/usr/bin/gcc -DMEMLIM=512 pan.c -o pan &> /dev/null")!=0) return 0.0;
 	if(system("./pan -a &> ./pan.out")!=0) return 0.0;
-	if(system("cat pan.out | perl -e 'while(<STDIN>) { if(/errors:\\s(\\d+)/) {exit($1);}}'")!=0) return 0.0;
+	int num = (system("cat pan.out | perl -e 'while(<STDIN>) { if(/errors:\\s(\\d+)/) {exit($1);}}'")); 
+	if (num != 0) return 0;
 	return 1.0;
 }
 

Modified: branches/uml/source/main/cMDEProperty.h
===================================================================
--- branches/uml/source/main/cMDEProperty.h	2007-11-28 12:21:58 UTC (rev 2212)
+++ branches/uml/source/main/cMDEProperty.h	2007-11-29 13:56:39 UTC (rev 2213)
@@ -19,6 +19,8 @@
 	// A function that prints the property to a file.
 	virtual void print() = 0;
 	virtual void printWitness() = 0;
+	
+	
 	// A function that checks to see if there is a witness trace for the property
 	float numWitnesses();
 	// A function that verifies a property
@@ -36,4 +38,11 @@
 	
 };
 
+struct ltcMDEProperty{ 
+	bool operator() (const cMDEProperty* p1, const cMDEProperty* p2) const
+	{
+		return (p1 < p2);
+	}
+};
+
 #endif

Modified: branches/uml/source/main/cPopulation.h
===================================================================
--- branches/uml/source/main/cPopulation.h	2007-11-28 12:21:58 UTC (rev 2212)
+++ branches/uml/source/main/cPopulation.h	2007-11-29 13:56:39 UTC (rev 2213)
@@ -58,6 +58,9 @@
 #ifndef tVector_h
 #include "tVector.h"
 #endif
+#ifndef _C_UMLMODEL_H_
+#include "cUMLModel.h"
+#endif
 
 #if USE_tMemTrack
 # ifndef tMemTrack_h
@@ -108,6 +111,9 @@
   int world_y;                         // Structured population
   int num_organisms;                   // Cell count with living organisms
   tArray<cDeme> deme_array;            // Deme structure of the population.
+  
+  // UML branch -- for property generation
+  cUMLModel* m_model;
  
   // Outside interactions...
   bool sync_events;   // Do we need to sync up the event list with population?
@@ -151,6 +157,8 @@
   cPopulation(cWorld* world);
   ~cPopulation();
 
+
+  
   // Activate the offspring of an organism in the population
   bool ActivateOffspring(cAvidaContext& ctx, cGenome& child_genome, cOrganism& parent_organism);
   bool ActivateParasite(cOrganism& parent, const cCodeLabel& label, const cGenome& injected_code);
@@ -244,6 +252,10 @@
   int getNumAsleep() { return numAsleep; }
   void incNumAsleep() { numAsleep++; }
   void decNumAsleep() { numAsleep--; }
+  
+  
+  // UML branch -- get the UML model
+  cUMLModel* getUMLModel() { return m_model; }
 };
 
 

Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc	2007-11-28 12:21:58 UTC (rev 2212)
+++ branches/uml/source/main/cTaskLib.cc	2007-11-29 13:56:39 UTC (rev 2213)
@@ -3150,7 +3150,10 @@
 	if(system("/usr/bin/gcc -DMEMLIM=512 pan.c -o pan &> /dev/null")!=0) return 0.0;
 	if(system("./pan -e -n -a -w19  -m100000 -c1 &> ./pan.out")!=0) return 0.0;
 	num_witness = (system("cat pan.out | perl -e 'while(<STDIN>) { if(/errors:\\s(\\d+)/) {exit($1);}}'"));
-
+	if (num_witness != 0) {
+		num_witness = 1;
+	}
+	
 	return num_witness; 
 		//(system("cat pan.out | perl -e 'while(<STDIN>) { if(/errors:\\s(\\d+)/) {exit($1);}}'"));
 }

Modified: branches/uml/source/main/cUMLModel.cc
===================================================================
--- branches/uml/source/main/cUMLModel.cc	2007-11-28 12:21:58 UTC (rev 2212)
+++ branches/uml/source/main/cUMLModel.cc	2007-11-29 13:56:39 UTC (rev 2213)
@@ -406,6 +406,8 @@
 	std::set<cMDEProperty*>::iterator prop_ptr;
 	float total = 0;
 	float temp_val = 0;
+	int success = 0;
+	int failure = 0;
 
 	for (prop_ptr=mdeprops.begin(); prop_ptr!=mdeprops.end(); prop_ptr++)  
 	{
@@ -413,8 +415,17 @@
 		if (temp_val == -1) { 
 			(*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) {
+			failure++;
+		} else { 
+			success++;
+		}
+		
+		
 		total += temp_val;
 	}
 	

Modified: branches/uml/source/main/cUMLModel.h
===================================================================
--- branches/uml/source/main/cUMLModel.h	2007-11-28 12:21:58 UTC (rev 2212)
+++ branches/uml/source/main/cUMLModel.h	2007-11-29 13:56:39 UTC (rev 2213)
@@ -88,7 +88,7 @@
 	bool witnessMode;
 	
 	// set of properties.
-	std::set<cMDEProperty*> mdeprops;
+	std::set<cMDEProperty*, ltcMDEProperty> mdeprops;
 
 	
   // The following are set once per Avida experiment, when the first cUMLModel is constructed:

Modified: branches/uml/source/main/cUMLStateDiagram.h
===================================================================
--- branches/uml/source/main/cUMLStateDiagram.h	2007-11-28 12:21:58 UTC (rev 2212)
+++ branches/uml/source/main/cUMLStateDiagram.h	2007-11-29 13:56:39 UTC (rev 2213)
@@ -71,7 +71,7 @@
   int numTriggers() { return triggers.size(); } 
   int numGuards() { return guards.size(); } 
   int numActions() { return actions.size(); }
-  void addName(std::string s) { name = s; } 
+  void addName(std::string s) { sd_name = s; } 
 
   unsigned int getNumberOfNonDeterministicStates();
 
@@ -143,7 +143,7 @@
   int getActionIndex();
   std::string getGuard() { return guards[getGuardIndex()]; } 
   transition_label getTransLabel();
-  std::string getName() { return name; } 
+  std::string getName() { return sd_name; } 
   
 // Visit graph
 //  void executeVisitor();
@@ -165,7 +165,7 @@
 	boost::graph_traits<state_diagram>::vertex_descriptor orig;
 	boost::graph_traits<state_diagram>::vertex_descriptor dest;
 	int actual_end_state;
-	std::string name;
+	std::string sd_name;
 	
 
 };




More information about the Avida-cvs mailing list