[Avida-SVN] r1153 - in branches/uml/source: main tools
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Mon Dec 25 10:23:08 PST 2006
Author: hjg
Date: 2006-12-25 13:23:07 -0500 (Mon, 25 Dec 2006)
New Revision: 1153
Modified:
branches/uml/source/main/cOrganism.cc
branches/uml/source/main/cOrganism.h
branches/uml/source/main/cStats.cc
branches/uml/source/main/cStats.h
branches/uml/source/main/cTaskLib.cc
branches/uml/source/tools/cDoubleSum.h
Log:
Added stat collecting for hydra & Spin. Added parsing for Spin output.
Modified: branches/uml/source/main/cOrganism.cc
===================================================================
--- branches/uml/source/main/cOrganism.cc 2006-12-25 17:22:39 UTC (rev 1152)
+++ branches/uml/source/main/cOrganism.cc 2006-12-25 18:23:07 UTC (rev 1153)
@@ -429,9 +429,10 @@
void cOrganism::ModelCheck(cAvidaContext& ctx)
{
-// cout << "Model check begin " << endl;
+ // CHECK OUT WHETHER THE IDEAL WORKS....
printXMI(ctx);
-// cout << "Model check end " << endl;
+ //printIdealXMI(ctx);
+
assert(m_interface);
const tArray<double> & resource_count = m_interface->GetResources();
@@ -729,9 +730,161 @@
}
-// hjg - 12/16/2006 - States have been modified to print XMI rather than HIL;
-// transitions have not yet been reworked
+void cOrganism::printIdealXMI(cAvidaContext& ctx)
+{
+ std::string temp;
+ temp = "0";
+ xmi += "<UML:Pseudostate xmi.id=\"s" + temp + "\" kind=\"initial\" outgoing=\"\" name=\"\" isSpecification=\"false\"/>\n";
+
+ for (int j = 1; j < 5; ++j) {
+ temp = "s" + StringifyAnInt(j);
+ xmi+="<UML:CompositeState xmi.id=\"";
+ xmi+=temp;
+ xmi+= "\" isConcurrent=\"false\" name=\"";
+ xmi+= temp;
+ xmi+= "\" isSpecification=\"false\"/>\n";
+ }
+
+ // end the set of states....
+ xmi+= "</UML:CompositeState.subvertex>\n";
+ xmi+= "</UML:CompositeState>\n";
+ xmi+= "</UML:StateMachine.top>\n";
+
+ // start the set of transitions...
+ xmi+="<UML:StateMachine.transitions>\n";
+
+ // trans 0
+
+ temp = "t0";
+
+ xmi+= "<UML:Transition xmi.id=\"" + temp + "\"";
+ temp = "s0";
+ xmi+= " source=\"" + temp + "\"";
+ temp = "s1";
+ xmi += " target=\"" + temp + "\" name=\"\" isSpecification=\"false\">\n";
+ //xmi += temp;
+ xmi += "</UML:Transition>\n";
+
+
+ // trans 1
+
+ temp = "t1";
+
+ xmi+= "<UML:Transition xmi.id=\"" + temp + "\"";
+ temp = "s1";
+ xmi+= " source=\"" + temp + "\"";
+ temp = "s2";
+ xmi += " target=\"" + temp + "\" name=\"\" isSpecification=\"false\">\n";
+ temp = "";
+ temp += "<UML:Transition.effect> <UML:UninterpretedAction xmi.id=\"XDE-176F1237-1448-4226-A095-075FABD68B33\"";
+ temp += " isAsynchronous=\"false\" name=\"\" isSpecification=\"false\">";
+ temp += "<UML:Action.script> <UML:ActionExpression language=\"\" ";
+ temp += "body=\"^TempSensor.getTempData()\"/> </UML:Action.script> ";
+ temp += "</UML:UninterpretedAction> </UML:Transition.effect> \n";
+ xmi += temp;
+ xmi += "</UML:Transition>\n";
+
+ // trans 2
+ temp = "t2";
+
+ xmi+= "<UML:Transition xmi.id=\"" + temp + "\"";
+ temp = "s2";
+ xmi+= " source=\"" + temp + "\"";
+ temp = "s3";
+ xmi += " target=\"" + temp + "\" name=\"\" isSpecification=\"false\">\n";
+
+ temp = "";
+ temp += "<UML:Transition.trigger> <UML:Event> <UML:ModelElement.namespace> ";
+ temp += "<UML:Namespace> <UML:Namespace.ownedElement> ";
+ temp += "<UML:CallEvent xmi.id=\"XDE-4C4256DD-D7D7-4687-AA73-761334859279\" " ;
+ temp += " operation=\"XDE-9517D6BA-8666-4A82-AFEA-62D60FE37B07\" name=\"setTempData\" ";
+ temp += " isSpecification=\"false\"/> </UML:Namespace.ownedElement> </UML:Namespace> ";
+ temp += " </UML:ModelElement.namespace> </UML:Event> </UML:Transition.trigger>\n";
+ xmi += temp;
+ xmi += "</UML:Transition>\n";
+
+ // trans 3
+ temp = "t3";
+
+ xmi+= "<UML:Transition xmi.id=\"" + temp + "\"";
+ temp = "s3";
+ xmi+= " source=\"" + temp + "\"";
+ temp = "s1";
+ xmi += " target=\"" + temp + "\" name=\"\" isSpecification=\"false\">\n";
+
+ temp = "";
+ xmi += temp;
+ xmi += "</UML:Transition>\n";
+
+ // trans 4
+ temp = "t4";
+
+ xmi+= "<UML:Transition xmi.id=\"" + temp + "\"";
+ temp = "s1";
+ xmi+= " source=\"" + temp + "\"";
+ temp = "s4";
+ xmi += " target=\"" + temp + "\" name=\"\" isSpecification=\"false\">\n";
+
+ temp = "";
+ temp += "<UML:Transition.effect> <UML:UninterpretedAction xmi.id=\"XDE-8280CF2B-DA14-4989-AC7F-D83012DE3234\"";
+ temp += " isAsynchronous=\"false\" name=\"\" isSpecification=\"false\"> ";
+ temp += "<UML:Action.script> <UML:ActionExpression language=\"\" ";
+ temp += " body=\"^TempSensor.getOpState()\"/> </UML:Action.script> ";
+ temp += " </UML:UninterpretedAction> </UML:Transition.effect>\n";
+
+ xmi += temp;
+ xmi += "</UML:Transition>\n";
+
+ // trans 5
+ temp = "t5";
+
+ xmi+= "<UML:Transition xmi.id=\"" + temp + "\"";
+ temp = "s4";
+ xmi+= " source=\"" + temp + "\"";
+ temp = "s1";
+ xmi += " target=\"" + temp + "\" name=\"\" isSpecification=\"false\">\n";
+
+ temp = "";
+ temp += "<UML:Transition.trigger> <UML:Event> <UML:ModelElement.namespace>";
+ temp += "<UML:Namespace> <UML:Namespace.ownedElement> ";
+ temp += "<UML:CallEvent xmi.id=\"XDE-C2891D3C-A49E-4DF0-BD95-A291630F4E4B\" ";
+ temp += " operation=\"XDE-4437EBF1-9C42-4EB4-B7CF-415697B567CD\" name=\"setTempOpState\"";
+ temp += " isSpecification=\"false\"/> </UML:Namespace.ownedElement> </UML:Namespace>";
+ temp += " </UML:ModelElement.namespace> </UML:Event> </UML:Transition.trigger>\n";
+
+ xmi += temp;
+ xmi += "</UML:Transition>\n";
+
+// for (tie(e, eend) = edges(uml_state_diagram); e != eend; ++e) {
+/* for (int k = 0; k < 6; ++k) {
+
+ // info determined from the trans itself....
+ //trans_label = uml_state_diagram[*e].edge_label;
+
+ temp = "t" + StringifyAnInt(k);
+
+ xmi+= "<UML:Transition xmi.id=\"" + temp + "\"";
+ temp = "s" + StringifyAnInt(uml_state_diagram[*e].start_state);
+ xmi+= " source=\"" + temp + "\"";
+ temp = "s" + StringifyAnInt(uml_state_diagram[*e].end_state);
+ xmi += " target=\"" + temp + "\" name=\"\" isSpecification=\"false\">\n";
+
+
+ temp = transGuardActionInfo[trans_label];
+ xmi += temp;
+ //temp = (transGuardActionInfo[uml_state_diagram[e*].edge_label])->second;
+
+ xmi += "</UML:Transition>\n";
+ }*/
+
+ //cout << "begin XMI" << endl;
+ //cout << xmi << endl;
+ //cout << "end XMI" << endl;
+
+
+}
+
void cOrganism::printXMI(cAvidaContext& ctx)
{
@@ -836,7 +989,7 @@
*/
- cout << "XMI : " << xmi << endl;
+ //cout << "XMI : " << xmi << endl;
}
@@ -861,15 +1014,15 @@
std::string cOrganism::getXMI()
{
-// std::string temp = xmi_begin + xmi + xmi_end;
+ std::string temp = xmi_begin + xmi + xmi_end;
// cout << "PRINT XMI" << endl;
// cout << temp << endl;
// cout << "END PRINT XMI" << endl;
// std::string temp = hil;
-// cout << "PRINT HIL" << endl;
-// cout << temp << endl;
-// cout << "END PRINT HIL" <<endl;
+ cout << "PRINT XMI" << endl;
+ cout << temp << endl;
+ cout << "END PRINT XMI" <<endl;
return (xmi_begin + xmi + xmi_end);
}
Modified: branches/uml/source/main/cOrganism.h
===================================================================
--- branches/uml/source/main/cOrganism.h 2006-12-25 17:22:39 UTC (rev 1152)
+++ branches/uml/source/main/cOrganism.h 2006-12-25 18:23:07 UTC (rev 1153)
@@ -240,6 +240,8 @@
// UML Stuff
void ModelCheck(cAvidaContext& ctx);
void printXMI(cAvidaContext& ctx);
+ void printIdealXMI(cAvidaContext& ctx);
+
void InitTransForXMI();
bool AddTrans(int trans, int orig, int dest);
double NumStates();
Modified: branches/uml/source/main/cStats.cc
===================================================================
--- branches/uml/source/main/cStats.cc 2006-12-25 17:22:39 UTC (rev 1152)
+++ branches/uml/source/main/cStats.cc 2006-12-25 18:23:07 UTC (rev 1153)
@@ -859,9 +859,24 @@
df.Write( GetUpdate(), "update" );
df.Write( av_number_of_states.Average(), "av num states");
df.Write( av_number_of_trans.Average(), "av num trans");
+ df.Write( m_hydraAttempt.Sum(), "total number of hydra attempts" );
+ df.Write( m_hydraPassed.Sum(), "total number of hydra passes" );
+ df.Write( m_spinAttempt.Sum(), "total number of spin attempts" );
+ df.Write( m_spinPassed.Sum(), "total number of spin passes" );
+ df.Write( m_panAttempt.Sum(), "total number of pan attempts" );
+ df.Write( m_panPassed.Sum(), "total number of pan passes" );
+
av_number_of_states.Clear();
av_number_of_trans.Clear();
+ m_hydraAttempt.Clear();
+ m_hydraPassed.Clear();
+ m_spinAttempt.Clear();
+ m_spinPassed.Clear();
+ m_panAttempt.Clear();
+ m_panPassed.Clear();
+
+
df.Endl();
}
Modified: branches/uml/source/main/cStats.h
===================================================================
--- branches/uml/source/main/cStats.h 2006-12-25 17:22:39 UTC (rev 1152)
+++ branches/uml/source/main/cStats.h 2006-12-25 18:23:07 UTC (rev 1153)
@@ -221,6 +221,13 @@
// Stats for UML state diagrams
cDoubleSum av_number_of_states;
cDoubleSum av_number_of_trans;
+
+ cDoubleSum m_hydraAttempt;
+ cDoubleSum m_hydraPassed;
+ cDoubleSum m_spinAttempt;
+ cDoubleSum m_spinPassed;
+ cDoubleSum m_panAttempt;
+ cDoubleSum m_panPassed;
cStats(); // @not_implemented
cStats(const cStats&); // @not_implemented
@@ -536,6 +543,12 @@
// UML Data Function
void UpdateModelStats (cOrganism::Graph& g);
+ void HydraAttempt() { ++m_hydraAttempt; }
+ void HydraPassed() { ++m_hydraPassed; }
+ void SpinAttempt() { ++m_spinAttempt; }
+ void SpinPassed() { ++m_spinPassed; }
+ void PanAttempt() { ++m_panAttempt; }
+ void PanPassed() { ++m_panPassed; }
// this value gets recorded when a creature with the particular
Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc 2006-12-25 17:22:39 UTC (rev 1152)
+++ branches/uml/source/main/cTaskLib.cc 2006-12-25 18:23:07 UTC (rev 1153)
@@ -2061,11 +2061,11 @@
double cTaskLib::Task_Hydra(cTaskContext* ctx) const
{
-
if (ctx->task_failed == 0) {
return 0;
}
+ m_world->GetStats().HydraAttempt();
cOrganism* organism = ctx->organism;
double bonus = 0.0;
@@ -2135,16 +2135,23 @@
return 0.0;
} else {
ctx->task_failed = ctx->task_failed && 1;
+ m_world->GetStats().HydraPassed();
return 1.0;
}
}
double cTaskLib::SpinCoprocess(const std::string& neverclaimFile) const {
+ m_world->GetStats().SpinAttempt();
int status=0;
std::string cmd = "./spin -a tmp.pr -N " + neverclaimFile + " &> /dev/null";
if(system(cmd.c_str())!=0) return 0.0;
- if(system("/usr/bin/gcc -DSAFETY pan.c -o pan &> /dev/null")!=0) return 0.0;
- if(system("./pan &> /dev/null")!=0) return 0.0;
+ m_world->GetStats().SpinPassed();
+ m_world->GetStats().PanAttempt();
+ //-e -n -a -w19 -m100000 -c1
+ if(system("/usr/bin/gcc pan.c -e -o pan &> /dev/null")!=0) return 0.0;
+ if(system("./pan -a &> ./pan.out")!=0) return 0.0;
+ if(system("cat pan.out | perl -e 'while(<STDIN>) { if(/errors:\s(\d+)/) {exit($1);}}'")!=0) return 0.0;
+ m_world->GetStats().PanPassed();
return 1.0;
}
Modified: branches/uml/source/tools/cDoubleSum.h
===================================================================
--- branches/uml/source/tools/cDoubleSum.h 2006-12-25 17:22:39 UTC (rev 1152)
+++ branches/uml/source/tools/cDoubleSum.h 2006-12-25 18:23:07 UTC (rev 1153)
@@ -26,6 +26,8 @@
static const double INF_ERR; // Value Returned by StdError if Infinate
cDoubleSum() { Clear(); }
+
+ cDoubleSum& operator++() { Add(1); return *this;}
void Clear() { s1 = s2 = s3 = s4 = n = 0; }
More information about the Avida-cvs
mailing list