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 String |
AUXILLARY_PREAMBLE |
int[] |
neighborhood |
Fitness |
neighborhoodBestFitness |
double[] |
neighborhoodBestGenome |
Fitness |
personalBestFitness |
double[] |
personalBestGenome |
double[] |
velocity |
genome, MAXIMUM_INTEGER_IN_DOUBLE, P_DOUBLEVECTORINDIVIDUALevaluated, EVALUATED_PREAMBLE, fitness, P_INDIVIDUAL, species| Constructor and Description |
|---|
Particle() |
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Creates a new individual cloned from a prototype,
and suitable to begin use in its own evolutionary
context.
|
(package private) int[] |
createRandomPattern(int myIndex,
boolean includeSelf,
int popsize,
int neighborhoodSize,
EvolutionState state,
int threadnum) |
(package private) int[] |
createToroidalPattern(int myindex,
boolean includeSelf,
int popsize,
int neighborhoodSize) |
(package private) StringBuilder |
encodeAuxillary() |
boolean |
equals(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(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,
PrintWriter writer)
Should print the individual in a way that can be read by computer,
including its fitness.
|
void |
readIndividual(EvolutionState state,
DataInput dataInput)
Reads the binary form of an individual from a DataInput, erasing the previous
information stored in this Individual.
|
void |
readIndividual(EvolutionState state,
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.
|
(package private) void |
resetAuxillaryInformation() |
void |
setGenome(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,
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, writeGenotypecloneGenes, reset, sizecompareTo, merge, printIndividual, printIndividualForHumans, printIndividualForHumans, toStringpublic static final String AUXILLARY_PREAMBLE
public double[] velocity
public int[] neighborhood
public double[] neighborhoodBestGenome
public Fitness neighborhoodBestFitness
public double[] personalBestGenome
public Fitness personalBestFitness
public int hashCode()
IndividualhashCode in class DoubleVectorIndividualpublic boolean equals(Object ind)
Individualequals in class DoubleVectorIndividualpublic void setup(EvolutionState state, Parameter base)
Individualsetup in interface Prototypesetup in interface Setupsetup in class DoubleVectorIndividualPrototype.setup(EvolutionState,Parameter)public Object clone()
PrototypeTypically 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 Prototypeclone in class DoubleVectorIndividualpublic 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)
int[] createRandomPattern(int myIndex,
boolean includeSelf,
int popsize,
int neighborhoodSize,
EvolutionState state,
int threadnum)
int[] createToroidalPattern(int myindex,
boolean includeSelf,
int popsize,
int neighborhoodSize)
void resetAuxillaryInformation()
public void reset(EvolutionState state, int thread)
DoubleVectorIndividualreset in class DoubleVectorIndividualpublic void setGenomeLength(int len)
VectorIndividualsetGenomeLength in class DoubleVectorIndividualpublic void setGenome(Object gen)
VectorIndividualsetGenome in class DoubleVectorIndividualpublic void join(Object[] pieces)
DoubleVectorIndividualjoin in class DoubleVectorIndividualStringBuilder encodeAuxillary()
public void printIndividual(EvolutionState state, int log)
IndividualprintIndividual in class Individualpublic void printIndividual(EvolutionState state, PrintWriter writer)
IndividualThe 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 Individualpublic void readIndividual(EvolutionState state, LineNumberReader reader) throws IOException
IndividualreadIndividual in class IndividualIOExceptionpublic void writeIndividual(EvolutionState state, DataOutput dataOutput) throws IOException
IndividualwriteIndividual in class IndividualIOExceptionpublic void readIndividual(EvolutionState state, DataInput dataInput) throws IOException
IndividualreadIndividual in class IndividualIOExceptionCopyright © 2014 Evolutionary Computation Laboratory at George Mason University. All rights reserved.