[Avida-SVN] r2730 - in branches/uml-merge: Avida.xcodeproj source/main source/orchid

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Mon Jul 28 10:33:45 PDT 2008


Author: hjg
Date: 2008-07-28 13:33:45 -0400 (Mon, 28 Jul 2008)
New Revision: 2730

Modified:
   branches/uml-merge/Avida.xcodeproj/project.pbxproj
   branches/uml-merge/source/main/cTaskLib.cc
   branches/uml-merge/source/orchid/cOrchidFactory.cc
   branches/uml-merge/source/orchid/cOrchidFactory.h
   branches/uml-merge/source/orchid/cOrchidOrganism.cc
   branches/uml-merge/source/orchid/cOrchidOrganism.h
   branches/uml-merge/source/orchid/cOrchidPopulation.cc
   branches/uml-merge/source/orchid/cOrchidPopulation.h
   branches/uml-merge/source/orchid/cUMLModel.cc
   branches/uml-merge/source/orchid/cUMLModel.h
Log:


Modified: branches/uml-merge/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/uml-merge/Avida.xcodeproj/project.pbxproj	2008-07-28 15:16:20 UTC (rev 2729)
+++ branches/uml-merge/Avida.xcodeproj/project.pbxproj	2008-07-28 17:33:45 UTC (rev 2730)
@@ -25,6 +25,7 @@
 /* Begin PBXBuildFile section */
 		2A57A3FF0D6B954D00FC54C7 /* cProbDemeProbSchedule.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2A57A3FD0D6B954D00FC54C7 /* cProbDemeProbSchedule.cc */; };
 		2A57A4000D6B954D00FC54C7 /* cProbDemeProbSchedule.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A57A3FE0D6B954D00FC54C7 /* cProbDemeProbSchedule.h */; };
+		3EFD625C0E3E31920041F2F5 /* cOrchidPopulation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3EFD625B0E3E31920041F2F5 /* cOrchidPopulation.cc */; };
 		424EE63A0E0F0E0800E6E1C7 /* cMDEAbsenceProperty.cc in Sources */ = {isa = PBXBuildFile; fileRef = 424EE61F0E0F0E0800E6E1C7 /* cMDEAbsenceProperty.cc */; };
 		424EE63B0E0F0E0800E6E1C7 /* cMDEAbsenceProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 424EE6200E0F0E0800E6E1C7 /* cMDEAbsenceProperty.h */; };
 		424EE63C0E0F0E0800E6E1C7 /* cMDECompoundExpression.h in Headers */ = {isa = PBXBuildFile; fileRef = 424EE6210E0F0E0800E6E1C7 /* cMDECompoundExpression.h */; };
@@ -396,6 +397,7 @@
 		1097463E0AE9606E00929ED6 /* cDeme.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cDeme.h; sourceTree = "<group>"; };
 		2A57A3FD0D6B954D00FC54C7 /* cProbDemeProbSchedule.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cProbDemeProbSchedule.cc; sourceTree = "<group>"; };
 		2A57A3FE0D6B954D00FC54C7 /* cProbDemeProbSchedule.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cProbDemeProbSchedule.h; sourceTree = "<group>"; };
+		3EFD625B0E3E31920041F2F5 /* cOrchidPopulation.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cOrchidPopulation.cc; sourceTree = "<group>"; };
 		4201F39A0BE187F6006279B9 /* cTopology.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cTopology.h; sourceTree = "<group>"; };
 		422B64520C8305C40012C545 /* cOrgMessagePredicate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cOrgMessagePredicate.h; sourceTree = "<group>"; };
 		423335880BC067E3000DF681 /* cHardwareGX.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHardwareGX.cc; sourceTree = "<group>"; };
@@ -1032,6 +1034,7 @@
 				42948E3F0E1276BC000BEEDE /* cOrchidOrganism.h */,
 				42948E510E127A18000BEEDE /* cOrchidOrganism.cc */,
 				42948E400E1276BC000BEEDE /* cOrchidPopulation.h */,
+				3EFD625B0E3E31920041F2F5 /* cOrchidPopulation.cc */,
 			);
 			path = orchid;
 			sourceTree = "<group>";
@@ -2208,6 +2211,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				70DCAC9C097AF7C0002F8733 /* primitive.cc in Sources */,
+				3EFD625C0E3E31920041F2F5 /* cOrchidPopulation.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2467,6 +2471,7 @@
 				);
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
+				HEADER_SEARCH_PATHS = /opt/local/include/;
 				WARNING_CFLAGS = (
 					"-Wall",
 					"-Wextra",
@@ -2500,6 +2505,7 @@
 				GCC_STRICT_ALIASING = YES;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_UNROLL_LOOPS = YES;
+				HEADER_SEARCH_PATHS = /opt/local/include/;
 				PER_ARCH_CFLAGS_i386 = "-DCOMPILE_ARCH=\\\"Intel\\\"";
 				PER_ARCH_CFLAGS_ppc = "-DCOMPILE_ARCH=\\\"G4-G5\\\" -mno-fused-madd -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-labels=16 -ftree-loop-linear -fsched-interblock -fgcse-sm -fgcse-las -mmultiple -mstring";
 				STRIP_INSTALLED_PRODUCT = NO;
@@ -2612,6 +2618,7 @@
 				GCC_STRICT_ALIASING = YES;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_UNROLL_LOOPS = YES;
+				HEADER_SEARCH_PATHS = /opt/local/include/;
 				OTHER_CFLAGS = (
 					"$(OTHER_CFLAGS_QUOTED_1)",
 					"-mpowerpc-gpopt",
@@ -2664,6 +2671,7 @@
 				GCC_STRICT_ALIASING = YES;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_UNROLL_LOOPS = YES;
+				HEADER_SEARCH_PATHS = /opt/local/include/;
 				PER_ARCH_CFLAGS_i386 = "-DCOMPILE_ARCH=\\\"Intel\\\"";
 				PER_ARCH_CFLAGS_ppc = "-DCOMPILE_ARCH=\\\"G5\\\" -mpowerpc-gpopt -mno-fused-madd -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-labels=16 -ftree-loop-linear -fsched-interblock -fgcse-sm -fgcse-las -mmultiple -mstring";
 				PREBINDING = NO;
@@ -2813,6 +2821,7 @@
 				GCC_STRICT_ALIASING = YES;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_UNROLL_LOOPS = YES;
+				HEADER_SEARCH_PATHS = /opt/local/include/;
 				PER_ARCH_CFLAGS_i386 = "-DCOMPILE_ARCH=\\\"Intel\\\"";
 				PER_ARCH_CFLAGS_ppc = "-DCOMPILE_ARCH=\\\"G4-G5\\\" -mno-fused-madd -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-labels=16 -ftree-loop-linear -fsched-interblock -fgcse-sm -fgcse-las -mmultiple -mstring";
 				PREBINDING = NO;

Modified: branches/uml-merge/source/main/cTaskLib.cc
===================================================================
--- branches/uml-merge/source/main/cTaskLib.cc	2008-07-28 15:16:20 UTC (rev 2729)
+++ branches/uml-merge/source/main/cTaskLib.cc	2008-07-28 17:33:45 UTC (rev 2730)
@@ -3095,11 +3095,11 @@
 	std::string sc_name;
 	
   // Print the XMI of this organism
-  if(orchid_org->GetUMLModel()->GetXMI() == "") {
-    orchid_org->GetUMLModel()->PrintXMI();
+  if(orchid_org->GetUMLModel()->GetXML() == "") {
+    orchid_org->GetUMLModel()->PrintXML();
   }
 	// Check if this model is different than the orchid_organism's parent's model
-	if (orchid_org->GetParentXMI() != orchid_org->GetUMLModel()->GetXMI()) {
+	if (orchid_org->GetParentXML() != orchid_org->GetUMLModel()->GetXML()) {
 		bonus = orchid_org->GetUMLModel()->checkForScenarios();
 	} else { 
 		bonus = orchid_org->GetParentBonus("scenarios"); 
@@ -3124,11 +3124,11 @@
 	double bonus = 0.0; 
   
   // Print the XMI of this organism
-  if(orchid_org->GetUMLModel()->GetXMI() == "") {
-    orchid_org->GetUMLModel()->PrintXMI();
+  if(orchid_org->GetUMLModel()->GetXML() == "") {
+    orchid_org->GetUMLModel()->PrintXML();
   }
   
-	std::string temp = orchid_org->GetUMLModel()->GetXMI();
+	std::string temp = orchid_org->GetUMLModel()->GetXML();
   
   if (orchid_org->GetUMLModel()->NumTrans() > orchid_org->GetUMLModel()->GetMaxTrans()) { 
     orchid_org->GetUMLModel()->SetMaxTrans(orchid_org->GetUMLModel()->NumTrans());
@@ -3147,7 +3147,7 @@
 	m_world->GetStats().HydraAttempt();
 
 	// Check if this model is different than the orchid_organism's parent's model
-	if (orchid_org->GetParentXMI() == temp) {
+	if (orchid_org->GetParentXML() == temp) {
 		bonus = orchid_org->GetParentBonus("hydra"); 
 		orchid_org->GetUMLModel()->SetBonusInfo("hydra", bonus);	
 		return bonus;
@@ -3319,7 +3319,7 @@
 	m_world->GetStats().N1Attempt();
 
 	// Verify the property
-	if(orchid_org->GetParentXMI() == orchid_org->GetUMLModel()->GetXMI()) {	
+	if(orchid_org->GetParentXML() == orchid_org->GetUMLModel()->GetXML()) {	
 		bonus = orchid_org->GetParentBonus("spinn1"); 
 	}	else {	
 		bonus = SpinCoprocess(ctx, "N1");
@@ -3345,7 +3345,7 @@
 	
 	m_world->GetStats().W1Attempt();
 	
-	if((orchid_org->GetParentXMI()) == (orchid_org->GetUMLModel()->GetXMI())) {	
+	if((orchid_org->GetParentXML()) == (orchid_org->GetUMLModel()->GetXML())) {	
 		bonus = orchid_org->GetParentBonus("spinw1"); 
 	}	else {
 		bonus = SpinWitnessCoprocess(ctx, "W1");
@@ -3379,7 +3379,7 @@
 	
 	m_world->GetStats().N2Attempt();
 
-	if(orchid_org->GetParentXMI() == orchid_org->GetUMLModel()->GetXMI()) {
+	if(orchid_org->GetParentXML() == orchid_org->GetUMLModel()->GetXML()) {
 		bonus = orchid_org->GetParentBonus("spinn2"); 
 	}	else {
 		bonus = SpinCoprocess(ctx, "N2");
@@ -3406,7 +3406,7 @@
 	
 	m_world->GetStats().W2Attempt();
 		
-	if(orchid_org->GetParentXMI() == orchid_org->GetUMLModel()->GetXMI()) {
+	if(orchid_org->GetParentXML() == orchid_org->GetUMLModel()->GetXML()) {
 		bonus = orchid_org->GetParentBonus("spinw2"); 
 	}	else {
 		bonus = SpinWitnessCoprocess(ctx, "W2");
@@ -3482,7 +3482,7 @@
 	std::string file_name;
 	std::ostringstream strstrm;
 
-	temp = orchid_org->GetUMLModel()->GetXMI();
+	temp = orchid_org->GetUMLModel()->GetXML();
 	
 	// call hydra when a // all scenario hits its max?
 	// all are non-zero?

Modified: branches/uml-merge/source/orchid/cOrchidFactory.cc
===================================================================
--- branches/uml-merge/source/orchid/cOrchidFactory.cc	2008-07-28 15:16:20 UTC (rev 2729)
+++ branches/uml-merge/source/orchid/cOrchidFactory.cc	2008-07-28 17:33:45 UTC (rev 2730)
@@ -34,7 +34,7 @@
  */
 void cOrchidFactory::cOrchidInheritParentInfo (cOrchidOrganism* parent, cOrchidOrganism* child)
 {
-	child->SetParentXMI(parent->GetUMLModel()->GetXMI());
+	child->SetParentXML(parent->GetUMLModel()->GetXML());
 	child->SetParentBonus(parent->GetParentBonus());
 	child->SetParentScenarioCompletion(parent->GetUMLModel()->GetScenarioCompletion());
 }
@@ -44,7 +44,7 @@
  that loadFile and seed_diagram (below) are incorporated into this file.  Accessors should be
  used to create the specific pieces of the cUMLModel; see template code below. 
  */
-cUMLModel* cOrchidFactory::BuildUMLModel(const std::string& filename)
+cUMLModel* cOrchidFactory::BuildUMLModel(const char* xmlfile, const char* seedmodelfile)
 {
 	cUMLModel* model = new cUMLModel();
 	// for each transition in the file:
@@ -52,10 +52,297 @@
 	// for each state(?) in the file:
 	//  model->createState(...);
 	// etc.
+	
+	int hydra_mode, witness_mode, gen_mode, related_class_mode;
+	
+	std::string data, line; 
+	int cur_class = -1;
+	int Num_classes;
+	std::ifstream infile;
+	infile.open(seedmodelfile);
+	assert(infile.is_open());
+	std::string class_name;
+	std::string temp, temp1, temp2;
+	std::string op_name, op_code;
+	std::string att_name, att_type, att_val;
+	int trig_i, guard_i, act_i, orig_i, dest_i;
+	std::vector<std::string> att_vals;
+	scenario_info s;
+	std::string path_step, util_name;
+	float util_val;
+	
+	model->GetXMLInfoFromFile(xmlfile);
+	
+	
+	while (getline (infile, line))
+	{
+		if (line == "==MODEL==") {
+			line.erase();
+			infile >> temp1 >> Num_classes;
+			infile >> temp1 >> hydra_mode;
+			infile >> temp1 >> witness_mode;
+			infile >> temp1 >> gen_mode;
+			infile >> temp1 >> related_class_mode;
+			// resize state diagrams & classes to correspond to the Number of classes.
+			model->ResizeClasses(Num_classes);
+			
+		} else if (line == "==CLASS==") { 
+			line.erase();
+			infile >> temp1 >> class_name;
+			cur_class++;
+			model->GetUMLClass(cur_class)->AddClassName(class_name);
+		} else if (line == "==ATTRIBUTES==") {
+			line.erase();
+			infile >> att_name;
+			while (att_name != "==END==") { 
+				infile >> att_type >> temp1 >> att_val;
+				att_vals.clear();
+				while (att_val != "]") { 
+					att_vals.push_back(att_val);
+					infile >> att_val;
+				}
+				
+				model->GetUMLClass(cur_class)->AddAttribute(att_name, att_type, att_vals);
+				infile >> att_name;				
+			}
+		} else if (line == "==OPERATIONS==") {
+			line.erase();
+			infile >> op_name;
+			while (op_name != "==END==") { 
+				infile >> op_code;
+				model->GetUMLClass(cur_class)->AddOperation(op_name, op_code);
+				infile >> op_name;				
+			}
+		} else if (line == "==ASSOCIATIONS==") {
+			line.erase();
+			infile >> class_name;
+			while (class_name != "==END==") { 
+				model->GetUMLClass(cur_class)->AddAssociatedClass(class_name);
+				infile >> class_name;			
+			}
+		} else if (line == "==SCENARIO==") { 
+			line.erase();
+			s.path.clear();
+			s.stateDiagramID = cur_class;
+			infile >> s.shouldLoop >> s.startState;
+			infile >> s.alt_Set_name;
+			infile >> temp;
+			
+			// loop for utility
+			if (temp == "-utility-") { 
+				infile >> temp;
+				//				std::cout << "utility " << temp << std::endl;
+				while (temp != "-end-utility-") { 
+					infile >> util_name >> util_val;
+					//					std::cout << "util_name " << util_name << " util_val " << util_val << std::endl;
+					s.utilityMap[util_name] = util_val;
+					infile >> temp;
+				}
+			}
+			infile >> temp;
+			//			std::cout << temp << std::endl;
+			
+			while (temp != "==END==") { 
+				infile >> path_step;
+				s.path.push_back(path_step);
+				infile >> temp;
+			} 
+			model->AddScenario(s);
+		} else if (line == "==TRANSITIONS==") { 
+			line.erase();
+			infile >> temp; 
+			while (temp != "==END==") { 
+				infile >> orig_i >> dest_i >> trig_i >> guard_i >> act_i; 
+				if (temp != "0") { 
+					model->GetUMLStateDiagram(cur_class)->AddTransitionTotal(orig_i, dest_i, trig_i, guard_i, act_i);
+				}	
+				infile >> temp; 
+			}
+		}	else if (line == "==TRANSITION=LABELS==") { 
+			line.erase();
+			infile >> temp;
+			while (temp != "==END==") { 
+				infile >> trig_i >> guard_i >> act_i; 
+				if (temp!="0") { 
+					model->GetUMLStateDiagram(cur_class)->AddTransitionLabel(trig_i, guard_i, act_i);
+				}
+				infile >> temp;
+			} 
+		}  else if (line == "==TRIGGERS==") { 
+			line.erase();
+			infile >> temp;
+			model->GetUMLStateDiagram(cur_class)->AddTrigger("<null>", "<null>");
+			while (temp != "==END==") { 
+				infile >> temp1 >> temp2; 
+				if (temp!="0") { 
+					model->GetUMLStateDiagram(cur_class)->AddTrigger(temp1, temp2);
+				}
+				infile >> temp;
+			} 
+		} else if (line == "==GUARDS==") { 
+			line.erase();
+			infile >> temp;
+			model->GetUMLStateDiagram(cur_class)->AddGuard("<null>");
+			while (temp != "==END==") { 
+				infile >> temp2; 
+				if (temp!="0") { 
+					model->GetUMLStateDiagram(cur_class)->AddGuard(temp2);
+				}
+				infile >> temp;
+			} 
+		} else if (line == "==ACTIONS==") { 
+			line.erase();
+			infile >> temp;
+			model->GetUMLStateDiagram(cur_class)->AddAction("<null>");
+			while (temp != "==END==") { 
+				infile >> temp2; 
+				if (temp!="01") { 
+					model->GetUMLStateDiagram(cur_class)->AddAction(temp2);
+				}
+				infile >> temp;
+			} 
+		} else if (line == "==KNOWN=EXISTENCE==") { 
+			line.erase(); 
+			//			infile >> temp;
+			getline (infile, temp);
+			while (temp!= "==END==") { 
+				//				infile >> temp2;
+				model->GetPropertyGenerator()->AddKnownExistenceProperty(temp);
+				getline (infile, temp);
+			}
+		} else if (line == "==KNOWN=ABSENCE==") { 
+			line.erase(); 
+			//			infile >> temp;
+			getline (infile, temp);
+			while (temp!= "==END==") { 
+				//				infile >> temp2;
+				model->GetPropertyGenerator()->AddKnownAbsenceProperty(temp);
+				//				infile >> temp;
+				getline (infile, temp);
+			}
+		} else if (line == "==KNOWN=UNIVERSAL==") { 
+			line.erase(); 
+			//			infile >> temp;
+			getline (infile, temp);
+			while (temp!= "==END==") { 
+				//				infile >> temp2;
+				model->GetPropertyGenerator()->AddKnownUniversalProperty(temp2);
+				//				infile >> temp;
+				getline (infile, temp);
+			}
+		} else if (line == "==KNOWN=PRECEDENCE==") { 
+			line.erase(); 
+			//			infile >> temp;
+			getline (infile, temp);
+			while (temp!= "==END==") { 
+				//				infile >> temp1 >> temp2;
+				getline (infile, temp2);
+				model->GetPropertyGenerator()->AddKnownPrecedenceProperty(temp, temp2);
+				//				infile >> temp;
+				getline (infile, temp);
+			}
+		} else if (line == "==KNOWN=RESPONSE==") { 
+			line.erase(); 
+			//			infile >> temp;
+			getline (infile, temp);
+			while (temp!= "==END==") { 
+				//				infile >> temp1 >> temp2;
+				getline (infile, temp2);
+				model->GetPropertyGenerator()->AddKnownResponseProperty(temp, temp2);
+				//				infile >> temp;
+				getline (infile, temp);
+			}
+		} else if (line == "==RELEVANT=ATTRIBUTE==") {
+			line.erase(); 
+			infile >> temp;
+			while (temp!= "==END==") { 
+				infile >> temp2;
+				model->GetPropertyGenerator()->AddRelevantAttribute(temp2);
+				//				std::cout << "relevant at " << temp2 << std::endl;
+				infile >> temp;
+			}
+		} else if (line == "==RELEVANT=OPERATION==") {
+			line.erase(); 
+			infile >> temp;
+			while (temp!= "==END==") { 
+				infile >> temp2;
+				model->GetPropertyGenerator()->AddRelevantOperation(temp2);
+				//				std::cout << "relevant op " << temp2 << std::endl;
+				infile >> temp;
+			}
+		}
+		
+	}
+	
+	//	seedTriggersGuardsActions(classes, state_diagrams);
+	// For each class... 
+	// triggers = methods
+	// guards = attribute equality / inequality
+	// actions = methods of related classes.
+	cUMLClass* c;
+	class_attribute a;
+	operation o;
+	int temp_size;
+	std::string temp3;
+	std::string at_type;
+	std::set<std::string> rc;
+	std::set<std::string>::iterator rcit;
+	
+	for (unsigned int i=0; i< model->NumClasses(); i++) { 
+		c = model->GetUMLClass(i); 
+		temp_size = c->NumAttributes();
+		
+		// Add nulls.
+		//		state_diagrams[i].AddGuard("<null>");
+		//		state_diagrams[i].AddTrigger("<null>", "<null>");
+		//		state_diagrams[i].AddAction("<null>");
+		
+		// For each attribute...
+		for (int j=0; j<temp_size; j++) {
+			a = c->GetAttribute(j);
+			for (unsigned int k=0; k<a.attribute_values.size(); k++){
+				// Create both an equality and an inequality expression
+				temp2 = a.attribute_values[k];
+				temp3 = a.attribute_name + "=" + temp2;
+				model->GetUMLStateDiagram(i)->AddGuard(temp3);
+				temp3 = a.attribute_name + "!=" + temp2;
+				model->GetUMLStateDiagram(i)->AddGuard(temp3);
+			}
+		}
+		
+		// For each method
+		temp_size = c->NumOperations();
+		for (int m=0; m<temp_size; m++) {
+			o = c->GetOperation(m);
+			model->GetUMLStateDiagram(i)->AddTrigger(o.op_name, o.op_code);
+		}
+		
+		// For each of the related classes, Add an action for each of 
+		// its methods... (yucky...)
+		rc.clear();
+		rc = model->GetUMLClass(i)->GetAssociatedClasses();
+		for (rcit=rc.begin(); rcit!=rc.end(); rcit++) { 
+			// Find the related class in the list of classes...
+			for (unsigned int k=0; k<model->NumClasses(); k++){
+				if (model->GetUMLClass(k)->GetClassName() == (*rcit)){
+					// For each of its operations, Add an action...
+					temp_size = model->GetUMLClass(k)->NumOperations();
+					for (int m=0; m<temp_size; m++) {
+						o = model->GetUMLClass(k)->GetOperation(m);
+						temp2 = "^" + model->GetUMLClass(k)->GetClassName() + "." + o.op_name + "()";
+						model->GetUMLStateDiagram(i)->AddAction(temp2);
+					}
+				}
+			}
+		}
+	}
+  
+	infile.close();
+
 	return model;
 }
 
-
+/*
 xmi_info loadFile(const char* filename) {
 	std::string data, line; // or maybe stringstream? (strstream?)
 	std::ifstream infile;
@@ -103,8 +390,8 @@
 	infile.close();
 	return x;
 }
+*/
 
-
 /*! This function intializes variables with data read from a file named "seed-model.cfg". 
  
  "This is a crappy little function to read in from a file. 

Modified: branches/uml-merge/source/orchid/cOrchidFactory.h
===================================================================
--- branches/uml-merge/source/orchid/cOrchidFactory.h	2008-07-28 15:16:20 UTC (rev 2729)
+++ branches/uml-merge/source/orchid/cOrchidFactory.h	2008-07-28 17:33:45 UTC (rev 2730)
@@ -18,7 +18,7 @@
   //! Transmit a parent's model and bonus info to its offspring
   static void cOrchidInheritParentInfo(cOrchidOrganism* parent, cOrchidOrganism* child);
   //! Build a cUMLModel from a file.
-  static cUMLModel* BuildUMLModel(const std::string& filename);
+  static cUMLModel* BuildUMLModel(const char* xmlfile, const char* seedmodelfile);
 };
 
 #endif

Modified: branches/uml-merge/source/orchid/cOrchidOrganism.cc
===================================================================
--- branches/uml-merge/source/orchid/cOrchidOrganism.cc	2008-07-28 15:16:20 UTC (rev 2729)
+++ branches/uml-merge/source/orchid/cOrchidOrganism.cc	2008-07-28 17:33:45 UTC (rev 2730)
@@ -22,7 +22,7 @@
 // The maximum number of transitions is used by the Min_trans task to evaluate
 // if the organism generated a model with more or less transitions.
 	if(m_model.GetGenMode() == 0) {
-		m_model.PrintXMI();	
+		m_model.PrintXML();	
 		// Update the value of max trans
 		if(m_model.NumTrans() > m_model.GetMaxTrans()) { 
       m_model.SetMaxTrans(m_model.NumTrans());

Modified: branches/uml-merge/source/orchid/cOrchidOrganism.h
===================================================================
--- branches/uml-merge/source/orchid/cOrchidOrganism.h	2008-07-28 15:16:20 UTC (rev 2729)
+++ branches/uml-merge/source/orchid/cOrchidOrganism.h	2008-07-28 17:33:45 UTC (rev 2730)
@@ -25,11 +25,11 @@
   //! Get the UML model of this organism. 
   cUMLModel* GetUMLModel() { return  &m_model; }
   //! Return the XMI string for the model generated by this organism's parent.
-  const std::string& GetParentXMI() { return m_parent_xmi; }
+  const std::string& GetParentXML() { return m_parent_xml; }
   //! Get the state diagram currently being manipulated (using m_state_diag) 
   cUMLStateDiagram* GetStateDiagram() { return m_model.GetStateDiagram(m_state_diag); }
   //! consider const std::string& (parameter name)
-  void SetParentXMI(const std::string& xmi) { m_parent_xmi = xmi; } 
+  void SetParentXML(const std::string& xml) { m_parent_xml = xml; } 
   //! The birth chamber calls this method to provide an offspring with information 
   //! about the bonus information received by its parent. 
   void SetParentBonus(const std::map<std::string,float>& parent_bonus) { m_parent_bonus = parent_bonus; }
@@ -52,7 +52,7 @@
   cWorld* m_world; //!< Avida world.
   int m_state_diag; //!< Index of the state diagram currently being manipulated.
   cUMLModel m_model; //!< UML model of this organism
-  std::string m_parent_xmi; //!< The XMI representation of the model generated by the parent
+  std::string m_parent_xml; //!< The XMI representation of the model generated by the parent
   std::map<std::string, float> m_parent_bonus; //!< The task bonuses received by the parent
   std::vector<double> m_parent_scenario_completion; //!< The scenario completion rate of the parent
 };

Modified: branches/uml-merge/source/orchid/cOrchidPopulation.cc
===================================================================
--- branches/uml-merge/source/orchid/cOrchidPopulation.cc	2008-07-28 15:16:20 UTC (rev 2729)
+++ branches/uml-merge/source/orchid/cOrchidPopulation.cc	2008-07-28 17:33:45 UTC (rev 2730)
@@ -2,11 +2,12 @@
 
 #include "cOrchidFactory.h"
 #include "cWorld.h"
+#include <cassert>
 
 cOrchidPopulation::cOrchidPopulation(cWorld* world)
 : m_world(world)
 {
-  m_model = cOrchidFactory::BuildUMLModel((const char*)m_world->GetConfig().ORCHID_SEED_MODEL.Get());
+  m_model = cOrchidFactory::BuildUMLModel("xmi_info", (const char*)m_world->GetConfig().ORCHID_SEED_MODEL.Get());
 }
 
 

Modified: branches/uml-merge/source/orchid/cOrchidPopulation.h
===================================================================
--- branches/uml-merge/source/orchid/cOrchidPopulation.h	2008-07-28 15:16:20 UTC (rev 2729)
+++ branches/uml-merge/source/orchid/cOrchidPopulation.h	2008-07-28 17:33:45 UTC (rev 2730)
@@ -10,7 +10,9 @@
   cOrchidPopulation(cWorld* world);
   ~cOrchidPopulation();
     
-  cUMLModel* GetUMLModel() { assert(m_model); return m_model; }
+  cUMLModel* GetUMLModel() { 
+    //assert(m_model); 
+    return m_model; }
 
 protected:
   cWorld* m_world;

Modified: branches/uml-merge/source/orchid/cUMLModel.cc
===================================================================
--- branches/uml-merge/source/orchid/cUMLModel.cc	2008-07-28 15:16:20 UTC (rev 2729)
+++ branches/uml-merge/source/orchid/cUMLModel.cc	2008-07-28 17:33:45 UTC (rev 2730)
@@ -57,6 +57,33 @@
 	delete gen;
 }
 
+cUMLClass* cUMLModel::GetUMLClass(int class_num) 
+{
+    if (classes.size() == 0) {
+      return NULL;
+    } else if ((class_num > classes.size()) || (class_num < 0)) {
+      return &classes[0];
+    } else { 
+      return &classes[class_num];
+    }
+  
+}
+
+
+cUMLStateDiagram* cUMLModel::GetUMLStateDiagram(int sd_num)
+{
+    if (state_diagrams.size() == 0) {
+      return NULL;
+    } else if ((sd_num > state_diagrams.size()) || (sd_num < 0)) {
+      return &state_diagrams[0];
+    } else { 
+      return &state_diagrams[sd_num];
+    }
+  
+
+}
+
+
 float cUMLModel::GetBonusInfo (std::string s)  
 { 
 	float val;
@@ -79,25 +106,78 @@
   return (&state_diagrams[x]);
 }
 
+/*! This method reads in the XML information about the model from a file. Specifically, it reads in: 
+  -- the beginning on the XML file that describes the model
+  -- the end of the XML file that describes the data types
+  -- the class headers that describe the attributes, operations, etc.
+  -- classes that we are not generating. 
 
-void cUMLModel::PrintXMI()
+*/
+
+void cUMLModel::GetXMLInfoFromFile(const char* filename) 
 {
-//	xmi = "";	
-//	xmi = xi.xmi_begin; 
+	std::string data, line; // or maybe stringstream? (strstream?)
+	std::ifstream infile;
+	infile.open(filename);  
+	assert(infile.is_open());
+	std::string s;
+	
+	while (getline (infile, line))
+	{
+		// handle xml_begin
+		if (line == "=XMI-BEGIN==================") {
+			line.erase();
+			infile >> line;
+			while (line != "=END========================") { 
+				// cat line to the xml_begin string...
+				xi.xml_begin += (line + " ");
+				infile >> line;
+			}
+		} else if (line == "=XMI-END====================") { 
+			// handle xml_end
+			line.erase();
+			infile >> line;
+			while (line != "=END========================") { 
+				// cat line to the xml_begin string...
+				xi.xml_end += (line + " ");
+				infile >> line;
+			}
+		} else if (line == "=CLASS======================") { 
+			// handle xml_end
+			line.erase();
+			infile >> line;
+			data = "";
+			while (line != "=END========================") { 
+				// cat line to the xml_begin string...
+				data += (line + " ");
+				infile >> line;
+			}
+			xi.classes_info.push_back(data);			
+		}
+		
+		line.erase();
+  }
+  infile.close();
+}
+
+void cUMLModel::PrintXML()
+{
+//	xml = "";	
+//	xml = xi.xml_begin; 
 //	
 //	std::cout << xi.classes_info.size() << " " << state_diagrams.size() << std::endl;
 //	assert (xi.classes_info.size() == state_diagrams.size());
 //	
 //	for (unsigned int i=0; i<xi.classes_info.size(); i++) { 
-//		xmi += xi.classes_info[i];
-//		xmi += (GetStateDiagram(i))->GetXMI("sd" + i);
+//		xml += xi.classes_info[i];
+//		xml += (GetStateDiagram(i))->GetXMI("sd" + i);
 //	}	
-//	xmi += xi.xmi_end;
+//	xml += xi.xml_end;
 }
 
-std::string cUMLModel::GetXMI()
+std::string cUMLModel::GetXML()
 {
-	return xmi;
+	return xml;
 }
 
 int cUMLModel::NumStates() 
@@ -318,8 +398,8 @@
 
 	assert(outfile.is_open());
 	
-	// export xmi to outfile.
-	outfile << xmi << endl;
+	// export xml to outfile.
+	outfile << xml << endl;
 	
 	// close outfile.
 	outfile.close();

Modified: branches/uml-merge/source/orchid/cUMLModel.h
===================================================================
--- branches/uml-merge/source/orchid/cUMLModel.h	2008-07-28 15:16:20 UTC (rev 2729)
+++ branches/uml-merge/source/orchid/cUMLModel.h	2008-07-28 17:33:45 UTC (rev 2730)
@@ -28,9 +28,9 @@
 };
 
 
-struct xmi_info { 
-  std::string xmi_begin;
-  std::string xmi_end;
+struct xml_info { 
+  std::string xml_begin;
+  std::string xml_end;
 	std::vector<std::string> classes_info;
 };
 
@@ -48,8 +48,9 @@
 	double checkForScenarios();
 	
 	// Used to generate and access the XMI version of the model.
-	std::string GetXMI(); // Get the XMI version of the model.
-	void PrintXMI(); // Create the XMI version of the model.
+	std::string GetXML(); // Get the XMI version of the model.
+  void GetXMLInfoFromFile(const char* filename); // Read in the XMI information from a file.
+	void PrintXML(); // Create the XMI version of the model.
 	void PrintUMLModelToFile(std::string);  // Print the UML model to a file.
 	int GetUMLValue(); // Print movie info
 	
@@ -76,6 +77,7 @@
 	int NumActions();
 	int NumSDs();
 	int NumSCs();
+  int NumClasses() { return classes.size(); }
 	cMDEPropertyGenerator* GetPropertyGenerator() { return gen; }
 	void CreateExpressionsFromClasses();
 
@@ -120,11 +122,15 @@
 	bool GetWitnessMode() {return witnessMode; }
 	int GetGenMode() { return genMode; }
 	int GetRelatedClassMode() { return relatedClassMode; }
-//	float checkProperties();
-	
 
+  void ResizeClasses(int num_class) { classes.resize(num_class); state_diagrams.resize(num_class); }
+  cUMLClass* GetUMLClass(int class_num); 
+  cUMLStateDiagram* GetUMLStateDiagram(int sd_num);
+  void AddScenario(scenario_info s) { scenarios.push_back(s); } 
+
 protected: 
-	std::string	xmi;
+	std::string	xml;
+  xml_info xi;
 	std::vector<cUMLStateDiagram> state_diagrams;
 	std::vector<cUMLClass> classes;
 	std::map<std::string, float> bonus_info;




More information about the Avida-cvs mailing list