[Avida-SVN] r1113 - in branches/uml: Avida.xcodeproj source/actions source/cpu source/main

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Tue Dec 5 18:43:42 PST 2006


Author: hjg
Date: 2006-12-05 21:43:42 -0500 (Tue, 05 Dec 2006)
New Revision: 1113

Modified:
   branches/uml/Avida.xcodeproj/project.pbxproj
   branches/uml/source/actions/PrintActions.cc
   branches/uml/source/cpu/cHardwareCPU.cc
   branches/uml/source/cpu/cHardwareCPU.h
   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/main/cTaskLib.h
Log:
The underlying UML representation has been changed to use the Boost graph library. 
Code has been introduced to use Hydra and Spin, as well as print HIL and XMI.


Modified: branches/uml/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/uml/Avida.xcodeproj/project.pbxproj	2006-12-06 01:34:11 UTC (rev 1112)
+++ branches/uml/Avida.xcodeproj/project.pbxproj	2006-12-06 02:43:42 UTC (rev 1113)
@@ -1971,6 +1971,7 @@
 				GCC_UNROLL_LOOPS = YES;
 				GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
 				PREBINDING = NO;
+				USER_HEADER_SEARCH_PATHS = "/opt/local/include/ $(inherited)";
 				WARNING_CFLAGS = (
 					"-Wextra",
 					"-Wno-four-char-constants",
@@ -1993,6 +1994,7 @@
 				GCC_STRICT_ALIASING = YES;
 				GCC_UNROLL_LOOPS = YES;
 				PREBINDING = NO;
+				USER_HEADER_SEARCH_PATHS = "/opt/local/include/ $(inherited)";
 				WARNING_CFLAGS = (
 					"-Wextra",
 					"-Wno-four-char-constants",
@@ -2143,6 +2145,7 @@
 				GCC_STRICT_ALIASING = YES;
 				GCC_UNROLL_LOOPS = YES;
 				PREBINDING = NO;
+				USER_HEADER_SEARCH_PATHS = "/opt/local/include/ $(inherited)";
 				WARNING_CFLAGS = (
 					"-Wextra",
 					"-Wno-four-char-constants",
@@ -2167,6 +2170,7 @@
 				GCC_UNROLL_LOOPS = YES;
 				OTHER_CFLAGS = "-falign-loops=16";
 				PREBINDING = NO;
+				USER_HEADER_SEARCH_PATHS = "/opt/local/include/ $(inherited)";
 				WARNING_CFLAGS = (
 					"-Wextra",
 					"-Wno-four-char-constants",
@@ -2239,6 +2243,7 @@
 				GCC_UNROLL_LOOPS = YES;
 				PREBINDING = NO;
 				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
+				USER_HEADER_SEARCH_PATHS = "/opt/local/include/ $(inherited)";
 				WARNING_CFLAGS = (
 					"-Wextra",
 					"-Wno-four-char-constants",

Modified: branches/uml/source/actions/PrintActions.cc
===================================================================
--- branches/uml/source/actions/PrintActions.cc	2006-12-06 01:34:11 UTC (rev 1112)
+++ branches/uml/source/actions/PrintActions.cc	2006-12-06 02:43:42 UTC (rev 1113)
@@ -64,6 +64,7 @@
 STATS_OUT_FILE(PrintInstructionData,   instruction.dat     );
 STATS_OUT_FILE(PrintGenotypeMap,       genotype_map.m      );
 STATS_OUT_FILE(PrintMarketData,		   market.dat		   );
+STATS_OUT_FILE(PrintUMLData,		   uml.dat			   );
 
 #define POP_OUT_FILE(METHOD, DEFAULT)                                                     /*  1 */ \
 class cAction ## METHOD : public cAction {                                                /*  2 */ \
@@ -1475,6 +1476,7 @@
   action_lib->Register<cActionPrintInstructionData>("PrintInstructionData");
   action_lib->Register<cActionPrintGenotypeMap>("PrintGenotypeMap");
   action_lib->Register<cActionPrintMarketData>("PrintMarketData");
+  action_lib->Register<cActionPrintUMLData>("PrintUMLData");
   
   // Population Out Files
   action_lib->Register<cActionPrintPhenotypeData>("PrintPhenotypeData");

Modified: branches/uml/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.cc	2006-12-06 01:34:11 UTC (rev 1112)
+++ branches/uml/source/cpu/cHardwareCPU.cc	2006-12-06 02:43:42 UTC (rev 1113)
@@ -352,14 +352,14 @@
     cInstEntryCPU("skip",      &cHardwareCPU::Inst_Skip),
 	
 	    // UML Element Creation
-	cInstEntryCPU("cr-state", &cHardwareCPU::Inst_CreateState, false, 
-					"Create a state"), 
+//	cInstEntryCPU("cr-state", &cHardwareCPU::Inst_CreateState, false, 
+//					"Create a state"), 
 	cInstEntryCPU("cr-trans", &cHardwareCPU::Inst_CreateTransition, false, 
 					"Create a transition"), 
-	cInstEntryCPU("model-ch", &cHardwareCPU::Inst_ModelCheck, false, 
-					"Model check the model"), 
-	cInstEntryCPU("cr-trans2", &cHardwareCPU::Inst_CreateTransitionIntStates, false, 
-					"Create a transition; States read from registers")
+//	cInstEntryCPU("model-ch", &cHardwareCPU::Inst_ModelCheck, false, 
+//					"Model check the model"), 
+//	cInstEntryCPU("cr-trans2", &cHardwareCPU::Inst_CreateTransitionIntStates, false, 
+//					"Create a transition; States read from registers")
   };
   
   const int n_size = sizeof(s_n_array)/sizeof(cNOPEntryCPU);
@@ -3376,6 +3376,8 @@
 
 
 //// UML Element Construction ////
+
+/*
 bool cHardwareCPU::Inst_CreateState(cAvidaContext& ctx)
 {
 	const int reg_used = FindModifiedRegister(REG_AX);
@@ -3408,8 +3410,6 @@
 }
 
 
-/// This function is the same as the Inst_TaskIO function ///
-/// It should be modified to update the fitness value for the organism without performing IO. ///
 bool cHardwareCPU::Inst_ModelCheck(cAvidaContext& ctx)
 {
 //  const int reg_used = FindModifiedRegister(REG_BX);
@@ -3423,10 +3423,9 @@
 //  GetRegister(reg_used) = value_in;
 //  organism->DoInput(value_in);
   return true;
+}
 
 
-}
-
 bool cHardwareCPU::Inst_CreateTransitionIntStates(cAvidaContext& ctx)
 {
 
@@ -3458,4 +3457,29 @@
 	return true;
 
 }
+*/
 
+bool cHardwareCPU::Inst_CreateTransition(cAvidaContext& ctx)
+{
+	// a transition should consist of an integer in a nop.
+	int reg_used = FindModifiedRegister(REG_AX);
+	int trans = GetRegister(reg_used);
+	
+// the origin and destination states are determined by the values in reg b and reg c.
+// both registers could be modified by a nop...
+	reg_used = FindModifiedRegister(REG_BX);
+    int orig_state = GetRegister(reg_used);
+	reg_used = FindNextRegister(reg_used);
+	int dest_state = GetRegister(reg_used);
+	
+	//cout << "trans: " << trans << " orig_state: " << orig_state << " dest_state: " << dest_state << endl;
+	return organism->AddTrans(trans, orig_state, dest_state);	
+	// create or find destination state
+
+	// check to see if this transition already exists; else add it
+
+	 
+//	return true;
+}
+
+

Modified: branches/uml/source/cpu/cHardwareCPU.h
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.h	2006-12-06 01:34:11 UTC (rev 1112)
+++ branches/uml/source/cpu/cHardwareCPU.h	2006-12-06 02:43:42 UTC (rev 1113)
@@ -472,10 +472,11 @@
   bool Inst_Skip(cAvidaContext& ctx);
   
     //// UML Element Construction ////
-  bool Inst_CreateState(cAvidaContext& ctx);
+//  bool Inst_CreateState(cAvidaContext& ctx);
+//  bool Inst_CreateTransition(cAvidaContext& ctx);
+//  bool Inst_ModelCheck(cAvidaContext& ctx);
   bool Inst_CreateTransition(cAvidaContext& ctx);
-  bool Inst_ModelCheck(cAvidaContext& ctx);
-  bool Inst_CreateTransitionIntStates(cAvidaContext& ctx);
+//  bool Inst_CreateTransitionIntStates(cAvidaContext& ctx);
 };
 
 

Modified: branches/uml/source/main/cOrganism.cc
===================================================================
--- branches/uml/source/main/cOrganism.cc	2006-12-06 01:34:11 UTC (rev 1112)
+++ branches/uml/source/main/cOrganism.cc	2006-12-06 02:43:42 UTC (rev 1113)
@@ -30,6 +30,8 @@
 #include "cWorld.h"
 #include "cStats.h"
 
+
+
 #include <iomanip>
 
 using namespace std;
@@ -78,10 +80,10 @@
   
   if (m_world->GetConfig().NET_ENABLED.Get()) m_net = new cNetSupport();
   m_id = m_world->GetStats().GetTotCreatures();
-
-  // initialize the transition information vector w/ the XMI info for transitions
-  InitTransForHIL();
-
+  
+  // UML
+  // initialize the hil string values
+  InitHILBandE();		
 }
 
 
@@ -409,8 +411,9 @@
 void cOrganism::ModelCheck(cAvidaContext& ctx)
 {
 
-//  printXMI(ctx);
+//	cout << "Model check begin " << endl;
 	printHIL(ctx);
+//	cout << "Model check end " << endl;
 
   assert(m_interface);
   const tArray<double> & resource_count = m_interface->GetResources();
@@ -464,51 +467,12 @@
     m_hardware->ProcessBonusInst(ctx, cInstruction(cur_inst) );
   }
   
+  m_world->GetStats().UpdateModelStats(uml_state_diagram);
   
 }
 
-void cOrganism::printHIL(cAvidaContext& ctx)
-{
-	int curr_state;
-	std::map <int, std::string>::iterator itr;
-	InitTransForHIL();
-	
-	for (t_transitionMap::iterator it = uml_trans_by_state.begin(); it != uml_trans_by_state.end(); ++it) {
-	
-		// initialize the value of current state... 
-		if (it == uml_trans_by_state.begin() ) {
-			curr_state = (*it).first;
-			cout << "Initial  \"\" " << (*it).first << ";" << endl;
-			cout << "State " << (*it).first << " {" << endl;
-		}
-		// what to do when the state we are processing transitions for changes...
-		if (curr_state != (*it).first) {
-			curr_state = (*it).first;
-			// finish previous state
-			cout << "}" << endl;
-			// add into for next state
-			cout << "State " << (*it).first << " {" << endl;
-		}
-		
-		// print out transition information....
-		// find trans in set of trans
-		if ( (itr = uml_trans_set.find((*it).second.first)) != uml_trans_set.end()) {
-			cout << "Transition \"" << (*itr).second << "\" to " << (*it).second.second << ";" << endl;
-		} 
-		
-		uml_state_set.erase((*it).first);
-		
-	}
-	cout << "}" << endl;
-	
-	// print info for states with no outgoing transitions
-	for (std::set<int>::iterator its = uml_state_set.begin(); its!= uml_state_set.end(); ++its) {
-		cout << "State " << (*its) << endl;
-		cout << "}" << endl;
-	}
-	
-}
 
+/*
 void cOrganism::printXMI(cAvidaContext& ctx)
 {
 
@@ -597,14 +561,59 @@
 	trans_info.push_back("<UML:Transition.effect> <UML:UninterpretedAction xmi.id=\"XDE-101E5C46-12EA-4169-9DC9-D3661EE9836B\" isAsynchronous=\"false\" name=\"\" isSpecification=\"false\"> <UML:Action.script> <UML:ActionExpression language=\"\" body=\"^ComputingComponent.setBrightnessValue(brightnessValue)\"/> </UML:Action.script> </UML:UninterpretedAction> </UML:Transition.effect>");
 	
 }
-
+*/
 void cOrganism::InitTransForHIL()
 {
 
 	// assign transition values to map elements
 	std::map <int, std::string>::iterator it;
-	 
-	if (uml_trans_set.size() >= 6) {
+	int count = 0;
+
+	for (it = transGuardActionInfo.begin(); it!=transGuardActionInfo.end(); ++it) { 
+	switch (count){
+		case 0:
+			(*it).second = "";
+			break;
+		case 1:
+			(*it).second = "getOperationalState";
+			break;
+		case 2:
+			(*it).second = "/operationalState:=1^ComputingComponent.ccTRUE";
+			break;	
+		case 3: 
+			(*it).second = "/operationalState:=0^ComputingComponent.ccFALSE";
+			break;
+		case 4: 
+			(*it).second = "getBrightnessValue";
+			break;
+		case 5:
+			(*it).second = "^Environment.getBrightnessValue";
+			break;
+		case 6:
+			 (*it).second = "setBrightnessValue(brightnessValue)";
+			break;
+		case 7:
+			(*it).second = "[brightnessValue<0]/correctedBrightnessValue:=0";
+			break;
+		case 8:
+			(*it).second = "[brightnessValue >=0 & brightnessValue<=1000]/correctedBrightnessValue:=brightnessValue";
+			break;
+		case 9:
+			(*it).second = "[brightnessValue>1000]/correctedBrightnessValue:=1000";
+			break;
+		case 10:
+			(*it).second = "^ComputingComponent.setBrightnessValue(brightnessValue)";
+			break;
+		default:
+			(*it).second = "--too many trans--";
+	}
+		count++;
+	}	
+}	
+	
+	
+	
+/*	if (transGuardActionInfo.size() >= 6) {
 	it = uml_trans_set.begin();
 	(*it).second = "";
 	++it;
@@ -617,7 +626,7 @@
 	(*it).second = "getOperationalState";
 	++it;
 	(*it).second = "getBrightnessValue";
-/*	++it;
+	++it;
 	(*it).second = "^ComputingComponent.setBrightnessValue(brightnessValue)";
 	++it;
 	(*it).second = "[brightnessValue<0]/correctedBrightnessValue:=0";
@@ -626,10 +635,476 @@
 	++it;
 	(*it).second = "[brightnessValue>1000]/correctedBrightnessValue:=1000";
 	++it;
-	(*it).second = "setBrightnessValue(brightnessValue)";*/
+	(*it).second = "setBrightnessValue(brightnessValue)";
+	}*/
+
+
+
+//void cOrganism::AssignTransMeaning (int trans)
+//{ 
+	
+
+//	return;
+//}
+
+
+bool cOrganism::AddTrans(int trans, int orig, int dest) 
+{
+	NameStateMap::iterator pos1, pos2;
+	bool inserted1, inserted2, inserted3;
+	bool exists = 0;
+	State u, v;
+
+
+	// create or find origin state
+	tie(pos1, inserted1) = states.insert(std::make_pair(orig, State()));
+        if (inserted1) {
+                u = add_vertex(uml_state_diagram);
+                //cout << "added state named " << orig << endl;
+                uml_state_diagram[u].state_label = orig;
+                pos1->second = u;
+        } else  {
+                u = pos1->second;
+                //cout << "found state named " << orig << endl;
+        }
+
+	// create or find dest state
+	tie(pos2, inserted2) = states.insert(std::make_pair(dest, State()));
+        if (inserted2) {
+                v = add_vertex(uml_state_diagram);
+                //cout << "added state named " << dest << endl;
+                uml_state_diagram[v].state_label = dest;
+                pos2->second = v;
+        } else  {
+                v = pos2->second;
+                //cout << "found state named " << dest << endl;
+        }
+		// call isTrans...	
+		exists = isTrans(u, v, trans);
+		if (exists == 0) {
+			tie(transitions, inserted3) = add_edge(u, v, uml_state_diagram);
+			//cout << "Adding transition " << u << " " << v << " " << trans << endl;
+			if (inserted3) {
+				uml_state_diagram[transitions].edge_label = trans;
+				//cout << "added edge labeled " << trans << endl;
+				// add trans to table...
+				transGuardActionInfo.insert(std::make_pair(trans, ""));
+			}
+		}
+	return true;
+}
+
+// similar to getTransBetweenVertices... 
+// optimization candidate perhaps using edge_range as per DBK
+bool cOrganism::isTrans(State u, State v, int trans_name)
+{
+	oei e1, e2;
+	bool exists = 0;
+
+	// check to see if another trans has the same start, dest, and label 
+	// if so, do not create trans. Else, create trans.
+	for (tie(e1, e2) = out_edges(u, uml_state_diagram); e1 != e2; ++e1) {
+		if ((target(*e1, uml_state_diagram) == v) && (uml_state_diagram[*e1].edge_label == trans_name)) {
+			 exists = 1;
+			 break;
+		} 
 	}
+	
+	return exists;
 }
 
+int cOrganism::getTransNumber (int pos) 
+{
+	int count = 0;
+	int trans_name = -1;
+	std::map <int, std::string>::iterator it;
+	
+	for (it = transGuardActionInfo.begin(); it!=transGuardActionInfo.end(); ++it) { 
+		if (count == pos){
+			trans_name = (*it).first;
+			break;
+		}
+		count++;
+	}
+	
+	return trans_name;
+
+}
+
+bool cOrganism::findTrans(int s0_pos, int s1_pos, int t_pos)
+{
+	int found_entry = 0;
+	int trans_name;
+	
+	trans_name = getTransNumber (t_pos); 
+	
+	if (trans_name == -1) {
+		return found_entry;
+	}
+	
+	if ((NumStates() <= s0_pos) || (NumStates() <= s1_pos)) {
+		return found_entry;
+	}
+	
+	cOrganism::State& s0 = getStateInPosition(s0_pos);
+	cOrganism::State& s1 = getStateInPosition(s1_pos);
+
+	if (isTrans(s0, s1, trans_name)) { 
+		found_entry = 1;
+	} 
+	
+	return found_entry;
+
+}
+
+
+void cOrganism::printHIL(cAvidaContext& ctx)
+{
+	Graph::vertex_iterator i, iend;
+	
+	oei e1, e2;
+	int trans_label;
+	int dest_state;
+	std::string temp;
+	int tempint;
+	
+	InitTransForHIL();
+
+	hil = "";
+	// loop through all states
+	// print initial information for the init state.
+	//cout << "Num states: " << NumStates() << endl;
+	if (NumStates() > 0) {
+		//cout << "Initial \"\" " << uml_state_diagram[0].state_label << endl;
+		hil += "Initial \"\" s"; 
+		temp = StringifyAnInt(uml_state_diagram[0].state_label);
+		hil += temp;
+		hil += " ; \n"; 
+
+	}
+	
+	for (tie(i, iend) = vertices(uml_state_diagram); i != iend; ++i) {
+//		cout << "State " << uml_state_diagram[*i].state_label << " { " << endl;
+		hil += "State s";
+		temp = StringifyAnInt(uml_state_diagram[*i].state_label);
+		hil += temp;
+		hil += " { \n"; 
+
+		// print each transition...
+		for (tie(e1, e2) = out_edges((*i), uml_state_diagram); e1 != e2; ++e1) {
+			trans_label = uml_state_diagram[*e1].edge_label;
+			dest_state = target(*e1, uml_state_diagram);
+			hil += "Transition \"" +  transGuardActionInfo[trans_label];
+//			temp = StringifyAnInt(tempint);
+			hil += "\" to s";
+			temp = StringifyAnInt( uml_state_diagram[dest_state].state_label);
+			hil += temp + " ; \n";
+		}
+		hil +=  "} \n"; 
+	}
+	//cout << "HIL : " << hil << endl;
+	
+}
+
+
+
+
+std::string cOrganism::StringifyAnInt(int x) { 
+	std::ostringstream o;
+	o << x;
+	return o.str();
+}
+
+// return the number of states in a state diagram
+double cOrganism::NumStates() 
+{
+	return (double) num_vertices(uml_state_diagram);
+}
+
+double cOrganism::NumTrans()
+{
+	return (double) num_edges(uml_state_diagram);
+}
+
+std::string cOrganism::getHil()
+{
+//	std::string temp = hil_begin + hil + hil_end;
+//	std::string temp = hil;
+
+//	cout << "PRINT HIL" << endl;
+//	cout << temp << endl;
+//	cout << "END PRINT HIL" <<endl;
+	return (hil_begin + hil + hil_end);
+}
+
+void cOrganism::InitHILBandE()
+{
+	hil_begin = "Formalize as promela ;\n \
+	Model XDEModel{\n \
+	Class BrightnessSensor {\n \
+		InstanceVar int brightnessValue ;\n \
+		InstanceVar int correctedBrightnessValue ;\n \
+        InstanceVar bool operationalState ;\n \
+        Signal getBrightnessValue( ) ;\n \
+        Signal getOperationalState( ) ;\n \
+        Signal setBrightnessValue(int ) ;\n ";
+
+
+	hil_end = " } \n \
+	Class ComputingComponent {\n \
+        InstanceVar bool automaticMode ;\n \
+        InstanceVar int brightnessValue ;\n \
+        InstanceVar int computedDimmerValue ;\n \
+        InstanceVar int desiredBrightnessValue ;\n \
+        InstanceVar bool initialized ;\n \
+        InstanceVar bool manualMode ;\n \
+        InstanceVar bool motionDetected ;\n \
+        Signal ccAck( ) ;\n \
+        Signal ccFALSE( ) ;\n \
+        Signal ccTRUE( ) ;\n \
+        Signal setBrightnessValue(int ) ;\n \
+        Signal setDesiredBrightnessValue(int ) ;\n \
+        Initial  \"\" Init ;\n \
+        State Init  {\n \
+                Transition \"\" to Initialize ;\n \
+        }\n \
+        CompositeState Initialize {\n \
+                Transition \"ccFALSE\" to PowerOff ;\n \
+        Initial  \"\" InitializationStart ;\n \
+        State BSensRec  {\n \
+                Transition \"^MotionSensor.getOperationalState\" to MSensReq ;\n \
+        }\n \
+        State BSensReq  {\n \
+                Transition \"ccTRUE\" to BSensRec ;\n \
+        }\n \
+        State DimmerRec  {\n \
+                Transition \"^BrightnessSensor.getOperationalState\" to BSensReq ;\n \
+        }\n \
+        State DimmerReq  {\n \
+                Transition \"ccTRUE\" to DimmerRec ;\n \
+        }\n \
+        State InitializationStart  {\n \
+                Transition \"^Dimmer.getOperationalState\" to DimmerReq ;\n \
+        }\n \
+        State MSensReq  {\n \
+                Transition \"ccTRUE/initialized:=1\" to NormalBehavior ;\n \
+        }\n \
+        }\n \
+        CompositeState NormalBehavior {\n \
+        Initial  \"\" NBInit ;\n \
+        CompositeState Automatic {\n \
+        Initial  \"/automaticMode:=1^UserInterface.setDisplayMode(1)\" AIdle ;\n \
+        State AIdle  {\n \
+                Transition \"ccAck^MotionSensor.isRoomOccupied\" to State1 ;\n \
+        }\n \
+        State ActualValueRequested  {\n \
+                Transition \"setBrightnessValue(brightnessValue)\" to BrightnessValueReceived ;\n \
+        }\n \
+        State BrightnessValueReceived  {\n \
+                Transition \"/computedDimmerValue:=desiredBrightnessValue-brightnessValue\" to CorrectionValueCalculated ;\n \
+        }\n \
+        State CorrectionValueCalculated  {\n \
+                Transition \"^Dimmer.changeDimmerValue(computedDimmerValue)\" to CorrectionValueSumbitted ;\n \
+        }\n \
+        State CorrectionValueSumbitted  {\n \
+                Transition \"ccAck/automaticMode:=0; motionDetected:=0\" to NBInit ;\n \
+        }\n \
+        State DesiredValueReceived  {\n \
+                Transition \"^BrightnessSensor.getBrightnessValue\" to ActualValueRequested ;\n \
+        }\n \
+        State DesiredValueRequested  {\n \
+                Transition \"setDesiredBrightnessValue(desiredBrightnessValue)\" to DesiredValueReceived ;\n \
+        }\n \
+        State MotionValueReceived  {\n \
+                Transition \"[motionDetected=1]^UserInterface.getDesiredBrightnessValue\" to DesiredValueRequested ;\n \
+                Transition \"[motionDetected=0]\" to NBInit ;\n \
+        }\n \
+        State State1  {\n \
+                Transition \"ccFALSE/motionDetected:=0\" to MotionValueReceived ;\n \
+                Transition \"ccTRUE/motionDetected:=1\" to MotionValueReceived ;\n \
+        }\n \
+        }\n \
+        State EnterAuto  {\n \
+                Transition \"\" to OpStatusAutoSet ;\n \
+        }\n \
+        State EnterManual  {\n \
+                Transition \"\" to OpStatusManualSet ;\n \
+        }\n \
+        CompositeState Manual {\n \
+        Initial  \"/manualMode:=1^UserInterface.setDisplayMode(2)\" MIdle ;\n \
+        State DimmerValueSet  {\n \
+                Transition \"ccAck\" to Done ;\n \
+        }\n \
+        State Done  {\n \
+                Transition \"/manualMode:=0\" to NBInit ;\n \
+        }\n \
+        State MIdle  {\n \
+                Transition \"ccAck^Dimmer.changeDimmerValue(1000)\" to DimmerValueSet ;\n \
+        }\n \
+        }\n \
+        State ManualModeCheck  {\n \
+                Transition \"ccTRUE\" to EnterManual ;\n \
+                Transition \"ccFALSE\" to EnterAuto ;\n \
+        }\n \
+        State NBInit  {\n \
+                Transition \"^UserInterface.isManualMode\" to ManualModeCheck ;\n \
+        }\n \
+        State OpStatusAutoSet  {\n \
+                Transition \"\" to Automatic ;\n \
+        }\n \
+        State OpStatusManualSet  {\n \
+                Transition \"\" to Manual ;\n \
+        }\n \
+        }\n \
+        State PowerOff  {\n \
+        }\n \
+}\n \
+Class Dimmer {\n \
+        InstanceVar int deltaDimmerValue ;\n \
+        InstanceVar int dimmerValue ;\n \
+        InstanceVar bool operationalState ;\n \
+        InstanceVar int tempDimmerValue ;\n \
+        Signal changeDimmerValue(int ) ;\n \
+        Signal dimmerAck( ) ;\n \
+        Signal getOperationalState( ) ;\n \
+        Initial  \"\" Idle ;\n \
+        State DetermineOS  {\n \
+                Transition \"/operationalState:=1^ComputingComponent.ccTRUE\" to Idle ;\n \
+                Transition \"/operationalState:=0^ComputingComponent.ccFALSE\" to Idle ;\n \
+        }\n \
+        State DimmerValueSet  {\n \
+                Transition \"dimmerAck^ComputingComponent.ccAck\" to Idle ;\n \
+        }\n \
+        State Idle  {\n \
+                Transition \"getOperationalState\" to DetermineOS ;\n \
+                Transition \"changeDimmerValue(deltaDimmerValue)/tempDimmerValue:=dimmerValue+deltaDimmerValue\" to TempValueReceived ;\n \
+        }\n \
+        State TempValueReceived  {\n \
+                Transition \"[tempDimmerValue>1000]/dimmerValue:=1000\" to ValueProcessed ;\n \
+                Transition \"[tempDimmerValue>=0 & tempDimmerValue<=1000]/dimmerValue:=tempDimmerValue\" to ValueProcessed ;\n \
+                Transition \"[tempDimmerValue<0]/dimmerValue:=0\" to ValueProcessed ;\n \
+        }\n \
+        State ValueProcessed  {\n \
+                Transition \"^Environment.setDimmerValue(dimmerValue)\" to DimmerValueSet ;\n \
+        }\n \
+}\n \
+Class Environment {\n \
+        InstanceVar int brightnessValue ;\n \
+        InstanceVar int dimmerValue ;\n \
+        InstanceVar bool motionValue ;\n \
+        InstanceVar int totalBrightnessValue ;\n \
+        Signal getBrightnessValue( ) ;\n \
+        Signal isRoomOccupied( ) ;\n \
+        Signal setDimmerValue(int ) ;\n \
+        Initial  \"\" Idle ;\n \
+        State BrightnessValueRequested  {\n \
+                Transition \"/brightnessValue:=1100\" to BrightnessValueSelected ;\n \
+                Transition \"/brightnessValue:=850\" to BrightnessValueSelected ;\n \
+                Transition \"/brightnessValue:=0\" to BrightnessValueSelected ;\n \
+                Transition \"/brightnessValue:=300\" to BrightnessValueSelected ;\n \
+        }\n \
+        State BrightnessValueSelected  {\n \
+                Transition \"/totalBrightnessValue:=brightnessValue+dimmerValue\" to TotalValueComputed ;\n \
+        }\n \
+        State DimmerValueSet  {\n \
+                Transition \"/totalBrightnessValue:=brightnessValue+dimmerValue^Dimmer.dimmerAck\" to Idle ;\n \
+        }\n \
+        State Idle  {\n \
+                Transition \"setDimmerValue(dimmerValue)\" to DimmerValueSet ;\n \
+                Transition \"isRoomOccupied\" to MotionValueRequested ;\n \
+                Transition \"getBrightnessValue\" to BrightnessValueRequested ;\n \
+        }\n \
+        State MotionValueRequested  {\n \
+                Transition \"/motionValue:=1^MotionSensor.msTRUE\" to MotionValueSelected ;\n \
+                Transition \"/motionValue:=0^MotionSensor.msFALSE\" to MotionValueSelected ;\n \
+        }\n \
+        State MotionValueSelected  {\n \
+                Transition \"\" to Idle ;\n \
+        }\n \
+        State TotalValueComputed  {\n \
+                Transition \"^BrightnessSensor.setBrightnessValue(totalBrightnessValue)\" to Idle ;\n \
+        }\n \
+}\n \
+Class MotionSensor {\n \
+        InstanceVar bool motionValue ;\n \
+        InstanceVar bool operationalState ;\n \
+        Signal getOperationalState( ) ;\n \
+        Signal isRoomOccupied( ) ;\n \
+        Signal msFALSE( ) ;\n \
+        Signal msTRUE( ) ;\n \
+        Initial  \"\" Idle ;\n \
+        State DetermineOS  {\n \
+                Transition \"/operationalState:=1^ComputingComponent.ccTRUE\" to Idle ;\n \
+                Transition \"/operationalState:=0^ComputingComponent.ccFALSE\" to Idle ;\n \
+        }\n \
+        State Idle  {\n \
+                Transition \"getOperationalState\" to DetermineOS ;\n \
+                Transition \"isRoomOccupied^Environment.isRoomOccupied\" to MotionValueRequested ;\n \
+        }\n \
+        State MotionValueRequested  {\n \
+                Transition \"msFALSE^ComputingComponent.ccFALSE\" to Idle ;\n \
+                Transition \"msTRUE^ComputingComponent.ccTRUE\" to Idle ;\n \
+        }\n \
+}\n \
+Class UserInterface {\n \
+        InstanceVar int desiredBrightnessValue ;\n \
+        InstanceVar short displayMode ;\n \
+        InstanceVar bool manualMode ;\n \
+        Signal getDesiredBrightnessValue( ) ;\n \
+        Signal isManualMode( ) ;\n \
+        Signal setDisplayMode(short ) ;\n \
+        Initial  \"\" DesiredValueRequested ;\n \
+        State DesiredValueRequested  {\n \
+                Transition \"/desiredBrightnessValue:=1000\" to Idle ;\n \
+                Transition \"/desiredBrightnessValue:=500\" to Idle ;\n \
+                Transition \"/desiredBrightnessValue:=0\" to Idle ;\n \
+        }\n \
+        State Idle  {\n \
+                Transition \"isManualMode\" to State2 ;\n \
+                Transition \"setDisplayMode(displayMode)\" to OperationalStatusSet ;\n \
+                Transition \"getDesiredBrightnessValue\" to State1 ;\n \
+        }\n \
+        State OperationalStatusSet  {\n \
+                Transition \"^ComputingComponent.ccAck\" to Idle ;\n \
+        }\n \
+        State State1  {\n \
+                Transition \"^ComputingComponent.setDesiredBrightnessValue(desiredBrightnessValue)\" to Idle ;\n \
+        }\n \
+        State State2  {\n \
+                Transition \"/manualMode:=1^ComputingComponent.ccTRUE\" to Idle ;\n \
+                Transition \"/manualMode:=0^ComputingComponent.ccFALSE\" to Idle ;\n \
+        }\n \
+}\n \
+\n \
+}\n \ "; 
+	return;
+}
+
+
+// This function takes in an integer and returns the state in that position within the states map. Recall that this
+// map relates integers (the number assigned to a state) to a state in the graph.
+// ... Potential candidate for optimization as per DBK ... 
+
+cOrganism::State& cOrganism::getStateInPosition (int num)
+{
+	int count = 0;
+	nsm_it i;
+	for (i=states.begin(); i!=states.end(); ++i)
+	{
+		if (count == num) {
+			break;
+		}
+		count++;
+	}
+	return i->second;
+}
+
+cOrganism::Graph& cOrganism::GetGraph()
+{
+	return uml_state_diagram;
+}
+
+
 bool cOrganism::InjectParasite(const cGenome& injected_code)
 {
   assert(m_interface);

Modified: branches/uml/source/main/cOrganism.h
===================================================================
--- branches/uml/source/main/cOrganism.h	2006-12-06 01:34:11 UTC (rev 1112)
+++ branches/uml/source/main/cOrganism.h	2006-12-06 02:43:42 UTC (rev 1113)
@@ -17,8 +17,15 @@
 #include <set>
 #include <string>
 #include <vector>
+//#include <boost/config.hpp>
+//#include <boost/graph/edge_list.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/graph_utility.hpp>
+//#include <boost/graph/filtered_graph.hpp>
+using namespace boost;
 
 
+
 #ifndef cCPUMemory_h
 #include "cCPUMemory.h"
 #endif
@@ -78,15 +85,35 @@
 class cEnvironment;
 class cCodeLabel;
 
+// structures used to label vertices and edges 
+struct edge_info {
+        int edge_label;
+		std::string edge_info;
+};
+
+struct state_info {
+        int state_label;
+};
+
+
 class cOrganism
 {
 public:
 
-//!Types of the UML maps for states and transitions
-	typedef std::map<int,int> t_stateMap; //!< state map type
-	typedef t_stateMap::iterator sm_it; //!< state map iterator type
-	typedef std::multimap<int,std::pair<int,int> > t_transitionMap; //!< transition map type
-	typedef t_transitionMap::iterator tr_it; //<! transition map iterator type
+//!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;
+// map the graph's vertex's to their descriptors
+typedef graph_traits<Graph>::vertex_descriptor State;
+typedef std::map<int, State> NameStateMap;
+typedef NameStateMap::iterator nsm_it; 
+// A map from the integer representing a transition to the string representing its label
+typedef std::map<int, std::string> TransMeaning;
+// map the graph's edge's to their descriptors
+typedef graph_traits<Graph>::edge_descriptor Transition;
+typedef graph_traits<Graph>::out_edge_iterator oei;
+
+
 	
 protected:
   cWorld* m_world;
@@ -126,6 +153,15 @@
   tBuffer<cOrgMessage> inbox;
   tBuffer<cOrgMessage> sent;
   
+  // UML internal state diagram components
+  Graph uml_state_diagram;		// the overall graph of the UML state diagram
+  Transition transitions;		// map of transition descriptors to transitions
+  NameStateMap states;			// map of the state names 
+  TransMeaning transGuardActionInfo; // map of transition integers to the string representing their label
+  std::string hil_begin;
+  std::string hil;
+  std::string hil_end;
+  
   class cNetSupport
   {
   public:
@@ -194,19 +230,41 @@
   void NetReset();
   
   // UML Stuff
-  t_stateMap uml_states;
-  t_transitionMap uml_transitions;
-  t_transitionMap uml_trans_by_state;
-  std::set <int> uml_state_set;
-  std::map <int, std::string> uml_trans_set;
+//  t_stateMap uml_states;
+//  t_transitionMap uml_transitions;
+//  t_transitionMap uml_trans_by_state;
+//  std::set <int> uml_state_set;
+//  std::map <int, std::string> uml_trans_set;
   void ModelCheck(cAvidaContext& ctx);
-  void printXMI(cAvidaContext& ctx);
+//  void printXMI(cAvidaContext& ctx);
   void printHIL(cAvidaContext& ctx);
-  std::vector<std::string> trans_info;
-  void InitTransForXMI();
+//  std::vector<std::string> trans_info;
+//  void InitTransForXMI();
   void InitTransForHIL();
+  void InitHILBandE();
+  bool AddTrans(int trans, int orig, int dest);
+  double NumStates();
+  double NumTrans();
+  void AssignTransMeaning(int trans);
+  Graph& GetGraph();
+  State& getStateInPosition (int num);
+  bool isTrans(State, State, int);
+  int getTransNumber (int pos);
+  bool findTrans(int s0_pos, int s1_pos, int t_pos);
+  
+  // 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.
+ // stl::set<int> getTransBetweenVertices(State, State);
+  std::string StringifyAnInt (int x);
+  std::string cOrganism::getHil();
 
+  
 
+//  NameStateMap::iterator pos;
+
+
+
+
   bool InjectParasite(const cGenome& genome);
   bool InjectHost(const cCodeLabel& in_label, const cGenome& genome);
   void AddParasite(cInjectGenotype* cur) { m_parasites.Push(cur); }

Modified: branches/uml/source/main/cStats.cc
===================================================================
--- branches/uml/source/main/cStats.cc	2006-12-06 01:34:11 UTC (rev 1112)
+++ branches/uml/source/main/cStats.cc	2006-12-06 02:43:42 UTC (rev 1113)
@@ -848,3 +848,30 @@
 	num_bought = num_sold = num_used = num_own_used = 0;
 df.Endl();
 }
+
+void cStats::PrintUMLData(const cString& filename)
+{
+	cDataFile& df = m_world->GetDataFile(filename);
+
+	df.WriteComment( "Avida uml data\n" );
+	df.WriteComment("the average number of transitions and states per organism");
+	df.WriteTimeStamp();
+	df.Write( GetUpdate(), "update" );
+	df.Write( av_number_of_states.Average(), "av num states");
+	df.Write( av_number_of_trans.Average(), "av num trans");
+	av_number_of_states.Clear();
+	av_number_of_trans.Clear();
+
+df.Endl();
+}
+
+void cStats::UpdateModelStats (cOrganism::Graph& g)
+{
+
+	av_number_of_states.Add(num_vertices(g));
+	av_number_of_trans.Add(num_edges(g));
+
+}
+
+
+

Modified: branches/uml/source/main/cStats.h
===================================================================
--- branches/uml/source/main/cStats.h	2006-12-06 01:34:11 UTC (rev 1112)
+++ branches/uml/source/main/cStats.h	2006-12-06 02:43:42 UTC (rev 1113)
@@ -40,6 +40,8 @@
 #include "nGeometry.h"
 #endif
 
+#include "cOrganism.h"
+
 class cGenotype;
 class cInjectGenotype;
 class cWorld;
@@ -215,6 +217,10 @@
   int num_sold;
   int num_used;
   int num_own_used;
+  
+  // Stats for UML state diagrams
+  cDoubleSum av_number_of_states;
+  cDoubleSum av_number_of_trans;	
 
   cStats(); // @not_implemented
   cStats(const cStats&); // @not_implemented
@@ -528,6 +534,10 @@
   int GetFailedResamplings() const { return num_failedResamplings;}  //AWC 06/29/06
 
 
+  // UML Data Function
+  void UpdateModelStats (cOrganism::Graph& g);
+
+
   // this value gets recorded when a creature with the particular
   // fitness value gets born. It will never change to a smaller value,
   // i.e., when the maximum fitness in the population drops, this value will
@@ -558,6 +568,7 @@
   void PrintInstructionData(const cString& filename);
   void PrintGenotypeMap(const cString& filename);
   void PrintMarketData(const cString& filename);
+  void PrintUMLData(const cString& filename);
 };
 
 

Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc	2006-12-06 01:34:11 UTC (rev 1112)
+++ branches/uml/source/main/cTaskLib.cc	2006-12-06 02:43:42 UTC (rev 1113)
@@ -324,14 +324,38 @@
 	  NewTask(name, "Successfully Received Network Message", &cTaskLib::Task_NetReceive);
   
   // UML tasks
-  if (name == "uml_sts")
-	NewTask(name, "Successfully Created the right number of states", &cTaskLib::Task_CreateStates);  
-  else if (name == "uml_trX") 
-	NewTask(name, "Successfully Created all transitions", &cTaskLib::Task_CreateTransX);  	
-  else if (name == "uml_trs")
+  if (name == "uml_ns")
+	NewTask(name, "Successfully Created the right number of states", &cTaskLib::Task_NumberOfState);
+  else if (name == "uml_nt")
+	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_trs")
     NewTask(name, "Successfully Created the right number of transitions", &cTaskLib::Task_CreateTranss);
+*/	
 	
-	
   // Make sure we have actually found a task  
   if (task_array.GetSize() == start_size) {
     cerr << "Unknown task entry '" << name << "'." << endl;
@@ -1837,6 +1861,7 @@
 }
 
 
+/*
 double cTaskLib::Task_CreateStates(cTaskContext* ctx) const
 {
 	cOrganism* organism = ctx->organism; 
@@ -2056,4 +2081,249 @@
 
 	return bonus;
 }
+*/
 
+// Count the number of states. Give rewards for upto 7. 7 is the number the brightness sensor needs...
+double cTaskLib::Task_NumberOfState(cTaskContext* ctx) const
+{
+	cOrganism* organism = ctx->organism;
+	double bonus = 0.0;
+	double numStates = organism->NumStates();
+	
+	// reward for constructing 7 states - brightness sensor
+	if (organism->NumStates() <= 7) {
+		bonus += numStates;
+	} 
+
+	return bonus;
+}
+
+double cTaskLib::Task_NumberOfTrans(cTaskContext* ctx) const
+{
+	cOrganism* organism = ctx->organism;
+	double bonus = 0.0;
+	double numTrans = organism->NumTrans();
+	
+	// reward for constructing 7 states - brightness sensor
+	if (organism->NumTrans() <= 11) {
+		bonus += numTrans;
+	} 
+
+	return bonus;
+}
+
+double cTaskLib::Task_Transition0(cTaskContext* ctx) const
+{
+	double bonus = 0.0;
+
+	if (ctx->organism->findTrans(0, 1, 0)) { 
+		bonus = 1.0;
+	}
+	return bonus;
+}
+
+double cTaskLib::Task_Transition1(cTaskContext* ctx) const
+{
+	double bonus = 0.0;
+
+	if (ctx->organism->findTrans(1, 2, 1)) { 
+		bonus = 1.0;
+	}
+	return bonus;
+}
+
+double cTaskLib::Task_Transition2(cTaskContext* ctx) const
+{
+	double bonus = 0.0;
+
+	if (ctx->organism->findTrans(2, 1, 2)) { 
+		bonus = 1.0;
+	}
+	return bonus;
+}
+
+double cTaskLib::Task_Transition3(cTaskContext* ctx) const
+{
+	double bonus = 0.0;
+
+	if (ctx->organism->findTrans(2, 1, 3)) { 
+		bonus = 1.0;
+	}
+	return bonus;
+}
+
+double cTaskLib::Task_Transition4(cTaskContext* ctx) const
+{
+	double bonus = 0.0;
+
+	if (ctx->organism->findTrans(1, 3, 4)) { 
+		bonus = 1.0;
+	}
+	return bonus;
+}
+
+double cTaskLib::Task_Transition5(cTaskContext* ctx) const
+{
+	double bonus = 0.0;
+
+	if (ctx->organism->findTrans(3, 4, 5)) { 
+		bonus = 1.0;
+	}
+	return bonus;
+}
+
+double cTaskLib::Task_Transition6(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 bonus = 0.0;
+
+	if (ctx->organism->findTrans(5, 6, 7)) { 
+		bonus = 1.0;
+	}
+	return bonus;
+}
+
+double cTaskLib::Task_Transition8(cTaskContext* ctx) const
+{
+	double bonus = 0.0;
+
+	if (ctx->organism->findTrans(5, 6, 8)) { 
+		bonus = 1.0;
+	}
+	return bonus;
+}
+
+double cTaskLib::Task_Transition9(cTaskContext* ctx) const
+{
+	double bonus = 0.0;
+
+	if (ctx->organism->findTrans(5, 6, 9)) { 
+		bonus = 1.0;
+	}
+	return bonus;
+}
+
+double cTaskLib::Task_Transition10(cTaskContext* ctx) const
+{
+	double bonus = 0.0;
+
+	if (ctx->organism->findTrans(6, 1, 10)) { 
+		bonus = 1.0;
+	}
+	return bonus;
+}
+
+
+double cTaskLib::Task_Hydra(cTaskContext* ctx) const
+{
+	cOrganism* organism = ctx->organism;
+	double bonus = 0.0;
+	std::string temp;
+	unsigned int status_total = 0;
+	int status=0;
+
+	int to_subavida[2]={0};
+	int from_subavida[2]={0};
+	
+	pipe(to_subavida); //write to 1, read from 0
+	pipe(from_subavida);
+	
+	pid_t subavida = fork();
+	if(subavida == 0) {
+		//child
+		close(to_subavida[1]);
+		close(from_subavida[0]);
+		dup2(to_subavida[0], STDIN_FILENO); //oldd, newd
+		dup2(from_subavida[1], STDOUT_FILENO);
+    // HJG - change to call hydra...
+//		execl("./subavida", "subavida", "-c", "runtime_test.cfg", NULL);
+		execl("./hydralite/hydra", NULL);
+		// We don't ever get here.
+	} 
+
+	temp = organism->getHil();
+	do {
+		status = write(to_subavida[1], temp.c_str()+status_total, temp.size());	
+		if (status < 0) {
+			break;
+		} else {
+			 status_total += status;
+		}
+	} while (status_total < temp.size());
+	//parent
+	close(to_subavida[0]);
+	close(from_subavida[1]);
+	close(to_subavida[1]);
+
+	std::string subavida_output;
+	char line[32]={0};
+	//do {
+		status = read(from_subavida[0], line, 31);
+//		cout << "BEFORE PRINT" << endl;
+//		cout << line << endl;
+//		cout << "AFTER PRINT" << endl;
+	//	if(status > 0) {
+	//		subavida_output += line;
+	//		memset(line, 0, 32);
+	//	}
+	//} while(((status==-1) && (errno == EINTR)) || (status>0));
+	
+
+
+	close(from_subavida[0]);
+
+// not pertinent for the UML project
+/*	
+	//write the genome of this organism to_avida[1].
+	const cInstSet& isa = ctx->GetOrganism()->GetHardware().GetInstSet();
+	const cGenome& genome = ctx->GetOrganism()->GetGenome();
+	for(int i=0; i<genome.GetSize(); ++i) {
+		//for each instruction in the genome, look up its textual representation.
+		const cString& inst = isa.GetName(genome[i]);
+		write(to_subavida[1], (const void*)((const char*)inst), inst.GetSize());
+		write(to_subavida[1], "\n", 1);
+	}
+	
+	close(to_subavida[1]);
+	std::string subavida_output;
+	char line[32]={0};
+	int status=0;
+	do {
+		status = read(from_subavida[0], line, 31);
+		if(status > 0) {
+			subavida_output += line;
+			memset(line, 0, 32);
+		}
+	} while(((status==-1) && (errno == EINTR)) || (status>0));
+	
+	close(from_subavida[0]);
+	pid_t done=0;
+	while((done=waitpid(subavida, &status, 0))==-1 && (errno == EINTR)); 
+	assert(done==subavida);
+	
+	//interpret the data that was read.
+	boost::regex fitness("fitness=(\\d+\\.\\d+)");
+	boost::match_results<std::string::const_iterator> match;
+	double ret=0.0;
+	
+	if(boost::regex_search(subavida_output, match, fitness)) {
+		std::istringstream iss(match[1]);
+		iss >> std::dec >> ret;
+	}
+*/	
+	
+	return bonus;
+
+
+}
+
+

Modified: branches/uml/source/main/cTaskLib.h
===================================================================
--- branches/uml/source/main/cTaskLib.h	2006-12-06 01:34:11 UTC (rev 1112)
+++ branches/uml/source/main/cTaskLib.h	2006-12-06 02:43:42 UTC (rev 1113)
@@ -230,10 +230,26 @@
   double Task_NetReceive(cTaskContext* ctx) const;
   
   // UML Tasks... 
-  double Task_CreateStates(cTaskContext* ctx) const;
-  double Task_CreateTransX(cTaskContext* ctx) const;
-  double Task_CreateTranss(cTaskContext* ctx) const;
+//  double Task_CreateStates(cTaskContext* ctx) const;
+//  double Task_CreateTransX(cTaskContext* ctx) const;
+//  double Task_CreateTranss(cTaskContext* ctx) const;
+	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;
 
+
+
 };
 
 




More information about the Avida-cvs mailing list