[Avida-SVN] r1145 - in branches/uml/source: cpu main

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Sun Dec 17 18:23:01 PST 2006


Author: hjg
Date: 2006-12-17 21:23:01 -0500 (Sun, 17 Dec 2006)
New Revision: 1145

Modified:
   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/cTaskContext.h
   branches/uml/source/main/cTaskLib.cc
   branches/uml/source/main/cTaskLib.h
Log:
Added the ability to use Spin & Hyrda as the backend for tasks, a different nop encoding for get_state and get_trans, and a remove_transition instruction. 



Modified: branches/uml/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.cc	2006-12-14 14:21:26 UTC (rev 1144)
+++ branches/uml/source/cpu/cHardwareCPU.cc	2006-12-18 02:23:01 UTC (rev 1145)
@@ -360,6 +360,9 @@
 					"Get a transition"), 				
 	cInstEntryCPU("get-state", &cHardwareCPU::Inst_GetState, false, 
 					"Get a state"), 				
+	cInstEntryCPU("remove-tr", &cHardwareCPU::Inst_DeleteTrans, false, 
+					"Remove a transition"),
+				
 //	cInstEntryCPU("model-ch", &cHardwareCPU::Inst_ModelCheck, false, 
 //					"Model check the model"), 
 //	cInstEntryCPU("cr-trans2", &cHardwareCPU::Inst_CreateTransitionIntStates, false, 
@@ -3493,16 +3496,10 @@
 	ReadLabel();
     GetLabel();
 
-	int state_pos = GetLabel().AsInt(1);
+	int state_pos = GetLabel().AsInt(3);
 //	cString a = GetLabel().AsString();
 
-/*	
-	a.ClipFront(<#int size#>)
-	if (a == "A") {
-		a = "a";
-	}
 
-*/
 
 	// This did not work. Time to try again.
 /*
@@ -3562,4 +3559,28 @@
 	return true;
 }
 
+bool cHardwareCPU::Inst_DeleteTrans(cAvidaContext& ctx) 
+{
+	ReadLabel();
+    GetLabel();
 
+	int trans_pos = GetLabel().AsInt(1);
+	
+	if ((trans_pos >= 0) && (trans_pos < organism->NumTrans())) {
+	
+		organism->deleteTrans(trans_pos);
+		// delete the transition in this position....
+//		int label = organism->getTransLabelInPosition(trans_pos);
+
+
+	
+	}
+
+	return true;
+
+
+
+}
+
+
+

Modified: branches/uml/source/cpu/cHardwareCPU.h
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.h	2006-12-14 14:21:26 UTC (rev 1144)
+++ branches/uml/source/cpu/cHardwareCPU.h	2006-12-18 02:23:01 UTC (rev 1145)
@@ -478,6 +478,7 @@
   bool Inst_CreateTransition(cAvidaContext& ctx);
   bool Inst_GetState(cAvidaContext& ctx);
   bool Inst_GetTrans(cAvidaContext& ctx);
+  bool Inst_DeleteTrans(cAvidaContext& ctx);
 //  bool Inst_CreateTransitionIntStates(cAvidaContext& ctx);
 };
 

Modified: branches/uml/source/main/cOrganism.cc
===================================================================
--- branches/uml/source/main/cOrganism.cc	2006-12-14 14:21:26 UTC (rev 1144)
+++ branches/uml/source/main/cOrganism.cc	2006-12-18 02:23:01 UTC (rev 1145)
@@ -53,8 +53,8 @@
 	return data;
 }
 
-std::string cOrganism::hil_begin = loadFile("hil_begin");
-std::string cOrganism::hil_end = loadFile("hil_end");
+std::string cOrganism::xmi_begin = loadFile("xmi_begin");
+std::string cOrganism::xmi_end = loadFile("xmi_end");
 
 
 cOrganism::cOrganism(cWorld* world, cAvidaContext& ctx, const cGenome& in_genome)
@@ -430,7 +430,7 @@
 {
 
 //	cout << "Model check begin " << endl;
-	printHIL(ctx);
+	printXMI(ctx);
 //	cout << "Model check end " << endl;
 
   assert(m_interface);
@@ -490,11 +490,15 @@
 }
 
 
-void cOrganism::InitTransForHIL()
+// 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.
+
+void cOrganism::InitTransForXMI()
 {
 
 	// 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) { 
@@ -503,21 +507,47 @@
 			(*it).second = "";
 			break;
 		case 1:
-			(*it).second = "getOperationalState";
+			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";
+			(*it).second =temp;
 			break;
 		case 2:
-			(*it).second = "/operationalState:=1^ComputingComponent.ccTRUE";
+			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";
+			(*it).second = temp;
 			break;	
 		case 3: 
-			(*it).second = "/operationalState:=0^ComputingComponent.ccFALSE";
+			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";
+			(*it).second = temp;
 			break;
 		case 4: 
-			(*it).second = "getBrightnessValue";
+			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";
+			(*it).second = temp;
 			break;
 		case 5:
-			(*it).second = "^Environment.getBrightnessValue";
+			(*it).second = "";
 			break;
-		case 6:
+/*		case 6:
 			 (*it).second = "setBrightnessValue(brightnessValue)";
 			break;
 		case 7:
@@ -531,7 +561,7 @@
 			break;
 		case 10:
 			(*it).second = "^ComputingComponent.setBrightnessValue(brightnessValue)";
-			break;
+			break;*/
 		default:
 			(*it).second = " ";
 	}
@@ -589,6 +619,11 @@
 			//cout << "Adding transition " << u << " " << v << " " << trans << endl;
 			if (inserted3) {
 				uml_state_diagram[transitions].edge_label = trans;
+				//uml_state_diagram[transitions].edge_info = "";
+				uml_state_diagram[transitions].start_state = orig;
+				uml_state_diagram[transitions].end_state = dest;
+				
+				
 				//cout << "added edge labeled " << trans << endl;
 				// add trans to table...
 				transGuardActionInfo.insert(std::make_pair(trans, ""));
@@ -597,6 +632,39 @@
 	return true;
 }
 
+
+// May eventually want to consider removing the states attached to a transition, if there are not
+// any other transitions that point to it...
+// Also, currently, this is not handling the potential that this is the only
+// transition with a certain integer label and thus it should be removed from the mapping
+// of labels to strings...
+void cOrganism::deleteTrans(int pos) 
+{
+
+	Graph::edge_iterator e, eend;
+	int count = 0;
+	int s_start_lab, s_end_lab; //, trans_lab;
+//	Transition t;
+
+	for (tie(e, eend) = edges(uml_state_diagram); e != eend; ++e) { 
+		if (count == pos) {
+//			remove_edge(e, uml_state_diagram);
+			//t = uml_state_diagram[*e];
+			s_start_lab = uml_state_diagram[*e].start_state;
+			s_end_lab = uml_state_diagram[*e].end_state;
+			//trans_lab = uml_state_diagram[*e].edge_label;
+			remove_edge(*e, uml_state_diagram);
+			break;
+		}
+
+		count ++;
+	}
+	
+	return;
+}
+
+
+
 // similar to getTransBetweenVertices... 
 // optimization candidate perhaps using edge_range as per DBK
 bool cOrganism::isTrans(State u, State v, int trans_name)
@@ -661,38 +729,92 @@
 }
 
 
-void cOrganism::printHIL(cAvidaContext& ctx)
+// hjg - 12/16/2006 - States have been modified to print XMI rather than HIL; 
+// transitions have not yet been reworked
+
+void cOrganism::printXMI(cAvidaContext& ctx)
 {
+
 	Graph::vertex_iterator i, iend;
+	Graph::edge_iterator e, eend;
 	
-	oei e1, e2;
+	//oei e1, e2;
 	int trans_label;
 	int dest_state;
 	std::string temp;
 	int tempint;
 	
-	InitTransForHIL();
+	InitTransForXMI();
 
-	hil = "";
+	xmi = "";
 	// 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"; 
+	/*	hil += "Initial \"\" s"; 
 		temp = StringifyAnInt(uml_state_diagram[0].state_label);
 		hil += temp;
-		hil += " ; \n"; 
-
+		hil += " ; \n"; */
+		xmi += "<UML:Pseudostate xmi.id=\"s0\" kind=\"initial\" outgoing=\"\" name=\"\" isSpecification=\"false\"/>\n";
 	}
 	
 	for (tie(i, iend) = vertices(uml_state_diagram); i != iend; ++i) {
 //		cout << "State " << uml_state_diagram[*i].state_label << " { " << endl;
-		hil += "State s";
+/*		hil += "State s";
 		temp = StringifyAnInt(uml_state_diagram[*i].state_label);
 		hil += temp;
 		hil += " { \n"; 
+*/
+		temp = "s" + StringifyAnInt(uml_state_diagram[*i].state_label);
+		xmi+="<UML:CompositeState xmi.id=\"";
+		xmi+=temp;
+		//xmi+= uml_state_diagram[*i].state_label;
+		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";
 
+
+
+	for (tie(e, eend) = edges(uml_state_diagram); e != eend; ++e) { 
+		// info determined from the trans itself....
+		trans_label = uml_state_diagram[*e].edge_label;
+		temp = "t" + StringifyAnInt(uml_state_diagram[*e].edge_label);
+		
+		// if I manage to set edge_info, I could then use that to print...
+		// currently the start state and end state are already encoded. :)
+		
+		//xmi+=temp;
+//		s = target(uml_state_diagram[e*], uml_state_diagram);
+		
+//		temp += "s" + StringifyAnInt(target(e, uml_state_diagram));
+
+		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";
+
+	
+	}
+
+/*
 		// print each transition...
 		for (tie(e1, e2) = out_edges((*i), uml_state_diagram); e1 != e2; ++e1) {
 			trans_label = uml_state_diagram[*e1].edge_label;
@@ -706,7 +828,10 @@
 		hil +=  "} \n"; 
 	}
 	//cout << "HIL : " << hil << endl;
-	
+	*/
+
+
+	//cout << "XMI : " << xmi << endl;
 }
 
 
@@ -729,15 +854,18 @@
 	return (double) num_edges(uml_state_diagram);
 }
 
-std::string cOrganism::getHil()
+std::string cOrganism::getXMI()
 {
-//	std::string temp = hil_begin + hil + hil_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;
-	return (hil_begin + hil + hil_end);
+	return (xmi_begin + xmi + xmi_end);
 }
 
 // This function takes in an integer and returns the state in that position within the states map. Recall that this

Modified: branches/uml/source/main/cOrganism.h
===================================================================
--- branches/uml/source/main/cOrganism.h	2006-12-14 14:21:26 UTC (rev 1144)
+++ branches/uml/source/main/cOrganism.h	2006-12-18 02:23:01 UTC (rev 1145)
@@ -89,6 +89,8 @@
 struct edge_info {
         int edge_label;
 		std::string edge_info;
+		int start_state;
+		int end_state;
 };
 
 struct state_info {
@@ -155,12 +157,12 @@
   
   // 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
+  Transition transitions;		// 
   NameStateMap states;			// map of the state names 
   TransMeaning transGuardActionInfo; // map of transition integers to the string representing their label
-  static std::string hil_begin;
-  std::string hil;
-  static std::string hil_end;
+  static std::string xmi_begin;
+  std::string xmi;
+  static std::string xmi_end;
   std::map<int, int>  PosToStateLabel;  // a map that relates the number in which the state was inserted
 										// to the label the organism assigns it.
 
@@ -237,8 +239,8 @@
   
   // UML Stuff
   void ModelCheck(cAvidaContext& ctx);
-  void printHIL(cAvidaContext& ctx);
-  void InitTransForHIL();
+  void printXMI(cAvidaContext& ctx);
+  void InitTransForXMI();
   bool AddTrans(int trans, int orig, int dest);
   double NumStates();
   double NumTrans();
@@ -250,12 +252,13 @@
   bool isTrans(State, State, int);
   int getTransNumber (int pos);
   bool findTrans(int s0_pos, int s1_pos, int t_pos);
+  void deleteTrans (int 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 getHil();
+  std::string getXMI();
 
   
 

Modified: branches/uml/source/main/cTaskContext.h
===================================================================
--- branches/uml/source/main/cTaskContext.h	2006-12-14 14:21:26 UTC (rev 1144)
+++ branches/uml/source/main/cTaskContext.h	2006-12-18 02:23:01 UTC (rev 1145)
@@ -32,8 +32,8 @@
   int net_completed;
   tBuffer<int>* received_messages;
   int logic_id;
+  int task_failed;
   
-  
   cTaskEntry* task_entry;
   cOrganism* organism;
 
@@ -44,7 +44,7 @@
                tBuffer<int>* in_received_messages = NULL, cOrganism* in_org = NULL)
     : input_buffer(inputs), output_buffer(outputs), other_input_buffers(other_inputs),
     other_output_buffers(other_outputs), net_valid(in_net_valid), net_completed(in_net_completed), 
-    received_messages(in_received_messages), organism(in_org), logic_id(0), task_entry(NULL)
+    received_messages(in_received_messages), organism(in_org), logic_id(0), task_entry(NULL), task_failed(1)
   {
   }
  

Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc	2006-12-14 14:21:26 UTC (rev 1144)
+++ branches/uml/source/main/cTaskLib.cc	2006-12-18 02:23:01 UTC (rev 1145)
@@ -11,6 +11,8 @@
 #include "cTaskLib.h"
 #include <unistd.h>
 #include <math.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 #include <errno.h>
 #include <boost/regex.hpp>
 
@@ -355,6 +357,8 @@
 	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 == "spinn1")
+	NewTask(name, "Successfully ran spin for N1 (yay!)", &cTaskLib::Task_SpinN1);
 /*  else if (name == "uml_trs")
     NewTask(name, "Successfully Created the right number of transitions", &cTaskLib::Task_CreateTranss);
 */	
@@ -1904,14 +1908,17 @@
 	return bonus;
 }
 
+// findTrans args (init state, dest state, trans )
+
 double cTaskLib::Task_Transition0(cTaskContext* ctx) const
 {
 	double bonus = 0.0;
-
-	// good for both bs and gsm
+	
+	// good for bs, gsm, & ms
 	if (ctx->organism->findTrans(0, 1, 0)) { 
 		bonus = 1.0;
 	}
+	ctx->task_failed = ctx->task_failed && bonus;
 	return bonus;
 }
 
@@ -1919,7 +1926,7 @@
 {
 	double bonus = 0.0;
 
-	// good for both bs and gsm
+	// good for bs, gsm & ms
 	 if (ctx->organism->findTrans(1, 2, 1)) { 
 	
 	// testing the creation of multiple trans to get reward concept
@@ -1927,6 +1934,7 @@
 
 		bonus = 1.0;
 	}
+	ctx->task_failed = ctx->task_failed && bonus;
 	return bonus;
 }
 
@@ -1935,13 +1943,15 @@
 {
 	double bonus = 0.0;
 
-	// brightness sensor
+	// brightness sensor & ms
 		if (ctx->organism->findTrans(2, 1, 2)) { 
 	// gsm:
 //	if (ctx->organism->findTrans(2, 3, 2)) { 
 	
 		bonus = 1.0;
 	}
+	
+	ctx->task_failed = ctx->task_failed && bonus;
 	return bonus;
 }
 
@@ -1950,12 +1960,16 @@
 	double bonus = 0.0;
 
 	//  brightness sensor
-		if (ctx->organism->findTrans(2, 1, 3)) { 
+	//	if (ctx->organism->findTrans(2, 1, 3)) { 
 	// gsm:
 	//if (ctx->organism->findTrans(3, 4, 3)) { 
+	// ms
+	if (ctx->organism->findTrans(1, 3, 3)) {
 
 		bonus = 1.0;
 	}
+	
+	ctx->task_failed = ctx->task_failed && bonus;
 	return bonus;
 }
 
@@ -1964,11 +1978,16 @@
 	double bonus = 0.0;
 
 	// brightness sensor
-		if (ctx->organism->findTrans(1, 3, 4)) { 
+//		if (ctx->organism->findTrans(1, 3, 4)) { 
+	// gsm
 //	if (ctx->organism->findTrans(4, 1, 4)) { 
+	// ms
+	if (ctx->organism->findTrans(3, 4, 4)) { 
 
 		bonus = 1.0;
 	}
+	
+	ctx->task_failed = ctx->task_failed && bonus;
 	return bonus;
 }
 
@@ -1976,9 +1995,14 @@
 {
 	double bonus = 0.0;
 
-	if (ctx->organism->findTrans(3, 4, 5)) { 
+// bs
+//	if (ctx->organism->findTrans(3, 4, 5)) { 
+// ms
+	if (ctx->organism->findTrans(4, 1, 5)){
 		bonus = 1.0;
 	}
+
+	ctx->task_failed = ctx->task_failed && bonus;	
 	return bonus;
 }
 
@@ -2035,9 +2059,12 @@
 
 double cTaskLib::Task_Hydra(cTaskContext* ctx) const
 {
-	// Sanity Check - Does hydra have a chance of succeeding?
-	if(Task_Transition10(ctx)==0.0) return 0.0; //etc.
 
+	if (ctx->task_failed == 0) {
+		return 0;
+	}
+
+
 	cOrganism* organism = ctx->organism;
 	double bonus = 0.0;
 	std::string temp;
@@ -2057,7 +2084,7 @@
 		close(from_subavida[0]);
 		dup2(to_subavida[0], STDIN_FILENO); //oldd, newd
 		dup2(from_subavida[1], STDOUT_FILENO);
-		execl("./hydralite/hydra", NULL);
+		execl("/usr/bin/java", "-cp .", "-jar", "./hydraulic.jar", NULL);
 		// We don't ever get here.
 	} 
 	//parent
@@ -2069,7 +2096,7 @@
 	// Then, read from from_subavida[0] as long as is possible, after which point subavida will die.
 
 	// Write the model to STDIN of subavida (be careful; write may not write all that you ask!)
-	temp = organism->getHil();
+	temp = organism->getXMI();
 	do {
 		status = write(to_subavida[1], temp.c_str()+status_total, temp.size());	
 		if (status < 0) {
@@ -2100,25 +2127,28 @@
 	while((done=waitpid(subavida, &status, 0))==-1 && (errno == EINTR)); 
 	assert(done==subavida);
 	
-	//Interpret the data that we read from subavida.
-	// hydra=5;spin=10 ... or whatever.
-	boost::regex hydra("hydra=(\\d+)");
-	boost::regex spin("spin=(\\d+)");
-	boost::match_results<std::string::const_iterator> match;
-	double hydraval=0.0;
-	double spinval=0.0;
-	
-	if(boost::regex_search(subavida_output, match, hydra)) {
-		std::istringstream iss(match[1]);
-		iss >> std::dec >> hydraval;
+	// if there are no errors, return 0 from hydraulic.  otherwise, return non-zero.
+	if(status != 0) {
+		ctx->task_failed = 0;
+		return 0.0;
+	} else {
+		ctx->task_failed = ctx->task_failed && 1;
+		return 1.0;
 	}
+}
 
-	if(boost::regex_search(subavida_output, match, spin)) {
-		std::istringstream iss(match[1]);
-		iss >> std::dec >> spinval;
-	}
-	
-	return pow(hydraval, spinval);
+double cTaskLib::SpinCoprocess(const std::string& neverclaimFile) const {
+	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;
+	return 1.0;
 }
 
-
+double cTaskLib::Task_SpinN1(cTaskContext* ctx) const {
+	if (ctx->task_failed) {
+		return SpinCoprocess("N1");
+	} 
+	return 0.0;
+}

Modified: branches/uml/source/main/cTaskLib.h
===================================================================
--- branches/uml/source/main/cTaskLib.h	2006-12-14 14:21:26 UTC (rev 1144)
+++ branches/uml/source/main/cTaskLib.h	2006-12-18 02:23:01 UTC (rev 1145)
@@ -248,8 +248,8 @@
 	double Task_Transition9(cTaskContext* ctx) const;
 	double Task_Transition10(cTaskContext* ctx) const;
 
-
-
+	double SpinCoprocess(const std::string& neverclaimFile) const;
+	double Task_SpinN1(cTaskContext* ctx) const;
 };
 
 




More information about the Avida-cvs mailing list