net.sourceforge.cilib.pso.pbestupdate.BoundedNonDominatedPersonalBestUpdateStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cilib-library Show documentation
Show all versions of cilib-library Show documentation
A library of composable components enabling simpler Computational Intelligence
The newest version!
/** __ __
* _____ _/ /_/ /_ Computational Intelligence Library (CIlib)
* / ___/ / / / __ \ (c) CIRG @ UP
* / /__/ / / / /_/ / http://cilib.net
* \___/_/_/_/_.___/
*/
package net.sourceforge.cilib.pso.pbestupdate;
import net.sourceforge.cilib.entity.EntityType;
import net.sourceforge.cilib.pso.particle.Particle;
import net.sourceforge.cilib.problem.solution.InferiorFitness;
import net.sourceforge.cilib.type.types.Types;
/**
* If the current fitness is better than the best fitness, or both are
* non-dominated, update the best fitness to the current fitness.
*/
public class BoundedNonDominatedPersonalBestUpdateStrategy extends NonDominatedPersonalBestUpdateStrategy {
/**
* {@inheritDoc}
*/
@Override
public PersonalBestUpdateStrategy getClone() {
return this;
}
/**
* If the current fitness is better than the best fitness, or both are
* non-dominated, update the best fitness to the current fitness.
*
* If the current fitness is not updated, increase the particle's pbest
* stagnation counter.
*
* @param particle The particle to update.
*/
@Override
public void updatePersonalBest(Particle particle) {
if (!Types.isInsideBounds(particle.getPosition())) {
particle.getProperties().put(EntityType.FITNESS, InferiorFitness.instance());
return;
}
super.updatePersonalBest(particle);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy