[Avida-SVN] r2456 - branches/uml/source/main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Fri Mar 14 05:44:29 PDT 2008
Author: hjg
Date: 2008-03-14 08:44:29 -0400 (Fri, 14 Mar 2008)
New Revision: 2456
Modified:
branches/uml/source/main/cMDEAbsenceProperty.cc
branches/uml/source/main/cMDEExistenceProperty.cc
branches/uml/source/main/cMDEExpression.h
branches/uml/source/main/cMDEPrecedenceProperty.cc
branches/uml/source/main/cMDEProperty.cc
branches/uml/source/main/cMDEPropertyGenerator.cc
branches/uml/source/main/cMDEPropertyGenerator.h
branches/uml/source/main/cMDEResponseProperty.cc
branches/uml/source/main/cMDESimpleOperationExpression.h
branches/uml/source/main/cMDEUniversalProperty.cc
branches/uml/source/main/cUMLModel.cc
Log:
Added comparability checks for attributes and operations.
Modified: branches/uml/source/main/cMDEAbsenceProperty.cc
===================================================================
--- branches/uml/source/main/cMDEAbsenceProperty.cc 2008-03-13 17:36:19 UTC (rev 2455)
+++ branches/uml/source/main/cMDEAbsenceProperty.cc 2008-03-14 12:44:29 UTC (rev 2456)
@@ -93,7 +93,10 @@
assert(outfile.is_open());
- outfile << _interesting << ", " << _uses_related_classes << ", ";
+ outfile << _interesting << ", ";
+ if (_uses_related_classes) {
+ outfile << "true" << ", ";
+ } else { outfile << "false" << ", "; }
outfile << "Globally, it is never the case that " << _expr_p << " holds. ";
outfile << std::endl << std::endl;
Modified: branches/uml/source/main/cMDEExistenceProperty.cc
===================================================================
--- branches/uml/source/main/cMDEExistenceProperty.cc 2008-03-13 17:36:19 UTC (rev 2455)
+++ branches/uml/source/main/cMDEExistenceProperty.cc 2008-03-14 12:44:29 UTC (rev 2456)
@@ -67,7 +67,10 @@
outfile.open (_properties.c_str(), std::ios_base::app);
assert(outfile.is_open());
- outfile << _interesting << ", " << _uses_related_classes << ", ";
+ outfile << _interesting << ", ";
+ if (_uses_related_classes) {
+ outfile << "true" << ", ";
+ } else { outfile << "false" << ", "; }
outfile << "Globally, " << _expr_p << " eventually holds." << std::endl<< std::endl;
outfile.close();
Modified: branches/uml/source/main/cMDEExpression.h
===================================================================
--- branches/uml/source/main/cMDEExpression.h 2008-03-13 17:36:19 UTC (rev 2455)
+++ branches/uml/source/main/cMDEExpression.h 2008-03-14 12:44:29 UTC (rev 2456)
@@ -58,6 +58,12 @@
void setUsedClassNames(std::set<std::string> s) { _used_class_names = s; }
std::set<std::string> getUsedClassNames() { return _used_class_names; }
+ // the attributes and operations involved in the expression
+ void addAttOpName(std::string a) {_at_op_names.insert(a); }
+ void setAttOpNames(std::set<std::string> s) { _at_op_names = s; }
+ std::set<std::string> getAtOpNames() { return _at_op_names; }
+
+
bool getUsesRelatedClasses() { return _uses_related_classes; }
void setUsesRelatedClasses(bool t) { _uses_related_classes = t; }
@@ -66,6 +72,7 @@
float _interesting;
std::set<std::string> _related_class_names;
std::set<std::string> _used_class_names;
+ std::set<std::string> _at_op_names;
bool _uses_related_classes;
};
Modified: branches/uml/source/main/cMDEPrecedenceProperty.cc
===================================================================
--- branches/uml/source/main/cMDEPrecedenceProperty.cc 2008-03-13 17:36:19 UTC (rev 2455)
+++ branches/uml/source/main/cMDEPrecedenceProperty.cc 2008-03-14 12:44:29 UTC (rev 2456)
@@ -92,7 +92,10 @@
assert(outfile.is_open());
- outfile << _interesting << ", " << _uses_related_classes << ", ";
+ outfile << _interesting << ", ";
+ if (_uses_related_classes) {
+ outfile << "true" << ", ";
+ } else { outfile << "false" << ", "; }
outfile << "Globally, it is always the case that if " << _expr_p << " holds, ";
outfile << "then "<< _expr_q << " previously held. ";
outfile << std::endl << std::endl;
Modified: branches/uml/source/main/cMDEProperty.cc
===================================================================
--- branches/uml/source/main/cMDEProperty.cc 2008-03-13 17:36:19 UTC (rev 2455)
+++ branches/uml/source/main/cMDEProperty.cc 2008-03-14 12:44:29 UTC (rev 2456)
@@ -61,8 +61,8 @@
void cMDEProperty::evaluate() {
float wit_reward = 0;
float verify_reward = 0;
- std::string cmd;
- std::string work_prop = "properties_that_passed";
+ //std::string cmd;
+ //std::string work_prop = "properties_that_passed";
// print the witness property
Modified: branches/uml/source/main/cMDEPropertyGenerator.cc
===================================================================
--- branches/uml/source/main/cMDEPropertyGenerator.cc 2008-03-13 17:36:19 UTC (rev 2455)
+++ branches/uml/source/main/cMDEPropertyGenerator.cc 2008-03-14 12:44:29 UTC (rev 2456)
@@ -224,7 +224,7 @@
}
if ((m_related_class_mode == 2) && (related == 1)) { val += .5; }
- if ((m_related_class_mode == 3) && (related == 0)) { val =0; }
+ if ((m_related_class_mode == 3) && (related == 0)) { val = 0; }
return val;
@@ -241,6 +241,7 @@
e->setRelatedClassNames(rcs);
e->addUsedClassName(c);
e->addRelatedClassName(c);
+ e->addAttOpName(c + "." + n);
e->setUsesRelatedClasses(true);
std::vector<cMDEExpression*>::iterator exprit;
@@ -266,6 +267,8 @@
e->setRelatedClassNames(rcs);
e->addUsedClassName(a1->getClassName());
e->addRelatedClassName(a1->getClassName());
+ e->addAttOpName(a1->getClassName() + "." + a1->getAttName());
+ e->addAttOpName(a1->getClassName() + "." + a2->getAttName());
e->setUsesRelatedClasses(true);
std::vector<cMDEExpression*>::iterator exprit;
@@ -290,6 +293,7 @@
e->setRelatedClassNames(rcs);
e->addUsedClassName(a1->getClassName());
e->addRelatedClassName(a1->getClassName());
+ e->addAttOpName(a1->getClassName() + "." + a1->getAttName());
e->setUsesRelatedClasses(true);
std::vector<cMDEExpression*>::iterator exprit;
@@ -310,13 +314,24 @@
{
bool val = false;
cMDECompoundExpression* e = new cMDECompoundExpression(e1, e2, op);
-
+
+ // If ats/ops are dependent, then don't create the expression
+ if (areExpressionsAtsOpsDependent(e1, e2)) return false;
+
// determine if it uses related classes
e->setUsesRelatedClasses(areExpressionsRelated(e1, e2));
+
+ // set at op names.
+ e->setAttOpNames(e1->getAtOpNames());
+ std::set<std::string> rcns = e2->getAtOpNames();
+ for (std::set<std::string>::iterator it = rcns.begin(); it!=rcns.end(); it++) {
+ e->addAttOpName(*it);
+ }
+
// set related class names
e->setRelatedClassNames(e1->getRelatedClassNames());
- std::set<std::string> rcns = e2->getRelatedClassNames();
+ rcns = e2->getRelatedClassNames();
for (std::set<std::string>::iterator it = rcns.begin(); it!=rcns.end(); it++) {
e->addRelatedClassName(*it);
}
@@ -414,3 +429,21 @@
return test;
}
+// try a set intersection and check that it is null.
+bool cMDEPropertyGenerator::areExpressionsAtsOpsDependent(cMDEExpression* e1, cMDEExpression* e2)
+{
+ // Get the at op names of expression 1
+ // Get the at op names of expression 2
+ std::set<std::string> atop1 = e1->getAtOpNames();
+ std::set<std::string> atop2 = e2->getAtOpNames();
+ std::set<std::string> results;
+ insert_iterator<std::set<std::string> > it1(results, results.begin());
+
+ // determine if it uses related classes
+ set_intersection(atop1.begin(), atop1.end(), atop2.begin(), atop2.end(), it1);
+
+ // If the set is empty then the expressions are independent.
+ if (results.size() == 0) return false;
+
+ return true;
+}
Modified: branches/uml/source/main/cMDEPropertyGenerator.h
===================================================================
--- branches/uml/source/main/cMDEPropertyGenerator.h 2008-03-13 17:36:19 UTC (rev 2455)
+++ branches/uml/source/main/cMDEPropertyGenerator.h 2008-03-14 12:44:29 UTC (rev 2456)
@@ -100,6 +100,8 @@
bool relativeMoveExpressionR(int x) { return relativeMoveIndex(expressions, expression_r, x); }
bool absoluteMoveExpressionR(int x) { return absoluteMoveIndex(expressions, expression_r, x); }
bool areExpressionsRelated(cMDEExpression*, cMDEExpression*);
+ bool areExpressionsAtsOpsDependent(cMDEExpression*, cMDEExpression*);
+
bool ANDExpressions();
bool ORExpressions();
Modified: branches/uml/source/main/cMDEResponseProperty.cc
===================================================================
--- branches/uml/source/main/cMDEResponseProperty.cc 2008-03-13 17:36:19 UTC (rev 2455)
+++ branches/uml/source/main/cMDEResponseProperty.cc 2008-03-14 12:44:29 UTC (rev 2456)
@@ -78,7 +78,10 @@
outfile.open (_properties.c_str(), std::ios_base::app);
assert(outfile.is_open());
- outfile << _interesting << ", " << _uses_related_classes << ", ";
+ outfile << _interesting << ", ";
+ if (_uses_related_classes) {
+ outfile << "true" << ", ";
+ } else { outfile << "false" << ", "; }
outfile << "Globally, it is always the case that if " << _expr_p << " holds, ";
outfile << "then "<< _expr_q << " eventually holds. ";
outfile << std::endl << std::endl;
Modified: branches/uml/source/main/cMDESimpleOperationExpression.h
===================================================================
--- branches/uml/source/main/cMDESimpleOperationExpression.h 2008-03-13 17:36:19 UTC (rev 2455)
+++ branches/uml/source/main/cMDESimpleOperationExpression.h 2008-03-14 12:44:29 UTC (rev 2456)
@@ -25,6 +25,7 @@
std::string getInEnglish() { return (_op_class + "." + _op_name + "()"); }
std::string getInPromela() { return (_op_class + "_q??[" + _op_name + "]"); }
std::set<std::string> getRelatedClasses() { return _related_classes; }
+ std::string getOpName() { return _op_name; }
// set functions
void setRelatedClasses(std::set<std::string> s) { _related_classes = s; }
Modified: branches/uml/source/main/cMDEUniversalProperty.cc
===================================================================
--- branches/uml/source/main/cMDEUniversalProperty.cc 2008-03-13 17:36:19 UTC (rev 2455)
+++ branches/uml/source/main/cMDEUniversalProperty.cc 2008-03-14 12:44:29 UTC (rev 2456)
@@ -92,7 +92,10 @@
outfile.open (_properties.c_str(), std::ios_base::app);
assert(outfile.is_open());
- outfile << _interesting << ", " << _uses_related_classes << ", ";
+ outfile << _interesting << ", ";
+ if (_uses_related_classes) {
+ outfile << "true" << ", ";
+ } else { outfile << "false" << ", "; }
outfile << "Globally, it is always the case that " << _expr_p << " holds. ";
outfile << std::endl << std::endl;
Modified: branches/uml/source/main/cUMLModel.cc
===================================================================
--- branches/uml/source/main/cUMLModel.cc 2008-03-13 17:36:19 UTC (rev 2455)
+++ branches/uml/source/main/cUMLModel.cc 2008-03-14 12:44:29 UTC (rev 2456)
@@ -561,12 +561,26 @@
// create both an equality and an inequality expression
temp2 = a.attribute_values[k];
- gen->addSimpleAttValExpression(a1, temp2, "==", c.getAssociatedClasses());
- gen->addSimpleAttValExpression(a1, temp2, "!=", c.getAssociatedClasses());
- gen->addSimpleAttValExpression(a1, temp2, ">", c.getAssociatedClasses());
- gen->addSimpleAttValExpression(a1, temp2, ">=", c.getAssociatedClasses());
- gen->addSimpleAttValExpression(a1, temp2, "<=", c.getAssociatedClasses());
- gen->addSimpleAttValExpression(a1, temp2, "<", c.getAssociatedClasses());
+
+ // Can't be less than the first value.
+ if (k==0) {
+ gen->addSimpleAttValExpression(a1, temp2, "==", c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, "!=", c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, ">", c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, ">=", c.getAssociatedClasses());
+ } else if (k==(a.attribute_values.size() -1)) {
+ gen->addSimpleAttValExpression(a1, temp2, "==", c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, "!=", c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, "<=", c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, "<", c.getAssociatedClasses());
+ } else {
+ gen->addSimpleAttValExpression(a1, temp2, "==", c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, "!=", c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, "<=", c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, "<", c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, ">", c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, ">=", c.getAssociatedClasses());
+ }
}
} else if ((at_type == "bool")||(at_type == "boolean")) {
More information about the Avida-cvs
mailing list