Search in sources :

Example 1 with Variable

use of org.evosuite.ga.variables.Variable in project evosuite by EvoSuite.

the class SBXCrossover method crossOver.

@Override
public void crossOver(Chromosome p1, Chromosome p2) throws ConstructionFailedException {
    NSGAChromosome n1 = (NSGAChromosome) p1;
    NSGAChromosome n2 = (NSGAChromosome) p2;
    for (int i = 0; i < n1.getNumberOfVariables(); i++) {
        Variable v1 = n1.getVariable(i);
        Variable v2 = n2.getVariable(i);
        if ((v1 instanceof DoubleVariable) && (v2 instanceof DoubleVariable))
            this.doCrossover((DoubleVariable) v1, (DoubleVariable) v2);
    }
}
Also used : NSGAChromosome(org.evosuite.ga.NSGAChromosome) Variable(org.evosuite.ga.variables.Variable) DoubleVariable(org.evosuite.ga.variables.DoubleVariable) DoubleVariable(org.evosuite.ga.variables.DoubleVariable)

Example 2 with Variable

use of org.evosuite.ga.variables.Variable in project evosuite by EvoSuite.

the class NSGAChromosome method clone.

@Override
public Chromosome clone() {
    NSGAChromosome c = new NSGAChromosome();
    c.setFitnessValues(this.getFitnessValues());
    c.setPreviousFitnessValues(this.getPreviousFitnessValues());
    for (Variable v : this.getVariables()) {
        c.addVariable(v.clone());
    }
    c.setChanged(this.isChanged());
    c.setCoverageValues(this.getCoverageValues());
    c.setNumsOfCoveredGoals(this.getNumsOfCoveredGoals());
    c.updateAge(this.getAge());
    c.setRank(this.getRank());
    c.setDistance(this.getDistance());
    c.setNumberOfMutations(this.getNumberOfMutations());
    c.setNumberOfEvaluations(this.getNumberOfEvaluations());
    return c;
}
Also used : Variable(org.evosuite.ga.variables.Variable) DoubleVariable(org.evosuite.ga.variables.DoubleVariable)

Aggregations

DoubleVariable (org.evosuite.ga.variables.DoubleVariable)2 Variable (org.evosuite.ga.variables.Variable)2 NSGAChromosome (org.evosuite.ga.NSGAChromosome)1