![JAR search and dependency download from the Maven repository](/logo.png)
net.sourceforge.cilib.algorithm.initialisation.SpecialisedPopluationInitialisationStrategy 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
/** __ __
* _____ _/ /_/ /_ Computational Intelligence Library (CIlib)
* / ___/ / / / __ \ (c) CIRG @ UP
* / /__/ / / / /_/ / http://cilib.net
* \___/_/_/_/_.___/
*/
package net.sourceforge.cilib.algorithm.initialisation;
import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.cilib.entity.Entity;
import net.sourceforge.cilib.problem.Problem;
/**
* Initialise a specialised collection of
* {@linkplain net.sourceforge.cilib.entity.Entity entity} objects.
*/
public class SpecialisedPopluationInitialisationStrategy implements PopulationInitialisationStrategy {
private static final long serialVersionUID = -9146471282965793922L;
private List entityList;
/**
* Create an instance of {@code SpecialisedPopluationInitialisationStrategy}.
*/
public SpecialisedPopluationInitialisationStrategy() {
this.entityList = new ArrayList(40);
}
/**
* Create a copy of the provided instance.
* @param copy The instance to copy.
*/
public SpecialisedPopluationInitialisationStrategy(SpecialisedPopluationInitialisationStrategy copy) {
this.entityList = new ArrayList(copy.entityList.size());
for (Entity entity : copy.entityList) {
this.entityList.add(entity.getClone());
}
}
/**
* {@inheritDoc}
*/
@Override
public SpecialisedPopluationInitialisationStrategy getClone() {
return new SpecialisedPopluationInitialisationStrategy(this);
}
/**
* {@inheritDoc}
*/
@Override
public Entity getEntityType() {
// this needs to be looked at... generalisation breaks here
throw new UnsupportedOperationException("Implementation needed");
}
/**
* {@inheritDoc}
*/
@Override
public Iterable initialise(Problem problem) {
Preconditions.checkNotNull(problem, "No problem has been specified");
Preconditions.checkState(!entityList.isEmpty(), "No entities have been defined!");
List entities = new ArrayList();
for (Entity entity : entityList) {
entity.initialise(problem);
entities.add(entity);
}
return entities;
}
/**
* {@inheritDoc}
*/
@Override
public void setEntityType(Entity entity) {
this.entityList.add(entity);
}
/**
* {@inheritDoc}
*/
@Override
public int getEntityNumber() {
return this.entityList.size();
}
/**
* {@inheritDoc}
*/
@Override
public void setEntityNumber(int entityNumber) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy