if (evalthreads < 1)
Output.initialError("Number of eval threads should be an integer >0.",
new Parameter(Evolve.P_EVALTHREADS));
*/
int breedthreads = Evolve.determineThreads(output, parameters, new Parameter(Evolve.P_BREEDTHREADS));
int evalthreads = Evolve.determineThreads(output, parameters, new Parameter(Evolve.P_EVALTHREADS));
@SuppressWarnings("unused")
boolean auto = (Evolve.V_THREADS_AUTO.equalsIgnoreCase(parameters.getString(new Parameter(Evolve.P_BREEDTHREADS),null)) ||
Evolve.V_THREADS_AUTO.equalsIgnoreCase(parameters.getString(new Parameter(Evolve.P_EVALTHREADS),null))); // at least one thread is automatic. Seeds may need to be dynamic.
// 3. create the Mersenne Twister random number generators,
// one per thread
MersenneTwisterFast[] random = new MersenneTwisterFast[breedthreads > evalthreads ?
breedthreads : evalthreads];
int[] seeds = new int[breedthreads > evalthreads ?
breedthreads : evalthreads];
String seed_message = "Seed: ";
for (int x=0;x<random.length;x++)
{
seeds[x] = conPanel.getSeed(currentJob,x);
seed_message = seed_message + seeds[x] + " ";
}
for (int x=0;x<random.length;x++)
{
for (int y=x+1;y<random.length;y++)
if (seeds[x]==seeds[y])
{
Output.initialError(Evolve.P_SEED+"."+x+" ("+seeds[x]+") and "+Evolve.P_SEED+"."+y+" ("+seeds[y]+") ought not be the same seed.");
}
random[x] = Evolve.primeGenerator(new MersenneTwisterFast(seeds[x])); // we prime the generator to be more sure of randomness.
}
state = (EvolutionState)parameters.getInstanceForParameter(
new Parameter(Evolve.P_STATE),null,EvolutionState.class);
state.parameters = parameters;
state.random = random;
state.output = output;
String jobFilePrefix = Console.this.conPanel.getJobFilePrefix();
if (Console.this.conPanel.getNumJobs() > 1)
{
if (jobFilePrefix == null || jobFilePrefix.length()<1)
{
jobFilePrefix = "job";
}
jobFilePrefix = jobFilePrefix+"."+Console.this.currentJob+".";
state.output.setFilePrefix(jobFilePrefix);
}
state.evalthreads = evalthreads;
state.breedthreads = breedthreads;
output.systemMessage("Threads: breed/" + breedthreads + " eval/" + evalthreads);
output.systemMessage(seed_message);
state.startFresh();
if (Console.this.conPanel.getNumJobs() > 0)
{
state.checkpointPrefix = jobFilePrefix+state.checkpointPrefix;
}
if (currentJob == 0)
{
statisticsPane.removeAll();
}
setupChartPanes();
setupInspectionPanes();
}
/**
* @throws NumberFormatException
* @throws BadParameterException
*/
void setupInspectionPanes()
throws NumberFormatException, BadParameterException
{
inspectionPane.removeAll();
// Setup the Evolution State inspection pane
JScrollPane stateInspectionPane = new JScrollPane();
JTree stateInspectionTree = new JTree(
new ReflectedObject(Console.this.state));
stateInspectionPane.setViewportView(stateInspectionTree);
inspectionPane.add("Evolution State", stateInspectionPane);
// Setup the subpopulation inspection panes
Parameter p_subPops = new Parameter("pop.subpops");
int numSubPops = parameters.getInt(p_subPops,null);
for (int subPop = 0; subPop < numSubPops; ++subPop)
{
SubpopulationPanel subPopPane = new SubpopulationPanel(Console.this, subPop);
subPopPane.setup(Console.this.state,p_subPops.push(""+subPop));
inspectionPane.add("SubPop "+subPop, subPopPane);
addListener(subPopPane);
}
}
/**
* @throws BadParameterException
*/
void setupChartPanes()
throws BadParameterException
{
// Set up statistics charts (if any)
StatisticsChartPane statPane = new StatisticsChartPane();
statPane.setup(state, new Parameter("stat"));
if (statPane.numCharts > 0)
statisticsPane.addTab("Job "+currentJob, statPane);
}
public void run()