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

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Mon Mar 5 05:24:46 PST 2007


Author: hjg
Date: 2007-03-05 08:24:46 -0500 (Mon, 05 Mar 2007)
New Revision: 1387

Modified:
   branches/uml/source/cpu/cHardwareCPU.h
   branches/uml/source/cpu/nHardware.h
   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:
Continued refactoring; added testing infrastructure for known model.


Modified: branches/uml/source/cpu/cHardwareCPU.h
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.h	2007-03-05 04:17:09 UTC (rev 1386)
+++ branches/uml/source/cpu/cHardwareCPU.h	2007-03-05 13:24:46 UTC (rev 1387)
@@ -66,9 +66,9 @@
 
 protected:
   // --------  Structure Constants  --------
-  static const int NUM_REGISTERS = 3;
+  static const int NUM_REGISTERS = 6;
   enum tRegisters { REG_AX = 0, REG_BX, REG_CX, REG_DX, REG_EX, REG_FX };
-  static const int NUM_NOPS = 3;
+  static const int NUM_NOPS = 6;
   
   // --------  Data Structures  --------
   struct cLocalThread

Modified: branches/uml/source/cpu/nHardware.h
===================================================================
--- branches/uml/source/cpu/nHardware.h	2007-03-05 04:17:09 UTC (rev 1386)
+++ branches/uml/source/cpu/nHardware.h	2007-03-05 13:24:46 UTC (rev 1387)
@@ -20,7 +20,7 @@
   static const int MAX_NOPS = 6;
   static const int MAX_LABEL_SIZE = 10;
   
-  enum tHeads { HEAD_IP = 0, HEAD_READ, HEAD_WRITE, HEAD_FLOW, NUM_HEADS };
+  enum tHeads { HEAD_IP = 0, HEAD_READ, HEAD_WRITE, HEAD_FLOW, NUM_HEADS = 6 };
   
   static const int STACK_SIZE = 10;
   static const int IO_SIZE = 3;

Modified: branches/uml/source/main/cOrganism.cc
===================================================================
--- branches/uml/source/main/cOrganism.cc	2007-03-05 04:17:09 UTC (rev 1386)
+++ branches/uml/source/main/cOrganism.cc	2007-03-05 13:24:46 UTC (rev 1387)
@@ -127,6 +127,7 @@
   trigger_index = 0;
   action_index = 0;
   guard_index = 0;
+  trans_label_index = 0;
   orig_state_index = -1;
   dest_state_index = -1;
   total_states = 0;
@@ -516,6 +517,18 @@
   
 }
 
+bool cOrganism::findTrans(int orig, int dest)
+{
+	for(std::vector<transition>::iterator i=transitions.begin(); i!=transitions.end(); ++i){
+		if((i->orig_state == orig) && (i->dest_state == dest)) {
+			return true;
+		}
+	}
+	
+	return false;
+
+}
+
 // For all of the next* functions
 // increment the index. If the index points to the end of the vector, it should then point to 
 // the beginning of the vector.
@@ -774,7 +787,15 @@
 
 }
 
+int cOrganism::numStates()
+{
+	return total_states;
+}
 
+int cOrganism::numTrans()
+{
+	return transitions.size();
+}
 
 void cOrganism::printXMI(cAvidaContext& ctx)
 {

Modified: branches/uml/source/main/cOrganism.h
===================================================================
--- branches/uml/source/main/cOrganism.h	2007-03-05 04:17:09 UTC (rev 1386)
+++ branches/uml/source/main/cOrganism.h	2007-03-05 13:24:46 UTC (rev 1387)
@@ -235,6 +235,9 @@
   // UML Stuff
   void modelCheck(cAvidaContext& ctx);   // evaluate the model
   void printXMI(cAvidaContext& ctx);	 // print the XMI version of the model
+  bool findTrans(int, int); // find a transition between two states
+  int numStates();
+  int numTrans();
 
 // The next functions increment the index of the various vectors.
   bool nextTrigger();

Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc	2007-03-05 04:17:09 UTC (rev 1386)
+++ branches/uml/source/main/cTaskLib.cc	2007-03-05 13:24:46 UTC (rev 1387)
@@ -331,8 +331,23 @@
 	  NewTask(name, "Successfully Received Network Message", &cTaskLib::Task_NetReceive);
   
   // UML tasks
-
+  else if (name == "trans1") // 
+	  NewTask(name, "Successfully created trans 1", &cTaskLib::Task_Trans1);
+  else if (name == "trans2") // 
+	  NewTask(name, "Successfully created trans 2", &cTaskLib::Task_Trans2);	  
+  else if (name == "trans3") // 
+	  NewTask(name, "Successfully created trans 3", &cTaskLib::Task_Trans3);
+  else if (name == "trans4") // 
+	  NewTask(name, "Successfully created trans 4", &cTaskLib::Task_Trans4);
+  else if (name == "trans5") // 
+	  NewTask(name, "Successfully created trans 5", &cTaskLib::Task_Trans5);
+  else if (name == "numStates") // 
+	  NewTask(name, "Successfully created 5 states", &cTaskLib::Task_NumStates);  	  
+  else if (name == "numTrans") // 
+	  NewTask(name, "Successfully created 5 transitions", &cTaskLib::Task_NumTrans);	
 	
+	
+	
   // Make sure we have actually found a task  
   if (task_array.GetSize() == start_size) {
     cerr << "Unknown task entry '" << name << "'." << endl;
@@ -1837,3 +1852,61 @@
   return 0.0;
 }
 
+double cTaskLib::Task_Trans1(cTaskContext* ctx) const
+{
+	if (ctx->organism->findTrans(1,2)) return 1.0;
+	return 0.0;
+	
+	// check for a transition between 2 states
+
+}
+
+double cTaskLib::Task_Trans2(cTaskContext* ctx) const
+{
+	return ctx->organism->findTrans(2,3);
+
+}
+
+double cTaskLib::Task_Trans3(cTaskContext* ctx) const
+{
+	return ctx->organism->findTrans(3,4);
+
+}
+
+double cTaskLib::Task_Trans4(cTaskContext* ctx) const
+{
+	return ctx->organism->findTrans(4,5);
+
+}
+  
+double cTaskLib::Task_Trans5(cTaskContext* ctx) const
+{
+	return ctx->organism->findTrans(5,1);
+
+}
+
+double cTaskLib::Task_NumStates(cTaskContext* ctx) const
+{
+	double ns = (double) ctx->organism->numStates();
+	
+	if (ns <= 5 ) {
+		return ns; 
+	} else{
+		return 0.0;
+	}
+	
+}
+
+double cTaskLib::Task_NumTrans(cTaskContext* ctx) const
+{
+	double nt = (double) ctx->organism->numTrans();
+	
+	if (nt <= 5 ) {
+		return nt; 
+	} else{
+		return 0.0;
+	}
+}
+
+
+

Modified: branches/uml/source/main/cTaskLib.h
===================================================================
--- branches/uml/source/main/cTaskLib.h	2007-03-05 04:17:09 UTC (rev 1386)
+++ branches/uml/source/main/cTaskLib.h	2007-03-05 13:24:46 UTC (rev 1387)
@@ -230,7 +230,14 @@
   double Task_NetSend(cTaskContext* ctx) const;
   double Task_NetReceive(cTaskContext* ctx) const;
   
-  // UML Tasks... 
+  // UML Tasks...
+  double Task_Trans1(cTaskContext* ctx) const;
+  double Task_Trans2(cTaskContext* ctx) const;
+  double Task_Trans3(cTaskContext* ctx) const;
+  double Task_Trans4(cTaskContext* ctx) const;   
+  double Task_Trans5(cTaskContext* ctx) const;
+  double Task_NumStates(cTaskContext* ctx) const;
+  double Task_NumTrans(cTaskContext* ctx) const;
 
 };
 




More information about the Avida-cvs mailing list