[Avida-SVN] r1751 - in branches/uml: . source/actions source/cpu source/main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Thu Jul 5 10:59:43 PDT 2007
Author: hjg
Date: 2007-07-05 13:59:43 -0400 (Thu, 05 Jul 2007)
New Revision: 1751
Modified:
branches/uml/CMakeLists.txt
branches/uml/source/actions/PrintActions.cc
branches/uml/source/cpu/cHardwareCPU.cc
branches/uml/source/cpu/cHardwareCPU.h
branches/uml/source/main/cBirthChamber.cc
branches/uml/source/main/cDeme.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
branches/uml/source/main/cUMLModel.cc
Log:
Added scenario tasks.
Modified: branches/uml/CMakeLists.txt
===================================================================
--- branches/uml/CMakeLists.txt 2007-07-05 16:41:28 UTC (rev 1750)
+++ branches/uml/CMakeLists.txt 2007-07-05 17:59:43 UTC (rev 1751)
@@ -31,7 +31,7 @@
# ------------------------------------------------------------------------------
IF(UNIX)
SET(COMPILER_WARNING_FLAGS "-Wextra -Wno-unknown-pragmas -Wconversion -Wno-trigraphs")
- SET(COMPILER_OPTIMIZATION_FLAGS "-ffast-math -fno-rtti -funroll-loops -fstrict-aliasing -ftree-vectorize -fvisibility-inlines-hidden")
+ SET(COMPILER_OPTIMIZATION_FLAGS "-ffast-math -funroll-loops -fstrict-aliasing -ftree-vectorize -fvisibility-inlines-hidden")
# Four types of c++ compilations:
# - debug (Debug)
Modified: branches/uml/source/actions/PrintActions.cc
===================================================================
--- branches/uml/source/actions/PrintActions.cc 2007-07-05 16:41:28 UTC (rev 1750)
+++ branches/uml/source/actions/PrintActions.cc 2007-07-05 17:59:43 UTC (rev 1751)
@@ -86,7 +86,7 @@
STATS_OUT_FILE(PrintMarketData, market.dat );
STATS_OUT_FILE(PrintSenseData, sense.dat );
STATS_OUT_FILE(PrintSenseExeData, sense_exe.dat );
-STATS_OUT_FILE(PrintUMLData, uml.dat );
+//STATS_OUT_FILE(PrintUMLData, uml.dat );
@@ -1873,7 +1873,7 @@
action_lib->Register<cActionPrintInstructionData>("print_instruction_data");
action_lib->Register<cActionPrintGenotypeMap>("print_genotype_map");
action_lib->Register<cActionPrintMarketData>("print_market_data");
- action_lib->Register<cActionPrintUMLData>("PrintUMLData");
+// action_lib->Register<cActionPrintUMLData>("PrintUMLData");
action_lib->Register<cActionPrintPhenotypeData>("print_number_phenotypes");
Modified: branches/uml/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.cc 2007-07-05 16:41:28 UTC (rev 1750)
+++ branches/uml/source/cpu/cHardwareCPU.cc 2007-07-05 17:59:43 UTC (rev 1751)
@@ -349,12 +349,12 @@
// UML Element Creation
/* tInstLibEntry<tMethod>("addState", &cHardwareCPU::Inst_AddState, false,
"Add a new state"),
-*/
+*/
+/*
tInstLibEntry<tMethod>("next", &cHardwareCPU::Inst_Next, false,
"Increment to the next position in the list"),
tInstLibEntry<tMethod>("prev", &cHardwareCPU::Inst_Prev, false,
"Decrement to the previous position in the list"),
-/*
tInstLibEntry<tMethod>("addTransLab", &cHardwareCPU::Inst_AddTransitionLabel, false,
"Add a transition label"),
*/
@@ -364,16 +364,15 @@
*/
tInstLibEntry<tMethod>("addTransT", &cHardwareCPU::Inst_AddTransitionTotal, false,
"Add a transition without adding a label."),
- tInstLibEntry<tMethod>("jump", &cHardwareCPU::Inst_JumpIndex, false,
+/* tInstLibEntry<tMethod>("jump", &cHardwareCPU::Inst_JumpIndex, false,
"Jump to a position in the list"),
-/* tInstLibEntry<tMethod>("first", &cHardwareCPU::Inst_First, false,
+ tInstLibEntry<tMethod>("first", &cHardwareCPU::Inst_First, false,
"Go to the first position in the list"),
tInstLibEntry<tMethod>("last", &cHardwareCPU::Inst_Last, false,
- "Go to the last position in the list"),
-*/
+ "Go to the last position in the list"),
tInstLibEntry<tMethod>("jump-d", &cHardwareCPU::Inst_JumpDist, false,
"Jump to a position in the list using labels."),
-
+*/
tInstLibEntry<tMethod>("sd-0", &cHardwareCPU::Inst_StateDiag0, false,
"Change to state diagram 0"),
tInstLibEntry<tMethod>("sd-1", &cHardwareCPU::Inst_StateDiag1, false,
@@ -3983,7 +3982,7 @@
//// UML Element Construction ////
-
+/*
bool cHardwareCPU::Inst_Next(cAvidaContext& ctx)
{
if(organism->GetCellID()==-1) return false;
@@ -4153,6 +4152,7 @@
}
return true;
}
+*/
/*
Modified: branches/uml/source/cpu/cHardwareCPU.h
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.h 2007-07-05 16:41:28 UTC (rev 1750)
+++ branches/uml/source/cpu/cHardwareCPU.h 2007-07-05 17:59:43 UTC (rev 1751)
@@ -536,10 +536,10 @@
//// UML Element Construction ////
// bool Inst_AddState(cAvidaContext& ctx);
- bool Inst_Next(cAvidaContext& ctx);
- bool Inst_Prev(cAvidaContext& ctx);
- bool Inst_JumpIndex(cAvidaContext& ctx);
- bool Inst_JumpDist(cAvidaContext& ctx);
+// bool Inst_Next(cAvidaContext& ctx);
+// bool Inst_Prev(cAvidaContext& ctx);
+// bool Inst_JumpIndex(cAvidaContext& ctx);
+// bool Inst_JumpDist(cAvidaContext& ctx);
// bool Inst_AddTransitionLabel(cAvidaContext& ctx);
// bool Inst_AddTransition(cAvidaContext& ctx);
bool Inst_AddTransitionTotal(cAvidaContext& ctx);
Modified: branches/uml/source/main/cBirthChamber.cc
===================================================================
--- branches/uml/source/main/cBirthChamber.cc 2007-07-05 16:41:28 UTC (rev 1750)
+++ branches/uml/source/main/cBirthChamber.cc 2007-07-05 17:59:43 UTC (rev 1751)
@@ -166,7 +166,7 @@
child_genotype->IncDeferAdjust();
// FOR UML branch - hjg
- child_array[0]->setParentModel(parent.getUMLModel());
+// child_array[0]->setParentModel(parent.getUMLModel());
return true;
}
Modified: branches/uml/source/main/cDeme.h
===================================================================
--- branches/uml/source/main/cDeme.h 2007-07-05 16:41:28 UTC (rev 1750)
+++ branches/uml/source/main/cDeme.h 2007-07-05 17:59:43 UTC (rev 1751)
@@ -25,7 +25,6 @@
#include "cGermline.h"
#include "tArray.h"
-#include "cUMLModel.h"
Modified: branches/uml/source/main/cOrganism.cc
===================================================================
--- branches/uml/source/main/cOrganism.cc 2007-07-05 16:41:28 UTC (rev 1750)
+++ branches/uml/source/main/cOrganism.cc 2007-07-05 17:59:43 UTC (rev 1751)
@@ -88,12 +88,14 @@
if (m_world->GetConfig().NET_ENABLED.Get()) m_net = new cNetSupport();
m_id = m_world->GetStats().GetTotCreatures();
- m_state_diag = 1;
+/* m_state_diag = 1;
+*/
m_orig_state_index = 0;
m_dest_state_index = 0;
- m_trigger_index = 0;
+/* m_trigger_index = 0;
m_guard_index = 0;
- m_action_index = 0;
+ m_action_index = 0;*/
+ m_model.seedDiagrams();
}
@@ -575,7 +577,7 @@
if(GetCellID()==-1) return;
- printStats();
+// printStats();
assert(m_interface);
@@ -702,7 +704,7 @@
}
*/
-
+/*
bool cOrganism::absoluteJumpGuard(int amount)
{
m_guard_index = 0;
@@ -727,8 +729,8 @@
m_trans_label_index =0;
return (relativeJumpTransitionLabel(amount));
}
+*/
-
bool cOrganism::absoluteJumpOriginState(int amount)
{
m_orig_state_index = 0;
@@ -741,6 +743,7 @@
return (relativeJumpDestinationState(amount));
}
+
bool cOrganism::addTransitionTotal()
{
bool val;
@@ -755,8 +758,10 @@
m_action_index = 0;
m_guard_index = 0;
} */
+
return val;
}
+/*
bool cOrganism::relativeJumpGuard(int amount)
{
@@ -781,7 +786,7 @@
m_trans_label_index += amount;
return true;
}
-
+*/
bool cOrganism::relativeJumpOriginState(int amount)
{
m_orig_state_index += amount;
@@ -793,7 +798,7 @@
m_dest_state_index += amount;
return true;
}
-
+ /*
void cOrganism::printStats()
{
// for each state diagram
@@ -801,4 +806,4 @@
// print the name, the number of states
}
-
\ No newline at end of file
+ */
\ No newline at end of file
Modified: branches/uml/source/main/cOrganism.h
===================================================================
--- branches/uml/source/main/cOrganism.h 2007-07-05 16:41:28 UTC (rev 1750)
+++ branches/uml/source/main/cOrganism.h 2007-07-05 17:59:43 UTC (rev 1751)
@@ -144,12 +144,12 @@
// manipulating
int m_orig_state_index;
int m_dest_state_index;
- int m_trans_label_index;
+/* int m_trans_label_index;
int m_trigger_index;
int m_guard_index;
- int m_action_index;
+ int m_action_index;*/
cUMLModel m_model; // Used when not running as deme
- cUMLModel* m_parent_model; // Used when not running as deme
+// cUMLModel* m_parent_model; // Used when not running as deme
class cNetSupport
{
@@ -310,34 +310,38 @@
// UML
void modelCheck(cAvidaContext& ctx);
cUMLModel* getUMLModel();
- cUMLModel* getParentUMLModel() { return m_parent_model; }
+// cUMLModel* getParentUMLModel() { return m_parent_model; }
int getStateDiagramIndex() { return m_state_diag; }
// bool lastStateDiagram () { m_state_diag = getUMLModel()->getStateDiagramSize(); }
// bool firstStateDiagram() { m_state_diag = 0; }
bool currTrans (int, int, int, int, int, int);
cUMLStateDiagram* getStateDiagram();
- void printStats();
- void setParentModel(cUMLModel* m) { m_parent_model = m; }
+// void printStats();
+// void setParentModel(cUMLModel* m) { m_parent_model = m; }
// The jump functions jump the index of the various vectors either forward (+ int) or backwards (- int)
+/*
bool absoluteJumpGuard(int);
bool absoluteJumpAction(int);
bool absoluteJumpTrigger(int);
bool absoluteJumpTransitionLabel(int);
+*/
bool absoluteJumpOriginState(int);
+
bool absoluteJumpDestinationState(int);
bool absoluteJumpStateDiagram (int);
-
+/*
bool relativeJumpGuard(int amount);
bool relativeJumpAction(int amount);
bool relativeJumpTrigger(int amount);
bool relativeJumpTransitionLabel(int amount);
+*/
bool relativeJumpOriginState(int amount);
bool relativeJumpDestinationState(int amount);
bool relativeJumpStateDiagram (int);
-
+
bool addTransitionTotal();
Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc 2007-07-05 16:41:28 UTC (rev 1750)
+++ branches/uml/source/main/cTaskLib.cc 2007-07-05 17:59:43 UTC (rev 1751)
@@ -403,6 +403,8 @@
NewTask(name, "Successfully created trans 9", &cTaskLib::Task_Trans9);
else if (name == "trans10") //
NewTask(name, "Successfully created trans 10", &cTaskLib::Task_Trans10);
+ else if (name == "scene-1") //
+ NewTask(name, "Successfully created scenario 1", &cTaskLib::Task_Scenario1);
else if (name == "numStates") //
NewTask(name, "Successfully created 5 states", &cTaskLib::Task_NumStates);
else if (name == "numTrans") //
@@ -2833,6 +2835,32 @@
}
+double cTaskLib::Task_Scenario1(cTaskContext& ctx) const
+{
+ double bonus = 0.0;
+ std::deque<std::string> path1;
+
+ if (!ctx.task_success_complete) {
+ return 0;
+ }
+
+ // create the scenario
+ path1.push_back("^TempSensor.getOpState()");
+ path1.push_back("setTempOpState");
+
+ // check for scneario
+ bonus = ctx.organism->getUMLModel()->getStateDiagram(1)->findPath(path1);
+
+ if (bonus == 1) {
+ ctx.task_success_complete = true;
+ } else {
+ ctx.task_success_complete = false;
+ }
+
+ return bonus;
+}
+
+
double cTaskLib::Task_NumStates(cTaskContext& ctx) const
{
double ns = (double) ctx.organism->getStateDiagram()->numStates();
Modified: branches/uml/source/main/cTaskLib.h
===================================================================
--- branches/uml/source/main/cTaskLib.h 2007-07-05 16:41:28 UTC (rev 1750)
+++ branches/uml/source/main/cTaskLib.h 2007-07-05 17:59:43 UTC (rev 1751)
@@ -287,6 +287,7 @@
double Task_Trans8(cTaskContext& ctx) const;
double Task_Trans9(cTaskContext& ctx) const;
double Task_Trans10(cTaskContext& ctx) const;
+ double Task_Scenario1(cTaskContext& ctx) const;
double Task_NumStates(cTaskContext& ctx) const;
double Task_NumTrans(cTaskContext& ctx) const;
double Task_PropTrigger(cTaskContext& ctx) const;
Modified: branches/uml/source/main/cUMLModel.cc
===================================================================
--- branches/uml/source/main/cUMLModel.cc 2007-07-05 16:41:28 UTC (rev 1750)
+++ branches/uml/source/main/cUMLModel.cc 2007-07-05 17:59:43 UTC (rev 1751)
@@ -70,16 +70,16 @@
{
// Read in states
if (line == "=STATES====================") {
- std::cout << "Ooh, I found a state! " << std::endl;
+// std::cout << "Ooh, I found a state! " << std::endl;
line.erase();
infile >> num_states;
- std::cout << "Numer of states: "<< num_states << std::endl;
+// std::cout << "Numer of states: "<< num_states << std::endl;
// Read in number of state diagrams
} else if (line == "=STATE-DIAGRAM=============") {
- std::cout << "Yippee! A state diagram for me! " << std::endl;
+// std::cout << "Yippee! A state diagram for me! " << std::endl;
line.erase();
infile >> num_sd;
- std::cout << "Numer of sds: "<< num_sd << std::endl;
+// std::cout << "Numer of sds: "<< num_sd << std::endl;
state_diagrams.resize(num_sd);
// Read in each state diagram
} else if (line == "=SD========================") {
@@ -91,7 +91,7 @@
while (tr_l != "-END---------------------------") {
infile >> tr_o;
state_diagrams[cur_sd].addTrigger(tr_l, tr_o);
- std::cout << "Adding a trigger " << tr_l << " " << tr_o << std::endl;
+// std::cout << "Adding a trigger " << tr_l << " " << tr_o << std::endl;
infile >> tr_l;
}
}else if (line == "-GUARDS--------------------") {
@@ -99,7 +99,7 @@
infile >> gu;
while (gu != "-END---------------------------") {
state_diagrams[cur_sd].addGuard(gu);
- std::cout << "Adding a guard " << gu << std::endl;
+// std::cout << "Adding a guard " << gu << std::endl;
infile >> gu;
}
} else if (line == "-ACTIONS--------------------") {
@@ -107,7 +107,7 @@
infile >> act;
while (act != "-END---------------------------") {
state_diagrams[cur_sd].addAction(act);
- std::cout << "Adding an action " << act << std::endl;
+// std::cout << "Adding an action " << act << std::endl;
infile >> act;
}
}
More information about the Avida-cvs
mailing list