[Avida-SVN] r1169 - branches/uml/source/main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Sat Jan 6 10:38:39 PST 2007
Author: hjg
Date: 2007-01-06 13:38:39 -0500 (Sat, 06 Jan 2007)
New Revision: 1169
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:
Enhanced logging of organisms that generate models that pass the SPIN task.
Modified: branches/uml/source/main/cOrganism.cc
===================================================================
--- branches/uml/source/main/cOrganism.cc 2007-01-05 16:31:32 UTC (rev 1168)
+++ branches/uml/source/main/cOrganism.cc 2007-01-06 18:38:39 UTC (rev 1169)
@@ -741,8 +741,16 @@
Graph::edge_iterator e, eend;
int count = 0;
int s_start_lab, s_end_lab; //, trans_lab;
+ State* st_start;
+ State* st_end;
+ nsm_it i;
+
// Transition t;
+ if ((pos < 0) || (pos > NumTrans())) {
+ return;
+ }
+
for (tie(e, eend) = edges(uml_state_diagram); e != eend; ++e) {
if (count == pos) {
// remove_edge(e, uml_state_diagram);
@@ -757,6 +765,24 @@
count ++;
}
+ for (i=states.begin(); i!=states.end(); ++i)
+ {
+ if (i->first == s_start_lab) {
+ st_start = &(i->second);
+ }
+ if (i->first == s_end_lab) {
+ st_end = &(i->second);
+ }
+ }
+
+ if ((out_degree(*st_start, uml_state_diagram) == 0) && (in_degree(*st_start, uml_state_diagram) == 0)) {
+ remove_vertex(*st_start, uml_state_diagram);
+ }
+
+ if ((out_degree(*st_end, uml_state_diagram) == 0) && (in_degree(*st_end, uml_state_diagram) == 0)) {
+ remove_vertex(*st_end, uml_state_diagram);
+ }
+
return;
}
@@ -1098,16 +1124,11 @@
}
+
+
// if you ask for something greater than the number of states then you get the highest numbered state.
int cOrganism::getStateLabelInPosition (int num)
{
- /*std::pair<vertex_iterator, vertex_iterator>
-vertices(const adjacency_list& g)*/
-// Graph::vertex_iterator vi, vi_end;
-// tie(vi,vi_end) = vertices(uml_state_diagram);
-// vi+=num;
- //graph_traits<Graph>::vertex_descriptor b = *vi;
-// return *vi;
int count = 0;
// This code uses a value ordering on the states (lowest number = position 0)
@@ -1120,12 +1141,7 @@
count++;
}
return i->first;
-
-/*
- int x = PosToStateLabel[num];
- return (states[x]);
-*/
}
@@ -1141,7 +1157,6 @@
}
count++;
}
- int test = i->first;
return i->first;
Modified: branches/uml/source/main/cOrganism.h
===================================================================
--- branches/uml/source/main/cOrganism.h 2007-01-05 16:31:32 UTC (rev 1168)
+++ branches/uml/source/main/cOrganism.h 2007-01-06 18:38:39 UTC (rev 1169)
@@ -104,7 +104,9 @@
//!Types of the UML types for states and transitions
// define graph -- multisetS - allows for the sorting of out edges by target vertex
-typedef adjacency_list<multisetS, vecS, directedS, state_info, edge_info> Graph;
+//bidirectionalS
+//typedef adjacency_list<multisetS, vecS, directedS, state_info, edge_info> Graph;
+typedef adjacency_list<multisetS, vecS, bidirectionalS, state_info, edge_info> Graph;
// map the graph's vertex's to their descriptors
typedef graph_traits<Graph>::vertex_descriptor State;
typedef std::map<int, State> NameStateMap;
Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc 2007-01-05 16:31:32 UTC (rev 1168)
+++ branches/uml/source/main/cTaskLib.cc 2007-01-06 18:38:39 UTC (rev 1169)
@@ -9,6 +9,8 @@
*/
#include "cTaskLib.h"
+#include "cGenotype.h"
+#include <iostream>
#include <unistd.h>
#include <math.h>
#include <sys/types.h>
@@ -2215,7 +2217,8 @@
}
}
-double cTaskLib::SpinCoprocess(const std::string& neverclaimFile) const {
+double cTaskLib::SpinCoprocess(cTaskContext* ctx, const std::string& neverclaimFile) const {
+ cOrganism* organism = ctx->organism;
m_world->GetStats().SpinAttempt();
int status=0;
std::string cmd = "cat " + neverclaimFile + " >> tmp.pr && ./spin -a tmp.pr &> /dev/null";
@@ -2228,13 +2231,18 @@
if(system("/usr/bin/gcc pan.c -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;
+ //cmd = "cp tmp.xmi " + organism->GetGenotype()->GetID() + ".xml";
+ std::ostringstream strstrm;
+ strstrm << "cp tmp.xmi " << m_world->GetStats().GetUpdate()
+ << "." + organism->GetID() << "." << organism->GetGenotype()->GetID() << ".xml";
+ if(system(strstrm.str().c_str())!=0) return 0.0;
m_world->GetStats().PanPassed();
return 1.0;
}
double cTaskLib::Task_SpinN1(cTaskContext* ctx) const {
if (ctx->task_failed) {
- return SpinCoprocess("N1");
+ return SpinCoprocess(ctx, "N1");
}
return 0.0;
}
Modified: branches/uml/source/main/cTaskLib.h
===================================================================
--- branches/uml/source/main/cTaskLib.h 2007-01-05 16:31:32 UTC (rev 1168)
+++ branches/uml/source/main/cTaskLib.h 2007-01-06 18:38:39 UTC (rev 1169)
@@ -32,6 +32,7 @@
class cOrganism;
+class cGenotype;
class cString;
class cWorld;
@@ -254,7 +255,7 @@
double Task_Transition_bs9(cTaskContext* ctx) const;
double Task_Transition_bs10(cTaskContext* ctx) const;
- double SpinCoprocess(const std::string& neverclaimFile) const;
+ double SpinCoprocess(cTaskContext* ctx, const std::string& neverclaimFile) const;
double Task_SpinN1(cTaskContext* ctx) const;
};
More information about the Avida-cvs
mailing list