/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package search.searchtechniques;
import org.jgap.Configuration;
import org.jgap.Gene;
import org.jgap.InvalidConfigurationException;
import org.jgap.impl.IntegerGene;
import search.genes.BitFieldInstructionGene;
import search.genes.GeneType;
import search.genes.IntegerInstructionGene;
import search.genes.StackInstructionGene;
import search.genes.SymbolInstructionGene;
/**
*
* @author mat
*/
public class GeneFactory {
GeneType type;
int size;
public GeneFactory(GeneType type, int size){
this.type=type;
this.size=size;
}
public Gene getInstance(Configuration gaConf) throws InvalidConfigurationException{
Gene ret = null;
switch(type){
case INTEGER:
return new IntegerInstructionGene(gaConf,size);
case SYMBOL:
return new SymbolInstructionGene(gaConf,size);
case BITFIELD:
return new BitFieldInstructionGene(gaConf,size);
case STACK:
return new StackInstructionGene(gaConf, size);
case FLAT:
return new IntegerGene(gaConf, 0, size);
case HCLUST:
return new IntegerGene(gaConf, 0, size + 2*(size - 1));
default:
throw new RuntimeException("Gene Type \"" + type
+ "\" is not a valid option.");
}
}
}