nus-yam/ex-repair huggingface dataset:
Program: 57312
Project: 57312
Buggy source:
/** 
 * Correct the current state estimate with an actual measurement.
 * @param z the measurement vector
 * @throws DimensionMismatchException if the dimension of the measurement vector does not fit
 * @throws org.apache.commons.math.linear.SingularMatrixException if the covariance matrix could not be inverted
 */
public void correct(final RealVector z){
  if (z != null && z.getDimension() != measurementMatrix.getRowDimension()) {
    throw new DimensionMismatchException(z.getDimension(),measurementMatrix.getRowDimension());
  }
  RealMatrix s=measurementMatrix.multiply(errorCovariance).multiply(measurementMatrixT).add(measurementModel.getMeasurementNoise());
  DecompositionSolver solver=new CholeskyDecompositionImpl(s).getSolver();
  RealMatrix invertedS=solver.getInverse();
  RealVector innovation=z.subtract(measurementMatrix.operate(stateEstimation));
  RealMatrix kalmanGain=errorCovariance.multiply(measurementMatrixT).multiply(invertedS);
  stateEstimation=stateEstimation.add(kalmanGain.operate(innovation));
  RealMatrix identity=MatrixUtils.createRealIdentityMatrix(kalmanGain.getRowDimension());
  errorCovariance=identity.subtract(kalmanGain.multiply(measurementMatrix)).multiply(errorCovariance);
}

Fixed version (ground truth):
/** 
 * Correct the current state estimate with an actual measurement.
 * @param z the measurement vector
 * @throws DimensionMismatchException if the dimension of the measurement vector does not fit
 * @throws org.apache.commons.math.linear.SingularMatrixException if the covariance matrix could not be inverted
 */
public void correct(final RealVector z){
  MathUtils.checkNotNull(z);
  if (z.getDimension() != measurementMatrix.getRowDimension()) {
    throw new DimensionMismatchException(z.getDimension(),measurementMatrix.getRowDimension());
  }
  RealMatrix s=measurementMatrix.multiply(errorCovariance).multiply(measurementMatrixT).add(measurementModel.getMeasurementNoise());
  DecompositionSolver solver=new CholeskyDecompositionImpl(s).getSolver();
  RealMatrix invertedS=solver.getInverse();
  RealVector innovation=z.subtract(measurementMatrix.operate(stateEstimation));
  RealMatrix kalmanGain=errorCovariance.multiply(measurementMatrixT).multiply(invertedS);
  stateEstimation=stateEstimation.add(kalmanGain.operate(innovation));
  RealMatrix identity=MatrixUtils.createRealIdentityMatrix(kalmanGain.getRowDimension());
  errorCovariance=identity.subtract(kalmanGain.multiply(measurementMatrix)).multiply(errorCovariance);
}
Program: 57313
Project: 57313
Buggy source:
/** 
 * Check all entries of the input array are >= 0.
 * @param in Array to be tested.
 * @exception NotPositiveException if one entry is negative.
 */
private void checkNonNegative(long[][] in){
  for (int i=0; i < in.length; i++) {
    for (int j=0; j < in[i].length; j++) {
      if (in[i][j] < 0) {
        throw new MathIllegalArgumentException(LocalizedFormats.NEGATIVE_ELEMENT_AT_2D_INDEX,i,j,in[i][j]);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Check all entries of the input array are >= 0.
 * @param in Array to be tested.
 * @exception MathIllegalArgumentException if one entry is negative.
 */
private void checkNonNegative(long[][] in){
  for (int i=0; i < in.length; i++) {
    for (int j=0; j < in[i].length; j++) {
      if (in[i][j] < 0) {
        throw new MathIllegalArgumentException(LocalizedFormats.NEGATIVE_ELEMENT_AT_2D_INDEX,i,j,in[i][j]);
      }
    }
  }
}
Program: 57314
Project: 57314
Buggy source:
/** 
 * Check all entries of the input array are strictly positive.
 * @param in Array to be tested.
 * @exception NotStrictlyPositiveException if one entry is not positive.
 */
private void checkPositive(double[] in){
  for (int i=0; i < in.length; i++) {
    if (in[i] <= 0) {
      throw new MathIllegalArgumentException(LocalizedFormats.NOT_POSITIVE_ELEMENT_AT_INDEX,i,in[i]);
    }
  }
}

Fixed version (ground truth):
/** 
 * Check all entries of the input array are strictly positive.
 * @param in Array to be tested.
 * @exception MathIllegalArgumentException if one entry is not positive.
 */
private void checkPositive(double[] in){
  for (int i=0; i < in.length; i++) {
    if (in[i] <= 0) {
      throw new MathIllegalArgumentException(LocalizedFormats.NOT_POSITIVE_ELEMENT_AT_INDEX,i,in[i]);
    }
  }
}
Program: 57315
Project: 57315
Buggy source:
/** 
 * For a random variable   {@code X} whose values are distributed accordingto this distribution, this method returns the largest  {@code x}, such that   {@code P(X < x) < p}.
 * @param p Desired probability.
 * @return the largest {@code x} such that {@code P(X < x) <= p}.
 * @throws MathException if the inverse cumulative probability can not becomputed due to convergence or other numerical errors.
 * @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
 */
public int inverseCumulativeProbability(final double p) throws MathException {
  if (p < 0 || p > 1) {
    throw new OutOfRangeException(p,0,1);
  }
  int x0=getDomainLowerBound(p);
  int x1=getDomainUpperBound(p);
  double pm;
  while (x0 < x1) {
    int xm=x0 + (x1 - x0) / 2;
    pm=checkedCumulativeProbability(xm);
    if (pm > p) {
      if (xm == x1) {
        --x1;
      }
 else {
        x1=xm;
      }
    }
 else {
      if (xm == x0) {
        ++x0;
      }
 else {
        x0=xm;
      }
    }
  }
  pm=checkedCumulativeProbability(x0);
  while (pm > p) {
    --x0;
    pm=checkedCumulativeProbability(x0);
  }
  return x0;
}

Fixed version (ground truth):
/** 
 * For a random variable   {@code X} whose values are distributed accordingto this distribution, this method returns the largest  {@code x}, such that   {@code P(X <= x) <= p}.
 * @param p Desired probability.
 * @return the largest {@code x} such that {@code P(X < x) <= p}.
 * @throws MathException if the inverse cumulative probability can not becomputed due to convergence or other numerical errors.
 * @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
 */
public int inverseCumulativeProbability(final double p) throws MathException {
  if (p < 0 || p > 1) {
    throw new OutOfRangeException(p,0,1);
  }
  int x0=getDomainLowerBound(p);
  int x1=getDomainUpperBound(p);
  double pm;
  while (x0 < x1) {
    int xm=x0 + (x1 - x0) / 2;
    pm=checkedCumulativeProbability(xm);
    if (pm > p) {
      if (xm == x1) {
        --x1;
      }
 else {
        x1=xm;
      }
    }
 else {
      if (xm == x0) {
        ++x0;
      }
 else {
        x0=xm;
      }
    }
  }
  pm=checkedCumulativeProbability(x0);
  while (pm > p) {
    --x0;
    pm=checkedCumulativeProbability(x0);
  }
  return x0;
}
Program: 57316
Project: 57316
Buggy source:
/** 
 * For this distribution,   {@code X}, this method returns   {@code P(X < x)}.
 * @param x Value at which the PDF is evaluated.
 * @return PDF for this distribution.
 * @throws MathException if the cumulative probability can not be computeddue to convergence or other numerical errors.
 */
@Override public double cumulativeProbability(int x) throws MathException {
  double ret;
  if (x < 0) {
    ret=0.0;
  }
 else   if (x >= numberOfTrials) {
    ret=1.0;
  }
 else {
    ret=1.0 - Beta.regularizedBeta(getProbabilityOfSuccess(),x + 1.0,numberOfTrials - x);
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * For this distribution,   {@code X}, this method returns   {@code P(X <= x)}.
 * @param x Value at which the PDF is evaluated.
 * @return PDF for this distribution.
 * @throws MathException if the cumulative probability can not be computeddue to convergence or other numerical errors.
 */
@Override public double cumulativeProbability(int x) throws MathException {
  double ret;
  if (x < 0) {
    ret=0.0;
  }
 else   if (x >= numberOfTrials) {
    ret=1.0;
  }
 else {
    ret=1.0 - Beta.regularizedBeta(getProbabilityOfSuccess(),x + 1.0,numberOfTrials - x);
  }
  return ret;
}
Program: 57317
Project: 57317
Buggy source:
/** 
 * For this distribution,   {@code X}, this method returns   {@code P(X < x)}.
 * @param x Value at which the PDF is evaluated.
 * @return PDF for this distribution.
 */
@Override public double cumulativeProbability(int x){
  double ret;
  int[] domain=getDomain(populationSize,numberOfSuccesses,sampleSize);
  if (x < domain[0]) {
    ret=0.0;
  }
 else   if (x >= domain[1]) {
    ret=1.0;
  }
 else {
    ret=innerCumulativeProbability(domain[0],x,1,populationSize,numberOfSuccesses,sampleSize);
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * For this distribution,   {@code X}, this method returns   {@code P(X <= x)}.
 * @param x Value at which the PDF is evaluated.
 * @return PDF for this distribution.
 */
@Override public double cumulativeProbability(int x){
  double ret;
  int[] domain=getDomain(populationSize,numberOfSuccesses,sampleSize);
  if (x < domain[0]) {
    ret=0.0;
  }
 else   if (x >= domain[1]) {
    ret=1.0;
  }
 else {
    ret=innerCumulativeProbability(domain[0],x,1,populationSize,numberOfSuccesses,sampleSize);
  }
  return ret;
}
Program: 57318
Project: 57318
Buggy source:
/** 
 * For this distribution,   {@code X}, this method returns  {@code P(x0 < X < x1)}.
 * @param x0 the inclusive, lower bound
 * @param x1 the inclusive, upper bound
 * @return the cumulative probability.
 * @throws MathException if the cumulative probability can not becomputed due to convergence or other numerical errors.
 * @throws IllegalArgumentException if {@code x0 > x1}.
 */
double cumulativeProbability(int x0,int x1) throws MathException ;

Fixed version (ground truth):
/** 
 * For this distribution,   {@code X}, this method returns  {@code P(x0 <= X <= x1)}.
 * @param x0 the inclusive, lower bound
 * @param x1 the inclusive, upper bound
 * @return the cumulative probability.
 * @throws MathException if the cumulative probability can not becomputed due to convergence or other numerical errors.
 * @throws IllegalArgumentException if {@code x0 > x1}.
 */
double cumulativeProbability(int x0,int x1) throws MathException ;
Program: 57319
Project: 57319
Buggy source:
/** 
 * For this distribution,   {@code X}, this method returns the largest  {@code x} such that {@code P(X < x) <= p}. <br/> Note that this definition implies: <ul> <li> If there is a minimum value,   {@code m}, with positive probability under (the density of)   {@code X}, then   {@code m - 1} isreturned by  {@code inverseCumulativeProbability(0).}  If there isno such value  {@code m},    {@code Integer.MIN_VALUE} is returned.</li> <li> If there is a maximum value,  {@code M}, such that  {@code P(X < M) = 1}, then   {@code M} is returned by{@code inverseCumulativeProbability(1)}. If there is no such value,   {@code M},   {@code Integer.MAX_VALUE} isreturned. </li> </ul>
 * @param p Cumulative probability.
 * @return the largest {@code x} such that {@code P(X < x) <= p}.
 * @throws MathException if the inverse cumulative probability cannot becomputed due to convergence or other numerical errors.
 * @throws IllegalArgumentException if {@code p} is not between 0 and 1(inclusive).
 */
int inverseCumulativeProbability(double p) throws MathException ;

Fixed version (ground truth):
/** 
 * For this distribution,   {@code X}, this method returns the largest  {@code x} such that {@code P(X <= x) <= p}. <br/> Note that this definition implies: <ul> <li> If there is a minimum value,   {@code m}, with positive probability under (the density of)   {@code X}, then   {@code m - 1} isreturned by  {@code inverseCumulativeProbability(0).}  If there isno such value  {@code m},    {@code Integer.MIN_VALUE} is returned.</li> <li> If there is a maximum value,  {@code M}, such that  {@code P(X <= M) = 1}, then   {@code M} is returned by{@code inverseCumulativeProbability(1)}. If there is no such value,   {@code M},   {@code Integer.MAX_VALUE} isreturned. </li> </ul>
 * @param p Cumulative probability.
 * @return the largest {@code x} such that {@code P(X < x) <= p}.
 * @throws MathException if the inverse cumulative probability cannot becomputed due to convergence or other numerical errors.
 * @throws IllegalArgumentException if {@code p} is not between 0 and 1(inclusive).
 */
int inverseCumulativeProbability(double p) throws MathException ;
Program: 57320
Project: 57320
Buggy source:
/** 
 * For this distribution,   {@code X}, this method returns   {@code P(X < x)}.
 * @param x Value at which the PDF is evaluated.
 * @return PDF for this distribution.
 * @throws MathException if the cumulative probability can not be computeddue to convergence or other numerical errors.
 */
@Override public double cumulativeProbability(int x) throws MathException {
  double ret;
  if (x < 0) {
    ret=0.0;
  }
 else {
    ret=Beta.regularizedBeta(probabilityOfSuccess,numberOfSuccesses,x + 1);
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * For this distribution,   {@code X}, this method returns   {@code P(X <= x)}.
 * @param x Value at which the PDF is evaluated.
 * @return PDF for this distribution.
 * @throws MathException if the cumulative probability can not be computeddue to convergence or other numerical errors.
 */
@Override public double cumulativeProbability(int x) throws MathException {
  double ret;
  if (x < 0) {
    ret=0.0;
  }
 else {
    ret=Beta.regularizedBeta(probabilityOfSuccess,numberOfSuccesses,x + 1);
  }
  return ret;
}
Program: 57321
Project: 57321
Buggy source:
/** 
 * For this distribution,   {@code X}, this method returns the largest  {@code x}, such that   {@code P(X < x) p}. It will return -1 when p = 0 and   {@code Integer.MAX_VALUE} when p = 1.
 * @param p Desired probability.
 * @return the largest {@code x} such that {@code P(X < x) <= p}.
 * @throws MathException if the inverse cumulative probability can not becomputed due to convergence or other numerical errors.
 * @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
 */
@Override public int inverseCumulativeProbability(final double p) throws MathException {
  int ret;
  if (p == 0) {
    ret=-1;
  }
 else   if (p == 1) {
    ret=Integer.MAX_VALUE;
  }
 else {
    ret=super.inverseCumulativeProbability(p);
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * For this distribution,   {@code X}, this method returns the largest  {@code x}, such that   {@code P(X <= x) <= p}. It will return -1 when p = 0 and   {@code Integer.MAX_VALUE} when p = 1.
 * @param p Desired probability.
 * @return the largest {@code x} such that {@code P(X <= x) <= p}.
 * @throws MathException if the inverse cumulative probability can not becomputed due to convergence or other numerical errors.
 * @throws OutOfRangeException if {@code p < 0} or {@code p > 1}.
 */
@Override public int inverseCumulativeProbability(final double p) throws MathException {
  int ret;
  if (p == 0) {
    ret=-1;
  }
 else   if (p == 1) {
    ret=Integer.MAX_VALUE;
  }
 else {
    ret=super.inverseCumulativeProbability(p);
  }
  return ret;
}
Program: 57322
Project: 57322
Buggy source:
/** 
 * Convert the instance into a double.
 * @return a double approximating the instance
 * @see #toSplitDouble()
 */
public double toDouble(){
  if (isInfinite()) {
    if (lessThan(getZero())) {
      return Double.NEGATIVE_INFINITY;
    }
 else {
      return Double.POSITIVE_INFINITY;
    }
  }
  if (isNaN()) {
    return Double.NaN;
  }
  Dfp y=this;
  boolean negate=false;
  if (lessThan(getZero())) {
    y=negate();
    negate=true;
  }
  int exponent=(int)(y.log10() * 3.32);
  if (exponent < 0) {
    exponent--;
  }
  Dfp tempDfp=DfpMath.pow(getTwo(),exponent);
  while (tempDfp.lessThan(y) || tempDfp.equals(y)) {
    tempDfp=tempDfp.multiply(2);
    exponent++;
  }
  exponent--;
  y=y.divide(DfpMath.pow(getTwo(),exponent));
  if (exponent > -1023) {
    y=y.subtract(getOne());
  }
  if (exponent < -1074) {
    return 0;
  }
  if (exponent > 1023) {
    return negate ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
  }
  y=y.multiply(newInstance(4503599627370496l)).rint();
  String str=y.toString();
  str=str.substring(0,str.length() - 1);
  long mantissa=Long.parseLong(str);
  if (mantissa == 4503599627370496L) {
    mantissa=0;
    exponent++;
  }
  if (exponent <= -1023) {
    exponent--;
  }
  while (exponent < -1023) {
    exponent++;
    mantissa>>>=1;
  }
  long bits=mantissa | ((exponent + 1023L) << 52);
  double x=Double.longBitsToDouble(bits);
  if (negate) {
    x=-x;
  }
  return x;
}

Fixed version (ground truth):
/** 
 * Convert the instance into a double.
 * @return a double approximating the instance
 * @see #toSplitDouble()
 */
public double toDouble(){
  if (isInfinite()) {
    if (lessThan(getZero())) {
      return Double.NEGATIVE_INFINITY;
    }
 else {
      return Double.POSITIVE_INFINITY;
    }
  }
  if (isNaN()) {
    return Double.NaN;
  }
  Dfp y=this;
  boolean negate=false;
  int cmp0=compare(this,getZero());
  if (cmp0 == 0) {
    return sign < 0 ? -0.0 : +0.0;
  }
 else   if (cmp0 < 0) {
    y=negate();
    negate=true;
  }
  int exponent=(int)(y.log10() * 3.32);
  if (exponent < 0) {
    exponent--;
  }
  Dfp tempDfp=DfpMath.pow(getTwo(),exponent);
  while (tempDfp.lessThan(y) || tempDfp.equals(y)) {
    tempDfp=tempDfp.multiply(2);
    exponent++;
  }
  exponent--;
  y=y.divide(DfpMath.pow(getTwo(),exponent));
  if (exponent > -1023) {
    y=y.subtract(getOne());
  }
  if (exponent < -1074) {
    return 0;
  }
  if (exponent > 1023) {
    return negate ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
  }
  y=y.multiply(newInstance(4503599627370496l)).rint();
  String str=y.toString();
  str=str.substring(0,str.length() - 1);
  long mantissa=Long.parseLong(str);
  if (mantissa == 4503599627370496L) {
    mantissa=0;
    exponent++;
  }
  if (exponent <= -1023) {
    exponent--;
  }
  while (exponent < -1023) {
    exponent++;
    mantissa>>>=1;
  }
  long bits=mantissa | ((exponent + 1023L) << 52);
  double x=Double.longBitsToDouble(bits);
  if (negate) {
    x=-x;
  }
  return x;
}
Program: 57325
Project: 57325
Buggy source:
/** 
 * Get the occurrence time of the event triggered in the current step.
 * @return occurrence time of the event triggered in the currentstep.
 */
public double getEventTime(){
  return pendingEventTime;
}

Fixed version (ground truth):
/** 
 * Get the occurrence time of the event triggered in the current step.
 * @return occurrence time of the event triggered in the currentstep or positive infinity if no events are triggered
 */
public double getEventTime(){
  return pendingEvent ? pendingEventTime : Double.POSITIVE_INFINITY;
}
Program: 57331
Project: 57331
Buggy source:
/** 
 * Get the previous soft grid point time.
 * @return previous soft grid point time
 * @see #setSoftBounds(double,double)
 */
public double getPreviousTime(){
  return softPreviousTime;
}

Fixed version (ground truth):
/** 
 * Get the previous soft grid point time.
 * @return previous soft grid point time
 * @see #setSoftPreviousTime(double)
 */
public double getPreviousTime(){
  return softPreviousTime;
}
Program: 57332
Project: 57332
Buggy source:
/** 
 * Get the current soft grid point time.
 * @return current soft grid point time
 * @see #setSoftBounds(double,double)
 */
public double getCurrentTime(){
  return softCurrentTime;
}

Fixed version (ground truth):
/** 
 * Get the current soft grid point time.
 * @return current soft grid point time
 * @see #setSoftCurrentTime(double)
 */
public double getCurrentTime(){
  return softCurrentTime;
}
Program: 57334
Project: 57334
Buggy source:
private static void reportError(String message){
  final boolean fatal=false;
  if (fatal) {
    Assert.fail(message);
  }
 else {
    System.out.println(message);
  }
}

Fixed version (ground truth):
private static void reportError(String message){
  final boolean fatal=true;
  if (fatal) {
    Assert.fail(message);
  }
 else {
    System.out.println(message);
  }
}
Program: 57335
Project: 57335
Buggy source:
/** 
 * Create a multi-start optimizer from a single-start optimizer.
 * @param optimizer Single-start optimizer to wrap.
 * @param starts Number of starts to perform (including thefirst one), multi-start is disabled if value is less than or equal to 1.
 * @param generator Random generator to use for restarts.
 */
public MultiStartUnivariateRealOptimizer(final BaseUnivariateRealOptimizer<FUNC> optimizer,final int starts,final RandomGenerator generator){
  this.optimizer=optimizer;
  this.starts=starts;
  this.generator=generator;
}

Fixed version (ground truth):
/** 
 * Create a multi-start optimizer from a single-start optimizer.
 * @param optimizer Single-start optimizer to wrap.
 * @param starts Number of starts to perform, must be >=1. Multi-start is disabled if  {@code starts == 1}.
 * @param generator Random generator to use for restarts.
 * @throws NullArgumentException if {@code optimizer} or {@code generator}is   {@code null}.
 * @throws NotStrictlyPositiveException if {@code starts < 1}.
 */
public MultiStartUnivariateRealOptimizer(final BaseUnivariateRealOptimizer<FUNC> optimizer,final int starts,final RandomGenerator generator){
  if (optimizer == null || generator == null) {
    throw new NullArgumentException();
  }
  if (starts < 1) {
    throw new NotStrictlyPositiveException(starts);
  }
  this.optimizer=optimizer;
  this.starts=starts;
  this.generator=generator;
}
Program: 57336
Project: 57336
Buggy source:
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}
Program: 57337
Project: 57337
Buggy source:
@Override public boolean isSupportLowerBoundInclusive(){
  return true;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportLowerBoundInclusive(){
  return true;
}
Program: 57338
Project: 57338
Buggy source:
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}
Program: 57339
Project: 57339
Buggy source:
/** 
 * {@inheritDoc}For first shape parameter <code>s1</code> and  second shape parameter <code>s2</code>,  the variance is <code>[ s1 * s2 ] / [ (s1 + s2)^2 * (s1 + s2 + 1) ]</code>
 * @return {@inheritDoc}
 */
@Override protected double calculateNumericalVariance(){
  final double alpha=getAlpha();
  final double beta=getBeta();
  final double alphabetasum=alpha + beta;
  return (alpha * beta) / ((alphabetasum * alphabetasum) * (alphabetasum + 1));
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}For first shape parameter <code>s1</code> and  second shape parameter <code>s2</code>,  the variance is <code>[ s1 * s2 ] / [ (s1 + s2)^2 * (s1 + s2 + 1) ]</code>
 * @return {@inheritDoc}
 */
@Override protected double calculateNumericalVariance(){
  final double a=getAlpha();
  final double b=getBeta();
  final double alphabetasum=a + b;
  return (a * b) / ((alphabetasum * alphabetasum) * (alphabetasum + 1));
}
Program: 57340
Project: 57340
Buggy source:
/** 
 * {@inheritDoc}For first shape parameter <code>s1</code> and  second shape parameter <code>s2</code>, the mean is <code>s1 / (s1 + s2)</code>
 * @return {@inheritDoc}
 */
@Override protected double calculateNumericalMean(){
  final double alpha=getAlpha();
  return alpha / (alpha + getBeta());
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}For first shape parameter <code>s1</code> and  second shape parameter <code>s2</code>, the mean is <code>s1 / (s1 + s2)</code>
 * @return {@inheritDoc}
 */
@Override protected double calculateNumericalMean(){
  final double a=getAlpha();
  return a / (a + getBeta());
}
Program: 57341
Project: 57341
Buggy source:
@Override public boolean isSupportLowerBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportLowerBoundInclusive(){
  return false;
}
Program: 57342
Project: 57342
Buggy source:
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}
Program: 57343
Project: 57343
Buggy source:
/** 
 * {@inheritDoc}The variance is  <code>scale^2 * Gamma(1 + (2 / shape)) - mean^2</code>  where <code>Gamma(...)</code> is the Gamma-function
 * @return {@inheritDoc}
 */
@Override protected double calculateNumericalVariance(){
  final double shape=getShape();
  final double scale=getScale();
  final double mean=getNumericalMean();
  return (scale * scale) * FastMath.exp(Gamma.logGamma(1 + (2 / shape))) - (mean * mean);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}The variance is  <code>scale^2 * Gamma(1 + (2 / shape)) - mean^2</code>  where <code>Gamma(...)</code> is the Gamma-function
 * @return {@inheritDoc}
 */
@Override protected double calculateNumericalVariance(){
  final double sh=getShape();
  final double sc=getScale();
  final double mn=getNumericalMean();
  return (sc * sc) * FastMath.exp(Gamma.logGamma(1 + (2 / sh))) - (mn * mn);
}
Program: 57344
Project: 57344
Buggy source:
/** 
 * {@inheritDoc}The mean is <code>scale * Gamma(1 + (1 / shape))</code> where <code>Gamma(...)</code> is the Gamma-function
 * @return {@inheritDoc}
 */
@Override protected double calculateNumericalMean(){
  final double shape=getShape();
  final double scale=getScale();
  return scale * FastMath.exp(Gamma.logGamma(1 + (1 / shape)));
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}The mean is <code>scale * Gamma(1 + (1 / shape))</code> where <code>Gamma(...)</code> is the Gamma-function
 * @return {@inheritDoc}
 */
@Override protected double calculateNumericalMean(){
  final double sh=getShape();
  final double sc=getScale();
  return sc * FastMath.exp(Gamma.logGamma(1 + (1 / sh)));
}
Program: 57345
Project: 57345
Buggy source:
@Override public boolean isSupportLowerBoundInclusive(){
  return true;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportLowerBoundInclusive(){
  return true;
}
Program: 57346
Project: 57346
Buggy source:
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}
Program: 57347
Project: 57347
Buggy source:
@Override public boolean isSupportLowerBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportLowerBoundInclusive(){
  return false;
}
Program: 57348
Project: 57348
Buggy source:
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}
Program: 57349
Project: 57349
Buggy source:
@Override public boolean isSupportLowerBoundInclusive(){
  return true;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportLowerBoundInclusive(){
  return true;
}
Program: 57350
Project: 57350
Buggy source:
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}
Program: 57351
Project: 57351
Buggy source:
@Override public boolean isSupportUpperBoundInclusive(){
  return true;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportUpperBoundInclusive(){
  return true;
}
Program: 57352
Project: 57352
Buggy source:
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}
Program: 57353
Project: 57353
Buggy source:
@Override public boolean isSupportLowerBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportLowerBoundInclusive(){
  return false;
}
Program: 57354
Project: 57354
Buggy source:
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}
Program: 57355
Project: 57355
Buggy source:
/** 
 * {@inheritDoc}For mean parameter <code>k</code>, the variance is <code>k^2</code>
 * @return {@inheritDoc}
 */
@Override protected double calculateNumericalVariance(){
  final double mean=getMean();
  return mean * mean;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}For mean parameter <code>k</code>, the variance is <code>k^2</code>
 * @return {@inheritDoc}
 */
@Override protected double calculateNumericalVariance(){
  final double m=getMean();
  return m * m;
}
Program: 57356
Project: 57356
Buggy source:
@Override public boolean isSupportLowerBoundInclusive(){
  return true;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportLowerBoundInclusive(){
  return true;
}
Program: 57357
Project: 57357
Buggy source:
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}
Program: 57358
Project: 57358
Buggy source:
@Override public boolean isSupportLowerBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportLowerBoundInclusive(){
  return false;
}
Program: 57359
Project: 57359
Buggy source:
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportUpperBoundInclusive(){
  return false;
}
Program: 57360
Project: 57360
Buggy source:
/** 
 * {@inheritDoc}For shape parameter <code>alpha</code> and scale  parameter <code>beta</code>, the variance is <code>alpha * beta^2</code>
 * @return {@inheritDoc}
 */
@Override protected double calculateNumericalVariance(){
  final double beta=getBeta();
  return getAlpha() * beta * beta;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}For shape parameter <code>alpha</code> and scale  parameter <code>beta</code>, the variance is <code>alpha * beta^2</code>
 * @return {@inheritDoc}
 */
@Override protected double calculateNumericalVariance(){
  final double b=getBeta();
  return getAlpha() * b * b;
}
Program: 57361
Project: 57361
Buggy source:
@Override public boolean isSupportLowerBoundInclusive(){
  return true;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isSupportLowerBoundInclusive(){
  return true;
}
Program: 57362
Project: 57362
Buggy source:
/** 
 * Create an   {@link java.lang.RuntimeException} for an internal error.
 * @param cause underlying cause
 * @return an {@link java.lang.RuntimeException} for an internal error
 */
public static RuntimeException createInternalError(final Throwable cause){
  final String argument="String_Node_Str";
  return new RuntimeException(){
    /** 
 * Serializable version identifier. 
 */
    private static final long serialVersionUID=-201865440834027016L;
    /** 
 * {@inheritDoc} 
 */
    @Override public String getMessage(){
      return buildMessage(Locale.US,LocalizedFormats.INTERNAL_ERROR,argument);
    }
    /** 
 * {@inheritDoc} 
 */
    @Override public String getLocalizedMessage(){
      return buildMessage(Locale.getDefault(),LocalizedFormats.INTERNAL_ERROR,argument);
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Create an   {@link java.lang.RuntimeException} for an internal error.
 * @param cause underlying cause
 * @return an {@link java.lang.RuntimeException} for an internal error
 */
public static RuntimeException createInternalError(final Throwable cause){
  final String argument="String_Node_Str";
  return new RuntimeException(cause){
    /** 
 * Serializable version identifier. 
 */
    private static final long serialVersionUID=-201865440834027016L;
    /** 
 * {@inheritDoc} 
 */
    @Override public String getMessage(){
      return buildMessage(Locale.US,LocalizedFormats.INTERNAL_ERROR,argument);
    }
    /** 
 * {@inheritDoc} 
 */
    @Override public String getLocalizedMessage(){
      return buildMessage(Locale.getDefault(),LocalizedFormats.INTERNAL_ERROR,argument);
    }
  }
;
}
Program: 57363
Project: 57363
Buggy source:
/** 
 * Check if instance dimension is equal to some expected value.
 * @param n expected dimension.
 * @exception IllegalArgumentException if the dimension isinconsistent with vector size
 */
protected void checkVectorDimensions(int n) throws DimensionMismatchException {
  int d=getDimension();
  if (d != n) {
    throw new DimensionMismatchException(d,n);
  }
}

Fixed version (ground truth):
/** 
 * Check if instance dimension is equal to some expected value.
 * @param n expected dimension.
 * @throws DimensionMismatchException if the dimension isinconsistent with vector size
 */
protected void checkVectorDimensions(int n) throws DimensionMismatchException {
  int d=getDimension();
  if (d != n) {
    throw new DimensionMismatchException(d,n);
  }
}
Program: 57364
Project: 57364
Buggy source:
/** 
 * @param f Function to optimize.
 * @param goal Goal type ({@link GoalType#MINIMIZE} or{@link GoalType#MAXIMIZE}).
 * @param startPoint Start point.
 */
public RealPointValuePair optimize(final FUNC f,final GoalType goal,double[] startPoint) throws FunctionEvaluationException {
  optima=new RealPointValuePair[starts];
  for (int i=0; i < starts; ++i) {
    try {
      optima[i]=optimizer.optimize(f,goal,(i == 0 ? startPoint : generator.nextVector()));
    }
 catch (    FunctionEvaluationException fee) {
      optima[i]=null;
    }
catch (    ConvergenceException oe) {
      optima[i]=null;
    }
    final int usedEvaluations=optimizer.getEvaluations();
    optimizer.setMaxEvaluations(optimizer.getMaxEvaluations() - usedEvaluations);
    totalEvaluations+=usedEvaluations;
  }
  sortPairs(goal);
  if (optima[0] == null) {
    throw new ConvergenceException(LocalizedFormats.NO_CONVERGENCE_WITH_ANY_START_POINT,starts);
  }
  return optima[0];
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public RealPointValuePair optimize(final FUNC f,final GoalType goal,double[] startPoint) throws FunctionEvaluationException {
  optima=new RealPointValuePair[starts];
  for (int i=0; i < starts; ++i) {
    try {
      optima[i]=optimizer.optimize(f,goal,i == 0 ? startPoint : generator.nextVector());
    }
 catch (    FunctionEvaluationException fee) {
      optima[i]=null;
    }
catch (    ConvergenceException oe) {
      optima[i]=null;
    }
    final int usedEvaluations=optimizer.getEvaluations();
    optimizer.setMaxEvaluations(optimizer.getMaxEvaluations() - usedEvaluations);
    totalEvaluations+=usedEvaluations;
  }
  sortPairs(goal);
  if (optima[0] == null) {
    throw new ConvergenceException(LocalizedFormats.NO_CONVERGENCE_WITH_ANY_START_POINT,starts);
  }
  return optima[0];
}
Program: 57365
Project: 57365
Buggy source:
/** 
 * {@inheritDoc}
 */
public VectorialPointValuePair optimize(final FUNC f,double[] target,double[] weights,double[] startPoint) throws FunctionEvaluationException {
  optima=new VectorialPointValuePair[starts];
  for (int i=0; i < starts; ++i) {
    try {
      optima[i]=optimizer.optimize(f,target,weights,(i == 0 ? startPoint : generator.nextVector()));
    }
 catch (    FunctionEvaluationException fee) {
      optima[i]=null;
    }
catch (    ConvergenceException oe) {
      optima[i]=null;
    }
    final int usedEvaluations=optimizer.getEvaluations();
    optimizer.setMaxEvaluations(optimizer.getMaxEvaluations() - usedEvaluations);
    totalEvaluations+=usedEvaluations;
  }
  sortPairs(target,weights);
  if (optima[0] == null) {
    throw new ConvergenceException(LocalizedFormats.NO_CONVERGENCE_WITH_ANY_START_POINT,starts);
  }
  return optima[0];
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public VectorialPointValuePair optimize(final FUNC f,double[] target,double[] weights,double[] startPoint) throws FunctionEvaluationException {
  optima=new VectorialPointValuePair[starts];
  for (int i=0; i < starts; ++i) {
    try {
      optima[i]=optimizer.optimize(f,target,weights,i == 0 ? startPoint : generator.nextVector());
    }
 catch (    FunctionEvaluationException fee) {
      optima[i]=null;
    }
catch (    ConvergenceException oe) {
      optima[i]=null;
    }
    final int usedEvaluations=optimizer.getEvaluations();
    optimizer.setMaxEvaluations(optimizer.getMaxEvaluations() - usedEvaluations);
    totalEvaluations+=usedEvaluations;
  }
  sortPairs(target,weights);
  if (optima[0] == null) {
    throw new ConvergenceException(LocalizedFormats.NO_CONVERGENCE_WITH_ANY_START_POINT,starts);
  }
  return optima[0];
}
Program: 57366
Project: 57366
Buggy source:
/** 
 * Optimize an objective function.
 * @param f Objective function.
 * @param goalType Type of optimization goal: either{@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}.
 * @param startPoint Start point for optimization.
 * @return the point/value pair giving the optimal value for objectivefunction.
 * @throws FunctionEvaluationException if the objective function throws oneduring the search.
 * @throws DimensionMismatchException if the start point dimension is wrong.
 * @throws TooManyEvaluationsException if the maximal number of evaluations isexceeded.
 * @throws NullArgumentException if any argument is {@code null}.
 */
RealPointValuePair optimize(FUNC f,GoalType goalType,double[] startPoint) throws FunctionEvaluationException ;

Fixed version (ground truth):
/** 
 * Optimize an objective function.
 * @param f Objective function.
 * @param goalType Type of optimization goal: either{@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}.
 * @param startPoint Start point for optimization.
 * @return the point/value pair giving the optimal value for objectivefunction.
 * @throws org.apache.commons.math.FunctionEvaluationException if theobjective function throws one during the search.
 * @throws org.apache.commons.math.exception.DimensionMismatchException if the start point dimension is wrong.
 * @throws org.apache.commons.math.exception.TooManyEvaluationsException if the maximal number of evaluations is exceeded.
 * @throws org.apache.commons.math.exception.NullArgumentException ifany argument is  {@code null}.
 */
RealPointValuePair optimize(FUNC f,GoalType goalType,double[] startPoint) throws FunctionEvaluationException ;
Program: 57367
Project: 57367
Buggy source:
/** 
 * Optimize an objective function. Optimization is considered to be a weighted least-squares minimization. The cost function to be minimized is <code>&sum;weight<sub>i</sub>(objective<sub>i</sub> - target<sub>i</sub>)<sup>2</sup></code>
 * @param f Objective function.
 * @param target Target value for the objective functions at optimum.
 * @param weight Weights for the least squares cost computation.
 * @param startPoint Start point for optimization.
 * @return the point/value pair giving the optimal value for objectivefunction.
 * @throws FunctionEvaluationException if the objective function throws oneduring the search.
 * @throws DimensionMismatchException if the start point dimension is wrong.
 * @throws TooManyEvaluationsException if the maximal number of evaluations isexceeded.
 * @throws NullArgumentException if any argument is {@code null}.
 */
VectorialPointValuePair optimize(FUNC f,double[] target,double[] weight,double[] startPoint) throws FunctionEvaluationException ;

Fixed version (ground truth):
/** 
 * Optimize an objective function. Optimization is considered to be a weighted least-squares minimization. The cost function to be minimized is <code>&sum;weight<sub>i</sub>(objective<sub>i</sub> - target<sub>i</sub>)<sup>2</sup></code>
 * @param f Objective function.
 * @param target Target value for the objective functions at optimum.
 * @param weight Weights for the least squares cost computation.
 * @param startPoint Start point for optimization.
 * @return the point/value pair giving the optimal value for objectivefunction.
 * @throws FunctionEvaluationException if the objective function throws oneduring the search.
 * @throws org.apache.commons.math.exception.DimensionMismatchException if the start point dimension is wrong.
 * @throws org.apache.commons.math.exception.TooManyEvaluationsException if the maximal number of evaluations is exceeded.
 * @throws org.apache.commons.math.exception.NullArgumentException ifany argument is  {@code null}.
 */
VectorialPointValuePair optimize(FUNC f,double[] target,double[] weight,double[] startPoint) throws FunctionEvaluationException ;
Program: 57368
Project: 57368
Buggy source:
/** 
 * Check if the optimization algorithm has converged considering the last two points. This method may be called several time from the same algorithm iteration with different points. This can be detected by checking the iteration number at each call if needed. Each time this method is called, the previous and current point correspond to points with the same role at each iteration, so they can be compared. As an example, simplex-based algorithms call this method for all points of the simplex, not only for the best or worst ones.
 * @param iteration Index of current iteration
 * @param previous Best point in the previous iteration.
 * @param current Best point in the current iteration.
 * @return {@code true} if the algorithm has converged.
 */
public boolean converged(final int iteration,final RealPointValuePair previous,final RealPointValuePair current){
  final double p=previous.getValue();
  final double c=current.getValue();
  final double difference=FastMath.abs(p - c);
  final double size=FastMath.max(FastMath.abs(p),FastMath.abs(c));
  return (difference <= size * getRelativeThreshold() || difference <= getAbsoluteThreshold());
}

Fixed version (ground truth):
/** 
 * Check if the optimization algorithm has converged considering the last two points. This method may be called several time from the same algorithm iteration with different points. This can be detected by checking the iteration number at each call if needed. Each time this method is called, the previous and current point correspond to points with the same role at each iteration, so they can be compared. As an example, simplex-based algorithms call this method for all points of the simplex, not only for the best or worst ones.
 * @param iteration Index of current iteration
 * @param previous Best point in the previous iteration.
 * @param current Best point in the current iteration.
 * @return {@code true} if the algorithm has converged.
 */
public boolean converged(final int iteration,final RealPointValuePair previous,final RealPointValuePair current){
  final double p=previous.getValue();
  final double c=current.getValue();
  final double difference=FastMath.abs(p - c);
  final double size=FastMath.max(FastMath.abs(p),FastMath.abs(c));
  return difference <= size * getRelativeThreshold() || difference <= getAbsoluteThreshold();
}
Program: 57369
Project: 57369
Buggy source:
/** 
 * Evaluate all the non-evaluated points of the simplex.
 * @param comparator Comparator to use to sort simplex vertices from best to worst.
 * @throws FunctionEvaluationException if no value can be computed for the parameters.
 * @throws TooManyEvaluationsException if the maximal number of evaluations is exceeded.
 */
protected void evaluateSimplex(final Comparator<RealPointValuePair> comparator) throws FunctionEvaluationException {
  for (int i=0; i < simplex.length; ++i) {
    final RealPointValuePair vertex=simplex[i];
    final double[] point=vertex.getPointRef();
    if (Double.isNaN(vertex.getValue())) {
      simplex[i]=new RealPointValuePair(point,computeObjectiveValue(point),false);
    }
  }
  Arrays.sort(simplex,comparator);
}

Fixed version (ground truth):
/** 
 * Evaluate all the non-evaluated points of the simplex.
 * @param comparator Comparator to use to sort simplex vertices from best to worst.
 * @throws FunctionEvaluationException if no value can be computed for the parameters.
 * @throws org.apache.commons.math.exception.TooManyEvaluationsException if the maximal number of evaluations is exceeded.
 */
protected void evaluateSimplex(final Comparator<RealPointValuePair> comparator) throws FunctionEvaluationException {
  for (int i=0; i < simplex.length; ++i) {
    final RealPointValuePair vertex=simplex[i];
    final double[] point=vertex.getPointRef();
    if (Double.isNaN(vertex.getValue())) {
      simplex[i]=new RealPointValuePair(point,computeObjectiveValue(point),false);
    }
  }
  Arrays.sort(simplex,comparator);
}
Program: 57370
Project: 57370
Buggy source:
/** 
 * {@inheritDoc} 
 */
protected RealPointValuePair doOptimize() throws FunctionEvaluationException {
  final double[] startPoint=getStartPoint();
  if ((startConfiguration == null) || (startConfiguration.length != startPoint.length)) {
    final double[] unit=new double[startPoint.length];
    Arrays.fill(unit,1.0);
    setStartConfiguration(unit);
  }
  final boolean isMinim=(getGoalType() == GoalType.MINIMIZE);
  final Comparator<RealPointValuePair> comparator=new Comparator<RealPointValuePair>(){
    public int compare(    final RealPointValuePair o1,    final RealPointValuePair o2){
      final double v1=o1.getValue();
      final double v2=o2.getValue();
      return isMinim ? Double.compare(v1,v2) : Double.compare(v2,v1);
    }
  }
;
  buildSimplex(startPoint);
  evaluateSimplex(comparator);
  RealPointValuePair[] previous=new RealPointValuePair[simplex.length];
  int iteration=0;
  final ConvergenceChecker<RealPointValuePair> checker=getConvergenceChecker();
  while (true) {
    if (iteration > 0) {
      boolean converged=true;
      for (int i=0; i < simplex.length; ++i) {
        converged&=checker.converged(iteration,previous[i],simplex[i]);
      }
      if (converged) {
        return simplex[0];
      }
    }
    System.arraycopy(simplex,0,previous,0,simplex.length);
    iterateSimplex(comparator);
    ++iteration;
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
protected RealPointValuePair doOptimize() throws FunctionEvaluationException {
  final double[] startPoint=getStartPoint();
  if ((startConfiguration == null) || (startConfiguration.length != startPoint.length)) {
    final double[] unit=new double[startPoint.length];
    Arrays.fill(unit,1.0);
    setStartConfiguration(unit);
  }
  final boolean isMinim=getGoalType() == GoalType.MINIMIZE;
  final Comparator<RealPointValuePair> comparator=new Comparator<RealPointValuePair>(){
    public int compare(    final RealPointValuePair o1,    final RealPointValuePair o2){
      final double v1=o1.getValue();
      final double v2=o2.getValue();
      return isMinim ? Double.compare(v1,v2) : Double.compare(v2,v1);
    }
  }
;
  buildSimplex(startPoint);
  evaluateSimplex(comparator);
  RealPointValuePair[] previous=new RealPointValuePair[simplex.length];
  int iteration=0;
  final ConvergenceChecker<RealPointValuePair> checker=getConvergenceChecker();
  while (true) {
    if (iteration > 0) {
      boolean converged=true;
      for (int i=0; i < simplex.length; ++i) {
        converged&=checker.converged(iteration,previous[i],simplex[i]);
      }
      if (converged) {
        return simplex[0];
      }
    }
    System.arraycopy(simplex,0,previous,0,simplex.length);
    iterateSimplex(comparator);
    ++iteration;
  }
}
Program: 57371
Project: 57371
Buggy source:
/** 
 * Compute the next simplex of the algorithm.
 * @param comparator Comparator to use to sort simplex vertices from best to worst.
 * @throws FunctionEvaluationException if the function cannot be evaluated atsome point.
 * @throws TooManyEvaluationsException if the algorithm fails to converge.
 * @throws DimensionMismatchException if the start point dimension is wrong.
 */
protected abstract void iterateSimplex(final Comparator<RealPointValuePair> comparator) throws FunctionEvaluationException ;

Fixed version (ground truth):
/** 
 * Compute the next simplex of the algorithm.
 * @param comparator Comparator to use to sort simplex vertices from best to worst.
 * @throws FunctionEvaluationException if the function cannot be evaluated atsome point.
 * @throws org.apache.commons.math.exception.TooManyEvaluationsException ifthe algorithm fails to converge.
 * @throws org.apache.commons.math.exception.DimensionMismatchException ifthe start point dimension is wrong.
 */
protected abstract void iterateSimplex(final Comparator<RealPointValuePair> comparator) throws FunctionEvaluationException ;