public class Particle extends DoubleVectorIndividual
Particle updates its location in two steps. First, it gathers current neighborhood and personal best statistics via the update(...) method. Then it updates the particle's velocity and location (genome) according to these statistics in the tweak(...) method. Notice that neither of these methods is the defaultMutate(...) method used in DoubleVectorIndividual: this means that in *theory* you could rig up Particles to also be mutated if you thought that was a good reason.
Many of the parameters passed into the tweak(...) method are based on weights determined by the PSOBreeder.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUXILLARY_PREAMBLE |
int[] |
neighborhood |
Fitness |
neighborhoodBestFitness |
double[] |
neighborhoodBestGenome |
Fitness |
personalBestFitness |
double[] |
personalBestGenome |
double[] |
velocity |
genome, MAXIMUM_INTEGER_IN_DOUBLE, P_DOUBLEVECTORINDIVIDUAL
evaluated, EVALUATED_PREAMBLE, fitness, P_INDIVIDUAL, species
Constructor and Description |
---|
Particle() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Creates a new individual cloned from a prototype,
and suitable to begin use in its own evolutionary
context.
|
boolean |
equals(java.lang.Object ind)
Returns true if I am genetically "equal" to ind.
|
int |
hashCode()
Returns a hashcode for the individual, such that individuals which
are equals(...) each other always return the same
hash code.
|
void |
join(java.lang.Object[] pieces)
Joins the n pieces and sets the genome to their concatenation.
|
void |
printIndividual(EvolutionState state,
int log)
Should print the individual in a way that can be read by computer,
including its fitness, with a verbosity of Output.V_NO_GENERAL.
|
void |
printIndividual(EvolutionState state,
java.io.PrintWriter writer)
Should print the individual in a way that can be read by computer,
including its fitness.
|
void |
readIndividual(EvolutionState state,
java.io.DataInput dataInput)
Reads the binary form of an individual from a DataInput, erasing the previous
information stored in this Individual.
|
void |
readIndividual(EvolutionState state,
java.io.LineNumberReader reader)
Reads in the individual from a form printed by printIndividual(), erasing the previous
information stored in this Individual.
|
void |
reset(EvolutionState state,
int thread)
Initializes the individual by randomly choosing doubles uniformly from
mingene to maxgene.
|
void |
setGenome(java.lang.Object gen)
Sets the gene array.
|
void |
setGenomeLength(int len)
Sets the genome length.
|
void |
setup(EvolutionState state,
Parameter base)
This should be used to set up only those things which you share in common
with all other individuals in your species; individual-specific items
which make you you should be filled in by Species.newIndividual(...),
and modified by breeders.
|
void |
tweak(EvolutionState state,
double[] globalBest,
double velocityCoeff,
double personalCoeff,
double informantCoeff,
double globalCoeff,
int thread) |
void |
update(EvolutionState state,
int subpop,
int myindex,
int thread) |
void |
writeIndividual(EvolutionState state,
java.io.DataOutput dataOutput)
Writes the binary form of an individual out to a DataOutput.
|
clamp, defaultBase, defaultCrossover, defaultMutate, distanceTo, genomeLength, genotypeToString, genotypeToStringForHumans, getGenome, isInRange, parseGenotype, polynomialMutate, readGenotype, simulatedBinaryCrossover, split, writeGenotype
cloneGenes, reset, size
compareTo, merge, printIndividual, printIndividualForHumans, printIndividualForHumans, toString
public static final java.lang.String AUXILLARY_PREAMBLE
public double[] velocity
public int[] neighborhood
public double[] neighborhoodBestGenome
public Fitness neighborhoodBestFitness
public double[] personalBestGenome
public Fitness personalBestFitness
public int hashCode()
Individual
hashCode
in class DoubleVectorIndividual
public boolean equals(java.lang.Object ind)
Individual
equals
in class DoubleVectorIndividual
public void setup(EvolutionState state, Parameter base)
Individual
setup
in interface Prototype
setup
in interface Setup
setup
in class DoubleVectorIndividual
Prototype.setup(EvolutionState,Parameter)
public java.lang.Object clone()
Prototype
Typically this should be a full "deep" clone. However, you may share certain elements with other objects rather than clone hem, depending on the situation:
Implementations.
public Object clone()
{
try
{
return super.clone();
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
}
public Object clone()
{
try
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
return myobj;
}
public Object clone()
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
return myobj;
}
clone
in interface Prototype
clone
in class DoubleVectorIndividual
public void update(EvolutionState state, int subpop, int myindex, int thread)
public void tweak(EvolutionState state, double[] globalBest, double velocityCoeff, double personalCoeff, double informantCoeff, double globalCoeff, int thread)
public void reset(EvolutionState state, int thread)
DoubleVectorIndividual
reset
in class DoubleVectorIndividual
public void setGenomeLength(int len)
VectorIndividual
setGenomeLength
in class DoubleVectorIndividual
public void setGenome(java.lang.Object gen)
VectorIndividual
setGenome
in class DoubleVectorIndividual
public void join(java.lang.Object[] pieces)
DoubleVectorIndividual
join
in class DoubleVectorIndividual
public void printIndividual(EvolutionState state, int log)
Individual
printIndividual
in class Individual
public void printIndividual(EvolutionState state, java.io.PrintWriter writer)
Individual
The default form of this method simply prints out whether or not the individual has been evaluated, its fitness, and then calls Individual.genotypeToString(). Feel free to override this to produce more sophisticated behavior, though it is rare to need to -- instead you could just override genotypeToString().
printIndividual
in class Individual
public void readIndividual(EvolutionState state, java.io.LineNumberReader reader) throws java.io.IOException
Individual
readIndividual
in class Individual
java.io.IOException
public void writeIndividual(EvolutionState state, java.io.DataOutput dataOutput) throws java.io.IOException
Individual
writeIndividual
in class Individual
java.io.IOException
public void readIndividual(EvolutionState state, java.io.DataInput dataInput) throws java.io.IOException
Individual
readIndividual
in class Individual
java.io.IOException