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

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Tue May 15 16:58:02 PDT 2007


Author: hjg
Date: 2007-05-15 19:58:01 -0400 (Tue, 15 May 2007)
New Revision: 1558

Modified:
   branches/uml/source/main/cPopulation.cc
   branches/uml/source/main/cUMLModel.cc
   branches/uml/source/main/cUMLModel.h
   branches/uml/source/main/cUMLStateDiagram.cc
Log:
Added support for stats & file export. 



Modified: branches/uml/source/main/cPopulation.cc
===================================================================
--- branches/uml/source/main/cPopulation.cc	2007-05-15 19:39:23 UTC (rev 1557)
+++ branches/uml/source/main/cPopulation.cc	2007-05-15 23:58:01 UTC (rev 1558)
@@ -763,7 +763,7 @@
 	case 7: {
       for (int deme_id = 0; deme_id < num_demes; deme_id++) {
         cDeme& cur_deme = deme_array[deme_id];
-        double f = cur_deme.getUMLModel()->evaluateModel();
+        double f = cur_deme.getUMLModel()->evaluateModel(deme_id, m_world);
         deme_fitness[deme_id] = f;
         total_fitness += f;
       }

Modified: branches/uml/source/main/cUMLModel.cc
===================================================================
--- branches/uml/source/main/cUMLModel.cc	2007-05-15 19:39:23 UTC (rev 1557)
+++ branches/uml/source/main/cUMLModel.cc	2007-05-15 23:58:01 UTC (rev 1558)
@@ -124,7 +124,7 @@
   
 }
 
-double cUMLModel::evaluateModel()
+double cUMLModel::evaluateModel(int deme_id, cWorld* world)
 {
 	double bonus = 0.0;
 	double mod_bonus = 0.0;
@@ -148,7 +148,7 @@
 	// Check if the model meets the properties. 
 	if (mod_bonus > 0.0) {
 		self_bonus["spin_attemp"] = 1;
-		mod_bonus += propertyN1();
+		mod_bonus += propertyN1(deme_id, world);
 		self_bonus["spin_pass"] = mod_bonus;		
 		bonus += mod_bonus;
 	}
@@ -377,7 +377,7 @@
 }
 
 
-double cUMLModel::checkProperty(const std::string& neverclaimFile) const {
+double cUMLModel::checkProperty(const std::string& neverclaimFile, int deme_id, cWorld* world) const {
 //	m_world->GetStats().SpinAttempt();
 	double status=0;
 	std::string cmd = "cat " + neverclaimFile + " >> tmp.pr && ./spin -a tmp.pr &> /dev/null";
@@ -392,15 +392,15 @@
 	
 	
 	std::ostringstream strstrm;
-	strstrm << "cp tmp.xmi "; // << m_world->GetStats().GetUpdate() << "." << organism->GetID();
-	strstrm << "tmp.xml";	
-	if(system(strstrm.str().c_str())!=0) return 0;
+	strstrm << "cp tmp.xmi " << world->GetStats().GetUpdate() << "." << deme_id;
+	strstrm << ".xml";	
+	if(system(strstrm.str().c_str())!=0) return 0.0;
 			
 //	m_world->GetStats().PanPassed();
 	return 3;
 }
 
-double cUMLModel::propertyN1() const {
+double cUMLModel::propertyN1(int deme_id, cWorld* world) const {
 	std::string temp = xmi;
 	double temp1 = 0;
 
@@ -418,7 +418,7 @@
 		
 		// check property
 //		if (ctx.task_success_complete) {
-			temp1 += checkProperty("N1");
+			temp1 += checkProperty("N1", deme_id, world);
 //		} 
 //	}
 	

Modified: branches/uml/source/main/cUMLModel.h
===================================================================
--- branches/uml/source/main/cUMLModel.h	2007-05-15 19:39:23 UTC (rev 1557)
+++ branches/uml/source/main/cUMLModel.h	2007-05-15 23:58:01 UTC (rev 1558)
@@ -3,6 +3,8 @@
 
 #include "cUMLStateDiagram.h"
 #include "cUMLClassDiagram.h"
+#include "cWorld.h"
+#include "cStats.h"
 
 #include <string>
 #include <iostream>
@@ -20,8 +22,8 @@
 	std::string getXMI(); // get the XMI version of the model
 	void printXMI();
 	double formalizeModel(); // formalize the model using Hydra
-	double checkProperty(const std::string& neverclaimFile) const; // check for property satisfaction using Spin
-	double propertyN1() const; // check for property N1
+	double checkProperty(const std::string& neverclaimFile, int, cWorld*) const; // check for property satisfaction using Spin
+	double propertyN1(int, cWorld*) const; // check for property N1
 	
 	void resetStateDiagrams (int);  
 	void seedDiagrams();
@@ -38,7 +40,7 @@
 	// Determine the "fitness" of the model
 	// does the model satisfy the sequence diagrams? 
 	// does the model meet the properties? 
-	double evaluateModel();
+	double evaluateModel(int, cWorld*);
 	double checkForSequenceDiagram1();
 
 protected: 

Modified: branches/uml/source/main/cUMLStateDiagram.cc
===================================================================
--- branches/uml/source/main/cUMLStateDiagram.cc	2007-05-15 19:39:23 UTC (rev 1557)
+++ branches/uml/source/main/cUMLStateDiagram.cc	2007-05-15 23:58:01 UTC (rev 1558)
@@ -441,7 +441,7 @@
 void cUMLStateDiagram::printXMI()
 {
 	std::string temp, temp1, temp2, temp3;
-	std::string trig_label, trig_op_label;
+	std::string trig_label, trig_op_name;
 
 	int s_count = 0;
 	int t_count = 0;
@@ -495,15 +495,15 @@
 		temp1 = transitions[t_count].trans.guard;
 		temp2 = transitions[t_count].trans.action;
 		trig_label = triggers[transitions[t_count].trans.trigger].label;
-		trig_op_label = triggers[transitions[t_count].trans.trigger].operation_id;
+		trig_op_name = triggers[transitions[t_count].trans.trigger].operation_id;
 
 
 		// print trigger, if any
 		if (trig_label != "<null>") {
 			xmi+= "<UML:Transition.trigger> <UML:Event> <UML:ModelElement.namespace> <UML:Namespace> ";
 			xmi+= "<UML:Namespace.ownedElement> <UML:CallEvent xmi.id=\"" + temp3;
-			xmi+= "tt\"  operation=\""+ trig_op_label + "\" ";
-			xmi+= "name=\"" + trig_label + "\" isSpecification=\"false\"/> "; 
+			xmi+= "tt\"  operation=\""+ trig_label + "\" ";
+			xmi+= "name=\"" + trig_op_name + "\" isSpecification=\"false\"/> "; 
 			xmi+= "</UML:Namespace.ownedElement> </UML:Namespace> </UML:ModelElement.namespace> ";
 			xmi+= "</UML:Event>  </UML:Transition.trigger> ";
 		}




More information about the Avida-cvs mailing list