Subject: | |
From: | |
Reply To: | |
Date: | Sat, 12 Feb 2011 01:14:29 -0700 |
Content-Type: | multipart/alternative |
Parts/Attachments: |
|
|
Is there a tutorial / example that demonstrates differential evolution setup? I read the DE part of the manual, but I think my setup is still wrong. If I had to guess, I think my breeding pipeline is setup incorrectly as I think the DEBreeder class is supposed to perform the crossover, not ec.vector.breed.VectorCrossoverPipeline. However, replacing causes an error. When running, the best individual in the population at end of run is best individual in population after 1st generation.
# Copyright 2006 by Sean Luke and George Mason University
# Licensed under the Academic Free License version 3.0
# See the file "LICENSE" for more information
# The parameters that were laid out in Tutorial 1 (see the documentation)
verbosity = 0
breedthreads = 1
evalthreads = 1
seed.0 = 4357
state = ec.simple.SimpleEvolutionState
pop = ec.Population
init = ec.simple.SimpleInitializer
finish = ec.simple.SimpleFinisher
breed = ec.de.DEBreeder
eval = ec.de.DEEvaluator
stat = ec.simple.SimpleStatistics
exch = ec.simple.SimpleExchanger
generations = 2000
quit-on-run-complete = true
checkpoint = false
prefix = ec
checkpoint-modulo = 1
breed.f = 0.1
breed.cr = 0.1
pop.subpop.0.species.mutation-bounded = true
stat.file = $out.stat
pop.subpops = 1
pop.subpop.0 = ec.Subpopulation
pop.subpop.0.size = 100
pop.subpop.0.duplicate-retries = 0
pop.subpop.0.species = ec.vector.FloatVectorSpecies
pop.subpop.0.species.crossover-type = one
pop.subpop.0.species.mutation-prob = 0.5
pop.subpop.0.species.pipe = ec.vector.breed.VectorMutationPipeline
pop.subpop.0.species.pipe.source.0 = ec.vector.breed.VectorCrossoverPipeline
pop.subpop.0.species.pipe.source.0.source.0 = ec.select.TournamentSelection
pop.subpop.0.species.pipe.source.0.source.1 = ec.select.TournamentSelection
pop.subpop.0.species.max-gene = 10
pop.subpop.0.species.min-gene = 0
select.tournament.size = 2
pop.subpop.0.species.fitness = ec.simple.SimpleFitness
pop.subpop.0.species.ind = ec.vector.DoubleVectorIndividual
pop.subpop.0.species.genome-size = 4
eval.problem = ec.app.evolvedm.ClosestToHalf
/*
Copyright 2006 by Sean Luke
Licensed under the Academic Free License version 3.0
See the file "LICENSE" for more information
*/
package ec.app.evolvedm;
import ec.*;
import ec.simple.*;
import ec.vector.*;
public class ClosestToHalf extends Problem implements SimpleProblemForm
{
public void evaluate(final EvolutionState state,
final Individual ind,
final int subpopulation,
final int threadnum)
{
if (ind.evaluated) return;
if (!(ind instanceof DoubleVectorIndividual))
state.output.fatal("Whoa! It's not a DoubleVectorIndividual!!!",null);
double sum=0;
DoubleVectorIndividual ind2 = (DoubleVectorIndividual)ind;
for(int x=0; x<ind2.genome.length; x++)
sum += Math.abs(0.5 - ind2.genome[x]);
System.out.println(100-sum);
if (!(ind2.fitness instanceof SimpleFitness))
state.output.fatal("Whoa! It's not a SimpleFitness!!!",null);
((SimpleFitness)ind2.fitness).setFitness(state,
/// ...the fitness...
(float)(100-sum),
///... is the individual ideal? Indicate here...
sum < 0.2);
ind2.evaluated = true;
}
}
|
|
|