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

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Fri Mar 21 15:09:38 PDT 2008


Author: hjg
Date: 2008-03-21 18:09:38 -0400 (Fri, 21 Mar 2008)
New Revision: 2486

Modified:
   branches/uml/source/main/cMDECompoundExpression.h
   branches/uml/source/main/cMDEPrecedenceProperty.cc
   branches/uml/source/main/cMDEPropertyGenerator.cc
   branches/uml/source/main/cMDEPropertyGenerator.h
   branches/uml/source/main/cMDESimpleAttValExpression.h
   branches/uml/source/main/cMDESimpleOperationExpression.h
   branches/uml/source/main/cUMLModel.cc
Log:
Added ability to specify relevant operations and attributes in the seed file.


Modified: branches/uml/source/main/cMDECompoundExpression.h
===================================================================
--- branches/uml/source/main/cMDECompoundExpression.h	2008-03-21 20:02:33 UTC (rev 2485)
+++ branches/uml/source/main/cMDECompoundExpression.h	2008-03-21 22:09:38 UTC (rev 2486)
@@ -73,8 +73,8 @@
 		float temp =0;
 		
 		// Check to see if the expressions use suspend or restart operations
-		temp += _exp_1->usesOperation("suspend") + _exp_1->usesOperation("restart");
-		temp += _exp_2->usesOperation("suspend") + _exp_2->usesOperation("restart");
+//		temp += _exp_1->usesOperation("suspend") + _exp_1->usesOperation("restart");
+//		temp += _exp_2->usesOperation("suspend") + _exp_2->usesOperation("restart");
 		
 		// Increase interesting based on the number of ANDs
 		temp += _exp_1->numANDs() + _exp_2->numANDs();
@@ -92,8 +92,8 @@
 		float temp =0;
 		
 		// Check to see if the expressions use suspend or restart operations
-		temp += _exp_1->usesOperation("suspend") + _exp_1->usesOperation("restart");
-		temp += _exp_2->usesOperation("suspend") + _exp_2->usesOperation("restart");
+//		temp += _exp_1->usesOperation("suspend") + _exp_1->usesOperation("restart");
+//		temp += _exp_2->usesOperation("suspend") + _exp_2->usesOperation("restart");
 		
 		// Increase interesting based on the number of ORs
 		temp += _exp_1->numORs() + _exp_2->numORs();

Modified: branches/uml/source/main/cMDEPrecedenceProperty.cc
===================================================================
--- branches/uml/source/main/cMDEPrecedenceProperty.cc	2008-03-21 20:02:33 UTC (rev 2485)
+++ branches/uml/source/main/cMDEPrecedenceProperty.cc	2008-03-21 22:09:38 UTC (rev 2486)
@@ -93,7 +93,8 @@
 	
 	
 	outfile << _interesting << ", "; 
-	if (_uses_related_classes) {
+	if (_uses_related_classes
+		) {
 		outfile << "true" << ", ";
 	} else { outfile << "false" << ", "; }
 	outfile << "Precedence, ";

Modified: branches/uml/source/main/cMDEPropertyGenerator.cc
===================================================================
--- branches/uml/source/main/cMDEPropertyGenerator.cc	2008-03-21 20:02:33 UTC (rev 2485)
+++ branches/uml/source/main/cMDEPropertyGenerator.cc	2008-03-21 22:09:38 UTC (rev 2486)
@@ -135,6 +135,7 @@
 		// add in how interesting the expression is. Use the STRONG and form. 
 		expr->interestingStrongANDExpressionEval(); 
 		interesting += expr->getInterestingExpressionEval();
+		interesting += getExpressionRelevancy(expr);
 			
 		// determine if they are related
 		related = expr->getUsesRelatedClasses();
@@ -224,6 +225,7 @@
 		// add in how interesting the expression is. Use the WEAK and form. 
 		expr->interestingWeakANDExpressionEval(); 
 		interesting += expr->getInterestingExpressionEval();
+		interesting += getExpressionRelevancy(expr);
 		
 		// determine if they are related
 		related = expr->getUsesRelatedClasses();
@@ -310,6 +312,7 @@
 		expr->interestingStrongANDExpressionEval(); 
 		interesting += expr->getInterestingExpressionEval();
 		e.setInterestingProperty(interesting);
+		interesting += getExpressionRelevancy(expr);
 		
 		// determine if they are related
 		related = expr->getUsesRelatedClasses();
@@ -373,6 +376,8 @@
 		e1->interestingStrongANDExpressionEval(); 
 		e2->interestingStrongANDExpressionEval(); 
 		interesting += e1->getInterestingExpressionEval() + e1->getInterestingExpressionEval();
+		interesting += getExpressionRelevancy(e1) + getExpressionRelevancy(e2);
+
 		bool related = areExpressionsRelated(e1, e2);
 
 		e.setSuppressed(false);
@@ -420,6 +425,7 @@
 		e1->interestingStrongANDExpressionEval(); 
 		e2->interestingStrongANDExpressionEval(); 
 		interesting += e1->getInterestingExpressionEval() + e1->getInterestingExpressionEval();
+		interesting += getExpressionRelevancy(e1) + getExpressionRelevancy(e2);
 		bool related = areExpressionsRelated(e1, e2);
 		
 		e.setInterestingProperty(interesting);
@@ -662,3 +668,24 @@
 	
 	return true;
 }
+
+
+float cMDEPropertyGenerator::getExpressionRelevancy(cMDEExpression* e) 
+{
+	float total =0;
+	// check if the expression uses the relevant attributes or operations
+	for (int i=0; i<relevant_attributes.size(); i++) {
+		total += e->usesAttribute(relevant_attributes[i]);
+//		std::cout << "relevant at " << relevant_attributes[i] << " " << total << std::endl;
+	}
+	
+	for (int i=0; i<relevant_operations.size(); i++) {
+		total += e->usesOperation(relevant_operations[i]);
+//		std::cout << "relevant op " << relevant_operations[i] << " " << total << std::endl;
+
+	}
+	
+}
+
+
+

Modified: branches/uml/source/main/cMDEPropertyGenerator.h
===================================================================
--- branches/uml/source/main/cMDEPropertyGenerator.h	2008-03-21 20:02:33 UTC (rev 2485)
+++ branches/uml/source/main/cMDEPropertyGenerator.h	2008-03-21 22:09:38 UTC (rev 2486)
@@ -118,6 +118,12 @@
 	
 	bool ANDExpressions();
 	bool ORExpressions();
+	
+	void addRelevantAttribute(std::string s) { relevant_attributes.push_back(s); }
+	void addRelevantOperation(std::string s) { relevant_operations.push_back(s); }
+	
+	float getExpressionRelevancy(cMDEExpression*); 
+
  
 	template <typename T>
 		bool absoluteMoveIndex (T x, int &y, int z)
@@ -178,6 +184,9 @@
 	float m_property_reward;
 	int m_related_class_mode;
 	
+	std::vector<std::string> relevant_attributes;
+	std::vector<std::string> relevant_operations;
+	
 
 	// vector of expressions
 	std::vector<cMDEExpression*> expressions;

Modified: branches/uml/source/main/cMDESimpleAttValExpression.h
===================================================================
--- branches/uml/source/main/cMDESimpleAttValExpression.h	2008-03-21 20:02:33 UTC (rev 2485)
+++ branches/uml/source/main/cMDESimpleAttValExpression.h	2008-03-21 22:09:38 UTC (rev 2486)
@@ -25,7 +25,8 @@
 		_att_val = val;
 		_att_operator = op;
 		_compound = false;
-		_expr = getInPromela();
+		_expr = 
+			getInPromela();
 	}
  	~cMDESimpleAttValExpression() {}
 	

Modified: branches/uml/source/main/cMDESimpleOperationExpression.h
===================================================================
--- branches/uml/source/main/cMDESimpleOperationExpression.h	2008-03-21 20:02:33 UTC (rev 2485)
+++ branches/uml/source/main/cMDESimpleOperationExpression.h	2008-03-21 22:09:38 UTC (rev 2486)
@@ -36,14 +36,14 @@
 		return false;
 	}
 	
-	void interestingExpressionEval() { 
+/*	void interestingExpressionEval() { 
 		// Currently, the interesting reward is evaluated based on: 
 		// - whether it includes one of the significant variables/operations
 		float temp =0;
 		// Check to see if the expressions use suspend or restart operations
 		temp += usesOperation("suspend") + usesOperation("restart");
 		_interesting = temp;		
-	}
+	}*/
 		
 protected:
 	std::string _op_name;

Modified: branches/uml/source/main/cUMLModel.cc
===================================================================
--- branches/uml/source/main/cUMLModel.cc	2008-03-21 20:02:33 UTC (rev 2485)
+++ branches/uml/source/main/cUMLModel.cc	2008-03-21 22:09:38 UTC (rev 2486)
@@ -184,7 +184,6 @@
 			while (temp!= "==END==") { 
 				infile >> temp2;
 				pg.addKnownExistenceProperty(temp2);
-				std::cout << "existence " << temp2 << std::endl;
 				infile >> temp;
 			}
 		} else if (line == "==KNOWN=ABSENCE==") { 
@@ -193,7 +192,6 @@
 			while (temp!= "==END==") { 
 				infile >> temp2;
 				pg.addKnownAbsenceProperty(temp2);
-				std::cout << "absence " << temp2 << std::endl;
 				infile >> temp;
 			}
 		} else if (line == "==KNOWN=UNIVERSAL==") { 
@@ -202,7 +200,6 @@
 			while (temp!= "==END==") { 
 				infile >> temp2;
 				pg.addKnownUniversalProperty(temp2);
-				std::cout << "universal " << temp2 << std::endl;
 				infile >> temp;
 			}
 		} else if (line == "==KNOWN=PRECEDENCE==") { 
@@ -211,7 +208,6 @@
 			while (temp!= "==END==") { 
 				infile >> temp1 >> temp2;
 				pg.addKnownPrecedenceProperty(temp1, temp2);
-				std::cout << "precedence " << temp1 << temp2 << std::endl;
 				infile >> temp;
 			}
 		} else if (line == "==KNOWN=RESPONSE==") { 
@@ -220,9 +216,26 @@
 			while (temp!= "==END==") { 
 				infile >> temp1 >> temp2;
 				pg.addKnownResponseProperty(temp1, temp2);
-				std::cout << "response " << temp1 << temp2 << std::endl;
 				infile >> temp;
 			}
+		} else if (line == "==RELEVANT=ATTRIBUTE==") {
+			line.erase(); 
+			infile >> temp;
+			while (temp!= "==END==") { 
+				infile >> temp2;
+				pg.addRelevantAttribute(temp2);
+				std::cout << "relevant at " << temp2 << std::endl;
+				infile >> temp;
+			}
+		} else if (line == "==RELEVANT=OPERATION==") {
+			line.erase(); 
+			infile >> temp;
+			while (temp!= "==END==") { 
+				infile >> temp2;
+				pg.addRelevantOperation(temp2);
+				std::cout << "relevant op " << temp2 << std::endl;
+				infile >> temp;
+			}
 		}
 		
 	}




More information about the Avida-cvs mailing list