[Avida-SVN] r2365 - in branches/uml/source: actions main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Sat Feb 23 06:31:42 PST 2008
Author: hjg
Date: 2008-02-23 09:31:42 -0500 (Sat, 23 Feb 2008)
New Revision: 2365
Modified:
branches/uml/source/actions/DriverActions.cc
branches/uml/source/actions/PrintActions.cc
branches/uml/source/main/cStats.h
branches/uml/source/main/cUMLModel.cc
branches/uml/source/main/cUMLModel.h
Log:
Added the ability for the organisms to generate the info needed for a UML model gen movie and also the ability to kill the run when 1000 models have passed.
Modified: branches/uml/source/actions/DriverActions.cc
===================================================================
--- branches/uml/source/actions/DriverActions.cc 2008-02-23 05:35:29 UTC (rev 2364)
+++ branches/uml/source/actions/DriverActions.cc 2008-02-23 14:31:42 UTC (rev 2365)
@@ -102,6 +102,26 @@
}
};
+class cActionExitModelsPassedPropertyGreater : public cAction
+{
+private:
+ double m_threshold;
+public:
+ cActionExitModelsPassedPropertyGreater(cWorld* world, const cString& args) : cAction(world, args), m_threshold(0.0)
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_threshold = largs.PopWord().AsDouble();
+ }
+
+ static const cString GetDescription() { return "Arguments: <double "; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ if (m_world->GetStats().getN2Passed() > m_threshold ) {
+ m_world->GetDriver().SetDone();
+ }
+ }
+};
void RegisterDriverActions(cActionLibrary* action_lib)
{
@@ -109,6 +129,7 @@
action_lib->Register<cActionExitAveLineageLabelGreater>("ExitAveLineageLabelGreater");
action_lib->Register<cActionExitAveLineageLabelLess>("ExitAveLineageLabelLess");
action_lib->Register<cActionExitPropertyGeneratedGreater>("ExitPropGeneratedGreater");
+ action_lib->Register<cActionExitModelsPassedPropertyGreater>("ExitModelsPassedPropertyGreater");
// @DMB - The following actions are DEPRECATED aliases - These will be removed in 2.7.
action_lib->Register<cActionExit>("exit");
Modified: branches/uml/source/actions/PrintActions.cc
===================================================================
--- branches/uml/source/actions/PrintActions.cc 2008-02-23 05:35:29 UTC (rev 2364)
+++ branches/uml/source/actions/PrintActions.cc 2008-02-23 14:31:42 UTC (rev 2365)
@@ -2248,6 +2248,50 @@
};
+class cActionDumpUMLGrid : public cAction
+{
+
+private:
+ cString m_filename;
+
+public:
+ cActionDumpUMLGrid(cWorld* m_world, const cString& args) : cAction(m_world, args), m_filename("")
+ {;}
+
+ static const cString GetDescription() { return "No Arguments"; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ cString filename(m_filename);
+ if (filename == "") filename.Set("grid_genotype_id.%d.dat", m_world->GetStats().GetUpdate());
+ ofstream& fp = m_world->GetDataFileOFStream(filename);
+
+ // cPopulation* pop = &m_world->GetPopulation();
+
+ int uml_val;
+
+ for (int i = 0; i < m_world->GetPopulation().GetWorldX(); i++) {
+ for (int j = 0; j < m_world->GetPopulation().GetWorldY(); j++) {
+ cPopulationCell& cell = m_world->GetPopulation().GetCell(j * m_world->GetPopulation().GetWorldX() + i);
+
+ if(cell.IsOccupied()) {
+ // then need to call something on the model that determines its value...
+ uml_val = cell.GetOrganism()->getUMLModel()->getUMLValue();
+ // uml_val = 0;
+ } else {
+ uml_val = -1;
+ }
+ //(cell.IsOccupied()) ? cell.GetOrganism()->GetPhenotype().IsReceiver() : -1;
+ fp << uml_val << " ";
+ }
+ fp << endl;
+ }
+
+ m_world->GetDataFileManager().Remove(filename);
+ }
+};
+
+
class cActionPrintDonationStats : public cAction
{
public:
@@ -2451,6 +2495,8 @@
action_lib->Register<cActionDumpTaskGrid>("dump_task_grid");
action_lib->Register<cActionDumpDonorGrid>("dump_donor_grid");
action_lib->Register<cActionDumpReceiverGrid>("dump_receiver_grid");
+ action_lib->Register<cActionDumpUMLGrid>("dump_uml_grid");
+
// UML
action_lib->Register<cActionPrintUMLData>("PrintUMLData");
Modified: branches/uml/source/main/cStats.h
===================================================================
--- branches/uml/source/main/cStats.h 2008-02-23 05:35:29 UTC (rev 2364)
+++ branches/uml/source/main/cStats.h 2008-02-23 14:31:42 UTC (rev 2365)
@@ -684,6 +684,7 @@
void W2Attempt() { m_W2Attempt.Add(1); }
void W2Passed() { m_W2Passed.Add(1); }
void N1andN2Passed() { m_N1andN2Passed.Add(1); }
+ double getN2Passed() { return m_N2Passed.Count(); }
void propSuccess(int x) {m_propertySuccess = x; }
void propFailure(int x) {m_propertyFailure = x; }
Modified: branches/uml/source/main/cUMLModel.cc
===================================================================
--- branches/uml/source/main/cUMLModel.cc 2008-02-23 05:35:29 UTC (rev 2364)
+++ branches/uml/source/main/cUMLModel.cc 2008-02-23 14:31:42 UTC (rev 2365)
@@ -699,4 +699,27 @@
}
+int cUMLModel::getUMLValue()
+{
+ float temp = 0;
+ int val;
+ float w1 = getBonusInfo("spinw1");
+ float w2 = getBonusInfo("spinw2");
+ float n1 = getBonusInfo("spinn1");
+ float n2 = getBonusInfo("spinn2");
+ for (unsigned int i=0; i< scenario_completion.size(); i++) {
+ temp += scenario_completion[i];
+ }
+ val = (int)((temp/scenario_completion.size()) * 10);
+ if (w1 || w2) val = 11;
+ if (w1 && w2) val = 12;
+ if (n1 || n2) val = 13;
+ if (n1 && n2) val = 14;
+
+ // (organism->getUMLModel()->getBonusInfo("spinw1") == 0) &&
+ // (organism->getUMLModel()->getBonusInfo("spinw2")
+ return val;
+
+}
+
Modified: branches/uml/source/main/cUMLModel.h
===================================================================
--- branches/uml/source/main/cUMLModel.h 2008-02-23 05:35:29 UTC (rev 2364)
+++ branches/uml/source/main/cUMLModel.h 2008-02-23 14:31:42 UTC (rev 2365)
@@ -41,6 +41,7 @@
std::string getXMI(); // get the XMI version of the model.
void printXMI(); // create the XMI version of the model.
void printUMLModelToFile(std::string); // print the UML model to a file.
+ int getUMLValue(); // print movie info
// Used to update and get the max number of trans.
int getMaxTrans() { return max_trans; }
More information about the Avida-cvs
mailing list