[Avida-SVN] r2715 - in branches/uml-merge/source: cpu main orchid
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Mon Jul 7 12:57:33 PDT 2008
Author: hjg
Date: 2008-07-07 15:57:33 -0400 (Mon, 07 Jul 2008)
New Revision: 2715
Modified:
branches/uml-merge/source/cpu/cHardwareManager.cc
branches/uml-merge/source/main/cBirthChamber.cc
branches/uml-merge/source/main/cOrganism.cc
branches/uml-merge/source/main/cOrganism.h
branches/uml-merge/source/main/cTaskLib.cc
branches/uml-merge/source/main/cTaskLib.h
branches/uml-merge/source/orchid/cOrchidFactory.cc
branches/uml-merge/source/orchid/cOrchidFactory.h
branches/uml-merge/source/orchid/cUMLModel.cc
branches/uml-merge/source/orchid/cUMLStateDiagram.cc
Log:
fixed buildOrchidOrganism -- avida-MDE now works.
Modified: branches/uml-merge/source/cpu/cHardwareManager.cc
===================================================================
--- branches/uml-merge/source/cpu/cHardwareManager.cc 2008-07-07 14:46:19 UTC (rev 2714)
+++ branches/uml-merge/source/cpu/cHardwareManager.cc 2008-07-07 19:57:33 UTC (rev 2715)
@@ -103,6 +103,8 @@
return new cHardwareExperimental(m_world, in_org, m_inst_set);
case HARDWARE_TYPE_CPU_GX:
return new cHardwareGX(m_world, in_org, m_inst_set);
+ case HARDWARE_TYPE_CPU_ORCHID:
+ return new cHardwareOrchid(m_world, in_org, m_inst_set);
default:
return NULL;
}
Modified: branches/uml-merge/source/main/cBirthChamber.cc
===================================================================
--- branches/uml-merge/source/main/cBirthChamber.cc 2008-07-07 14:46:19 UTC (rev 2714)
+++ branches/uml-merge/source/main/cBirthChamber.cc 2008-07-07 19:57:33 UTC (rev 2715)
@@ -182,9 +182,9 @@
child_genotype->IncDeferAdjust();
- // If we're using Orchid, we have to build that facet of the organism:
+ // If we're using Orchid, we have to provide the offspring with the parent's info:
if(m_world->GetConfig().ENABLE_ORCHID.Get()) {
- child_array[0]->SetOrchidOrganism(cOrchidFactory::BuildOrchidOrganism(parent.GetOrchidOrganism(), m_world));
+ cOrchidFactory::cOrchidInheritParentInfo(parent.GetOrchidOrganism(), child_array[0]->GetOrchidOrganism());
}
return true;
Modified: branches/uml-merge/source/main/cOrganism.cc
===================================================================
--- branches/uml-merge/source/main/cOrganism.cc 2008-07-07 14:46:19 UTC (rev 2714)
+++ branches/uml-merge/source/main/cOrganism.cc 2008-07-07 19:57:33 UTC (rev 2715)
@@ -98,6 +98,11 @@
if (m_world->GetConfig().NET_ENABLED.Get()) m_net = new cNetSupport();
m_id = m_world->GetStats().GetTotCreatures();
+
+ // If so configured, initialize cOrchidOrganism -- this is only initialization, does not include parent stuff.
+ if (m_world->GetConfig().ENABLE_ORCHID.Get()) {
+ m_orchid = cOrchidFactory::BuildOrchidOrganism(m_world);
+ }
}
Modified: branches/uml-merge/source/main/cOrganism.h
===================================================================
--- branches/uml-merge/source/main/cOrganism.h 2008-07-07 14:46:19 UTC (rev 2714)
+++ branches/uml-merge/source/main/cOrganism.h 2008-07-07 19:57:33 UTC (rev 2715)
@@ -60,6 +60,9 @@
#ifndef cOrgMessage_h
#include "cOrgMessage.h"
#endif
+#ifndef _C_ORCHID_FACTORY_H_
+#include "cOrchidFactory.h"
+#endif
#ifndef tArray_h
#include "tArray.h"
#endif
@@ -86,7 +89,6 @@
class cSaleItem;
-
class cOrganism
{
protected:
Modified: branches/uml-merge/source/main/cTaskLib.cc
===================================================================
--- branches/uml-merge/source/main/cTaskLib.cc 2008-07-07 14:46:19 UTC (rev 2714)
+++ branches/uml-merge/source/main/cTaskLib.cc 2008-07-07 19:57:33 UTC (rev 2715)
@@ -3063,6 +3063,25 @@
//--------Orchid tasks --------
+
+double cTaskLib::Task_Properties(cTaskContext& ctx) const
+{
+ double bonus = 0.0;
+ cOrchidOrganism* orchid_org = ctx.GetOrganism()->GetOrchidOrganism();
+ //cPopulation* pop = (&m_world->GetPopulation());
+
+ // call some sort of check properties function for the model.
+ orchid_org->GetUMLModel()->GetPropertyGenerator()->ResetPropertyReward();
+ bonus = orchid_org->GetUMLModel()->GetPropertyGenerator()->GetPropertyReward();
+ //pop->getUMLModel()->checkProperties();
+ //m_world->GetStats().propSuccess(pop->getUMLModel()->numSuccess());
+ //m_world->GetStats().propFailure(pop->getUMLModel()->numFailure());
+
+ return bonus;
+
+}
+
+
/*! This task evaluates if the UML model generated by an organism supports the key scenarios.
Essentially, an organism is rewarded in proportion to the percent of scenarios supported.
*/
@@ -3073,6 +3092,10 @@
double bonus = 0.0;
std::string sc_name;
+ // Print the XMI of this organism
+ if(orchid_org->GetUMLModel()->GetXMI() == "") {
+ orchid_org->GetUMLModel()->PrintXMI();
+ }
// Check if this model is different than the orchid_organism's parent's model
if (orchid_org->GetParentXMI() != orchid_org->GetUMLModel()->GetXMI()) {
bonus = orchid_org->GetUMLModel()->checkForScenarios();
@@ -3097,7 +3120,17 @@
cOrchidOrganism* orchid_org = ctx.GetOrganism()->GetOrchidOrganism();
assert(orchid_org);
double bonus = 0.0;
+
+ // Print the XMI of this organism
+ if(orchid_org->GetUMLModel()->GetXMI() == "") {
+ orchid_org->GetUMLModel()->PrintXMI();
+ }
+
std::string temp = orchid_org->GetUMLModel()->GetXMI();
+
+ if (orchid_org->GetUMLModel()->NumTrans() > orchid_org->GetUMLModel()->GetMaxTrans()) {
+ orchid_org->GetUMLModel()->SetMaxTrans(orchid_org->GetUMLModel()->NumTrans());
+ }
// Check and see if the model supports enough of the scenarios
// that you want to run Hydra. This can be configured to be
Modified: branches/uml-merge/source/main/cTaskLib.h
===================================================================
--- branches/uml-merge/source/main/cTaskLib.h 2008-07-07 14:46:19 UTC (rev 2714)
+++ branches/uml-merge/source/main/cTaskLib.h 2008-07-07 19:57:33 UTC (rev 2715)
@@ -302,6 +302,7 @@
// -------- Orchid tasks --------
double Task_Scenarios(cTaskContext& ctx) const;
+ double Task_Properties(cTaskContext& ctx) const;
double Task_Hydra(cTaskContext& ctx) const;
double SpinCoprocess(cTaskContext& ctx, const std::string& neverclaimFile) const;
double SpinWitnessCoprocess(cTaskContext& ctx, const std::string& neverclaimFile) const;
Modified: branches/uml-merge/source/orchid/cOrchidFactory.cc
===================================================================
--- branches/uml-merge/source/orchid/cOrchidFactory.cc 2008-07-07 14:46:19 UTC (rev 2714)
+++ branches/uml-merge/source/orchid/cOrchidFactory.cc 2008-07-07 19:57:33 UTC (rev 2715)
@@ -5,28 +5,11 @@
#include "cWorld.h"
-/*! This method is called from cBirthChamber::DoAsexBirth, and is used to initialize
- an orchid organism from its parent. It must return a pointer to a new cOrchidOrganism
- (e.g., return new cOrchidOrganism(...)). The resulting pointer is owned by the caller.
-
- NOTE: I suspect that parent will be null for the ancestor... not sure about this.
+/*! This method is called from
*/
-cOrchidOrganism* cOrchidFactory::BuildOrchidOrganism(cOrchidOrganism* parent, cWorld* world)
+cOrchidOrganism* cOrchidFactory::BuildOrchidOrganism(cWorld* world)
{
-
- cOrchidOrganism* child = new cOrchidOrganism(world);
-
- // Initialize the child with its parents information...
-
- child->SetParentXMI(parent->GetUMLModel()->GetXMI());
- child->SetParentBonus(parent->GetParentBonus());
- child->SetParentScenarioCompletion(parent->GetUMLModel()->GetScenarioCompletion());
-
- // For orchid -- provides the offspring with information about its parent's model.
- // child_array[0]->SetParentXMI(parent.GetUMLModel()->GetXMI());
- // child_array[0]->SetParentBonus(parent.GetParentBonus());
- // child_array[0]->SetParentScenarioCompletion(parent.GetUMLModel()->GetScenarioCompletion());
-
+ cOrchidOrganism* child = new cOrchidOrganism(world);
return child;
}
@@ -43,3 +26,16 @@
{
return 0;
}
+
+
+/*! This method is called from cBirthChamber::DoAsexBirth, and is used to initialize
+ an orchid organism from its parent.
+
+ NOTE: I suspect that parent will be null for the ancestor... not sure about this.
+ */
+void cOrchidFactory::cOrchidInheritParentInfo (cOrchidOrganism* parent, cOrchidOrganism* child)
+{
+ child->SetParentXMI(parent->GetUMLModel()->GetXMI());
+ child->SetParentBonus(parent->GetParentBonus());
+ child->SetParentScenarioCompletion(parent->GetUMLModel()->GetScenarioCompletion());
+}
Modified: branches/uml-merge/source/orchid/cOrchidFactory.h
===================================================================
--- branches/uml-merge/source/orchid/cOrchidFactory.h 2008-07-07 14:46:19 UTC (rev 2714)
+++ branches/uml-merge/source/orchid/cOrchidFactory.h 2008-07-07 19:57:33 UTC (rev 2715)
@@ -10,10 +10,13 @@
class cOrchidFactory
{
public:
- //! Build an OrchidOrganism from its parent.
- static cOrchidOrganism* BuildOrchidOrganism(cOrchidOrganism* parent, cWorld* world);
+ //! Build an OrchidOrganism.
+ static cOrchidOrganism* BuildOrchidOrganism(cWorld* world);
//! Build an OrchidPopulation.
static cOrchidPopulation* BuildOrchidPopulation(const cWorld* world);
+ //! Transmit a parent's model and bonus info to its offspring
+ static void cOrchidInheritParentInfo (cOrchidOrganism* parent, cOrchidOrganism* child);
+
};
#endif
Modified: branches/uml-merge/source/orchid/cUMLModel.cc
===================================================================
--- branches/uml-merge/source/orchid/cUMLModel.cc 2008-07-07 14:46:19 UTC (rev 2714)
+++ branches/uml-merge/source/orchid/cUMLModel.cc 2008-07-07 19:57:33 UTC (rev 2715)
@@ -357,7 +357,7 @@
return;
}
-xmi_info cUMLModel::xi;// = loadFile("xmi_info");
+xmi_info cUMLModel::xi = loadFile("xmi_info");
int cUMLModel::max_trans = 0;
Modified: branches/uml-merge/source/orchid/cUMLStateDiagram.cc
===================================================================
--- branches/uml-merge/source/orchid/cUMLStateDiagram.cc 2008-07-07 14:46:19 UTC (rev 2714)
+++ branches/uml-merge/source/orchid/cUMLStateDiagram.cc 2008-07-07 19:57:33 UTC (rev 2715)
@@ -600,7 +600,7 @@
xmi+= "<UML:Transition xmi.id=\"" + temp3 + "\"";
xmi+= " source=\"" + temp1 + "\"";
- xmi += " tarGet=\"" + temp2 + "\" name=\"\" isSpecification=\"false\">\n";
+ xmi += " target=\"" + temp2 + "\" name=\"\" isSpecification=\"false\">\n";
// Get guard, trigger, and action
temp1 = guards[(sd0[ed]._gu)];
@@ -646,7 +646,7 @@
xmi+= "<UML:Transition xmi.id=\"" + temp3 + "\"";
xmi+= " source=\"" + temp1 + "\"";
- xmi += " tarGet=\"" + temp2 + "\" name=\"\" isSpecification=\"false\">\n";
+ xmi += " target=\"" + temp2 + "\" name=\"\" isSpecification=\"false\">\n";
xmi += "</UML:Transition>\n";
xmi += "</UML:StateMachine.transitions> </UML:StateMachine> </UML:Namespace.ownedElement> ";
xmi += " </UML:Class>";
More information about the Avida-cvs
mailing list