toxgene.core.genes.trees.ToxRecursiveElement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ToxGene Show documentation
Show all versions of ToxGene Show documentation
Modified ToXGene for the iBench project.
The newest version!
/**
* Implements a gene for a recursive element.
*
* @author Denilson Barbosa
* @version 0.1
*/
package toxgene.core.genes.trees;
import java.util.Vector;
import java.io.PrintStream;
import toxgene.core.genes.Gene;
import toxgene.core.genes.lists.ListGene;
import toxgene.core.genes.lists.ToxListElement;
import toxgene.core.random.ToxRandom;
public class ToxRecursiveElement implements TreeGene, ListGene{
/**
* Maximum depth of recursion, determined by the probability distribution
* given by the user.
*/
private long maxDepth;
/**
* Current depth of recursion. Reset to 0 when hit maxDepth.
*/
private int depth;
/**
* Mimum quantity of occurrences of this element. This value does not need
* to be the same as the recursive ancestor of this element.
*/
private int min;
/**
* Maximum number of occurrences of this element. This values does not
* need to be the same as the recursive ancestor of this element*/
private int max;
/**
* The parent is the ancestor of this element that is the actual recursive
* element.
*/
private ToxElement parent;
private ToxRandom qttyRand, levelsRand;
private String name;
private int qtty;
private Gene backup;
/**
* Vector with all recursive siblings. When we go one level down here we
* need to let the other siblings know.
*/
private Vector siblings;
public ToxRecursiveElement(int min, int max, ToxRandom rand, String name){
qtty = -1;
this.min = min;
this.max = max;
this.qttyRand = rand;
this.name = name;
//the ancestor element is at level 0
this.depth = 1;
}
public void setContent(ToxElement parent, ToxRandom rand,
Vector recSiblings){
this.parent = parent;
this.levelsRand = rand;
int size = recSiblings.size();
siblings = new Vector(size-1);
for (int i=0; i maxInstances) times = maxInstances;
for (int i=0; i