aima.core.search.local.Individual Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
package aima.core.search.local;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Artificial Intelligence A Modern Approach (3rd Edition): page 127.
*
* A state in a genetic algorithm is represented as an individual from the
* population.
*
* @author Ciaran O'Reilly
*
* @param
* the type of the alphabet used in the representation of the
* individuals in the population (this is to provide flexibility in
* terms of how a problem can be encoded).
*/
public class Individual {
private List representation = new ArrayList();
/**
* Construct an individual using the provided representation.
*
* @param representation
* the individual's representation.
*/
public Individual(List representation) {
this.representation = Collections.unmodifiableList(representation);
}
/**
*
* @return the individual's representation.
*/
public List getRepresentation() {
return representation;
}
/**
*
* @return the length of the individual's representation.
*/
public int length() {
return representation.size();
}
}