nus-yam/ex-repair huggingface dataset:
Program: 180666
Project: 180666
Buggy source:
/** 
 * The actual function we are trying to evolve.
 */
@Override public double getCorrectResult(final double x){
  return x + x * x + x * x * x;
}

Fixed version (ground truth):
/** 
 * The actual function we are trying to evolve.
 */
@Override public double getCorrectResult(final double x){
  return x + x * x + x * x * x + x * x * x* x;
}
Program: 180667
Project: 180667
Buggy source:
/** 
 * The actual function we are trying to evolve.
 */
@Override public double getCorrectResult(final double x){
  return x + x * x + x * x * x;
}

Fixed version (ground truth):
/** 
 * The actual function we are trying to evolve.
 */
@Override public double getCorrectResult(final double x){
  return x + x * x + x * x * x + x * x * x* x;
}
Program: 180668
Project: 180668
Buggy source:
/** 
 * The actual function we are trying to evolve.
 */
@Override public double getCorrectResult(final double x){
  return x + x * x + x * x * x;
}

Fixed version (ground truth):
/** 
 * The actual function we are trying to evolve.
 */
@Override public double getCorrectResult(final double x){
  return x + x * x + x * x * x + x * x * x* x;
}
Program: 180669
Project: 180669
Buggy source:
/** 
 * Calculates and returns the fitness of the given program. The fitness of a  program is calculated as the number of food pieces that the ant did not manage to reach. That is, a fitness of 0.0 means the ant found every food item.
 * @param p {@inheritDoc}
 * @return the calculated fitness for the given program.
 */
@Override public double getFitness(final CandidateProgram p){
  final GPCandidateProgram program=(GPCandidateProgram)p;
  landscape.setFoodLocations(foodLocations);
  ant.reset(allowedTimeSteps,landscape);
  while (ant.getTimesteps() < ant.getMaxMoves()) {
    program.evaluate();
  }
  return (double)(foodLocations.size() - ant.getFoodEaten());
}

Fixed version (ground truth):
/** 
 * Calculates and returns the fitness of the given program. The fitness of a  program is calculated as the number of food pieces that the ant did not manage to reach. That is, a fitness of 0.0 means the ant found every food item.
 * @param p {@inheritDoc}
 * @return the calculated fitness for the given program.
 */
@Override public double getFitness(final CandidateProgram p){
  final GPCandidateProgram program=(GPCandidateProgram)p;
  landscape.setFoodLocations(new ArrayList<Point>(foodLocations));
  ant.reset(allowedTimeSteps,landscape);
  while (ant.getTimesteps() < ant.getMaxMoves()) {
    program.evaluate();
  }
  return (double)(foodLocations.size() - ant.getFoodEaten());
}
Program: 180670
Project: 180670
Buggy source:
/** 
 * Constructs a new AntTrail with the given <code>FOOD_LOCATIONS</code> which must all be positioned at points within the given <code>landscapeSize </code>. 
 * @param FOOD_LOCATIONS the points on the landscape which will be occupied by food
 * @param landscapeSize the dimensions of the landscape that the ant will operate within
 * @param allowedTimeSteps the number of moves and turns the ant will be allowed to collect the food before timing out.
 */
public AntTrail(final Point[] foodLocations,final Dimension landscapeSize,final int allowedTimeSteps){
  this.foodLocations=new ArrayList<Point>(Arrays.asList(foodLocations));
  this.allowedTimeSteps=allowedTimeSteps;
  landscape=new AntLandscape(landscapeSize,null);
  ant=new Ant(allowedTimeSteps,landscape);
  final List<Node> syntax=new ArrayList<Node>();
  syntax.add(new IfFoodAheadFunction(ant));
  syntax.add(new Seq2Function());
  syntax.add(new Seq3Function());
  syntax.add(new AntMoveAction(ant));
  syntax.add(new AntTurnLeftAction(ant));
  syntax.add(new AntTurnRightAction(ant));
  setSyntax(syntax);
}

Fixed version (ground truth):
/** 
 * Constructs a new AntTrail with the given <code>FOOD_LOCATIONS</code> which must all be positioned at points within the given <code>landscapeSize </code>. 
 * @param FOOD_LOCATIONS the points on the landscape which will be occupied by food
 * @param landscapeSize the dimensions of the landscape that the ant will operate within
 * @param allowedTimeSteps the number of moves and turns the ant will be allowed to collect the food before timing out.
 */
public AntTrail(final Point[] foodLocations,final Dimension landscapeSize,final int allowedTimeSteps){
  this.foodLocations=Arrays.asList(foodLocations);
  this.allowedTimeSteps=allowedTimeSteps;
  landscape=new AntLandscape(landscapeSize,null);
  ant=new Ant(allowedTimeSteps,landscape);
  final List<Node> syntax=new ArrayList<Node>();
  syntax.add(new IfFoodAheadFunction(ant));
  syntax.add(new Seq2Function());
  syntax.add(new Seq3Function());
  syntax.add(new AntMoveAction(ant));
  syntax.add(new AntTurnLeftAction(ant));
  syntax.add(new AntTurnRightAction(ant));
  setSyntax(syntax);
}
Program: 180671
Project: 180671
Buggy source:
/** 
 * Overwrites the default pool size value.
 * @param poolSize the new size of the mating pool to use.
 */
public void setPoolSize(final int poolSize){
  if (poolSize >= 1) {
    this.poolSize=poolSize;
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  assert(this.poolSize >= 1);
}

Fixed version (ground truth):
/** 
 * Overwrites the default pool size value.
 * @param poolSize the new size of the mating pool to use.
 */
public void setPoolSize(final int poolSize){
  if (poolSize == -1 || poolSize >= 1) {
    this.poolSize=poolSize;
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  assert(this.poolSize >= 1);
}
Program: 180672
Project: 180672
Buggy source:
/** 
 * Compare an object for equality. If the given object is a Node then it  may be equal if each Node in the tree is equal. Equality of individual  Nodes is dependant on the specific node type but typically will be  whether they are the same type and have the same children for function nodes and whether they have the same value or are the same variable for  terminal nodes.
 * @param obj an object to be compared for equivalence.
 * @return true if this node tree is the same as the obj argument; false otherwise.
 */
@Override public boolean equals(Object obj){
  boolean equal=true;
  if (obj instanceof Node) {
    Node n=(Node)obj;
    if (n.getArity() != this.getArity()) {
      equal=false;
    }
    for (int i=0; i < n.getArity() && equal; i++) {
      Node thatChild=n.getChild(i);
      Node thisChild=this.getChild(i);
      if ((thisChild != null) ^ (thatChild != null)) {
        equal=false;
      }
 else {
        equal=((thisChild == null) && (thatChild == null) || thisChild.equals(thatChild));
      }
    }
  }
 else {
    equal=false;
  }
  return equal;
}

Fixed version (ground truth):
/** 
 * Compare an object for equality. If the given object is a Node then it  may be equal if each Node in the tree is equal. Equality of individual  Nodes is dependant on the specific node type but typically will be  whether they are the same type and have the same children for function nodes and whether they have the same value or are the same variable for  terminal nodes.
 * @param obj an object to be compared for equivalence.
 * @return true if this node tree is the same as the obj argument; false otherwise.
 */
@Override public boolean equals(Object obj){
  boolean equal=true;
  if (obj instanceof Node) {
    Node n=(Node)obj;
    if (n.getArity() != this.getArity()) {
      equal=false;
    }
 else     if (n.getIdentifier() != this.getIdentifier()) {
      equal=false;
    }
 else {
      for (int i=0; i < n.getArity() && equal; i++) {
        Node thatChild=n.getChild(i);
        Node thisChild=this.getChild(i);
        if ((thisChild != null) ^ (thatChild != null)) {
          equal=false;
        }
 else {
          equal=((thisChild == null) && (thatChild == null) || thisChild.equals(thatChild));
        }
      }
    }
  }
 else {
    equal=false;
  }
  return equal;
}
Program: 180673
Project: 180673
Buggy source:
@Override public boolean equals(Object obj){
  if (obj != null && obj instanceof NonTerminalSymbol) {
    NonTerminalSymbol otherSymbol=(NonTerminalSymbol)obj;
    return this.getGrammarRule() == otherSymbol.getGrammarRule();
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  boolean equal=true;
  if (obj != null && obj instanceof NonTerminalSymbol) {
    NonTerminalSymbol otherSymbol=(NonTerminalSymbol)obj;
    if (this.getGrammarRule() == otherSymbol.getGrammarRule()) {
      for (int i=0; i < children.size(); i++) {
        Symbol thatChild=otherSymbol.getChild(i);
        Symbol thisChild=this.getChild(i);
        if (!ObjectUtils.equals(thisChild,thatChild)) {
          equal=false;
          break;
        }
      }
    }
 else {
      equal=false;
    }
  }
 else {
    equal=false;
  }
  return equal;
}
Program: 180674
Project: 180674
Buggy source:
/** 
 * Construct a RampedHalfAndHalfInitialiser.
 * @param model The model being assessed
 */
public RampedHalfAndHalfInitialiser(GPModel model){
  this.model=model;
  grow=new GrowInitialiser(model);
  full=new FullInitialiser(model);
  model.getLifeCycleManager().addConfigListener(new ConfigAdapter(){
    @Override public void onConfigure(){
      configure();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Construct a RampedHalfAndHalfInitialiser.
 * @param model The model being assessed
 */
public RampedHalfAndHalfInitialiser(GPModel model,int minDepth){
  this.model=model;
  this.minDepth=minDepth;
  grow=new GrowInitialiser(model);
  full=new FullInitialiser(model);
  model.getLifeCycleManager().addConfigListener(new ConfigAdapter(){
    @Override public void onConfigure(){
      configure();
    }
  }
);
}
Program: 180675
Project: 180675
Buggy source:
/** 
 * Compares the given argument for equivalence to this GECandidateProgram. Two candidate programs are equal if they have equal genotypes, or if  they have equal (but non-null) phenotypes.
 * @return true if the object is an equivalent candidate program, false otherwise.
 */
@Override public boolean equals(Object o){
  GRCandidateProgram prog=(GRCandidateProgram)o;
  Symbol thisParseTree=this.parseTree;
  Symbol progParseTree=prog.parseTree;
  if (thisParseTree == null && progParseTree == null) {
    return true;
  }
 else {
    return thisParseTree.equals(progParseTree);
  }
}

Fixed version (ground truth):
/** 
 * Compares the given argument for equivalence to this GECandidateProgram. Two GR candidate programs are equal if they have equal syntax regardless of grammar rules used or if both have a null parse tree.
 * @return true if the object is an equivalent candidate program, false otherwise.
 */
@Override public boolean equals(Object o){
  if (o instanceof GRCandidateProgram) {
    GRCandidateProgram prog=(GRCandidateProgram)o;
    return prog.toString().equals(this.toString());
  }
 else {
    return false;
  }
}
Program: 180676
Project: 180676
Buggy source:
public static int max(int[] values){
  int min=Integer.MIN_VALUE;
  for (int i=0; i < values.length; i++) {
    if (values[i] < min) {
      min=values[i];
    }
  }
  return min;
}

Fixed version (ground truth):
public static int max(int[] values){
  int max=Integer.MIN_VALUE;
  for (int i=0; i < values.length; i++) {
    if (values[i] > max) {
      max=values[i];
    }
  }
  return max;
}
Program: 180677
Project: 180677
Buggy source:
/** 
 * Construct a GEModel with a set of sensible defaults. See the appropriate accessor method for information of each default value.
 */
public GEModel(){
  mapper=new DepthFirstMapper(this);
  codonGenerator=new StandardGenerator(this);
  grammar=null;
  maxDepth=14;
  maxInitialDepth=8;
  maxCodonSize=Integer.MAX_VALUE;
  maxChromosomeLength=-1;
  cacheSource=true;
  setInitialiser(new RampedHalfAndHalfInitialiser(this));
  setCrossover(new OnePointCrossover(this));
  setMutation(new PointMutation(this));
}

Fixed version (ground truth):
/** 
 * Construct a GEModel with a set of sensible defaults. See the appropriate accessor method for information of each default value.
 */
public GEModel(){
  getStatsManager().setStatsEngine(new GEStatsEngine(this));
  mapper=new DepthFirstMapper(this);
  codonGenerator=new StandardGenerator(this);
  grammar=null;
  maxDepth=14;
  maxInitialDepth=8;
  maxCodonSize=Integer.MAX_VALUE;
  maxChromosomeLength=-1;
  cacheSource=true;
  setInitialiser(new RampedHalfAndHalfInitialiser(this));
  setCrossover(new OnePointCrossover(this));
  setMutation(new PointMutation(this));
}
Program: 180678
Project: 180678
Buggy source:
/** 
 * Construct a GPModel with a set of sensible defaults. See the appropriate accessor method for information of each default value.
 */
public GPModel(){
  maxInitialDepth=6;
  maxProgramDepth=12;
  setInitialiser(new FullInitialiser(this));
  setCrossover(new UniformPointCrossover(this));
  setMutation(new SubtreeMutation(this));
}

Fixed version (ground truth):
/** 
 * Construct a GPModel with a set of sensible defaults. See the appropriate accessor method for information of each default value.
 */
public GPModel(){
  getStatsManager().setStatsEngine(new GPStatsEngine(this));
  maxInitialDepth=6;
  maxProgramDepth=12;
  setInitialiser(new FullInitialiser(this));
  setCrossover(new UniformPointCrossover(this));
  setMutation(new SubtreeMutation(this));
}
Program: 180679
Project: 180679
Buggy source:
/** 
 * Requests the controlling model to calculate the fitness of this  <code>GPCandidateProgram</code>.
 * @return the fitness of this candidate program according to the model.
 */
public double getFitness(){
  String source=null;
  if (model.cacheFitness()) {
    source=rootNode.toString();
  }
  if (!model.cacheFitness() || !source.equals(sourceCache)) {
    fitness=model.getFitness(this);
    sourceCache=source;
  }
  return fitness;
}

Fixed version (ground truth):
/** 
 * Requests the controlling model to calculate the fitness of this  <code>GPCandidateProgram</code>.
 * @return the fitness of this candidate program according to the model.
 */
@Override public double getFitness(){
  String source=null;
  if (model.cacheFitness()) {
    source=rootNode.toString();
  }
  if (!model.cacheFitness() || !source.equals(sourceCache)) {
    fitness=model.getFitness(this);
    sourceCache=source;
  }
  return fitness;
}
Program: 180680
Project: 180680
Buggy source:
private void setNthNode(int n,Node newNode,int current){
  int arity=getArity();
  for (int i=0; i < arity; i++) {
    if (current + 1 == n) {
      setChild(i,newNode);
      return;
    }
    Node child=getChild(i);
    int childLength=child.getLength();
    if (n <= childLength + current) {
      child.setNthNode(n,newNode,current + 1);
    }
    current+=childLength;
  }
  throw new IndexOutOfBoundsException("String_Node_Str");
}

Fixed version (ground truth):
private void setNthNode(int n,Node newNode,int current){
  int arity=getArity();
  for (int i=0; i < arity; i++) {
    if (current + 1 == n) {
      setChild(i,newNode);
      return;
    }
    Node child=getChild(i);
    int childLength=child.getLength();
    if (n <= childLength + current) {
      child.setNthNode(n,newNode,current + 1);
      return;
    }
    current+=childLength;
  }
  throw new IndexOutOfBoundsException("String_Node_Str");
}
Program: 180681
Project: 180681
Buggy source:
/** 
 * Construct a GRModel with a set of sensible defaults. See the appropriate accessor method for information of each default value.
 */
public GRModel(){
  grammar=null;
  maxDepth=14;
  maxInitialDepth=8;
  setInitialiser(new RampedHalfAndHalfInitialiser(this));
  setCrossover(new WhighamCrossover(this));
  setMutation(new WhighamMutation(this));
}

Fixed version (ground truth):
/** 
 * Construct a GRModel with a set of sensible defaults. See the appropriate accessor method for information of each default value.
 */
public GRModel(){
  getStatsManager().setStatsEngine(new GRStatsEngine(this));
  grammar=null;
  maxDepth=14;
  maxInitialDepth=8;
  setInitialiser(new RampedHalfAndHalfInitialiser(this));
  setCrossover(new WhighamCrossover(this));
  setMutation(new WhighamMutation(this));
}
Program: 180682
Project: 180682
Buggy source:
/** 
 * Returns the location of one move on from the given location in the  direction of the provided orientation. The landscape is a torus so this  method is required to calculate the necessary wrapping.
 * @param location the current location to calculate the next move from.
 * @param orientation the direction of the move.
 * @return the next location one move on from the given location in the direction of the provided orientation.
 */
public Point getNextLocation(Point location,Orientation orientation){
  Point newLocation=new Point(location);
switch (orientation) {
case NORTH:
    newLocation.y=(location.y > 0) ? (location.y - 1) : (size.height - 1);
  break;
case EAST:
newLocation.x=(location.x < size.width - 1) ? (location.x + 1) : 0;
break;
case SOUTH:
newLocation.y=(location.y < size.height - 1) ? (location.y + 1) : 0;
break;
case WEST:
newLocation.x=(location.x > 0) ? (location.y - 1) : (size.width - 1);
break;
default :
break;
}
return newLocation;
}

Fixed version (ground truth):
/** 
 * Returns the location of one move on from the given location in the  direction of the provided orientation. The landscape is a torus so this  method is required to calculate the necessary wrapping.
 * @param location the current location to calculate the next move from.
 * @param orientation the direction of the move.
 * @return the next location one move on from the given location in the direction of the provided orientation.
 */
public Point getNextLocation(Point location,Orientation orientation){
  Point newLocation=new Point(location);
switch (orientation) {
case NORTH:
    newLocation.y=(location.y > 0) ? (location.y - 1) : (size.height - 1);
  break;
case EAST:
newLocation.x=(location.x < size.width - 1) ? (location.x + 1) : 0;
break;
case SOUTH:
newLocation.y=(location.y < size.height - 1) ? (location.y + 1) : 0;
break;
case WEST:
newLocation.x=(location.x > 0) ? (location.x - 1) : (size.width - 1);
break;
default :
break;
}
return newLocation;
}
Program: 180683
Project: 180683
Buggy source:
/** 
 * Constructs an instance of <code>LinearRankSelector</code>.
 * @param model
 * @param gradient
 */
public LinearRankSelector(final Model model,final double gradient){
  this.model=model;
  setGradient(gradient);
  model.getLifeCycleManager().addConfigListener(new ConfigAdapter(){
    @Override public void onConfigure(){
      configure();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs an instance of <code>LinearRankSelector</code>.
 * @param model
 * @param gradient
 */
public LinearRankSelector(final Model model,final double gradient){
  this.model=model;
  setGradient(gradient);
  programSelection=new ProgramLinearRankSelector();
  poolSelection=new ProgramLinearRankSelector();
  model.getLifeCycleManager().addConfigListener(new ConfigAdapter(){
    @Override public void onConfigure(){
      configure();
    }
  }
);
}
Program: 180684
Project: 180684
Buggy source:
/** 
 * Executes a single evolutionary run of this <code>RunManager's</code>  <code>Model</code>.
 * @param runNo the sequential number which identifies this run out of the set of runs being performed.
 */
public void run(final int runNo){
  LifeCycleManager.getLifeCycleManager().onRunStart();
  final long startTime=System.nanoTime();
  StatsManager.getStatsManager().addRunData(RUN_NUMBER,runNo);
  List<CandidateProgram> pop=initialisation.initialise();
  updateBestProgram(pop);
  for (int gen=1; gen <= model.getNoGenerations(); gen++) {
    pop=generation.generation(gen,pop);
    updateBestProgram(pop);
    if (bestFitness <= model.getTerminationFitness()) {
      LifeCycleManager.getLifeCycleManager().onSuccess();
      break;
    }
  }
  LifeCycleManager.getLifeCycleManager().onRunEnd();
  final long runtime=System.nanoTime() - startTime;
  StatsManager.getStatsManager().addRunData(RUN_TIME,runtime);
}

Fixed version (ground truth):
/** 
 * Executes a single evolutionary run of this <code>RunManager's</code>  <code>Model</code>.
 * @param runNo the sequential number which identifies this run out of the set of runs being performed.
 */
public void run(final int runNo){
  setup();
  LifeCycleManager.getLifeCycleManager().onRunStart();
  final long startTime=System.nanoTime();
  StatsManager.getStatsManager().addRunData(RUN_NUMBER,runNo);
  List<CandidateProgram> pop=initialisation.initialise();
  updateBestProgram(pop);
  for (int gen=1; gen <= model.getNoGenerations(); gen++) {
    pop=generation.generation(gen,pop);
    updateBestProgram(pop);
    if (bestFitness <= model.getTerminationFitness()) {
      LifeCycleManager.getLifeCycleManager().onSuccess();
      break;
    }
  }
  LifeCycleManager.getLifeCycleManager().onRunEnd();
  final long runtime=System.nanoTime() - startTime;
  StatsManager.getStatsManager().addRunData(RUN_TIME,runtime);
}
Program: 180685
Project: 180685
Buggy source:
/** 
 * Constructs an instance of RunManager to be controlled by parameters  retrieved from the given <code>Model</code>. Fitness evaluation will  also be diverted to the given model.
 * @param model the model which will control the run with the parameters and fitness function to use.
 */
public RunManager(final Model model){
  this.model=model;
  bestProgram=null;
  bestFitness=Double.POSITIVE_INFINITY;
  generation=new GenerationManager(model);
  initialisation=new InitialisationManager(model);
}

Fixed version (ground truth):
/** 
 * Constructs an instance of RunManager to be controlled by parameters  retrieved from the given <code>Model</code>. Fitness evaluation will  also be diverted to the given model.
 * @param model the model which will control the run with the parameters and fitness function to use.
 */
public RunManager(final Model model){
  this.model=model;
  generation=new GenerationManager(model);
  initialisation=new InitialisationManager(model);
}
Program: 180686
Project: 180686
Buggy source:
/** 
 * Construct a GRModel with a set of sensible defaults. See the appropriate accessor method for information of each default value.
 */
public GRAbstractModel(){
  maxDepth=20;
  maxInitialDepth=8;
  initialiser=new RampedHalfAndHalfInitialiser(this);
  crossover=new WhighamCrossover(this);
  mutator=new WhighamMutation(this);
  setStatsEngine(new GRStatsEngine());
}

Fixed version (ground truth):
/** 
 * Construct a GRModel with a set of sensible defaults. See the appropriate accessor method for information of each default value.
 */
public GRAbstractModel(){
  maxDepth=12;
  maxInitialDepth=8;
  initialiser=new RampedHalfAndHalfInitialiser(this);
  crossover=new WhighamCrossover(this);
  mutator=new WhighamMutation(this);
  setStatsEngine(new GRStatsEngine());
}
Program: 180687
Project: 180687
Buggy source:
public Node parse(String source){
  if (source == null) {
    return null;
  }
  int openingBracket=source.indexOf('(');
  String identifier=null;
  List<String> args=null;
  if (openingBracket == -1) {
    identifier=source;
    args=new ArrayList<String>();
  }
 else {
    identifier=source.substring(0,openingBracket);
    String argumentStr=source.substring(openingBracket + 1,source.length() - 1);
    args=splitArguments(argumentStr);
  }
  Node node=initialiseFunction(identifier);
  if (node == null) {
    node=parseTerminal(identifier);
  }
  if (node == null || node.getArity() != args.size()) {
    throw new MalformedProgramException();
  }
 else {
    for (int i=0; i < args.size(); i++) {
      node.setChild(i,parse(args.get(i)));
    }
  }
  return node;
}

Fixed version (ground truth):
public Node parse(String source){
  if (source == null) {
    return null;
  }
  int openingBracket=source.indexOf('(');
  String identifier=null;
  List<String> args=null;
  if (openingBracket == -1) {
    identifier=source;
    args=new ArrayList<String>();
  }
 else {
    identifier=source.substring(0,openingBracket);
    int closingBracket=source.lastIndexOf(')');
    String argumentStr=source.substring(openingBracket + 1,closingBracket);
    args=splitArguments(argumentStr);
  }
  Node node=initialiseFunction(identifier);
  if (node == null) {
    node=parseTerminal(identifier);
  }
  if (node == null || node.getArity() != args.size()) {
    throw new MalformedProgramException();
  }
 else {
    for (int i=0; i < args.size(); i++) {
      node.setChild(i,parse(args.get(i)));
    }
  }
  return node;
}
Program: 180688
Project: 180688
Buggy source:
/** 
 * Constructs an instance of CrossoverManager which will setup the crossover  operation. Note that the actual crossover operation will be performed by  the subclass of <code>Crossover</code> returned by the models  getCrossover() method.
 * @param model the Model which defines the Crossover operator and ProgramSelector to use to perform one act of crossover on  a population.
 * @see Crossover
 */
public CrossoverManager(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs an instance of CrossoverManager which will setup the crossover  operation. Note that the actual crossover operation will be performed by  the subclass of <code>Crossover</code> returned by the models  getCrossover() method.
 * @param model the Model which defines the Crossover operator and ProgramSelector to use to perform one act of crossover on  a population.
 * @see Crossover
 */
public CrossoverManager(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180689
Project: 180689
Buggy source:
/** 
 * Constructs an instance of <code>Elitism</code> which will perform the  evolutionary operation of elitism. 
 * @param model the Model which defines the run parameters such as numberof elites to use.
 */
public ElitismManager(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs an instance of <code>Elitism</code> which will perform the  evolutionary operation of elitism. 
 * @param model the Model which defines the run parameters such as numberof elites to use.
 */
public ElitismManager(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180691
Project: 180691
Buggy source:
/** 
 * Constructs an instance of <code>InitialisationManager</code> which will  setup the initialisation operation.
 * @param model the model which defines the Initialiser operator and any other control parameters.
 * @see Initialiser
 */
public InitialisationManager(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs an instance of <code>InitialisationManager</code> which will  setup the initialisation operation.
 * @param model the model which defines the Initialiser operator and any other control parameters.
 * @see Initialiser
 */
public InitialisationManager(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180692
Project: 180692
Buggy source:
/** 
 * Constructs an instance of MutationManager which will setup the mutation  operation. Note that the actual mutation operation will be performed by  the subclass of <code>Mutation</code> returned by the model's  <code>getMutation()</code> method.
 * @param model the Model which defines the Mutation operator and ProgramSelector to use to perform one act of mutation on  an individual in the population.
 * @see Mutation
 */
public MutationManager(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs an instance of MutationManager which will setup the mutation  operation. Note that the actual mutation operation will be performed by  the subclass of <code>Mutation</code> returned by the model's  <code>getMutation()</code> method.
 * @param model the Model which defines the Mutation operator and ProgramSelector to use to perform one act of mutation on  an individual in the population.
 * @see Mutation
 */
public MutationManager(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180693
Project: 180693
Buggy source:
/** 
 * Constructs an instance of PoolSelectionManager which will setup the  breeding pool selection operation.
 * @param model the Model which defines the PoolSelector operator and anyother control parameters.
 * @see PoolSelector
 */
public PoolSelectionManager(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs an instance of PoolSelectionManager which will setup the  breeding pool selection operation.
 * @param model the Model which defines the PoolSelector operator and anyother control parameters.
 * @see PoolSelector
 */
public PoolSelectionManager(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180694
Project: 180694
Buggy source:
/** 
 * Constructs an instance of ReproductionManager which will setup the  reproduction operation. The selection of the program to be reproduced is performed by the parent selector obtained from a call to the model's  <code>getParentSelector()</code> method.
 * @param model the model which defines the ProgramSelector to use to select the program to be reproduced.
 */
public ReproductionManager(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs an instance of ReproductionManager which will setup the  reproduction operation. The selection of the program to be reproduced is performed by the parent selector obtained from a call to the model's  <code>getParentSelector()</code> method.
 * @param model the model which defines the ProgramSelector to use to select the program to be reproduced.
 */
public ReproductionManager(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180695
Project: 180695
Buggy source:
public LinearRankSelector(double gradient){
  this.gradient=gradient;
  nMinus=2 / (gradient + 1);
  nPlus=(2 * gradient) / (gradient + 1);
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
public LinearRankSelector(double gradient){
  this.gradient=gradient;
  nMinus=2 / (gradient + 1);
  nPlus=(2 * gradient) / (gradient + 1);
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180696
Project: 180696
Buggy source:
/** 
 */
public RandomSelector(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 */
public RandomSelector(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180697
Project: 180697
Buggy source:
/** 
 * Construct a StandardGenerator.
 * @param model the model that controls the run, providing the maximum codon size.
 */
public StandardGenerator(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Construct a StandardGenerator.
 * @param model the model that controls the run, providing the maximum codon size.
 */
public StandardGenerator(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180698
Project: 180698
Buggy source:
/** 
 * Constructs an instance of BreadthFirstMapper.
 * @param model the controlling model providing configuration details such as the Grammar.
 */
public BreadthFirstMapper(){
  wrapping=false;
  extending=true;
  removingUnusedCodons=true;
  noMappedCodons=-1;
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs an instance of BreadthFirstMapper.
 * @param model the controlling model providing configuration details such as the Grammar.
 */
public BreadthFirstMapper(){
  wrapping=false;
  extending=true;
  removingUnusedCodons=true;
  noMappedCodons=-1;
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180699
Project: 180699
Buggy source:
/** 
 * Constructs an instance of DepthFirstMapper.
 * @param model the controlling model providing configuration details such as the Grammar.
 */
public DepthFirstMapper(){
  wrapping=true;
  extending=false;
  maxWraps=3;
  removingUnusedCodons=true;
  noMappedCodons=-1;
  noWraps=0;
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs an instance of DepthFirstMapper.
 * @param model the controlling model providing configuration details such as the Grammar.
 */
public DepthFirstMapper(){
  wrapping=true;
  extending=false;
  maxWraps=3;
  removingUnusedCodons=true;
  noMappedCodons=-1;
  noWraps=0;
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180700
Project: 180700
Buggy source:
/** 
 * Constructs an instance of FixedPointCrossover.
 * @param model the current controlling model.
 */
public FixedPointCrossover(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs an instance of FixedPointCrossover.
 * @param model the current controlling model.
 */
public FixedPointCrossover(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180701
Project: 180701
Buggy source:
public OnePointCrossover(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
public OnePointCrossover(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180702
Project: 180702
Buggy source:
private void updateModel(){
  popSize=((GEModel)Controller.getModel()).getPopulationSize();
}

Fixed version (ground truth):
private void updateModel(){
  model=(GEModel)Controller.getModel();
  popSize=model.getPopulationSize();
}
Program: 180703
Project: 180703
Buggy source:
/** 
 * Generate a population of new CandidatePrograms constructed by randomly  generating their chromosomes. The size of the population will be equal  to the result of calling getPopulationSize() on the controlling model.  All programs in the population will be unique. Each candidate program  will have a chromosome length equal to the initialLength provided to the  constructor.
 * @return A List of newly generated CandidatePrograms which will form the initial population for a GE run.
 */
@Override public List<CandidateProgram> getInitialPopulation(){
  List<CandidateProgram> firstGen=new ArrayList<CandidateProgram>(popSize);
  int i=0;
  while (i < popSize) {
    GECandidateProgram candidate=new GECandidateProgram();
    candidate.appendNewCodons(initialLength);
    firstGen.add(candidate);
    i++;
  }
  return firstGen;
}

Fixed version (ground truth):
/** 
 * Generate a population of new CandidatePrograms constructed by randomly  generating their chromosomes. The size of the population will be equal  to the result of calling getPopulationSize() on the controlling model.  All programs in the population will be unique. Each candidate program  will have a chromosome length equal to the initialLength provided to the  constructor.
 * @return A List of newly generated CandidatePrograms which will form the initial population for a GE run.
 */
@Override public List<CandidateProgram> getInitialPopulation(){
  List<CandidateProgram> firstGen=new ArrayList<CandidateProgram>(popSize);
  int i=0;
  while (i < popSize) {
    GECandidateProgram candidate=new GECandidateProgram(model);
    candidate.appendNewCodons(initialLength);
    firstGen.add(candidate);
    i++;
  }
  return firstGen;
}
Program: 180704
Project: 180704
Buggy source:
/** 
 * Constructs a RandomInitialiser.
 * @param model The GE model that will provide any required control parameters such as the desired population size.
 * @param initialLength The initial length that chromosomes should be generated to.
 */
public FixedLengthInitialiser(int initialLength){
  this.initialLength=initialLength;
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs a RandomInitialiser.
 * @param model The GE model that will provide any required control parameters such as the desired population size.
 * @param initialLength The initial length that chromosomes should be generated to.
 */
public FixedLengthInitialiser(int initialLength){
  this.initialLength=initialLength;
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180705
Project: 180705
Buggy source:
private void updateModel(){
  GEModel model=(GEModel)Controller.getModel();
  rng=model.getRNG();
  grammar=model.getGrammar();
  popSize=model.getPopulationSize();
  maxInitialProgramDepth=model.getMaxInitialProgramDepth();
  maxCodonSize=model.getMaxCodonSize();
}

Fixed version (ground truth):
private void updateModel(){
  model=(GEModel)Controller.getModel();
  rng=model.getRNG();
  grammar=model.getGrammar();
  popSize=model.getPopulationSize();
  maxInitialProgramDepth=model.getMaxInitialProgramDepth();
  maxCodonSize=model.getMaxCodonSize();
}
Program: 180706
Project: 180706
Buggy source:
/** 
 * Constructs a full initialiser.
 * @param model
 */
public FullInitialiser(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs a full initialiser.
 * @param model
 */
public FullInitialiser(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180707
Project: 180707
Buggy source:
public GECandidateProgram getInitialProgram(int depth){
  GrammarNode start=grammar.getStartRule();
  List<Integer> codons=new ArrayList<Integer>();
  buildDerivationTree(codons,start,0,depth);
  return new GECandidateProgram(codons);
}

Fixed version (ground truth):
public GECandidateProgram getInitialProgram(int depth){
  GrammarNode start=grammar.getStartRule();
  List<Integer> codons=new ArrayList<Integer>();
  buildDerivationTree(codons,start,0,depth);
  return new GECandidateProgram(model,codons);
}
Program: 180708
Project: 180708
Buggy source:
/** 
 * Constructs a grow initialiser.
 * @param model
 */
public GrowInitialiser(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs a grow initialiser.
 * @param model
 */
public GrowInitialiser(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180709
Project: 180709
Buggy source:
private void updateModel(){
  GEModel model=(GEModel)Controller.getModel();
  rng=model.getRNG();
  grammar=model.getGrammar();
  popSize=model.getPopulationSize();
  maxInitialProgramDepth=model.getMaxInitialProgramDepth();
  maxCodonSize=model.getMaxCodonSize();
}

Fixed version (ground truth):
private void updateModel(){
  model=(GEModel)Controller.getModel();
  rng=model.getRNG();
  grammar=model.getGrammar();
  popSize=model.getPopulationSize();
  maxInitialProgramDepth=model.getMaxInitialProgramDepth();
  maxCodonSize=model.getMaxCodonSize();
}
Program: 180710
Project: 180710
Buggy source:
public GECandidateProgram getInitialProgram(int depth){
  GrammarNode start=grammar.getStartRule();
  int minDepth=0;
  if (start instanceof GrammarRule) {
    minDepth=((GrammarRule)start).getMinDepth();
  }
  if (minDepth > depth) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  List<Integer> codons=new ArrayList<Integer>();
  buildDerivationTree(codons,start,0,depth);
  return new GECandidateProgram(codons);
}

Fixed version (ground truth):
public GECandidateProgram getInitialProgram(int depth){
  GrammarNode start=grammar.getStartRule();
  int minDepth=0;
  if (start instanceof GrammarRule) {
    minDepth=((GrammarRule)start).getMinDepth();
  }
  if (minDepth > depth) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  List<Integer> codons=new ArrayList<Integer>();
  buildDerivationTree(codons,start,0,depth);
  return new GECandidateProgram(model,codons);
}
Program: 180711
Project: 180711
Buggy source:
/** 
 * Construct a RampedHalfAndHalfInitialiser.
 * @param model The model being assessed
 */
public RampedHalfAndHalfInitialiser(){
  grow=new GrowInitialiser();
  full=new FullInitialiser();
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Construct a RampedHalfAndHalfInitialiser.
 * @param model The model being assessed
 */
public RampedHalfAndHalfInitialiser(){
  grow=new GrowInitialiser();
  full=new FullInitialiser();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180712
Project: 180712
Buggy source:
/** 
 * Construct a point mutation with user specified point probability.
 * @param model The current controlling model. Parameters such as the codongenerator to use will come from here.
 * @param pointProbability The probability each node in a selected program has of undergoing a mutation. 1.0 would result in all nodes  being changed, and 0.0 would mean no nodes were changed. A  typical value would be 0.01.
 */
public PointMutation(double pointProbability){
  this.pointProbability=pointProbability;
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Construct a point mutation with user specified point probability.
 * @param model The current controlling model. Parameters such as the codongenerator to use will come from here.
 * @param pointProbability The probability each node in a selected program has of undergoing a mutation. 1.0 would result in all nodes  being changed, and 0.0 would mean no nodes were changed. A  typical value would be 0.01.
 */
public PointMutation(double pointProbability){
  this.pointProbability=pointProbability;
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180713
Project: 180713
Buggy source:
/** 
 * Construct a single point mutation.
 * @param model The current controlling model. Parameters such as the codongenerator to use will come from here.
 */
public SinglePointMutation(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Construct a single point mutation.
 * @param model The current controlling model. Parameters such as the codongenerator to use will come from here.
 */
public SinglePointMutation(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180714
Project: 180714
Buggy source:
/** 
 * Constructs a new program individual with the specified codons as the  genotypic chromosome.
 * @param codons the program's initial genotypic chromosome.
 * @param model the controlling model which provides the configuration parameters for the run. 				
 */
public GECandidateProgram(List<Integer> codons){
  this.codons=codons;
  parseTree=null;
  mapped=false;
  fitness=-1;
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Constructs a new program individual with the specified codons as the  genotypic chromosome.
 * @param codons the program's initial genotypic chromosome.
 * @param model the controlling model which provides the configuration parameters for the run. 				
 */
public GECandidateProgram(GEModel model,List<Integer> codons){
  this.model=model;
  this.codons=codons;
  parseTree=null;
  mapped=false;
  fitness=-1;
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}
Program: 180715
Project: 180715
Buggy source:
public UniformPointCrossover(){
  updateModel();
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}

Fixed version (ground truth):
public UniformPointCrossover(){
  LifeCycleManager.getLifeCycleManager().addGenerationListener(new GenerationAdapter(){
    @Override public void onGenerationStart(){
      updateModel();
    }
  }
);
}