Program: 31753
Project: 31753
Buggy source:
@Override public LogisticRegressionParams doCompute(MasterContext<LogisticRegressionParams,LogisticRegressionParams> context){
  if (isInitialized.compareAndSet(false,true)) {
    if (!context.isFirstIteration()) {
      LogisticRegressionParams lastMasterResult=context.getMasterResult();
      if (lastMasterResult != null && lastMasterResult.getParameters() != null) {
        this.weights=lastMasterResult.getParameters();
        return lastMasterResult;
      }
 else {
        return initWeights();
      }
    }
  }
  if (context.isFirstIteration()) {
    if (this.isContinuousEnabled) {
      return initOrRecoverParams(context);
    }
 else {
      return initWeights();
    }
  }
 else {
    double[] gradients=new double[this.inputNum + 1];
    double trainError=0.0d, testError=0d;
    long trainSize=0, testSize=0;
    for (    LogisticRegressionParams param : context.getWorkerResults()) {
      if (param != null) {
        for (int i=0; i < gradients.length; i++) {
          gradients[i]+=param.getParameters()[i];
        }
        trainError+=param.getTrainError();
        testError+=param.getTestError();
        trainSize+=param.getTrainSize();
        testSize+=param.getTestSize();
      }
    }
    if (this.weightCalculator == null) {
      this.weightCalculator=new Weight(weights.length,trainSize,learningRate,this.propagation,this.regularizedConstant,RegulationLevel.to(this.validParams.get(CommonConstants.REG_LEVEL_KEY)));
    }
 else {
      this.weightCalculator.setNumTrainSize(trainSize);
    }
    double[] oldWeights=Arrays.copyOf(this.weights,this.weights.length);
    this.weights=this.weightCalculator.calculateWeights(this.weights,gradients);
    double finalTrainError=trainError / trainSize;
    double finalTestError=testError / testSize;
    LOG.info("String_Node_Str",context.getCurrentIteration(),finalTrainError,finalTestError);
    LogisticRegressionParams lrParams=new LogisticRegressionParams(weights,finalTrainError,finalTestError,trainSize,testSize);
    boolean vtTriggered=false;
    if (validationTolerance > 0d) {
      double weightSumSquare=0d;
      double diffWeightSumSquare=0d;
      for (int i=0; i < weights.length; i++) {
        weightSumSquare+=Math.pow(weights[i],2);
        diffWeightSumSquare+=Math.pow(weights[i] - oldWeights[i],2);
      }
      if (Math.pow(diffWeightSumSquare,0.5) < this.validationTolerance * Math.max(Math.pow(weightSumSquare,0.5),1d)) {
        LOG.info("String_Node_Str",Math.pow(diffWeightSumSquare,0.5),Math.pow(weightSumSquare,0.5),validationTolerance);
        vtTriggered=true;
      }
    }
    if (finalTestError < this.bestValidationError) {
      this.bestValidationError=finalTestError;
    }
    if (judger.judge(finalTrainError + finalTestError / 2,convergenceThreshold) || vtTriggered) {
      LOG.info("String_Node_Str",context.getCurrentIteration());
      lrParams.setHalt(true);
    }
 else {
      LOG.debug("String_Node_Str",context.getCurrentIteration());
    }
    return lrParams;
  }
}

Fixed version (ground truth):
@Override public LogisticRegressionParams doCompute(MasterContext<LogisticRegressionParams,LogisticRegressionParams> context){
  if (isInitialized.compareAndSet(false,true)) {
    if (!context.isFirstIteration()) {
      LogisticRegressionParams lastMasterResult=context.getMasterResult();
      if (lastMasterResult != null && lastMasterResult.getParameters() != null) {
        this.weights=lastMasterResult.getParameters();
        return lastMasterResult;
      }
 else {
        return initWeights();
      }
    }
  }
  if (context.isFirstIteration()) {
    if (this.isContinuousEnabled) {
      return initOrRecoverParams(context);
    }
 else {
      return initWeights();
    }
  }
 else {
    double[] gradients=new double[this.inputNum + 1];
    double trainError=0.0d, testError=0d;
    long trainSize=0, testSize=0;
    for (    LogisticRegressionParams param : context.getWorkerResults()) {
      if (param != null) {
        for (int i=0; i < gradients.length; i++) {
          gradients[i]+=param.getParameters()[i];
        }
        trainError+=param.getTrainError();
        testError+=param.getTestError();
        trainSize+=param.getTrainSize();
        testSize+=param.getTestSize();
      }
    }
    if (this.weightCalculator == null) {
      this.weightCalculator=new Weight(weights.length,trainSize,learningRate,this.propagation,this.regularizedConstant,RegulationLevel.to(this.validParams.get(CommonConstants.REG_LEVEL_KEY)),0d);
    }
 else {
      this.weightCalculator.setNumTrainSize(trainSize);
    }
    double[] oldWeights=Arrays.copyOf(this.weights,this.weights.length);
    this.weights=this.weightCalculator.calculateWeights(this.weights,gradients);
    double finalTrainError=trainError / trainSize;
    double finalTestError=testError / testSize;
    LOG.info("String_Node_Str",context.getCurrentIteration(),finalTrainError,finalTestError);
    LogisticRegressionParams lrParams=new LogisticRegressionParams(weights,finalTrainError,finalTestError,trainSize,testSize);
    boolean vtTriggered=false;
    if (validationTolerance > 0d) {
      double weightSumSquare=0d;
      double diffWeightSumSquare=0d;
      for (int i=0; i < weights.length; i++) {
        weightSumSquare+=Math.pow(weights[i],2);
        diffWeightSumSquare+=Math.pow(weights[i] - oldWeights[i],2);
      }
      if (Math.pow(diffWeightSumSquare,0.5) < this.validationTolerance * Math.max(Math.pow(weightSumSquare,0.5),1d)) {
        LOG.info("String_Node_Str",Math.pow(diffWeightSumSquare,0.5),Math.pow(weightSumSquare,0.5),validationTolerance);
        vtTriggered=true;
      }
    }
    if (finalTestError < this.bestValidationError) {
      this.bestValidationError=finalTestError;
    }
    if (judger.judge(finalTrainError + finalTestError / 2,convergenceThreshold) || vtTriggered) {
      LOG.info("String_Node_Str",context.getCurrentIteration());
      lrParams.setHalt(true);
    }
 else {
      LOG.debug("String_Node_Str",context.getCurrentIteration());
    }
    return lrParams;
  }
}