[Avida-SVN] r2688 - in branches/uml-merge: Avida.xcodeproj source/cpu source/main source/orchid
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Wed Jun 25 11:23:28 PDT 2008
Author: hjg
Date: 2008-06-25 14:23:27 -0400 (Wed, 25 Jun 2008)
New Revision: 2688
Modified:
branches/uml-merge/Avida.xcodeproj/project.pbxproj
branches/uml-merge/source/cpu/cHardwareOrchid.cc
branches/uml-merge/source/cpu/cHardwareOrchid.h
branches/uml-merge/source/main/cTaskLib.cc
branches/uml-merge/source/main/cTaskLib.h
branches/uml-merge/source/orchid/cOrchidOrganism.cc
branches/uml-merge/source/orchid/cOrchidOrganism.h
Log:
improved documentation of orchid tasks & instructions
Modified: branches/uml-merge/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/uml-merge/Avida.xcodeproj/project.pbxproj 2008-06-25 15:14:12 UTC (rev 2687)
+++ branches/uml-merge/Avida.xcodeproj/project.pbxproj 2008-06-25 18:23:27 UTC (rev 2688)
@@ -1948,7 +1948,6 @@
DCC30C4D0762532C008F7A48 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
- compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 0;
mainGroup = DCC30C490762532C008F7A48;
productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;
Modified: branches/uml-merge/source/cpu/cHardwareOrchid.cc
===================================================================
--- branches/uml-merge/source/cpu/cHardwareOrchid.cc 2008-06-25 15:14:12 UTC (rev 2687)
+++ branches/uml-merge/source/cpu/cHardwareOrchid.cc 2008-06-25 18:23:27 UTC (rev 2688)
@@ -692,24 +692,18 @@
"Absolute move p"),
tInstLibEntry<tMethod>("next-p", &cHardwareOrchid::Inst_NextExpressionP, false,
"Next p"),
- tInstLibEntry<tMethod>("prev-p", &cHardwareOrchid::Inst_PrevExpressionP, false,
- "Previous p"),
tInstLibEntry<tMethod>("move-rel-q", &cHardwareOrchid::Inst_RelativeMoveExpressionQ, false,
"Relative move q"),
tInstLibEntry<tMethod>("move-abs-q", &cHardwareOrchid::Inst_AbsoluteMoveExpressionQ, false,
"Absolute move q"),
tInstLibEntry<tMethod>("next-q", &cHardwareOrchid::Inst_NextExpressionQ, false,
- "Next q"),
- tInstLibEntry<tMethod>("prev-q", &cHardwareOrchid::Inst_PrevExpressionQ, false,
- "Previous q"),
+ "Next q"),
tInstLibEntry<tMethod>("move-rel-r", &cHardwareOrchid::Inst_RelativeMoveExpressionR, false,
"Relative move r"),
tInstLibEntry<tMethod>("move-abs-r", &cHardwareOrchid::Inst_AbsoluteMoveExpressionR, false,
"Absolute move r"),
tInstLibEntry<tMethod>("next-r", &cHardwareOrchid::Inst_NextExpressionR, false,
- "Next r"),
- tInstLibEntry<tMethod>("prev-r", &cHardwareOrchid::Inst_PrevExpressionR, false,
- "Previous r"),
+ "Next r"),
tInstLibEntry<tMethod>("and-exp", &cHardwareOrchid::Inst_ANDExpressions, false,
"AND expressions"),
tInstLibEntry<tMethod>("or-exp", &cHardwareOrchid::Inst_ORExpressions, false,
@@ -6876,7 +6870,14 @@
// -------- Orchid instructions --------
-/*! This instruction...
+
+
+
+////////// Avida-MDE Model Manipulation Instructions //////////
+
+/*! This instruction creates a transition using a pre-defined label that comprises
+ a trigger, guard, and action. Normally these labels are provided in a config
+ file and are the messages on a sequence diagram.
*/
bool cHardwareOrchid::Inst_AddTransitionFromLabel(cAvidaContext& ctx)
{
@@ -6884,16 +6885,40 @@
}
-/*! This instruction...
+/*! This instruction creates a transition using an individually selected trigger,
+ guard, and action. These triggers, guards, and actions are inferred from the
+ class diagram and are described by a config file.
*/
bool cHardwareOrchid::Inst_AddTransitionTotal(cAvidaContext& ctx)
{
- return organism->GetOrchidOrganism()->AddTransitionTotal();
+ return organism->GetOrchidOrganism()->GetStateDiagram()->AddTransitionTotal();
}
-/* These instructions...
+/*! These two instructions create a a set of transitions that loop. Specifically,
+ the start loop instruction begins the loop. The origin state determines the
+ starting and ending state of the loop. All transitions created between
+ when StartLoop and EndLoop are called are pushed onto a stack. When
+ EndLoop is called, the transition labels are popped and used to create
+ a loop of transitions -- the origin and destination state of these transitions
+ is ignored.
*/
+bool cHardwareOrchid::Inst_StartLoop(cAvidaContext& ctx)
+{
+ organism->GetOrchidOrganism()->GetStateDiagram()->StartLooping();
+ return true;
+}
+
+bool cHardwareOrchid::Inst_EndLoop(cAvidaContext& ctx)
+{
+ organism->GetOrchidOrganism()->GetStateDiagram()->EndLooping();
+ return true;
+}
+
+
+/* These instructions move an index (e.g., StateDiagram, OrigState, etc.) to
+ a designated position within a vector.
+ */
bool cHardwareOrchid::Inst_StateDiag0(cAvidaContext& ctx)
{ return (organism->GetOrchidOrganism()->AbsoluteJumpStateDiagram(0)); }
@@ -7129,7 +7154,11 @@
{ return (organism->GetOrchidOrganism()->GetStateDiagram()->AbsoluteJumpAction(13)); }
-/*! This instruction...
+/*! These instructions move an index (e.g., StateDiagram, OrigState, etc.) to
+ a relative number of positions from its current location wrapping around the end.
+
+ The number of positions is calculated by interpreting the NOPS that follow the
+ instruction as an integer.
*/
bool cHardwareOrchid::Inst_RelativeMoveTrigger(cAvidaContext& ctx)
{
@@ -7138,90 +7167,71 @@
return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpTrigger(jump_amount));
}
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_AbsoluteMoveTrigger(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_RelativeMoveGuard(cAvidaContext& ctx)
{
ReadLabel();
int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetStateDiagram()->AbsoluteJumpTrigger(jump_amount));
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpGuard(jump_amount));
}
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_NextTrigger(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_RelativeMoveAction(cAvidaContext& ctx)
{
- return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpTrigger(1));
+ ReadLabel();
+ int jump_amount = GetLabel().AsInt(NUM_NOPS);
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpAction(jump_amount));
}
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_RelativeMoveGuard(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_RelativeMoveOrigin(cAvidaContext& ctx)
{
ReadLabel();
int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpGuard(jump_amount));
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpOriginState(jump_amount));
}
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_AbsoluteMoveGuard(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_RelativeMoveDestination(cAvidaContext& ctx)
{
ReadLabel();
int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetStateDiagram()->AbsoluteJumpGuard(jump_amount));
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpDestinationState(jump_amount));
}
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_NextGuard(cAvidaContext& ctx)
-{ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpGuard(1)); }
-
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_RelativeMoveAction(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_RelativeMoveTransLabel(cAvidaContext& ctx)
{
ReadLabel();
int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpAction(jump_amount));
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpTransitionLabel(jump_amount));
}
-/*! This instruction...
+
+
+/*! These instructions move an index (e.g., StateDiagram, OrigState, etc.) to
+ an absolute position wrapping around the end.
+
+ The number of positions is calculated by interpreting the NOPS that follow the
+ instruction as an integer.
*/
-bool cHardwareOrchid::Inst_AbsoluteMoveAction(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_AbsoluteMoveTrigger(cAvidaContext& ctx)
{
ReadLabel();
int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetStateDiagram()->AbsoluteJumpAction(jump_amount));
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->AbsoluteJumpTrigger(jump_amount));
}
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_NextAction(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_AbsoluteMoveGuard(cAvidaContext& ctx)
{
- return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpAction(1));
+ ReadLabel();
+ int jump_amount = GetLabel().AsInt(NUM_NOPS);
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->AbsoluteJumpGuard(jump_amount));
}
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_RelativeMoveOrigin(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_AbsoluteMoveAction(cAvidaContext& ctx)
{
ReadLabel();
int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpOriginState(jump_amount));
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->AbsoluteJumpAction(jump_amount));
}
-
-/*! This instruction...
- */
bool cHardwareOrchid::Inst_AbsoluteMoveOrigin(cAvidaContext& ctx)
{
ReadLabel();
@@ -7229,66 +7239,61 @@
return (organism->GetOrchidOrganism()->GetStateDiagram()->AbsoluteJumpOriginState(jump_amount));
}
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_NextOrigin(cAvidaContext& ctx)
-{ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpOriginState(1)); }
-
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_RelativeMoveDestination(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_AbsoluteMoveDestination(cAvidaContext& ctx)
{
ReadLabel();
int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpDestinationState(jump_amount));
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->AbsoluteJumpDestinationState(jump_amount));
}
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_AbsoluteMoveDestination(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_AbsoluteMoveTransLabel(cAvidaContext& ctx)
{
ReadLabel();
int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetStateDiagram()->AbsoluteJumpDestinationState(jump_amount));
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->AbsoluteJumpTransitionLabel(jump_amount));
}
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_NextDestination(cAvidaContext& ctx)
-{ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpDestinationState(1)); }
-
-/*! This instruction...
+/*! These instructions move an index (e.g., StateDiagram, OrigState, etc.) one position forward.
*/
-bool cHardwareOrchid::Inst_RelativeMoveTransLabel(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_NextTrigger(cAvidaContext& ctx)
{
- ReadLabel();
- int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpTransitionLabel(jump_amount));
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpTrigger(1));
}
+bool cHardwareOrchid::Inst_NextGuard(cAvidaContext& ctx)
+{
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpGuard(1));
+}
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_AbsoluteMoveTransLabel(cAvidaContext& ctx)
+
+bool cHardwareOrchid::Inst_NextAction(cAvidaContext& ctx)
{
- ReadLabel();
- int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetStateDiagram()->AbsoluteJumpTransitionLabel(jump_amount));
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpAction(1));
}
+bool cHardwareOrchid::Inst_NextOrigin(cAvidaContext& ctx)
+{
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpOriginState(1));
+}
-/*! This instruction...
- */
+bool cHardwareOrchid::Inst_NextDestination(cAvidaContext& ctx)
+{
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpDestinationState(1));
+}
+
bool cHardwareOrchid::Inst_NextTransLabel(cAvidaContext& ctx)
-{ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpTransitionLabel(1)); }
+{
+ return (organism->GetOrchidOrganism()->GetStateDiagram()->RelativeJumpTransitionLabel(1));
+}
-/*! This instruction...
+
+////////// Avida-Marple Property Generation & Manipulation Instructions //////////
+
+
+/*! These instructions create the various types of properties (e.g., Absence, Universality, Response).
*/
bool cHardwareOrchid::Inst_AbsenceProperty(cAvidaContext& ctx)
{
@@ -7307,8 +7312,6 @@
}
-/*! This instruction...
- */
bool cHardwareOrchid::Inst_UniversialityProperty(cAvidaContext& ctx)
{
float val = 0;
@@ -7327,8 +7330,6 @@
}
-/*! This instruction...
- */
bool cHardwareOrchid::Inst_ExistenceProperty(cAvidaContext& ctx)
{
float val = 0;
@@ -7345,8 +7346,6 @@
}
-/*! This instruction...
- */
bool cHardwareOrchid::Inst_PrecedenceProperty(cAvidaContext& ctx)
{
float val = 0;
@@ -7361,8 +7360,6 @@
}
-/*! This instruction...
- */
bool cHardwareOrchid::Inst_ResponseProperty(cAvidaContext& ctx)
{
float val = 0;
@@ -7377,7 +7374,12 @@
}
-/*! This instruction...
+/*! These instructions move an index (e.g., P, Q) to a relative number of positions
+ from its current location wrapping around the end. Note that P, Q, and R are all
+ indices into the same vector of expressions.
+
+ The number of positions is calculated by interpreting the NOPS that follow the
+ instruction as an integer.
*/
bool cHardwareOrchid::Inst_RelativeMoveExpressionP(cAvidaContext& ctx)
{
@@ -7386,53 +7388,36 @@
return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionP(jump_amount));
}
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_NextExpressionP(cAvidaContext& ctx)
-{ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionP(1)); }
-
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_PrevExpressionP(cAvidaContext& ctx)
-{ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionP(-1)); }
-
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_AbsoluteMoveExpressionP(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_RelativeMoveExpressionQ(cAvidaContext& ctx)
{
ReadLabel();
int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->AbsoluteMoveExpressionP(jump_amount));
+ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionQ(jump_amount));
}
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_RelativeMoveExpressionQ(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_RelativeMoveExpressionR(cAvidaContext& ctx)
{
ReadLabel();
int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionQ(jump_amount));
+ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionR(jump_amount));
}
-/*! This instruction...
+/*! These instructions move an index (e.g., P, Q, or R) to an absolute position
+ wrapping around the end. Note that P, Q, and R are all indices into the
+ same vector of expressions.
+
+ The number of positions is calculated by interpreting the NOPS that follow the
+ instruction as an integer.
*/
-bool cHardwareOrchid::Inst_NextExpressionQ(cAvidaContext& ctx)
-{ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionQ(1)); }
+bool cHardwareOrchid::Inst_AbsoluteMoveExpressionP(cAvidaContext& ctx)
+{
+ ReadLabel();
+ int jump_amount = GetLabel().AsInt(NUM_NOPS);
+ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->AbsoluteMoveExpressionP(jump_amount));
+}
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_PrevExpressionQ(cAvidaContext& ctx)
-{ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionQ(-1)); }
-
-
-/*! This instruction...
- */
bool cHardwareOrchid::Inst_AbsoluteMoveExpressionQ(cAvidaContext& ctx)
{
ReadLabel();
@@ -7440,40 +7425,32 @@
return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->AbsoluteMoveExpressionQ(jump_amount));
}
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_RelativeMoveExpressionR(cAvidaContext& ctx)
+bool cHardwareOrchid::Inst_AbsoluteMoveExpressionR(cAvidaContext& ctx)
{
ReadLabel();
int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionR(jump_amount));
+ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->AbsoluteMoveExpressionR(jump_amount));
}
-/*! This instruction...
+
+/*! These instructions move an index (e.g., P, Q, or R.) one position forward.
*/
-bool cHardwareOrchid::Inst_NextExpressionR(cAvidaContext& ctx)
-{ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionR(1)); }
+bool cHardwareOrchid::Inst_NextExpressionP(cAvidaContext& ctx)
+{ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionP(1)); }
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_PrevExpressionR(cAvidaContext& ctx)
-{ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionR(-1)); }
+bool cHardwareOrchid::Inst_NextExpressionQ(cAvidaContext& ctx)
+{ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionQ(1)); }
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_AbsoluteMoveExpressionR(cAvidaContext& ctx)
-{
- ReadLabel();
- int jump_amount = GetLabel().AsInt(NUM_NOPS);
- return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->AbsoluteMoveExpressionR(jump_amount));
-}
+bool cHardwareOrchid::Inst_NextExpressionR(cAvidaContext& ctx)
+{ return (organism->GetOrchidOrganism()->GetUMLModel()->GetPropertyGenerator()->RelativeMoveExpressionR(1)); }
-/*! This instruction...
+
+/*! This instruction ANDs two expressions (pointed to by P & Q) together to create
+ a new expression and appends it to the end of the expression list.
*/
bool cHardwareOrchid::Inst_ANDExpressions(cAvidaContext& ctx)
{
@@ -7483,7 +7460,8 @@
}
-/*! This instruction...
+/*! This instruction ORs two expressions (pointed to by P & Q) together to create
+ a new expression and appends it to the end of the expression list.
*/
bool cHardwareOrchid::Inst_ORExpressions(cAvidaContext& ctx)
{
@@ -7493,19 +7471,4 @@
}
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_StartLoop(cAvidaContext& ctx)
-{
- organism->GetOrchidOrganism()->GetStateDiagram()->StartLooping();
- return true;
-}
-
-/*! This instruction...
- */
-bool cHardwareOrchid::Inst_EndLoop(cAvidaContext& ctx)
-{
- organism->GetOrchidOrganism()->GetStateDiagram()->EndLooping();
- return true;
-}
Modified: branches/uml-merge/source/cpu/cHardwareOrchid.h
===================================================================
--- branches/uml-merge/source/cpu/cHardwareOrchid.h 2008-06-25 15:14:12 UTC (rev 2687)
+++ branches/uml-merge/source/cpu/cHardwareOrchid.h 2008-06-25 18:23:27 UTC (rev 2688)
@@ -786,15 +786,12 @@
bool Inst_RelativeMoveExpressionP(cAvidaContext& ctx);
bool Inst_NextExpressionP(cAvidaContext& ctx);
- bool Inst_PrevExpressionP(cAvidaContext& ctx);
bool Inst_AbsoluteMoveExpressionP(cAvidaContext& ctx);
bool Inst_RelativeMoveExpressionQ(cAvidaContext& ctx);
bool Inst_NextExpressionQ(cAvidaContext& ctx);
- bool Inst_PrevExpressionQ(cAvidaContext& ctx);
bool Inst_AbsoluteMoveExpressionQ(cAvidaContext& ctx);
bool Inst_RelativeMoveExpressionR(cAvidaContext& ctx);
bool Inst_NextExpressionR(cAvidaContext& ctx);
- bool Inst_PrevExpressionR(cAvidaContext& ctx);
bool Inst_AbsoluteMoveExpressionR(cAvidaContext& ctx);
bool Inst_StartLoop(cAvidaContext& ctx);
bool Inst_EndLoop(cAvidaContext& ctx);
Modified: branches/uml-merge/source/main/cTaskLib.cc
===================================================================
--- branches/uml-merge/source/main/cTaskLib.cc 2008-06-25 15:14:12 UTC (rev 2687)
+++ branches/uml-merge/source/main/cTaskLib.cc 2008-06-25 18:23:27 UTC (rev 2688)
@@ -442,8 +442,7 @@
NewTask(name, "Non-determinism", &cTaskLib::Task_Nondeterminism);
else if (name == "export-xmi")
NewTask(name, "Export XMI", &cTaskLib::Task_ExportXMI);
- else if (name == "check-props")
- NewTask(name, "Check Properties", &cTaskLib::Task_Properties);
+
@@ -3062,7 +3061,10 @@
}
-/*! This task...
+//--------Orchid tasks --------
+
+/*! 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.
*/
double cTaskLib::Task_Scenarios(cTaskContext& ctx) const
{
@@ -3086,24 +3088,9 @@
}
-/*! This task...
- */
-double cTaskLib::Task_Properties(cTaskContext& ctx) const
-{
- cOrchidOrganism* orchid_org = ctx.GetOrganism()->GetOrchidOrganism();
- assert(orchid_org);
- double bonus = 0.0;
-
- // call some sort of check properties function for the model.
- 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...
+/*! This task translates the XMI version of the UML model generated by
+ the organism into Promela using Hydra (an external tool)
*/
double cTaskLib::Task_Hydra(cTaskContext& ctx) const
{
@@ -3112,8 +3099,11 @@
double bonus = 0.0;
std::string temp = orchid_org->GetUMLModel()->GetXMI();
- // call hydra when a // all scenario hits its max?
- // all are non-zero?
+ // Check and see if the model supports enough of the scenarios
+ // that you want to run Hydra. This can be configured to be
+ // everytime, when 100% of the scenarios are complete,
+ // when a different percentage of scenarios are complete, etc.
+ // Configure it in the seed-model.cfg file.
if (!orchid_org->GetUMLModel()->ReadyForHydra()) {
orchid_org->GetUMLModel()->SetBonusInfo("hydra", bonus);
return 0;
@@ -3121,6 +3111,7 @@
m_world->GetStats().HydraAttempt();
+ // Check if this model is different than the orchid_organism's parent's model
if (orchid_org->GetParentXMI() == temp) {
bonus = orchid_org->GetParentBonus("hydra");
orchid_org->GetUMLModel()->SetBonusInfo("hydra", bonus);
@@ -3211,21 +3202,21 @@
}
-/*! This task...
+/*! This task runs Spin, an external model checker, to verify that the model passes a property,
+ which is specified in the neverclaim file. It is essentially an invisible task
+ in that it is called by other tasks.
*/
double cTaskLib::SpinCoprocess(cTaskContext& ctx, const std::string& neverclaimFile) const {
std::string file_name = "tmp-" + neverclaimFile + ".pr";
std::string cmd = "cp tmp.pr "+ file_name;
if(system(cmd.c_str())!=0) return 0.0;
- //std::string cmd = "cat " + neverclaimFile + " >> tmp.pr && ./spin -a tmp.pr &> /dev/null";
cmd = "cat " + neverclaimFile + " >> " + file_name + " && ./spin -a " + file_name + " &> /dev/null";
if(system(cmd.c_str())!=0) return 0.0;
if(system("/usr/bin/gcc -DMEMLIM=512 pan.c -o pan &> /dev/null")!=0) return 0.0;
if(system("./pan -a &> ./pan.out")!=0) return 0.0;
if(system("cat pan.out | perl -e 'while(<STDIN>) { if(/errors:\\s(\\d+)/) {exit($1);}}'")!=0) return 0.0;
- //if(system("cat pan.out | perl -e 'while(<STDIN>) { if(/unreached/) {exit(1);}}'")!=0) return 0.2;
- //Commented out to remove overhead...
+ // Save the XMI representation of the model that passed.
std::ostringstream strstrm, strstrm2;
strstrm << "cp tmp.xmi " << neverclaimFile << "." << m_world->GetStats().GetUpdate() << "." << ctx.GetOrganism()->GetID();
strstrm << ".xml";
@@ -3233,13 +3224,19 @@
strstrm2 << neverclaimFile << "." << m_world->GetStats().GetUpdate() << "." << ctx.GetOrganism()->GetID();
// print the relevant information about the scenarios
- //std::string temp_str = neverclaimFile + "." + m_world->GetStats().GetUpdate() + "."; // + ctx.GetOrganism()->GetID();
ctx.GetOrganism()->GetOrchidOrganism()->GetUMLModel()->PrintScenarioUtility(strstrm2.str().c_str());
return 1.0;
}
-/*! This task...
+/*! Similar to the SpinCoprocess task, this task also runs Spin, an external model checker.
+ However, this task is used to verify that at least one path through the model adheres to
+ a property. This task was created to catch cheating organisms that passed the property
+ If X, then Y property tasks by generating models that did not contain X.
+
+ The witness property (or inverse of the actual property you want the models to adhere to)
+ is specified in the neverclaim file. This task works by using Spin to check that there is
+ at least one violation of the witness property.
*/
double cTaskLib::SpinWitnessCoprocess(cTaskContext& ctx, const std::string& neverclaimFile) const {
int num_witness = 0;
@@ -3260,28 +3257,24 @@
}
return num_witness;
- //(system("cat pan.out | perl -e 'while(<STDIN>) { if(/errors:\\s(\\d+)/) {exit($1);}}'"));
}
-/*! This task...
+/*! This task verifies a property stored in a file called N1.
*/
double cTaskLib::Task_SpinN1(cTaskContext& ctx) const {
cOrchidOrganism* orchid_org = ctx.GetOrganism()->GetOrchidOrganism();
assert(orchid_org);
double bonus = 0.0;
- /*if (orchid_org->GetUMLModel()->GetBonusInfo("spinw1") <= 1)
- {
- orchid_org->GetUMLModel()->SetBonusInfo("spinn1", bonus);
- return bonus;
- }*/
+ // See if the witness needs to be true.
if(orchid_org->GetUMLModel()->GetWitnessMode()) {
if(orchid_org->GetUMLModel()->GetBonusInfo("spinw1") < 1) {
orchid_org->GetUMLModel()->SetBonusInfo("spinn1", bonus);
return bonus;
}
} else {
+ // See if Hydra has run successfully
if(orchid_org->GetUMLModel()->GetBonusInfo("hydra") == 0) {
orchid_org->GetUMLModel()->SetBonusInfo("spinn1", bonus);
return bonus;
@@ -3290,6 +3283,7 @@
m_world->GetStats().N1Attempt();
+ // Verify the property
if(orchid_org->GetParentXMI() == orchid_org->GetUMLModel()->GetXMI()) {
bonus = orchid_org->GetParentBonus("spinn1");
} else {
@@ -3302,7 +3296,8 @@
}
-/*! This task...
+/*! This task verifies a witness property stored in a file called W1. Note that
+ witness property W1 should correspond to property N1.
*/
double cTaskLib::Task_SpinW1(cTaskContext& ctx) const {
cOrchidOrganism* orchid_org = ctx.GetOrganism()->GetOrchidOrganism();
@@ -3327,7 +3322,8 @@
}
-/*! This task...
+/*! This task verifies a property stored in a file called N2. It is
+ essentially the same function as SpinN1.
*/
double cTaskLib::Task_SpinN2(cTaskContext& ctx) const {
cOrchidOrganism* orchid_org = ctx.GetOrganism()->GetOrchidOrganism();
@@ -3360,7 +3356,9 @@
}
-/*! This task...
+/*! This task verifies a witness property stored in a file called W2. Note that
+ witness property W2 should correspond to property N2. This function is
+ essentially the same as SpinW1
*/
double cTaskLib::Task_SpinW2(cTaskContext& ctx) const {
cOrchidOrganism* orchid_org = ctx.GetOrganism()->GetOrchidOrganism();
@@ -3385,27 +3383,16 @@
}
-/*! This task...
+/*! This task rewards an organism for generating a state diagram that
+ uses fewer transitions.
*/
double cTaskLib::Task_MinTrans(cTaskContext& ctx) const {
- // This task rewards orchid_orgs for having fewer edges
+ // This task rewards orchid_orgs for having fewer transitions
cOrchidOrganism* orchid_org = ctx.GetOrganism()->GetOrchidOrganism();
assert(orchid_org);
double bonus = 0.0;
cUMLModel* mod = orchid_org->GetUMLModel();
int mt, nt;
-
- /* if ((orchid_org->GetUMLModel()->GetBonusInfo("spinw1") == 0) &&
- (orchid_org->GetUMLModel()->GetBonusInfo("spinw2") == 0)) {
- return bonus;
- }
- if ((orchid_org->GetUMLModel()->GetBonusInfo("scenario5") != 9) ||
- (orchid_org->GetUMLModel()->GetBonusInfo("scenario6") != 4)) {
- return bonus;
- }*/
- /* if (orchid_org->GetUMLModel()->GetBonusInfo("hydra") == 0){
- return bonus;
- }*/
// Ok. Subtract the number of edges from the maximum number of edges seen so far.
mt = mod->GetMaxTrans();
@@ -3422,7 +3409,8 @@
}
-/*! This task...
+/*! This task rewards an organism for generating a state diagram that
+ has non-deterministic states.
*/
double cTaskLib::Task_Nondeterminism(cTaskContext& ctx) const {
cOrchidOrganism* orchid_org = ctx.GetOrganism()->GetOrchidOrganism();
Modified: branches/uml-merge/source/main/cTaskLib.h
===================================================================
--- branches/uml-merge/source/main/cTaskLib.h 2008-06-25 15:14:12 UTC (rev 2687)
+++ branches/uml-merge/source/main/cTaskLib.h 2008-06-25 18:23:27 UTC (rev 2688)
@@ -312,7 +312,6 @@
double Task_MinTrans(cTaskContext& ctx) const;
double Task_Nondeterminism(cTaskContext& ctx) const;
double Task_ExportXMI(cTaskContext& ctx) const;
- double Task_Properties(cTaskContext& ctx) const;
// -------- End of Orchid tasks. --------
};
Modified: branches/uml-merge/source/orchid/cOrchidOrganism.cc
===================================================================
--- branches/uml-merge/source/orchid/cOrchidOrganism.cc 2008-06-25 15:14:12 UTC (rev 2687)
+++ branches/uml-merge/source/orchid/cOrchidOrganism.cc 2008-06-25 18:23:27 UTC (rev 2688)
@@ -6,17 +6,20 @@
*/
cOrchidOrganism::cOrchidOrganism(cWorld* world)
: m_state_diag(0)
-, m_orig_state_index(0)
-, m_dest_state_index(0)
, m_model((const char*)world->GetConfig().ORCHID_SEED_MODEL.Get())
-{
-}
+{}
-/*! Model check this organism... (more)
+/*! An evaluation function used by the orchid branch to evaluate the generated model/
+ properties and to track stats information.
*/
void cOrchidOrganism::ModelCheck(cAvidaContext& ctx)
{
+
+// If the generation mode is set to Avida-MDE (model generation mode)
+// then print the XMI version of the model and get the number of transitions.
+// 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();
// Update the value of max trans
@@ -25,8 +28,10 @@
}
}
+// Evaluate the tasks
// DoOutput(ctx, true);
+// Update the UML and property stats.
cUMLModel* org_model = GetUMLModel();
// cUMLModel* pop_model = m_world->GetPopulation().GetUMLModel();
// m_world->GetStats().OrchidStatsPostTaskCheck(org_model, pop_model);
@@ -34,19 +39,18 @@
}
-cUMLModel* cOrchidOrganism::GetUMLModel()
+/*! Move the state diagram index to the designated position in the vector
+*/
+bool cOrchidOrganism::AbsoluteJumpStateDiagram(int position)
{
- return &m_model;
-}
-
-
-bool cOrchidOrganism::AbsoluteJumpStateDiagram(int amount)
-{
m_state_diag = 0;
- return RelativeJumpStateDiagram(amount);
+ return RelativeJumpStateDiagram(position);
}
+/*! Move the state diagram index the designated amount forward being sure to
+ wrap around the ends of the vector as necessary.
+*/
bool cOrchidOrganism::RelativeJumpStateDiagram(int amount)
{
int size = GetUMLModel()->GetStateDiagramSize();
@@ -70,42 +74,4 @@
}
-cUMLStateDiagram* cOrchidOrganism::GetStateDiagram()
-{
- return m_model.GetStateDiagram(m_state_diag);
-}
-
-bool cOrchidOrganism::AbsoluteJumpOriginState(int amount)
-{
- m_orig_state_index = 0;
- return (RelativeJumpOriginState(amount));
-}
-
-
-bool cOrchidOrganism::AbsoluteJumpDestinationState(int amount)
-{
- m_dest_state_index = 0;
- return (RelativeJumpDestinationState(amount));
-}
-
-
-bool cOrchidOrganism::AddTransitionTotal()
-{
- bool val;
- val = GetStateDiagram()->AddTransitionTotal();
- return val;
-}
-
-bool cOrchidOrganism::RelativeJumpOriginState(int amount)
-{
- m_orig_state_index += amount;
- return true;
-}
-
-bool cOrchidOrganism::RelativeJumpDestinationState(int amount)
-{
- m_dest_state_index += amount;
- return true;
-}
-
Modified: branches/uml-merge/source/orchid/cOrchidOrganism.h
===================================================================
--- branches/uml-merge/source/orchid/cOrchidOrganism.h 2008-06-25 15:14:12 UTC (rev 2687)
+++ branches/uml-merge/source/orchid/cOrchidOrganism.h 2008-06-25 18:23:27 UTC (rev 2688)
@@ -20,48 +20,40 @@
public:
//! Default constructor.
cOrchidOrganism(cWorld* world);
- //!
+ //! Evaluate the model according to the tasks and update the stats
void ModelCheck(cAvidaContext& ctx);
- //!
- cUMLModel* GetUMLModel();
+ //! 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; }
- //!
- int GetStateDiagramIndex() { return m_state_diag; }
- //! (use meaningful names for parameters)
- bool CurrTrans (int, int, int, int, int, int);
- //!
- cUMLStateDiagram* GetStateDiagram();
+ //! 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; }
- //!
+ //! 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; }
- //! (names)
- float GetParentBonus(const std::string& s) { return m_parent_bonus[s]; }
+ //! Provide specific information about the bonus received by the parent for a specific task
+ float GetParentBonus(const std::string& task_name) { return m_parent_bonus[task_name]; }
//! Returns the bonus map for this organism's parent.
const std::map<std::string, float>& GetParentBonus() { return m_parent_bonus; }
//! Returns a vector for scenario completion of this organism's parent.
const std::vector<double>& GetParentScenarioCompletion() { return m_parent_scenario_completion; }
- //! (names)
- void SetParentScenarioCompletion (const std::vector<double>& s) { m_parent_scenario_completion = s; }
+ //! The birth chamber calls this method to provide an offspring with information about the
+ //! well the parent completed the scenarios.
+ void SetParentScenarioCompletion (const std::vector<double>& scenarios_completion)
+ { m_parent_scenario_completion = scenarios_completion; }
- // The jump functions jump the index of the various vectors either forward (+ int) or backwards (- int)
- bool AbsoluteJumpOriginState(int);
- bool AbsoluteJumpDestinationState(int);
- bool AbsoluteJumpStateDiagram (int);
- bool RelativeJumpOriginState(int amount);
- bool RelativeJumpDestinationState(int amount);
- bool RelativeJumpStateDiagram (int);
- bool AddTransitionTotal();
+ // The jump functions jump the index of the state diagram vector either forward (+ int) or backwards (- int)
+ bool AbsoluteJumpStateDiagram (int position);
+ bool RelativeJumpStateDiagram (int amount);
protected:
int m_state_diag; //!< Index of the state diagram currently being manipulated.
- int m_orig_state_index; //!<
- int m_dest_state_index; //!<
- cUMLModel m_model; //!<
- std::string m_parent_xmi; //!<
- std::map<std::string, float> m_parent_bonus; //!<
- std::vector<double> m_parent_scenario_completion; //!<
+ cUMLModel m_model; //!< UML model of this organism
+ std::string m_parent_xmi; //!< 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
};
#endif
More information about the Avida-cvs
mailing list