[Avida-SVN] r2397 - in branches/uml: Avida.xcodeproj source/cpu source/main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Fri Feb 29 07:16:12 PST 2008
Author: hjg
Date: 2008-02-29 10:16:12 -0500 (Fri, 29 Feb 2008)
New Revision: 2397
Added:
branches/uml/source/main/cMDECompoundExpression.h
branches/uml/source/main/cMDEExpressionAttribute.h
branches/uml/source/main/cMDESimpleAttAttExpression.h
branches/uml/source/main/cMDESimpleAttValExpression.h
branches/uml/source/main/cMDESimpleExpression.h
branches/uml/source/main/cMDESimpleOperationExpression.h
Modified:
branches/uml/Avida.xcodeproj/project.pbxproj
branches/uml/source/cpu/cHardwareCPU.cc
branches/uml/source/main/cMDEAbsenceProperty.cc
branches/uml/source/main/cMDEExistenceProperty.cc
branches/uml/source/main/cMDEExistenceProperty.h
branches/uml/source/main/cMDEExpression.h
branches/uml/source/main/cMDEProperty.h
branches/uml/source/main/cMDEPropertyGenerator.cc
branches/uml/source/main/cMDEPropertyGenerator.h
branches/uml/source/main/cPopulation.h
branches/uml/source/main/cUMLModel.cc
branches/uml/source/main/cUMLModel.h
Log:
Added an expression hierarchy that enables a developer to determine if an expression is interesting.
Modified: branches/uml/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/uml/Avida.xcodeproj/project.pbxproj 2008-02-29 01:04:18 UTC (rev 2396)
+++ branches/uml/Avida.xcodeproj/project.pbxproj 2008-02-29 15:16:12 UTC (rev 2397)
@@ -32,6 +32,13 @@
3E26D90C0CFA0453009616CC /* cMDEProperty.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3E26D9040CFA0453009616CC /* cMDEProperty.h */; };
3E26D90D0CFA0453009616CC /* cMDEUniversalProperty.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3E26D9050CFA0453009616CC /* cMDEUniversalProperty.cc */; };
3E26D90E0CFA0453009616CC /* cMDEUniversalProperty.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3E26D9060CFA0453009616CC /* cMDEUniversalProperty.h */; };
+ 3E36C88A0D78538500802E27 /* cMDECompoundExpression.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3E36C8830D78538500802E27 /* cMDECompoundExpression.h */; };
+ 3E36C88B0D78538500802E27 /* cMDEExpression.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3E36C8840D78538500802E27 /* cMDEExpression.h */; };
+ 3E36C88C0D78538500802E27 /* cMDEExpressionAttribute.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3E36C8850D78538500802E27 /* cMDEExpressionAttribute.h */; };
+ 3E36C88D0D78538500802E27 /* cMDESimpleAttAttExpression.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3E36C8860D78538500802E27 /* cMDESimpleAttAttExpression.h */; };
+ 3E36C88E0D78538500802E27 /* cMDESimpleAttValExpression.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3E36C8870D78538500802E27 /* cMDESimpleAttValExpression.h */; };
+ 3E36C88F0D78538500802E27 /* cMDESimpleExpression.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3E36C8880D78538500802E27 /* cMDESimpleExpression.h */; };
+ 3E36C8900D78538500802E27 /* cMDESimpleOperationExpression.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3E36C8890D78538500802E27 /* cMDESimpleOperationExpression.h */; };
3E54F4170CFB147300FC5B63 /* cMDEProperty.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3E54F4160CFB147300FC5B63 /* cMDEProperty.cc */; };
3E849FD60D4A7ECB003DE1BF /* cMDEExistenceProperty.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3E849FD50D4A7ECB003DE1BF /* cMDEExistenceProperty.h */; };
3E849FD80D4A7F04003DE1BF /* cMDEResponseProperty.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3E849FD70D4A7F04003DE1BF /* cMDEResponseProperty.cc */; };
@@ -350,6 +357,13 @@
3E849FF00D4A8331003DE1BF /* cMDEPrecedenceProperty.h in CopyFiles */,
3E97D6CA0D63307E00FA7028 /* cMDEExpression.h in CopyFiles */,
3E13BB360D6F49BD0014F96F /* cMDEPropertyGenerator.h in CopyFiles */,
+ 3E36C88A0D78538500802E27 /* cMDECompoundExpression.h in CopyFiles */,
+ 3E36C88B0D78538500802E27 /* cMDEExpression.h in CopyFiles */,
+ 3E36C88C0D78538500802E27 /* cMDEExpressionAttribute.h in CopyFiles */,
+ 3E36C88D0D78538500802E27 /* cMDESimpleAttAttExpression.h in CopyFiles */,
+ 3E36C88E0D78538500802E27 /* cMDESimpleAttValExpression.h in CopyFiles */,
+ 3E36C88F0D78538500802E27 /* cMDESimpleExpression.h in CopyFiles */,
+ 3E36C8900D78538500802E27 /* cMDESimpleOperationExpression.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -387,6 +401,13 @@
3E26D9040CFA0453009616CC /* cMDEProperty.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMDEProperty.h; sourceTree = "<group>"; };
3E26D9050CFA0453009616CC /* cMDEUniversalProperty.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cMDEUniversalProperty.cc; sourceTree = "<group>"; };
3E26D9060CFA0453009616CC /* cMDEUniversalProperty.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMDEUniversalProperty.h; sourceTree = "<group>"; };
+ 3E36C8830D78538500802E27 /* cMDECompoundExpression.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMDECompoundExpression.h; sourceTree = "<group>"; };
+ 3E36C8840D78538500802E27 /* cMDEExpression.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMDEExpression.h; sourceTree = "<group>"; };
+ 3E36C8850D78538500802E27 /* cMDEExpressionAttribute.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMDEExpressionAttribute.h; sourceTree = "<group>"; };
+ 3E36C8860D78538500802E27 /* cMDESimpleAttAttExpression.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMDESimpleAttAttExpression.h; sourceTree = "<group>"; };
+ 3E36C8870D78538500802E27 /* cMDESimpleAttValExpression.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMDESimpleAttValExpression.h; sourceTree = "<group>"; };
+ 3E36C8880D78538500802E27 /* cMDESimpleExpression.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMDESimpleExpression.h; sourceTree = "<group>"; };
+ 3E36C8890D78538500802E27 /* cMDESimpleOperationExpression.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMDESimpleOperationExpression.h; sourceTree = "<group>"; };
3E54F4160CFB147300FC5B63 /* cMDEProperty.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cMDEProperty.cc; sourceTree = "<group>"; };
3E849FD50D4A7ECB003DE1BF /* cMDEExistenceProperty.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMDEExistenceProperty.h; sourceTree = "<group>"; };
3E849FD70D4A7F04003DE1BF /* cMDEResponseProperty.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cMDEResponseProperty.cc; sourceTree = "<group>"; };
@@ -1421,6 +1442,13 @@
3E26D9040CFA0453009616CC /* cMDEProperty.h */,
3E26D9050CFA0453009616CC /* cMDEUniversalProperty.cc */,
3E26D9060CFA0453009616CC /* cMDEUniversalProperty.h */,
+ 3E36C8830D78538500802E27 /* cMDECompoundExpression.h */,
+ 3E36C8840D78538500802E27 /* cMDEExpression.h */,
+ 3E36C8850D78538500802E27 /* cMDEExpressionAttribute.h */,
+ 3E36C8860D78538500802E27 /* cMDESimpleAttAttExpression.h */,
+ 3E36C8870D78538500802E27 /* cMDESimpleAttValExpression.h */,
+ 3E36C8880D78538500802E27 /* cMDESimpleExpression.h */,
+ 3E36C8890D78538500802E27 /* cMDESimpleOperationExpression.h */,
3EDCA0150C46C9B70078778D /* cUMLModel.cc */,
3EDCA0160C46C9B70078778D /* cUMLModel.h */,
3ED30B200D43D73D00B3E0A7 /* cUMLClass.cc */,
Modified: branches/uml/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.cc 2008-02-29 01:04:18 UTC (rev 2396)
+++ branches/uml/source/cpu/cHardwareCPU.cc 2008-02-29 15:16:12 UTC (rev 2397)
@@ -5108,12 +5108,13 @@
// Call a function on the model to create this property.
// Currently it just uses p
std::string s = organism->getUMLModel()->getPropertyGenerator()->getPstring();
+ float intp = organism->getUMLModel()->getPropertyGenerator()->getPInterest();
if (s != "<null>" ) {
// std::string n = organism->getStateDiagram()->getName();
// s = n + "." + s;
// val = organism->getUMLModel()->addAbsenceProperty(s);
- val = m_world->GetPopulation().getUMLModel()->getPropertyGenerator()->addAbsenceProperty(s);
+ val = m_world->GetPopulation().getUMLModel()->getPropertyGenerator()->addAbsenceProperty(s, intp);
}
organism->getUMLModel()->getPropertyGenerator()->addPropertyReward(val);
@@ -5126,12 +5127,13 @@
float val = 0;
// Call a function on the model to create this property.
std::string s = organism->getUMLModel()->getPropertyGenerator()->getPstring();
+ float intp = organism->getUMLModel()->getPropertyGenerator()->getPInterest();
if (s != "<null>" ) {
// std::string n = organism->getStateDiagram()->getName();
// s = n + "." + s;
// val = organism->getUMLModel()->addUniversalProperty(s);
- val = m_world->GetPopulation().getUMLModel()->getPropertyGenerator()->addUniversalProperty(s);
+ val = m_world->GetPopulation().getUMLModel()->getPropertyGenerator()->addUniversalProperty(s, intp);
}
organism->getUMLModel()->getPropertyGenerator()->addPropertyReward(val);
@@ -5144,12 +5146,13 @@
float val = 0;
// Call a function on the model to create this property.
std::string s = organism->getUMLModel()->getPropertyGenerator()->getPstring();
+ float intp = organism->getUMLModel()->getPropertyGenerator()->getPInterest();
if (s != "<null>" ) {
// std::string n = organism->getStateDiagram()->getName();
// s = n + "." + s;
// val = organism->getUMLModel()->addExistenceProperty(s);
- val = m_world->GetPopulation().getUMLModel()->getPropertyGenerator()->addExistenceProperty(s);
+ val = m_world->GetPopulation().getUMLModel()->getPropertyGenerator()->addExistenceProperty(s, intp);
}
organism->getUMLModel()->getPropertyGenerator()->addPropertyReward(val);
@@ -5163,9 +5166,12 @@
// Call a function on the model to create this property.
std::string p = organism->getUMLModel()->getPropertyGenerator()->getPstring();
std::string q = organism->getUMLModel()->getPropertyGenerator()->getQstring();
+ float intp = organism->getUMLModel()->getPropertyGenerator()->getPInterest();
+ float intq = organism->getUMLModel()->getPropertyGenerator()->getQInterest();
+ float inttotal = intp + intq;
if (p != q) {
- val = m_world->GetPopulation().getUMLModel()->getPropertyGenerator()->addPrecedenceProperty(p, q);
+ val = m_world->GetPopulation().getUMLModel()->getPropertyGenerator()->addPrecedenceProperty(p, q, inttotal);
}
organism->getUMLModel()->getPropertyGenerator()->addPropertyReward(val);
@@ -5179,9 +5185,12 @@
// Call a function on the model to create this property.
std::string p = organism->getUMLModel()->getPropertyGenerator()->getPstring();
std::string q = organism->getUMLModel()->getPropertyGenerator()->getQstring();
+ float intp = organism->getUMLModel()->getPropertyGenerator()->getPInterest();
+ float intq = organism->getUMLModel()->getPropertyGenerator()->getQInterest();
+ float inttotal = intp + intq;
if (p != q) {
- val = m_world->GetPopulation().getUMLModel()->getPropertyGenerator()->addResponseProperty(p, q);
+ val = m_world->GetPopulation().getUMLModel()->getPropertyGenerator()->addResponseProperty(p, q, inttotal);
}
organism->getUMLModel()->getPropertyGenerator()->addPropertyReward(val);
@@ -5271,4 +5280,4 @@
return (organism->getUMLModel()->getPropertyGenerator()->ORExpressions());
}
-
\ No newline at end of file
+
Modified: branches/uml/source/main/cMDEAbsenceProperty.cc
===================================================================
--- branches/uml/source/main/cMDEAbsenceProperty.cc 2008-02-29 01:04:18 UTC (rev 2396)
+++ branches/uml/source/main/cMDEAbsenceProperty.cc 2008-02-29 15:16:12 UTC (rev 2397)
@@ -89,4 +89,5 @@
outfile.close();
-}
\ No newline at end of file
+}
+
Added: branches/uml/source/main/cMDECompoundExpression.h
===================================================================
--- branches/uml/source/main/cMDECompoundExpression.h (rev 0)
+++ branches/uml/source/main/cMDECompoundExpression.h 2008-02-29 15:16:12 UTC (rev 2397)
@@ -0,0 +1,97 @@
+#ifndef _C_MDECOMPOUDEXPRESSION_H_
+#define _C_MDECOMPOUDEXPRESSION_H_
+/*
+ * cMDECompoundExpression.h
+ *
+ *
+ *
+ */
+#include "cMDEExpression.h"
+#include <string>
+#include <iostream>
+#include <cassert>
+#include <set>
+
+
+
+class cMDECompoundExpression : public cMDEExpression{
+
+public:
+ cMDECompoundExpression (cMDEExpression* e1,
+ cMDEExpression* e2,
+ std::string op) {
+ _exp_1 = e1;
+ _exp_2 = e2;
+ // Op must be either && or ||
+ _exp_op = op;
+ _expr = getInEnglish();
+ }
+// ~cMDECompoundExpression() {}
+
+ // get functions
+ std::string getInEnglish() {
+ std::string s;
+ s = "(" + _exp_1->getInEnglish() + " " + _exp_op + " ";
+ s = s + _exp_2->getInEnglish() + ")";
+ return (s); }
+ std::string getInPromela() {
+ std::string s;
+ s = "(" + _exp_1->getInPromela() + " " + _exp_op + " ";
+ s = s + _exp_2->getInPromela() + ")";
+ return (s);}
+
+ // This function is used to see if an expression uses a given attribute
+ bool usesAttribute(std::string s) {
+ return (_exp_1->usesAttribute(s) || _exp_2->usesAttribute(s)); }
+
+ // This function is used to see if an expression uses a given operation
+ bool usesOperation(std::string s) {
+ return (_exp_1->usesOperation(s) || _exp_2->usesOperation(s)); }
+
+ // This function returns the number of ANDs in a given expression
+ int numANDs() {
+ int num = 0;
+ if (_exp_op == "&&") num = 1;
+ return (num + _exp_1->numANDs() + _exp_2->numANDs());
+ }
+
+ // This function returns the number of ORs in a given expression
+ int numORs() {
+ int num = 0;
+ if (_exp_op == "||") num = 1;
+ return (num + _exp_1->numANDs() + _exp_2->numANDs());
+ }
+
+ void interestingExpressionEval() {
+ // Currently, the interesting reward is evaluated based on:
+ // - whether it includes one of the significant variables/operations
+ float temp;
+
+ // 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");
+
+ // Increase interesting based on the number of ANDs
+ temp += _exp_1->numANDs() + _exp_2->numANDs();
+
+ // Decrease interesting based on the number of ORs
+ temp = temp - ((_exp_1->numORs())/2) - ((_exp_2->numORs())/2);
+
+ _interesting = temp;
+
+ }
+
+ //std::set<std::string> getRelatedClasses() { return _related_classes; }
+
+
+protected:
+ cMDEExpression* _exp_1;
+ cMDEExpression* _exp_2;
+ std::string _exp_op;
+
+};
+
+
+
+
+#endif
Modified: branches/uml/source/main/cMDEExistenceProperty.cc
===================================================================
--- branches/uml/source/main/cMDEExistenceProperty.cc 2008-02-29 01:04:18 UTC (rev 2396)
+++ branches/uml/source/main/cMDEExistenceProperty.cc 2008-02-29 15:16:12 UTC (rev 2397)
@@ -61,4 +61,5 @@
outfile.close();
-}
\ No newline at end of file
+}
+
Modified: branches/uml/source/main/cMDEExistenceProperty.h
===================================================================
--- branches/uml/source/main/cMDEExistenceProperty.h 2008-02-29 01:04:18 UTC (rev 2396)
+++ branches/uml/source/main/cMDEExistenceProperty.h 2008-02-29 15:16:12 UTC (rev 2397)
@@ -32,8 +32,6 @@
std::string getPropertyType() { return "Existence"; }
std::string getPropertyParameters() { return _expr_p; }
-
-
private:
std::string _expr_p;
};
Modified: branches/uml/source/main/cMDEExpression.h
===================================================================
--- branches/uml/source/main/cMDEExpression.h 2008-02-29 01:04:18 UTC (rev 2396)
+++ branches/uml/source/main/cMDEExpression.h 2008-02-29 15:16:12 UTC (rev 2397)
@@ -18,14 +18,36 @@
class cMDEExpression{
public:
+
+
+ virtual ~cMDEExpression() {}
+
// A function that returns an expression
std::string getExpr() const { return _expr; }
- void setExpr(std::string s) { _expr = s; }
- bool operator==(const cMDEExpression that) {
+
+ bool operator==(const cMDEExpression &that) const {
return (_expr == that.getExpr());
}
- // the related classes are the classes that this expression may be
+ virtual std::string getInEnglish() =0;
+ virtual std::string getInPromela() =0;
+
+ // This function is used to see if an expression uses a given attribute
+ virtual bool usesAttribute(std::string) { return false; }
+
+ // This function is used to see if an expression uses a given operation
+ virtual bool usesOperation(std::string) { return false; }
+
+ // This function calculates the number of ANDs used by a given expression
+ virtual int numANDs() { return 0; }
+
+ // This function calculates the number of ORs used by a given expression
+ virtual int numORs() { return 0; }
+
+ virtual void interestingExpressionEval() { _interesting = 0; }
+ virtual float getInterestingExpressionEval() { return _interesting; }
+
+/* // the related classes are the classes that this expression may be
// related to.
void addRelatedClass(std::string c) { _related_classes.insert(c); }
void setRelatedClasses(std::set<std::string> s) { _related_classes = s; }
@@ -38,13 +60,14 @@
void addClass(std::string c) {_class_names.insert(c); }
bool isClass(std::string c) {
return false; //find(_class_names.begin(), _class_names.end(), c)
- }
+ }*/
protected:
std::string _expr;
- std::set<std::string> _related_classes;
- std::set<std::string> _class_names;
+ float _interesting;
+// std::set<std::string> _related_classes;
+// std::set<std::string> _class_names;
// Ok, eventually, to do more complex expression creation, we need to get it to check the types...
// std::string _types;
Added: branches/uml/source/main/cMDEExpressionAttribute.h
===================================================================
--- branches/uml/source/main/cMDEExpressionAttribute.h (rev 0)
+++ branches/uml/source/main/cMDEExpressionAttribute.h 2008-02-29 15:16:12 UTC (rev 2397)
@@ -0,0 +1,46 @@
+#ifndef _C_MDEEXPRESSIONATTRIBUTE_H_
+#define _C_MDEEXPRESSIONATTRIBUTE_H_
+/*
+ * cMDEExpressionAttribute.h
+ *
+ *
+ *
+ */
+#include <string>
+#include <iostream>
+#include <cassert>
+#include <set>
+
+
+
+class cMDEExpressionAttribute {
+
+public:
+ cMDEExpressionAttribute() {}
+ ~cMDEExpressionAttribute() {}
+
+ cMDEExpressionAttribute (std::string n, std::string t, std::string c) {
+ _att_name =n; _att_type = t; _att_class=c; }
+
+ // get functions
+ std::string getInEnglish() { return (_att_class + "." + _att_name); }
+ std::string getInPromela() { return (_att_class + "_V." + _att_name); }
+ std::set<std::string> getRelatedClasses() { return _related_classes; }
+ std::string getAttName() { return _att_name; }
+
+ // set functions
+ void setRelatedClasses(std::set<std::string> s) { _related_classes = s; }
+
+
+protected:
+ std::string _att_name;
+ std::string _att_type;
+ std::string _att_class;
+ std::set<std::string> _related_classes;
+
+};
+
+
+
+
+#endif
Modified: branches/uml/source/main/cMDEProperty.h
===================================================================
--- branches/uml/source/main/cMDEProperty.h 2008-02-29 01:04:18 UTC (rev 2396)
+++ branches/uml/source/main/cMDEProperty.h 2008-02-29 15:16:12 UTC (rev 2397)
@@ -34,10 +34,18 @@
virtual void evaluate();
void setEvaluationInformation (float eval) { _reward = eval; }
float getEvaluationInformation() { return _reward; }
+
+ // These functions get and set how interesting a property is. This
+ // information is calculated by the property generator when
+ // the property is created.
+ void setInterestingProperty(float inter) {_interesting = inter; }
+ float getInteresting() { return _interesting; }
+
protected:
std::string _scope;
float _reward;
+ float _interesting;
};
Modified: branches/uml/source/main/cMDEPropertyGenerator.cc
===================================================================
--- branches/uml/source/main/cMDEPropertyGenerator.cc 2008-02-29 01:04:18 UTC (rev 2396)
+++ branches/uml/source/main/cMDEPropertyGenerator.cc 2008-02-29 15:16:12 UTC (rev 2397)
@@ -39,21 +39,32 @@
mdeprops.erase(it++);
delete p;
}
+
+ /*for( std::vector<cMDEExpression*>::iterator it = expressions.begin(),
+ exp = expressions.end(); it != exp; )
+ {
+ cMDEExpression* p = *it;
+ delete p;
+ }*/
+
+ //expressions.erase(expressions.begin(), expressions.end());
}
-float cMDEPropertyGenerator::addExistenceProperty(std::string s)
+float cMDEPropertyGenerator::addExistenceProperty(std::string s, float i)
{
// a pointer to the existence property
float val = 0;
+ float interesting = (i + 0)/5; // 0 points for an existence property.
+
cMDEExistenceProperty e(s);
// first, try to find the property
- //
std::set<cMDEProperty*, ltcMDEProperty>::iterator mdepropiter = mdeprops.find(&e);
if (mdepropiter != mdeprops.end()) {
val = (*mdepropiter)->getEvaluationInformation();
+ val += (*mdepropiter)->getInteresting();
} else {
e.evaluate();
val = e.getEvaluationInformation();
@@ -61,24 +72,29 @@
if (val >0) {
m_property_success++;
m_existence_property_success++;
+ e.setInterestingProperty(interesting);
} else {
m_property_failure++;
m_existence_property_failure++;
+ e.setInterestingProperty(0);
}
}
return val;
}
-float cMDEPropertyGenerator::addAbsenceProperty(std::string s)
+float cMDEPropertyGenerator::addAbsenceProperty(std::string s, float i)
{
// a pointer to the absence property
float val = 0;
+ float interesting = (i + 2)/5; // 2 points for an absence property.
+
cMDEAbsenceProperty e(s);
std::set<cMDEProperty*, ltcMDEProperty>::iterator mdepropiter = mdeprops.find(&e);
if (mdepropiter != mdeprops.end()) {
val = (*mdepropiter)->getEvaluationInformation();
+ val += (*mdepropiter)->getInteresting();
} else {
e.evaluate();
val = e.getEvaluationInformation();
@@ -86,9 +102,11 @@
if (val >0) {
m_property_success++;
m_absence_property_success++;
+ e.setInterestingProperty(interesting);
} else {
m_property_failure++;
m_absence_property_failure++;
+ e.setInterestingProperty(0);
}
}
@@ -96,15 +114,18 @@
}
-float cMDEPropertyGenerator::addUniversalProperty(std::string s)
+float cMDEPropertyGenerator::addUniversalProperty(std::string s, float i)
{
// a pointer to the universal property
float val = 0;
+ float interesting = (i + 2)/5; // 2 points for a universal property.
+
cMDEUniversalProperty e(s);
std::set<cMDEProperty*, ltcMDEProperty>::iterator mdepropiter = mdeprops.find(&e);
if (mdepropiter != mdeprops.end()) {
val = (*mdepropiter)->getEvaluationInformation();
+ val += (*mdepropiter)->getInteresting();
} else {
e.evaluate();
val = e.getEvaluationInformation();
@@ -112,9 +133,11 @@
if (val >0) {
m_property_success++;
m_universal_property_success++;
+ e.setInterestingProperty(interesting);
} else {
m_property_failure++;
m_universal_property_failure++;
+ e.setInterestingProperty(0);
}
}
@@ -123,89 +146,18 @@
}
-
-// Check if the expression exists in the vector. If not, add it.
-bool cMDEPropertyGenerator::addExpression(std::string s, std::set<std::string> t)
-{
- bool val = false;
- cMDEExpression e;
- e.setExpr(s);
- e.setRelatedClasses(t);
- std::vector<cMDEExpression>::iterator exprit;
- exprit = find(expressions.begin(), expressions.end(), e);
- if (exprit == expressions.end()) {
- expressions.push_back(e);
- val = true;
- }
- return val;
-}
-
-// AND expressions p & q to create a new expression
-// return true if this is a new expression
-// return false otherwise
-bool cMDEPropertyGenerator::ANDExpressions()
+float cMDEPropertyGenerator::addResponseProperty(std::string s1, std::string s2, float i)
{
- bool val = false;
- std::set<std::string> class_names, class_names2;
- std::set<std::string>::iterator c;
- std::string totalstring;
- cMDEExpression p, q;
-
- if (expression_p != expression_q){
- p = getP();
- q = getQ();
- totalstring = "(" + p.getExpr() + " && " + q.getExpr() + ")";
-
- class_names = p.getRelatedClasses();
- class_names2 = q.getRelatedClasses();
-
- for (c=class_names2.begin(); c != class_names2.end(); c++) {
- class_names.insert(*c);
- }
-
- val = addExpression(totalstring, class_names);
- }
- return (val);
-}
-
-// OR expressions p & q to create a new expression
-// return true if this is a new expression
-// return false otherwise
-bool cMDEPropertyGenerator::ORExpressions()
-{
-
- bool val = false;
- std::set<std::string> class_names, class_names2;
- std::set<std::string>::iterator c;
- std::string totalstring;
- cMDEExpression p, q;
-
- if (expression_p != expression_q){
- p = getP();
- q = getQ();
-
- class_names = p.getRelatedClasses();
- class_names2 = q.getRelatedClasses();
-
- for (c=class_names2.begin(); c != class_names2.end(); c++) {
- class_names.insert(*c);
- }
-
- totalstring = "(" + p.getExpr() + " || " + q.getExpr() + ")";
- val = addExpression(totalstring, class_names);
- }
- return (val);
-}
-
-float cMDEPropertyGenerator::addResponseProperty(std::string s1, std::string s2)
-{
// a pointer to the universal property
float val = 0;
+ float interesting = (i + 1)/5; // 1 points for a response property.
+
cMDEResponseProperty e(s1, s2);
std::set<cMDEProperty*, ltcMDEProperty>::iterator mdepropiter = mdeprops.find(&e);
if (mdepropiter != mdeprops.end()) {
val = (*mdepropiter)->getEvaluationInformation();
+ val += (*mdepropiter)->getInteresting();
} else {
e.evaluate();
val = e.getEvaluationInformation();
@@ -213,33 +165,42 @@
if (val >0) {
m_property_success++;
m_response_property_success++;
+ e.setInterestingProperty(interesting);
} else {
m_property_failure++;
m_response_property_failure++;
+ e.setInterestingProperty(0);
}
}
return val;
}
-float cMDEPropertyGenerator::addPrecedenceProperty(std::string s1, std::string s2)
+float cMDEPropertyGenerator::addPrecedenceProperty(std::string s1, std::string s2, float i)
{
// a pointer to the universal property
float val = 0;
+ float interesting = (i + 1)/5; // 1 points for a precedence property.
+
cMDEPrecedenceProperty e(s1, s2);
std::set<cMDEProperty*, ltcMDEProperty>::iterator mdepropiter = mdeprops.find(&e);
if (mdepropiter != mdeprops.end()) {
val = (*mdepropiter)->getEvaluationInformation();
+ val += (*mdepropiter)->getInteresting();
} else {
e.evaluate();
val = e.getEvaluationInformation();
+
mdeprops.insert (new cMDEPrecedenceProperty(e));
if (val >0) {
m_property_success++;
m_precedence_property_success++;
+ e.setInterestingProperty(interesting);
} else {
m_property_failure++;
m_precedence_property_failure++;
+ e.setInterestingProperty(0);
+
}
}
return val;
@@ -247,12 +208,123 @@
}
+bool cMDEPropertyGenerator::addSimpleOperationExpression(std::string n, std::string c)
+{
+ bool val = false;
+ cMDESimpleOperationExpression* e = new cMDESimpleOperationExpression(n, c);
+ // set related classes?
+ //
+ std::vector<cMDEExpression*>::iterator exprit;
+ exprit = find(expressions.begin(), expressions.end(), e);
+ if (exprit == expressions.end()) {
+ expressions.push_back(e);
+ val = true;
+ } else {
+ delete e;
+ }
+ return val;
+}
+
+
+bool cMDEPropertyGenerator::addSimpleAttAttExpression(cMDEExpressionAttribute* a1,
+ cMDEExpressionAttribute* a2,
+ std::string op)
+{
+ bool val = false;
+ cMDESimpleAttAttExpression* e = new cMDESimpleAttAttExpression(a1, a2, op);
+ // set related classes?
+ //
+ std::vector<cMDEExpression*>::iterator exprit;
+ exprit = find(expressions.begin(), expressions.end(), e);
+ if (exprit == expressions.end()) {
+ expressions.push_back(e);
+ val = true;
+ } else {
+ delete e;
+ }
+ return val;
+}
+
+bool cMDEPropertyGenerator::addSimpleAttValExpression(cMDEExpressionAttribute* a1,
+ std::string value,
+ std::string op)
+{
+ bool val = false;
+ cMDESimpleAttValExpression* e = new cMDESimpleAttValExpression(a1, value, op);
+ // set related classes?
+ //
+ std::vector<cMDEExpression*>::iterator exprit;
+ exprit = find(expressions.begin(), expressions.end(), e);
+ if (exprit == expressions.end()) {
+ expressions.push_back(e);
+ val = true;
+ } else {
+ delete e;
+ }
+ return val;
+}
+
+bool cMDEPropertyGenerator::addCompoundExpression(cMDEExpression* e1,
+ cMDEExpression* e2,
+ std::string op)
+{
+ bool val = false;
+ cMDECompoundExpression* e = new cMDECompoundExpression(e1, e2, op);
+ // set related classes?
+ //
+ std::vector<cMDEExpression*>::iterator exprit;
+ exprit = find(expressions.begin(), expressions.end(), e);
+ if (exprit == expressions.end()) {
+ expressions.push_back(e);
+ val = true;
+ } else {
+ delete e;
+ }
+ return val;
+
+}
+
+
+
+
+// AND expressions p & q to create a new expression
+// return true if this is a new expression
+// return false otherwise
+bool cMDEPropertyGenerator::ANDExpressions()
+{
+ bool val = false;
+
+ if (expression_p != expression_q){
+ val = addCompoundExpression(getP(), getQ(), "&&");
+ }
+ return (val);
+}
+
+// OR expressions p & q to create a new expression
+// return true if this is a new expression
+// return false otherwise
+bool cMDEPropertyGenerator::ORExpressions()
+{
+
+ bool val = false;
+
+ if (expression_p != expression_q){
+ val = addCompoundExpression(getP(), getQ(), "||");
+ }
+ return (val);
+}
+
+
+
+
void cMDEPropertyGenerator::printExpressions()
{
- std::vector<cMDEExpression>::iterator exprit;
+ std::vector<cMDEExpression*>::iterator exprit;
+ int count =0;
for (exprit = expressions.begin(); exprit < expressions.end(); exprit++){
- std::cout << exprit->getExpr() << std::endl;
+ std::cout << count << " " << (*exprit)->getExpr() << std::endl;
+ count++;
}
}
Modified: branches/uml/source/main/cMDEPropertyGenerator.h
===================================================================
--- branches/uml/source/main/cMDEPropertyGenerator.h 2008-02-29 01:04:18 UTC (rev 2396)
+++ branches/uml/source/main/cMDEPropertyGenerator.h 2008-02-29 15:16:12 UTC (rev 2397)
@@ -8,6 +8,11 @@
#include "cMDEResponseProperty.h"
#include "cMDEPrecedenceProperty.h"
#include "cMDEExpression.h"
+#include "cMDEExpressionAttribute.h"
+#include "cMDESimpleOperationExpression.h"
+#include "cMDESimpleAttAttExpression.h"
+#include "cMDESimpleAttValExpression.h"
+#include "cMDECompoundExpression.h"
#include <string>
#include <iostream>
@@ -53,24 +58,41 @@
void addPropertyReward(float x) { m_property_reward += x; }
float getPropertyReward() { return m_property_reward; }
+ bool addSimpleOperationExpression(std::string, std::string);
+ bool addSimpleAttAttExpression(cMDEExpressionAttribute*, cMDEExpressionAttribute*, std::string);
+ bool addSimpleAttValExpression(cMDEExpressionAttribute*, std::string, std::string);
+ bool addCompoundExpression(cMDEExpression*, cMDEExpression*, std::string);
+ void printExpressions();
+
+
// Properties
- float addExistenceProperty(std::string);
- float addAbsenceProperty(std::string);
- float addUniversalProperty(std::string);
- float addResponseProperty(std::string, std::string);
- float addPrecedenceProperty(std::string, std::string);
+ float addExistenceProperty(std::string, float);
+ float addAbsenceProperty(std::string, float);
+ float addUniversalProperty(std::string, float);
+ float addResponseProperty(std::string, std::string, float);
+ float addPrecedenceProperty(std::string, std::string, float);
bool addExpression(std::string, std::set<std::string>);
// bool relatedExpressions(cMDEExpression*, cMDEExpression*);
- void printExpressions();
- cMDEExpression getP() { return expressions[expression_p]; }
- cMDEExpression getQ() { return (expressions[expression_q]); }
- cMDEExpression getR() { return (expressions[expression_r]); }
- std::string getPstring() { return (expressions[expression_p]).getExpr(); }
- std::string getQstring() { return (expressions[expression_q]).getExpr(); }
- std::string getRstring() { return (expressions[expression_r]).getExpr(); }
+ cMDEExpression* getP() { return expressions[expression_p]; }
+ cMDEExpression* getQ() { return (expressions[expression_q]); }
+ cMDEExpression* getR() { return (expressions[expression_r]); }
+ std::string getPstring() { return (expressions[expression_p])->getExpr(); }
+ std::string getQstring() { return (expressions[expression_q])->getExpr(); }
+ std::string getRstring() { return (expressions[expression_r])->getExpr(); }
+
+ float getPInterest() {
+ (expressions[expression_p])->interestingExpressionEval();
+ return (expressions[expression_p])->getInterestingExpressionEval() ; }
+ float getQInterest() {
+ (expressions[expression_q])->interestingExpressionEval();
+ return (expressions[expression_q])->getInterestingExpressionEval() ; }
+ float getRInterest() {
+ (expressions[expression_r])->interestingExpressionEval();
+ return (expressions[expression_r])->getInterestingExpressionEval() ; }
+
bool relativeMoveExpressionP(int x) { return relativeMoveIndex(expressions, expression_p, x); }
bool absoluteMoveExpressionP(int x) { return absoluteMoveIndex(expressions, expression_p, x); }
bool relativeMoveExpressionQ(int x) { return relativeMoveIndex(expressions, expression_q, x); }
@@ -80,6 +102,7 @@
bool ANDExpressions();
bool ORExpressions();
+
template <typename T>
bool absoluteMoveIndex (T x, int &y, int z)
{
@@ -139,7 +162,7 @@
// vector of expressions
- std::vector<cMDEExpression> expressions;
+ std::vector<cMDEExpression*> expressions;
};
Added: branches/uml/source/main/cMDESimpleAttAttExpression.h
===================================================================
--- branches/uml/source/main/cMDESimpleAttAttExpression.h (rev 0)
+++ branches/uml/source/main/cMDESimpleAttAttExpression.h 2008-02-29 15:16:12 UTC (rev 2397)
@@ -0,0 +1,63 @@
+#ifndef _C_MDESIMPLEATTATTEXPRESSION_H_
+#define _C_MDESIMPLEATTATTEXPRESSION_H_
+/*
+ * cMDESimpleAttAttExpression.h
+ *
+ *
+ * Created by Heather Goldsby on 2/28/2008.
+ * A class used to represent simple expressions that are created by relating two
+ * attributes.
+ *
+ */
+#include "cMDEExpression.h"
+#include "cMDEExpressionAttribute.h"
+#include <string>
+#include <iostream>
+#include <cassert>
+#include <set>
+
+
+
+class cMDESimpleAttAttExpression : public cMDEExpression{
+
+public:
+ cMDESimpleAttAttExpression (cMDEExpressionAttribute* a1,
+ cMDEExpressionAttribute* a2,
+ std::string op) {
+ _att_1 = a1;
+ _att_2 = a2;
+ _att_operator = op;
+ _expr = getInEnglish();
+ }
+ ~cMDESimpleAttAttExpression() {}
+
+ // get functions
+ std::string getInEnglish() {
+ return (_att_1->getInEnglish() + " " + _att_operator + " " + _att_2->getInEnglish()); }
+ std::string getInPromela() {
+ return (_att_1->getInPromela() + " " + _att_operator + " " + _att_2->getInPromela()); }
+
+ // Check to see if the Expression uses a specific attribute.
+ bool usesAttribute(std::string s) {
+ if ((s == _att_1->getAttName()) || (s==_att_2->getAttName())) return true;
+ return false;
+ }
+
+
+
+
+
+ //std::set<std::string> getRelatedClasses() { return _related_classes; }
+
+
+protected:
+ cMDEExpressionAttribute* _att_1;
+ cMDEExpressionAttribute* _att_2;
+ std::string _att_operator;
+
+};
+
+
+
+
+#endif
Added: branches/uml/source/main/cMDESimpleAttValExpression.h
===================================================================
--- branches/uml/source/main/cMDESimpleAttValExpression.h (rev 0)
+++ branches/uml/source/main/cMDESimpleAttValExpression.h 2008-02-29 15:16:12 UTC (rev 2397)
@@ -0,0 +1,56 @@
+#ifndef _C_MDESIMPLEATTVALEXPRESSION_H_
+#define _C_MDESIMPLEATTVALEXPRESSION_H_
+/*
+ * cMDESimpleAttValExpression.h
+ *
+ *
+ *
+ */
+#include "cMDEExpression.h"
+#include "cMDEExpressionAttribute.h"
+#include <string>
+#include <iostream>
+#include <cassert>
+#include <set>
+
+
+
+class cMDESimpleAttValExpression : public cMDEExpression{
+
+public:
+ cMDESimpleAttValExpression (cMDEExpressionAttribute* a1,
+ std::string val,
+ std::string op) {
+ _att_1 = a1;
+ _att_val = val;
+ _att_operator = op;
+ _expr = getInEnglish();
+ }
+ ~cMDESimpleAttValExpression() {}
+
+ // get functions
+ std::string getInEnglish() {
+ return (_att_1->getInEnglish() + " " + _att_operator + " " + _att_val); }
+ std::string getInPromela() {
+ return (_att_1->getInPromela() + " " + _att_operator + " " + _att_val); }
+
+ // Check to see if the Expression uses a specific attribute.
+ bool usesAttribute(std::string s) {
+ if (s == _att_1->getAttName()) return true;
+ return false;
+ }
+
+ //std::set<std::string> getRelatedClasses() { return _related_classes; }
+
+
+protected:
+ cMDEExpressionAttribute* _att_1;
+ std::string _att_val;
+ std::string _att_operator;
+
+};
+
+
+
+
+#endif
Added: branches/uml/source/main/cMDESimpleExpression.h
===================================================================
--- branches/uml/source/main/cMDESimpleExpression.h (rev 0)
+++ branches/uml/source/main/cMDESimpleExpression.h 2008-02-29 15:16:12 UTC (rev 2397)
@@ -0,0 +1,45 @@
+#ifndef _C_MDEEXPRESSIONATTRIBUTE_H_
+#define _C_MDEEXPRESSIONATTRIBUTE_H_
+/*
+ * cMDEExpressionAttribute.h
+ *
+ *
+ * Created by Heather Goldsby on 2/12/2008.
+ * Copyright 2007 __MyCompanyName__. All rights reserved.
+ *
+ */
+#include <string>
+#include <iostream>
+#include <cassert>
+#include <set>
+
+
+
+class cMDEExpressionAttribute{
+
+public:
+ cMDEExpressionAttribute (std::string n, std::string t, std::string c) {
+ _att_name =n; _att_type = t; _att_class=c; }
+ ~cMDEExpressionAttribute() {}
+
+ // get functions
+ std::string getInEnglish() { return (_att_class + "." + _att_name); }
+ std::string getInPromela() { return (_att_class + "_V." + _att_name); }
+ std::set<std::string> getRelatedClasses() { return _related_classes; }
+
+ // set functions
+ void setRelatedClasses(std::set<std::string> s) { _related_classes = s; }
+
+
+protected:
+ std::string _att_name;
+ std::string _att_type;
+ std::string _att_class;
+ std::set<std::string> _related_classes;
+
+};
+
+
+
+
+#endif
Added: branches/uml/source/main/cMDESimpleOperationExpression.h
===================================================================
--- branches/uml/source/main/cMDESimpleOperationExpression.h (rev 0)
+++ branches/uml/source/main/cMDESimpleOperationExpression.h 2008-02-29 15:16:12 UTC (rev 2397)
@@ -0,0 +1,57 @@
+#ifndef _C_MDESIMPLEOPERATIONEXPRESSION_H_
+#define _C_MDESIMPLEOPERATIONEXPRESSION_H_
+/*
+ * cMDESimpleOperationExpression.h
+ *
+ *
+ *
+ */
+#include <string>
+#include <iostream>
+#include <cassert>
+#include <set>
+#include <cMDEExpression.h>
+
+
+
+class cMDESimpleOperationExpression : public cMDEExpression{
+
+public:
+ cMDESimpleOperationExpression (std::string n, std::string c) {
+ _op_name =n; _op_class=c; _expr = getInEnglish();}
+ ~cMDESimpleOperationExpression() {}
+
+ // get functions
+ 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; }
+
+ // set functions
+ void setRelatedClasses(std::set<std::string> s) { _related_classes = s; }
+
+ // This function is used to see if an expression uses a given operation
+ bool usesOperation(std::string s) {
+ if (s==_op_name) return true;
+ return false;
+ }
+
+ void interestingExpressionEval() {
+ // Currently, the interesting reward is evaluated based on:
+ // - whether it includes one of the significant variables/operations
+ float temp;
+ // Check to see if the expressions use suspend or restart operations
+ temp += usesOperation("suspend") + usesOperation("restart");
+ _interesting = temp;
+ }
+
+protected:
+ std::string _op_name;
+ std::string _op_class;
+ std::set<std::string> _related_classes;
+
+};
+
+
+
+
+#endif
Modified: branches/uml/source/main/cPopulation.h
===================================================================
--- branches/uml/source/main/cPopulation.h 2008-02-29 01:04:18 UTC (rev 2396)
+++ branches/uml/source/main/cPopulation.h 2008-02-29 15:16:12 UTC (rev 2397)
@@ -111,12 +111,12 @@
int world_y; // Structured population
int num_organisms; // Cell count with living organisms
tArray<cDeme> deme_array; // Deme structure of the population.
+
+ // Outside interactions...
+ bool sync_events; // Do we need to sync up the event list with 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?
///////////////// Private Methods ////////////////////
void BuildTimeSlicer(cChangeList* change_list); // Build the schedule object
Modified: branches/uml/source/main/cUMLModel.cc
===================================================================
--- branches/uml/source/main/cUMLModel.cc 2008-02-29 01:04:18 UTC (rev 2396)
+++ branches/uml/source/main/cUMLModel.cc 2008-02-29 15:16:12 UTC (rev 2397)
@@ -28,10 +28,8 @@
x.xmi_begin += (line + " ");
infile >> line;
}
-// std::cout << "XMI BEGIN" << x.xmi_begin << std::endl;
} else if (line == "=XMI-END====================") {
// handle xmi_end
-// std::cout << "XMI END"<< std::endl;
line.erase();
infile >> line;
while (line != "=END========================") {
@@ -39,7 +37,6 @@
x.xmi_end += (line + " ");
infile >> line;
}
-// std::cout << "XMI END" << x.xmi_end << std::endl;
} else if (line == "=CLASS======================") {
// handle xmi_end
line.erase();
@@ -51,7 +48,6 @@
infile >> line;
}
x.classes_info.push_back(data);
-// std::cout << "CLASS" << data << std::endl;
}
line.erase();
@@ -169,7 +165,6 @@
infile >> temp;
}
} else if (line == "==ACTIONS==") {
-// int count =1;
line.erase();
infile >> temp;
state_diagrams[cur_class].addAction("<null>");
@@ -177,8 +172,6 @@
infile >> temp2;
if (temp=="1") {
state_diagrams[cur_class].addAction(temp2);
-// std::cout << "action : " << count << " " << temp2 << std::endl;
-// count++;
}
infile >> temp;
}
@@ -208,7 +201,6 @@
state_diagrams[i].addGuard("<null>");
state_diagrams[i].addTrigger("<null>", "<null>");
// state_diagrams[i].addAction("<null>");
-// int counter =1;
// For each attribute...
for (int j=0; j<temp_size; j++) {
@@ -218,12 +210,8 @@
temp2 = a.attribute_values[k];
temp3 = a.attribute_name + "=" + temp2;
state_diagrams[i].addGuard(temp3);
-// cout << "guard: " << counter << " " << temp3 << std::endl;
temp3 = a.attribute_name + "!=" + temp2;
state_diagrams[i].addGuard(temp3);
-// counter ++;
-// cout << "guard: " << counter << " " << temp3 << std::endl;
-// counter ++;
}
}
@@ -232,16 +220,13 @@
for (int m=0; m<temp_size; m++) {
o = c.getOperation(m);
state_diagrams[i].addTrigger(o.op_name, o.op_code);
- // std::cout << "trigger: " << (m+1) << " " << o.op_name << " " << o.op_code << std::endl;
}
// For each of the related classes, add an action for each of
// its methods... (yucky...)
-// counter =1;
rc.clear();
rc = classes[i].getAssociatedClasses();
for (rcit=rc.begin(); rcit!=rc.end(); rcit++) {
- //cout << "Related class " << (*rcit) << std::endl;
// Find the related class in the list of classes...
for (unsigned int k=0; k<classes.size(); k++){
if (classes[k].getClassName() == (*rcit)){
@@ -251,8 +236,6 @@
o = classes[k].getOperation(m);
temp2 = "^" + classes[k].getClassName() + "." + o.op_name + "()";
state_diagrams[i].addAction(temp2);
-// std::cout << "action: " << counter << " " << temp2 << std::endl;
-// counter++;
}
}
}
@@ -262,85 +245,7 @@
infile.close();
return;
}
-/*
-// This function uses the information generated
-void seedTriggersGuardsActions(std::vector<cUMLClass>& classes,
- std::vector<cUMLStateDiagram>& state_diagrams) {
-
- std::string class_name;
- class_attribute a;
- operation o;
- cUMLClass c;
- int temp_size;
- std::string temp1, temp2, temp3;
- std::string at_type;
-
- state_diagrams.resize(classes.size());
- // For each class...
- // triggers = methods
- // guards = attribute equality / inequality
- // actions = methods of related classes.
- for (unsigned int i=0; i<classes.size(); i++) {
- c = classes[i];
- temp_size = c.numAttributes();
-
- // For each attribute...
- for (int j=0; j<temp_size; j++) {
- a = c.getAttribute(j);
- temp1 = class_name + "_V." + a.attribute_name;
- at_type = a.attribute_type;
-
- if ((at_type == "int") || (at_type == "integer")) {
- // For each attribute value
- for (unsigned int k=0; k<a.attribute_values.size(); k++){
- // create both an equality and an inequality expression
- temp2 = a.attribute_values[k];
- temp3 = temp1 + "==" + temp2;
- gen->addExpression(temp3, c.getAssociatedClasses());
- //std::cout << temp3 << std::endl;
- temp3 = temp1 + "!=" + temp2;
- //std::cout << temp3 << std::endl;
- gen->addExpression(temp3, c.getAssociatedClasses());
-
- temp3 = temp1 + ">" + temp2;
- gen->addExpression(temp3, c.getAssociatedClasses());
-
- temp3 = temp1 + "<" + temp2;
- gen->addExpression(temp3, c.getAssociatedClasses());
-
- temp3 = temp1 + ">=" + temp2;
- gen->addExpression(temp3, c.getAssociatedClasses());
-
- temp3 = temp1 + "<=" + temp2;
- gen->addExpression(temp3, c.getAssociatedClasses());
-
- }
- } else if ((at_type == "bool")||(at_type == "boolean")) {
- for (unsigned int k=0; k<a.attribute_values.size(); k++){
- // create both an equality and an inequality expression
- temp2 = a.attribute_values[k];
- temp3 = temp1 + "==" + temp2;
- gen->addExpression(temp3, c.getAssociatedClasses());
- //std::cout << temp3 << std::endl;
- temp3 = temp1 + "!=" + temp2;
- //std::cout << temp3 << std::endl;
- gen->addExpression(temp3, c.getAssociatedClasses());
- }
- }
- }
-
- // For each method
- temp_size = c.numOperations();
- for (int m=0; m<temp_size; m++) {
- o = c.getOperation(m);
- state_diagrams[i].addTrigger(o.op_name, o.op_code);
- std::cout << "trigger: " << o.op_name << " " << o.op_code << std::endl;
- }
- }
-
-}*/
-
xmi_info cUMLModel::xi = loadFile("xmi_info");
int cUMLModel::max_trans = 0;
@@ -403,9 +308,7 @@
void cUMLModel::printXMI()
{
- xmi = "";
-// int v;
-
+ xmi = "";
xmi = xi.xmi_begin;
assert (xi.classes_info.size() == state_diagrams.size());
@@ -525,7 +428,6 @@
case 0:
ret_val = 1;
for (unsigned int i=0; i< scenario_completion.size(); i++) {
- //ret_val &= scenario_completion[i];
if (scenario_completion[i] != 1) ret_val &= 0;
}
break;
@@ -545,7 +447,6 @@
ret_val = 1;
if (!(getBonusInfo("isDeterministic"))) { ret_val=0; break; }
for (unsigned int i=0; i< scenario_completion.size(); i++) {
- //ret_val &= scenario_completion[i];
if (scenario_completion[i] != 1) ret_val &= 0;
}
break;
@@ -571,7 +472,6 @@
// open outfile.
std::ofstream outfile;
outfile.open(file_name.c_str());
-// outfile.open("out.xmi");
assert(outfile.is_open());
@@ -634,54 +534,44 @@
int temp_size;
std::string temp1, temp2, temp3;
std::string at_type;
-
+ cMDEExpressionAttribute* a1, a2;
+
// For each class, create its set of expressions.
for (unsigned int i=0; i<classes.size(); i++) {
c = classes[i];
class_name = c.getClassName();
temp_size = c.numAttributes();
-
+
// For each attribute...
for (int j=0; j<temp_size; j++) {
+
a = c.getAttribute(j);
- temp1 = class_name + "_V." + a.attribute_name;
at_type = a.attribute_type;
+ a1 = new cMDEExpressionAttribute(a.attribute_name, at_type, class_name);
+
if ((at_type == "int") || (at_type == "integer")) {
+
// For each attribute value
for (unsigned int k=0; k<a.attribute_values.size(); k++){
+
// create both an equality and an inequality expression
temp2 = a.attribute_values[k];
- temp3 = temp1 + "==" + temp2;
- gen->addExpression(temp3, c.getAssociatedClasses());
- //std::cout << temp3 << std::endl;
- temp3 = temp1 + "!=" + temp2;
- //std::cout << temp3 << std::endl;
- gen->addExpression(temp3, c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, "==");
+ gen->addSimpleAttValExpression(a1, temp2, "!=");
+ gen->addSimpleAttValExpression(a1, temp2, ">");
+ gen->addSimpleAttValExpression(a1, temp2, ">=");
+ gen->addSimpleAttValExpression(a1, temp2, "<=");
+ gen->addSimpleAttValExpression(a1, temp2, "<");
- temp3 = temp1 + ">" + temp2;
- gen->addExpression(temp3, c.getAssociatedClasses());
-
- temp3 = temp1 + "<" + temp2;
- gen->addExpression(temp3, c.getAssociatedClasses());
-
- temp3 = temp1 + ">=" + temp2;
- gen->addExpression(temp3, c.getAssociatedClasses());
-
- temp3 = temp1 + "<=" + temp2;
- gen->addExpression(temp3, c.getAssociatedClasses());
-
}
} else if ((at_type == "bool")||(at_type == "boolean")) {
for (unsigned int k=0; k<a.attribute_values.size(); k++){
// create both an equality and an inequality expression
temp2 = a.attribute_values[k];
- temp3 = temp1 + "==" + temp2;
- gen->addExpression(temp3, c.getAssociatedClasses());
- //std::cout << temp3 << std::endl;
- temp3 = temp1 + "!=" + temp2;
- //std::cout << temp3 << std::endl;
- gen->addExpression(temp3, c.getAssociatedClasses());
+ gen->addSimpleAttValExpression(a1, temp2, "==");
+ gen->addSimpleAttValExpression(a1, temp2, "!=");
+
}
}
}
@@ -690,10 +580,7 @@
temp_size = c.numOperations();
for (int m=0; m<temp_size; m++) {
o = c.getOperation(m);
- temp1 = class_name;
- temp3 = class_name + "_q??[" + o.op_name + "]";
- gen->addExpression(temp3, c.getAssociatedClasses());
- //std::cout << temp1 << std::endl;
+ gen->addSimpleOperationExpression(o.op_name, class_name);
}
}
}
Modified: branches/uml/source/main/cUMLModel.h
===================================================================
--- branches/uml/source/main/cUMLModel.h 2008-02-29 01:04:18 UTC (rev 2396)
+++ branches/uml/source/main/cUMLModel.h 2008-02-29 15:16:12 UTC (rev 2397)
@@ -4,6 +4,7 @@
#include "cUMLClass.h"
#include "cUMLStateDiagram.h"
#include "cMDEPropertyGenerator.h"
+#include "cMDEExpressionAttribute.H"
#include <string>
#include <iostream>
More information about the Avida-cvs
mailing list