[Avida-SVN] r1164 - branches/uml/source/main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Wed Jan 3 10:39:10 PST 2007
Author: hjg
Date: 2007-01-03 13:39:10 -0500 (Wed, 03 Jan 2007)
New Revision: 1164
Modified:
branches/uml/source/main/cOrganism.cc
branches/uml/source/main/cOrganism.h
branches/uml/source/main/cTaskLib.cc
branches/uml/source/main/cTaskLib.h
Log:
Changed task configurations for ms and bs
Modified: branches/uml/source/main/cOrganism.cc
===================================================================
--- branches/uml/source/main/cOrganism.cc 2007-01-02 16:18:37 UTC (rev 1163)
+++ branches/uml/source/main/cOrganism.cc 2007-01-03 18:39:10 UTC (rev 1164)
@@ -491,10 +491,9 @@
}
-// This sets the meaning of the transitions. The only question is whether some of the operation,
-// and action ids that have been changed to "" are needed.
+// This sets the meaning of the transitions to those of the Multi-Sensor Example.
-void cOrganism::InitTransForXMI()
+void cOrganism::InitTransForMSXMI()
{
// assign transition values to map elements
@@ -548,21 +547,119 @@
temp += " </UML:ModelElement.namespace> </UML:Event> </UML:Transition.trigger>\n";
(*it).second = temp;
break;
-/* case 6:
- (*it).second = "setBrightnessValue(brightnessValue)";
+ default:
+ (*it).second = " ";
+ }
+ count++;
+ }
+}
+
+
+void cOrganism::InitTransForBSXMI()
+{
+
+ // assign transition values to map elements
+ std::map <int, std::string>::iterator it;
+ std::string temp;
+ int count = 0;
+
+ for (it = transGuardActionInfo.begin(); it!=transGuardActionInfo.end(); ++it) {
+ switch (count){
+ case 0:
+ (*it).second = "";
break;
+ case 1:
+ temp = "";
+ temp += "<UML:Transition.trigger> <UML:Event> <UML:ModelElement.namespace> <UML:Namespace> ";
+ temp += "<UML:Namespace.ownedElement> <UML:CallEvent xmi.id=\"XDE-7126ED39-5D5D-4160-924B-303514B17EAB\" ";
+ temp += " operation=\"XDE-1266DA8A-61C0-43B4-A77C-200F54A6585D\" name=\"getOperationalState\"";
+ temp += " isSpecification=\"false\"/> </UML:Namespace.ownedElement> </UML:Namespace> ";
+ temp += " </UML:ModelElement.namespace> </UML:Event> </UML:Transition.trigger>";
+ (*it).second = temp;
+ break;
+ case 2:
+ temp = "";
+ temp += "<UML:Transition.effect> <UML:UninterpretedAction xmi.id=\"XDE-D9BCD8D1-7FC4-4B14-9E76-D3A642799013\"";
+ temp += " isAsynchronous=\"false\" name=\"\" isSpecification=\"false\"> <UML:Action.script> ";
+ temp += "<UML:ActionExpression language=\"\" body=\"operationalState:=1;^ComputingComponent.ccTRUE\"/> ";
+ temp += "</UML:Action.script> </UML:UninterpretedAction> </UML:Transition.effect>";
+ (*it).second = temp;
+ break;
+ case 3:
+ temp = "";
+ temp += "<UML:Transition.effect> <UML:UninterpretedAction xmi.id=\"XDE-9F00136E-D61D-4BB0-B7D6-1E795238FD1E\"";
+ temp += " isAsynchronous=\"false\" name=\"\" isSpecification=\"false\"> <UML:Action.script> ";
+ temp += " <UML:ActionExpression language=\"\" body=\"operationalState:=0;^ComputingComponent.ccFALSE\"/> ";
+ temp += "</UML:Action.script> </UML:UninterpretedAction> </UML:Transition.effect> ";
+ (*it).second = "";
+ break;
+ case 4:
+ temp = "";
+ temp += "<UML:Transition.trigger> <UML:Event> <UML:ModelElement.namespace> <UML:Namespace> ";
+ temp += "<UML:Namespace.ownedElement> <UML:CallEvent xmi.id=\"XDE-A28463C5-2F9F-457C-B6F3-241526CA4791\" ";
+ temp += " operation=\"XDE-E84A5762-CA92-4E03-A237-FE5AE2C99D9A\" name=\"getBrightnessValue\" ";
+ temp += "isSpecification=\"false\"/> </UML:Namespace.ownedElement> </UML:Namespace> ";
+ temp += " </UML:ModelElement.namespace> </UML:Event> </UML:Transition.trigger> ";
+ (*it).second =temp;
+ break;
+ case 5:
+ temp = "";
+ temp += "<UML:Transition.effect> <UML:UninterpretedAction xmi.id=\"XDE-6C3D3042-5C7A-4746-8A90-BEDB86FD2FF4\" ";
+ temp += "isAsynchronous=\"false\" name=\"\" isSpecification=\"false\"> <UML:Action.script> ";
+ temp += " <UML:ActionExpression language=\"\" body=\"^Environment.getBrightnessValue\"/> ";
+ temp += "</UML:Action.script> </UML:UninterpretedAction> </UML:Transition.effect> ";
+ (*it).second = temp;
+ break;
+ case 6:
+ temp = "";
+ temp += "<UML:Transition.trigger> <UML:Event> <UML:ModelElement.namespace> <UML:Namespace> ";
+ temp += " <UML:Namespace.ownedElement> <UML:CallEvent xmi.id=\"XDE-79243838-9C4E-4908-9637-9F9583043BE4\" ";
+ temp += " operation=\"XDE-C8BD0DBA-E427-41A0-95F4-98FAA920ACA9\" name=\"setBrightnessValue\" ";
+ temp += "isSpecification=\"false\"/> </UML:Namespace.ownedElement> </UML:Namespace> ";
+ temp += " </UML:ModelElement.namespace> </UML:Event> </UML:Transition.trigger> ";
+ (*it).second = temp;
+ break;
case 7:
- (*it).second = "[brightnessValue<0]/correctedBrightnessValue:=0";
+ temp = "";
+ temp += "<UML:Transition.guard> <UML:Guard> <UML:Guard.expression> ";
+ temp += "<UML:BooleanExpression body=\"brightnessValue >=0 & brightnessValue<=1000\" language=\"\"/>";
+ temp += " </UML:Guard.expression> </UML:Guard> </UML:Transition.guard> <UML:Transition.effect> ";
+ temp += " <UML:UninterpretedAction xmi.id=\"XDE-8E3B2DF6-D63B-4A70-9CD3-FF0DE13EEDAD\" ";
+ temp += " isAsynchronous=\"false\" name=\"\" isSpecification=\"false\"> <UML:Action.script> ";
+ temp += " <UML:ActionExpression language=\"\" body=\"correctedBrightnessValue:=brightnessValue\"/> ";
+ temp += " </UML:Action.script> </UML:UninterpretedAction> </UML:Transition.effect> ";
+ (*it).second = temp;
break;
case 8:
- (*it).second = "[brightnessValue >=0 & brightnessValue<=1000]/correctedBrightnessValue:=brightnessValue";
+ temp = "";
+ temp += "<UML:Transition.effect> <UML:UninterpretedAction xmi.id=\"XDE-101E5C46-12EA-4169-9DC9-D3661EE9836B\" ";
+ temp += "isAsynchronous=\"false\" name="" isSpecification=\"false\"> <UML:Action.script> ";
+ temp += " <UML:ActionExpression language=\"\" body=\"^ComputingComponent.setBrightnessValue(brightnessValue)\"/> ";
+ temp += " </UML:Action.script> </UML:UninterpretedAction> </UML:Transition.effect> ";
+ (*it).second = temp;
break;
case 9:
- (*it).second = "[brightnessValue>1000]/correctedBrightnessValue:=1000";
+ temp = "";
+ temp += "<UML:Transition.guard> <UML:Guard> <UML:Guard.expression> ";
+ temp += "<UML:BooleanExpression body=\"brightnessValue<0\" language=\"\"/> ";
+ temp += " </UML:Guard.expression> </UML:Guard> </UML:Transition.guard> <UML:Transition.effect> ";
+ temp += " <UML:UninterpretedAction xmi.id=\"XDE-0B7A10EB-A9FC-4DE8-BBF1-AF1C9A970E7F\" ";
+ temp += " isAsynchronous=\"false\" name=\"\" isSpecification=\"false\"> <UML:Action.script> ";
+ temp += " <UML:ActionExpression language=\"\" body=\"correctedBrightnessValue:=0\"/> ";
+ temp += " </UML:Action.script> </UML:UninterpretedAction> </UML:Transition.effect> ";
+ (*it).second = temp;
break;
case 10:
- (*it).second = "^ComputingComponent.setBrightnessValue(brightnessValue)";
- break;*/
+ temp = "";
+ temp += "<UML:Transition.guard> <UML:Guard> <UML:Guard.expression> ";
+ temp += "<UML:BooleanExpression body=\"brightnessValue>1000\" language=\"\"/> ";
+ temp += " </UML:Guard.expression> </UML:Guard> </UML:Transition.guard> <UML:Transition.effect> ";
+ temp += " <UML:UninterpretedAction xmi.id=\"XDE-7D6DDE48-7568-4043-B00A-87EFBE1A6CB3\" ";
+ temp += " isAsynchronous=\"false\" name=\"\" isSpecification=\"false\"> <UML:Action.script> ";
+ temp += " <UML:ActionExpression language=\"\" body=\"correctedBrightnessValue:=1000\"/> ";
+ temp += " </UML:Action.script> </UML:UninterpretedAction> </UML:Transition.effect> ";
+ (*it).second = temp;
+ break;
default:
(*it).second = " ";
}
@@ -570,7 +667,6 @@
}
}
-
bool cOrganism::AddTrans(int trans, int orig, int dest)
@@ -729,7 +825,7 @@
}
-
+/*
void cOrganism::printIdealXMI(cAvidaContext& ctx)
{
std::string temp;
@@ -858,6 +954,8 @@
}
+*/
+
void cOrganism::printXMI(cAvidaContext& ctx)
{
@@ -869,7 +967,7 @@
std::string temp, temp1, temp2;
int tempint;
- InitTransForXMI();
+ InitTransForBSXMI();
xmi = "";
// loop through all states
Modified: branches/uml/source/main/cOrganism.h
===================================================================
--- branches/uml/source/main/cOrganism.h 2007-01-02 16:18:37 UTC (rev 1163)
+++ branches/uml/source/main/cOrganism.h 2007-01-03 18:39:10 UTC (rev 1164)
@@ -240,9 +240,10 @@
// UML Stuff
void ModelCheck(cAvidaContext& ctx);
void printXMI(cAvidaContext& ctx);
- void printIdealXMI(cAvidaContext& ctx);
+// void printIdealXMI(cAvidaContext& ctx);
- void InitTransForXMI();
+ void InitTransForMSXMI();
+ void InitTransForBSXMI();
bool AddTrans(int trans, int orig, int dest);
double NumStates();
double NumTrans();
Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc 2007-01-02 16:18:37 UTC (rev 1163)
+++ branches/uml/source/main/cTaskLib.cc 2007-01-03 18:39:10 UTC (rev 1164)
@@ -335,28 +335,40 @@
NewTask(name, "Successfully Created the right number of transitions", &cTaskLib::Task_NumberOfTrans);
else if (name == "uml_hy")
NewTask(name, "Ran Hydra... Returning bonus proportional to the number of errors", &cTaskLib::Task_Hydra);
- else if (name == "uml_tr0")
- NewTask(name, "Successfully Created transition 0", &cTaskLib::Task_Transition0);
- else if (name == "uml_tr1")
- NewTask(name, "Successfully Created transition 1", &cTaskLib::Task_Transition1);
- else if (name == "uml_tr2")
- NewTask(name, "Successfully Created transition 2", &cTaskLib::Task_Transition2);
- else if (name == "uml_tr3")
- NewTask(name, "Successfully Created transition 3", &cTaskLib::Task_Transition3);
- else if (name == "uml_tr4")
- NewTask(name, "Successfully Created transition 4", &cTaskLib::Task_Transition4);
- else if (name == "uml_tr5")
- NewTask(name, "Successfully Created transition 5", &cTaskLib::Task_Transition5);
- else if (name == "uml_tr6")
- NewTask(name, "Successfully Created transition 6", &cTaskLib::Task_Transition6);
- else if (name == "uml_tr7")
- NewTask(name, "Successfully Created transition 7", &cTaskLib::Task_Transition7);
- else if (name == "uml_tr8")
- NewTask(name, "Successfully Created transition 8", &cTaskLib::Task_Transition8);
- else if (name == "uml_tr9")
- NewTask(name, "Successfully Created transition 9", &cTaskLib::Task_Transition9);
- else if (name == "uml_tr10")
- NewTask(name, "Successfully Created transition 10", &cTaskLib::Task_Transition10);
+ else if (name == "uml_tr_ms0")
+ NewTask(name, "Successfully Created transition 0", &cTaskLib::Task_Transition_ms0);
+ else if (name == "uml_tr_ms1")
+ NewTask(name, "Successfully Created transition 1", &cTaskLib::Task_Transition_ms1);
+ else if (name == "uml_tr_ms2")
+ NewTask(name, "Successfully Created transition 2", &cTaskLib::Task_Transition_ms2);
+ else if (name == "uml_tr_ms3")
+ NewTask(name, "Successfully Created transition 3", &cTaskLib::Task_Transition_ms3);
+ else if (name == "uml_tr_ms4")
+ NewTask(name, "Successfully Created transition 4", &cTaskLib::Task_Transition_ms4);
+ else if (name == "uml_tr_ms5")
+ NewTask(name, "Successfully Created transition 5", &cTaskLib::Task_Transition_ms5);
+ else if (name == "uml_tr_bs0")
+ NewTask(name, "Successfully Created transition 0", &cTaskLib::Task_Transition_bs0);
+ else if (name == "uml_tr_bs1")
+ NewTask(name, "Successfully Created transition 1", &cTaskLib::Task_Transition_bs1);
+ else if (name == "uml_tr_bs2")
+ NewTask(name, "Successfully Created transition 2", &cTaskLib::Task_Transition_bs2);
+ else if (name == "uml_tr_bs3")
+ NewTask(name, "Successfully Created transition 3", &cTaskLib::Task_Transition_bs3);
+ else if (name == "uml_tr_bs4")
+ NewTask(name, "Successfully Created transition 4", &cTaskLib::Task_Transition_bs4);
+ else if (name == "uml_tr_bs5")
+ NewTask(name, "Successfully Created transition 5", &cTaskLib::Task_Transition_bs5);
+ else if (name == "uml_tr_bs6")
+ NewTask(name, "Successfully Created transition 6", &cTaskLib::Task_Transition_bs6);
+ else if (name == "uml_tr_bs7")
+ NewTask(name, "Successfully Created transition 7", &cTaskLib::Task_Transition_bs7);
+ else if (name == "uml_tr_bs8")
+ NewTask(name, "Successfully Created transition 8", &cTaskLib::Task_Transition_bs8);
+ else if (name == "uml_tr_bs9")
+ NewTask(name, "Successfully Created transition 9", &cTaskLib::Task_Transition_bs9);
+ else if (name == "uml_tr_bs10")
+ NewTask(name, "Successfully Created transition 10", &cTaskLib::Task_Transition_bs10);
else if (name == "spinn1")
NewTask(name, "Successfully ran spin for N1 (yay!)", &cTaskLib::Task_SpinN1);
/* else if (name == "uml_trs")
@@ -1908,13 +1920,15 @@
return bonus;
}
-// findTrans args (init state, dest state, trans )
+/*
-double cTaskLib::Task_Transition0(cTaskContext* ctx) const
+The following tasks check for the graph topology of the multisensor
+
+*/
+double cTaskLib::Task_Transition_ms0(cTaskContext* ctx) const
{
double bonus = 0.0;
- // good for bs, gsm, & ms
if (ctx->organism->findTrans(0, 1, 0)) {
bonus = 1.0;
}
@@ -1922,15 +1936,11 @@
return bonus;
}
-double cTaskLib::Task_Transition1(cTaskContext* ctx) const
+double cTaskLib::Task_Transition_ms1(cTaskContext* ctx) const
{
double bonus = 0.0;
- // good for bs, gsm & ms
if (ctx->organism->findTrans(1, 2, 1)) {
-
- // testing the creation of multiple trans to get reward concept
-// if ((ctx->organism->findTrans(1, 2, 1)) && (ctx->organism->findTrans(2, 3, 2))) {
bonus = 1.0;
}
@@ -1939,14 +1949,10 @@
}
-double cTaskLib::Task_Transition2(cTaskContext* ctx) const
+double cTaskLib::Task_Transition_ms2(cTaskContext* ctx) const
{
double bonus = 0.0;
- // brightness sensor
- // if (ctx->organism->findTrans(2, 1, 2)) {
- // gsm:
-// if (ctx->organism->findTrans(2, 3, 2)) {
if (ctx->organism->findTrans(2, 3, 2)) {
@@ -1957,15 +1963,10 @@
return bonus;
}
-double cTaskLib::Task_Transition3(cTaskContext* ctx) const
+double cTaskLib::Task_Transition_ms3(cTaskContext* ctx) const
{
double bonus = 0.0;
- // brightness sensor
- // if (ctx->organism->findTrans(2, 1, 3)) {
- // gsm:
- //if (ctx->organism->findTrans(3, 4, 3)) {
- // ms
if (ctx->organism->findTrans(3, 1, 3)) {
bonus = 1.0;
@@ -1975,15 +1976,10 @@
return bonus;
}
-double cTaskLib::Task_Transition4(cTaskContext* ctx) const
+double cTaskLib::Task_Transition_ms4(cTaskContext* ctx) const
{
double bonus = 0.0;
- // brightness sensor
-// if (ctx->organism->findTrans(1, 3, 4)) {
- // gsm
-// if (ctx->organism->findTrans(4, 1, 4)) {
- // ms
if (ctx->organism->findTrans(1, 4, 4)) {
bonus = 1.0;
@@ -1993,13 +1989,10 @@
return bonus;
}
-double cTaskLib::Task_Transition5(cTaskContext* ctx) const
+double cTaskLib::Task_Transition_ms5(cTaskContext* ctx) const
{
double bonus = 0.0;
-// bs
-// if (ctx->organism->findTrans(3, 4, 5)) {
-// ms
if (ctx->organism->findTrans(4, 1, 5)){
bonus = 1.0;
}
@@ -2008,17 +2001,98 @@
return bonus;
}
-double cTaskLib::Task_Transition6(cTaskContext* ctx) const
+
+/*
+The following tasks check for the graph topology of the brightness sensor.
+The order of the transitions has been changed from the original runs to enable the min/max
+transitions to come last. The objective is to enable Avida to evolve these using Spin/Hydra.
+
+*/
+double cTaskLib::Task_Transition_bs0(cTaskContext* ctx) const
{
double bonus = 0.0;
+
+ if (ctx->organism->findTrans(0, 1, 0)) {
+ bonus = 1.0;
+ }
+ ctx->task_failed = ctx->task_failed && bonus;
+ return bonus;
+}
+double cTaskLib::Task_Transition_bs1(cTaskContext* ctx) const
+{
+ double bonus = 0.0;
+
+ if (ctx->organism->findTrans(1, 2, 1)) {
+
+ bonus = 1.0;
+ }
+ ctx->task_failed = ctx->task_failed && bonus;
+ return bonus;
+}
+
+
+double cTaskLib::Task_Transition_bs2(cTaskContext* ctx) const
+{
+ double bonus = 0.0;
+
+ if (ctx->organism->findTrans(2, 1, 2)) {
+
+ bonus = 1.0;
+ }
+
+ ctx->task_failed = ctx->task_failed && bonus;
+ return bonus;
+}
+
+double cTaskLib::Task_Transition_bs3(cTaskContext* ctx) const
+{
+ double bonus = 0.0;
+
+ if (ctx->organism->findTrans(2, 1, 3)) {
+
+ bonus = 1.0;
+ }
+
+ ctx->task_failed = ctx->task_failed && bonus;
+ return bonus;
+}
+
+double cTaskLib::Task_Transition_bs4(cTaskContext* ctx) const
+{
+ double bonus = 0.0;
+
+ if (ctx->organism->findTrans(1, 3, 4)) {
+ bonus = 1.0;
+ }
+
+ ctx->task_failed = ctx->task_failed && bonus;
+ return bonus;
+}
+
+double cTaskLib::Task_Transition_bs5(cTaskContext* ctx) const
+{
+ double bonus = 0.0;
+
+ if (ctx->organism->findTrans(3, 4, 5)) {
+ bonus = 1.0;
+ }
+
+ ctx->task_failed = ctx->task_failed && bonus;
+ return bonus;
+}
+
+double cTaskLib::Task_Transition_bs6(cTaskContext* ctx) const
+{
+ double bonus = 0.0;
+
if (ctx->organism->findTrans(4, 5, 6)) {
bonus = 1.0;
}
return bonus;
}
-double cTaskLib::Task_Transition7(cTaskContext* ctx) const
+double cTaskLib::Task_Transition_bs7(cTaskContext* ctx) const
{
double bonus = 0.0;
@@ -2028,17 +2102,17 @@
return bonus;
}
-double cTaskLib::Task_Transition8(cTaskContext* ctx) const
+double cTaskLib::Task_Transition_bs8(cTaskContext* ctx) const
{
double bonus = 0.0;
- if (ctx->organism->findTrans(5, 6, 8)) {
+ if (ctx->organism->findTrans(6, 1, 8)) {
bonus = 1.0;
}
return bonus;
}
-double cTaskLib::Task_Transition9(cTaskContext* ctx) const
+double cTaskLib::Task_Transition_bs9(cTaskContext* ctx) const
{
double bonus = 0.0;
@@ -2048,11 +2122,11 @@
return bonus;
}
-double cTaskLib::Task_Transition10(cTaskContext* ctx) const
+double cTaskLib::Task_Transition_bs10(cTaskContext* ctx) const
{
double bonus = 0.0;
- if (ctx->organism->findTrans(6, 1, 10)) {
+ if (ctx->organism->findTrans(5, 6, 10)) {
bonus = 1.0;
}
return bonus;
Modified: branches/uml/source/main/cTaskLib.h
===================================================================
--- branches/uml/source/main/cTaskLib.h 2007-01-02 16:18:37 UTC (rev 1163)
+++ branches/uml/source/main/cTaskLib.h 2007-01-03 18:39:10 UTC (rev 1164)
@@ -236,17 +236,23 @@
double Task_NumberOfState(cTaskContext* ctx) const;
double Task_NumberOfTrans(cTaskContext* ctx) const;
double Task_Hydra(cTaskContext* ctx) const;
- double Task_Transition0(cTaskContext* ctx) const;
- double Task_Transition1(cTaskContext* ctx) const;
- double Task_Transition2(cTaskContext* ctx) const;
- double Task_Transition3(cTaskContext* ctx) const;
- double Task_Transition4(cTaskContext* ctx) const;
- double Task_Transition5(cTaskContext* ctx) const;
- double Task_Transition6(cTaskContext* ctx) const;
- double Task_Transition7(cTaskContext* ctx) const;
- double Task_Transition8(cTaskContext* ctx) const;
- double Task_Transition9(cTaskContext* ctx) const;
- double Task_Transition10(cTaskContext* ctx) const;
+ double Task_Transition_ms0(cTaskContext* ctx) const;
+ double Task_Transition_ms1(cTaskContext* ctx) const;
+ double Task_Transition_ms2(cTaskContext* ctx) const;
+ double Task_Transition_ms3(cTaskContext* ctx) const;
+ double Task_Transition_ms4(cTaskContext* ctx) const;
+ double Task_Transition_ms5(cTaskContext* ctx) const;
+ double Task_Transition_bs0(cTaskContext* ctx) const;
+ double Task_Transition_bs1(cTaskContext* ctx) const;
+ double Task_Transition_bs2(cTaskContext* ctx) const;
+ double Task_Transition_bs3(cTaskContext* ctx) const;
+ double Task_Transition_bs4(cTaskContext* ctx) const;
+ double Task_Transition_bs5(cTaskContext* ctx) const;
+ double Task_Transition_bs6(cTaskContext* ctx) const;
+ double Task_Transition_bs7(cTaskContext* ctx) const;
+ double Task_Transition_bs8(cTaskContext* ctx) const;
+ double Task_Transition_bs9(cTaskContext* ctx) const;
+ double Task_Transition_bs10(cTaskContext* ctx) const;
double SpinCoprocess(const std::string& neverclaimFile) const;
double Task_SpinN1(cTaskContext* ctx) const;
More information about the Avida-cvs
mailing list