[Avida-cvs] [avida-svn] r692 - in development/source: actions analyze
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Fri May 19 07:02:56 PDT 2006
Author: brysonda
Date: 2006-05-19 10:02:55 -0400 (Fri, 19 May 2006)
New Revision: 692
Modified:
development/source/actions/LandscapeActions.cc
development/source/analyze/cAnalyze.cc
development/source/analyze/cAnalyzeCommand.h
development/source/analyze/cAnalyzeJobQueue.h
Log:
Add an additional option to AnalyzeLandscape that allows for the specification of the maximum desired distance, rather than hard coding in a distance of 10.
Also fix the calling of actions from analyze mode. Actions are case sensitive.
Modified: development/source/actions/LandscapeActions.cc
===================================================================
--- development/source/actions/LandscapeActions.cc 2006-05-18 15:50:35 UTC (rev 691)
+++ development/source/actions/LandscapeActions.cc 2006-05-19 14:02:55 UTC (rev 692)
@@ -34,30 +34,34 @@
int m_trials;
int m_min_found;
int m_max_trials;
- tArray<int> m_depths;
- tList<cLandscape> m_batches[10];
+ int m_max_dist;
public:
cActionAnalyzeLandscape(cWorld* world, const cString& args)
- : cAction(world, args), m_filename("land-analyze.dat"), m_trials(1000), m_min_found(0), m_max_trials(0)
+ : cAction(world, args), m_filename("land-analyze.dat"), m_trials(1000), m_min_found(0), m_max_trials(0), m_max_dist(10)
{
cString largs(args);
if (largs.GetSize()) m_filename = largs.PopWord();
if (largs.GetSize()) m_trials = largs.PopWord().AsInt();
if (largs.GetSize()) m_min_found = largs.PopWord().AsInt();
if (largs.GetSize()) m_max_trials = largs.PopWord().AsInt();
+ if (largs.GetSize()) m_max_dist = largs.PopWord().AsInt();
+ if (m_max_dist <= 0) m_max_dist = 10;
}
const cString GetDescription()
{
- return "AnalyzeLandscape [filename='land-analyze.dat'] [int trials=1000] [int min_found=0] [int max_trials=0]";
+ return "AnalyzeLandscape [filename='land-analyze.dat'] [int trials=1000] [int min_found=0] [int max_trials=0] [int max_dist=10]";
}
void Process(cAvidaContext& ctx)
{
int update = -1;
cLandscape* land = NULL;
+ tArray<tList<cLandscape> > batches(m_max_dist);
+ tArray<int> depths;
+
if (ctx.GetAnalyzeMode()) {
if (m_world->GetConfig().VERBOSITY.Get() >= VERBOSE_ON) {
cString msg("Performing landscape analysis on batch ");
@@ -70,16 +74,16 @@
cAnalyzeGenotype* genotype = NULL;
tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
while (genotype = batch_it.Next()) {
- LoadGenome(genotype->GetGenome());
- m_depths.Push(genotype->GetDepth());
+ LoadGenome(batches, genotype->GetGenome());
+ depths.Push(genotype->GetDepth());
}
} else {
if (m_world->GetConfig().VERBOSITY.Get() >= VERBOSE_DETAILS)
m_world->GetDriver().NotifyComment("Performing landscape analysis...");
cGenotype* genotype = m_world->GetClassificationManager().GetBestGenotype();
- LoadGenome(genotype->GetGenome());
- m_depths.Push(genotype->GetDepth());
+ LoadGenome(batches, genotype->GetGenome());
+ depths.Push(genotype->GetDepth());
update = m_world->GetStats().GetUpdate();
}
@@ -87,12 +91,12 @@
cDataFile& outfile = m_world->GetDataFile(m_filename);
outfile.WriteComment("Landscape analysis. Distance results are grouped by update/depth.");
- for (int i = 0; i < m_depths.GetSize(); i++) {
- for (int dist = 1; dist <= 10; dist++) {
- land = m_batches[dist - 1].Pop();
+ for (int i = 0; i < depths.GetSize(); i++) {
+ for (int dist = 1; dist <= batches.GetSize(); dist++) {
+ land = batches[dist - 1].Pop();
outfile.Write(update, "update");
- outfile.Write(m_depths[i], "tree depth");
+ outfile.Write(depths[i], "tree depth");
outfile.Write(dist, "distance");
outfile.Write(land->GetProbDead(), "fractional mutations lethal");
outfile.Write(land->GetProbNeg(), "fractional mutations detrimental");
@@ -110,16 +114,16 @@
}
private:
- void LoadGenome(const cGenome& genome)
+ void LoadGenome(tArray<tList<cLandscape> >& batches, const cGenome& genome)
{
cAnalyzeJobQueue& jobqueue = m_world->GetAnalyze().GetJobQueue();
cInstSet& inst_set = m_world->GetHardwareManager().GetInstSet();
- for (int dist = 10; dist >= 1; dist--) {
+ for (int dist = batches.GetSize(); dist >= 1; dist--) {
cLandscape* land = new cLandscape(m_world, genome, inst_set);
land->SetDistance(dist);
land->SetTrials(m_trials);
- m_batches[dist - 1].PushRear(land);
+ batches[dist - 1].PushRear(land);
if (dist == 1) {
jobqueue.AddJob(new tAnalyzeJob<cLandscape>(land, &cLandscape::Process));
} else {
Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc 2006-05-18 15:50:35 UTC (rev 691)
+++ development/source/analyze/cAnalyze.cc 2006-05-19 14:02:55 UTC (rev 692)
@@ -7038,7 +7038,6 @@
}
cString fun_name = cur_string.PopWord();
- fun_name.ToUpper();
if (FindAnalyzeCommandDef(fun_name) != NULL) {
cerr << "Error: Cannot create function '" << fun_name
@@ -7275,7 +7274,6 @@
while (init_file.GetLineNum() < init_file.GetNumLines()) {
cString cur_string = init_file.GetNextLine();
cString command = cur_string.PopWord();
- command.ToUpper();
cAnalyzeCommand* cur_command;
cAnalyzeCommandDefBase* command_def = FindAnalyzeCommandDef(command);
@@ -7311,10 +7309,10 @@
cin.getline(text_input, 2048);
cString cur_input(text_input);
cString command = cur_input.PopWord();
- command.ToUpper();
cAnalyzeCommand * cur_command;
cAnalyzeCommandDefBase * command_def = FindAnalyzeCommandDef(command);
+
if (command == "END") {
// We are done with this section of code; break out...
break;
@@ -7766,9 +7764,10 @@
{
SetupCommandDefLibrary();
+ cString uppername(name);
tListIterator<cAnalyzeCommandDefBase> lib_it(command_lib);
while (lib_it.Next() != (void *) NULL) {
- if (lib_it.Get()->GetName() == name) break;
+ if (lib_it.Get()->GetName() == uppername) break;
}
cAnalyzeCommandDefBase* command_def = lib_it.Get();
@@ -7794,7 +7793,6 @@
cin.getline(text_input, 2048);
cString cur_input(text_input);
cString command = cur_input.PopWord();
- command.ToUpper();
cAnalyzeCommand * cur_command;
cAnalyzeCommandDefBase * command_def = FindAnalyzeCommandDef(command);
Modified: development/source/analyze/cAnalyzeCommand.h
===================================================================
--- development/source/analyze/cAnalyzeCommand.h 2006-05-18 15:50:35 UTC (rev 691)
+++ development/source/analyze/cAnalyzeCommand.h 2006-05-19 14:02:55 UTC (rev 692)
@@ -19,22 +19,27 @@
template <class T> class tList;
-class cAnalyzeCommand {
+class cAnalyzeCommand
+{
protected:
- cString command;
- cString args;
+ cString m_command;
+ cString m_args;
+
+
private:
- // disabled copy constructor.
- cAnalyzeCommand(const cAnalyzeCommand &);
+ cAnalyzeCommand(); // @not_implemented
+ cAnalyzeCommand(const cAnalyzeCommand&); // @not_implemented
+ cAnalyzeCommand& operator=(const cAnalyzeCommand&); // @not_implemented
+
+
public:
- cAnalyzeCommand(const cString & _command, const cString & _args)
- : command(_command), args(_args) { command.ToUpper(); }
+ cAnalyzeCommand(const cString& command, const cString& args) : m_command(command), m_args(args) { ; }
virtual ~cAnalyzeCommand() { ; }
- const cString & GetCommand() { return command; }
- const cString & GetArgs() const { return args; }
- cString GetArgs() { return args; }
- virtual tList<cAnalyzeCommand> * GetCommandList() { return NULL; }
+ const cString& GetCommand() { return m_command; }
+ const cString& GetArgs() const { return m_args; }
+ cString GetArgs() { return m_args; }
+ virtual tList<cAnalyzeCommand>* GetCommandList() { return NULL; }
/*
added to satisfy Boost.Python; the semantics are fairly useless --
Modified: development/source/analyze/cAnalyzeJobQueue.h
===================================================================
--- development/source/analyze/cAnalyzeJobQueue.h 2006-05-18 15:50:35 UTC (rev 691)
+++ development/source/analyze/cAnalyzeJobQueue.h 2006-05-19 14:02:55 UTC (rev 692)
@@ -39,10 +39,11 @@
cRandomMT* m_rng_pool[MT_RANDOM_POOL_SIZE];
pthread_mutex_t m_mutex;
-
+ cAnalyzeJobQueue(); // @not_implemented
cAnalyzeJobQueue(const cAnalyzeJobQueue&); // @not_implemented
cAnalyzeJobQueue& operator=(const cAnalyzeJobQueue&); // @not_implemented
+
public:
cAnalyzeJobQueue(cWorld* world);
~cAnalyzeJobQueue();
More information about the Avida-cvs
mailing list