[Avida-SVN] r1199 - branches/uml/source/main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Tue Jan 23 09:14:20 PST 2007
Author: hjg
Date: 2007-01-23 12:14:20 -0500 (Tue, 23 Jan 2007)
New Revision: 1199
Modified:
branches/uml/source/main/cOrganism.cc
branches/uml/source/main/cOrganism.h
branches/uml/source/main/cTaskLib.cc
Log:
Added graph reachability test to Hydra task.
Modified: branches/uml/source/main/cOrganism.cc
===================================================================
--- branches/uml/source/main/cOrganism.cc 2007-01-23 16:01:13 UTC (rev 1198)
+++ branches/uml/source/main/cOrganism.cc 2007-01-23 17:14:20 UTC (rev 1199)
@@ -1298,7 +1298,39 @@
}
+bool cOrganism::isConnected ()
+{
+// std::vector<int> component(num_vertices(uml_state_diagram));
+// int num = connected_components(uml_state_diagram, &component[0]);
+// if (num > 1) {
+// return 0;
+// }
+ Graph::vertex_iterator i, iend;
+ tie(i, iend) = vertices(uml_state_diagram);
+ int count = 0;
+
+
+/* if (NumStates() > 0) {
+ temp = StringifyAnInt(uml_state_diagram[0].state_label);
+ xmi += "<UML:Pseudostate xmi.id=\"s" + temp + "\" kind=\"initial\" outgoing=\"\" name=\"s";
+ xmi += temp + "\" isSpecification=\"false\"/>\n";
+ ++i;
+ }
+*/
+
+ for (; i != iend; ++i) {
+ if (in_degree(*i, uml_state_diagram) == 0) {
+ count ++;
+ if (count > 1) {
+ return 0;
+ }
+ }
+ }
+ return 1;
+}
+
+
// if you ask for something greater than the number of trans -- you get the highest numbered one...
int cOrganism::getTransLabelInPosition (int num)
{
@@ -1322,6 +1354,8 @@
}
+
+
bool cOrganism::InjectParasite(const cGenome& injected_code)
{
assert(m_interface);
Modified: branches/uml/source/main/cOrganism.h
===================================================================
--- branches/uml/source/main/cOrganism.h 2007-01-23 16:01:13 UTC (rev 1198)
+++ branches/uml/source/main/cOrganism.h 2007-01-23 17:14:20 UTC (rev 1199)
@@ -22,6 +22,7 @@
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
//#include <boost/graph/filtered_graph.hpp>
+#include <boost/graph/connected_components.hpp>
using namespace boost;
@@ -259,6 +260,7 @@
int getTransNumber (int pos);
bool findTrans(int s0_pos, int s1_pos, int t_pos);
void deleteTrans (int pos);
+ bool isConnected();
// This returns the list of transitions between two states. What I want is to look up one based
// on its placement in the trans_set, but this has already been solved by HIL printing. Check there after dinner.
Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc 2007-01-23 16:01:13 UTC (rev 1198)
+++ branches/uml/source/main/cTaskLib.cc 2007-01-23 17:14:20 UTC (rev 1199)
@@ -2181,9 +2181,15 @@
}
+
double cTaskLib::Task_Hydra(cTaskContext* ctx) const
{
cOrganism* organism = ctx->organism;
+
+ if (organism->isConnected() == 0) {
+ ctx->task_failed = 0;
+ return 0;
+ }
if (ctx->task_failed == 0) {
return 0;
More information about the Avida-cvs
mailing list