nus-yam/ex-repair huggingface dataset:
Program: 144016
Project: 144016
Buggy source:
public static Builder write(OutputStream outputStream,List<Rule> rules,ProbabilisticSoftLogicPredicateManager predicateManager,LogicManager<Integer,Double> logicManager,VariableType<Integer> variableType,GroundingMode groundingMode) throws IOException {
  ObjectOutputStream objectOutputStream=new ObjectOutputStream(outputStream);
  objectOutputStream.writeObject(predicateManager);
  ProbabilisticSoftLogicPredicateManager.IdWeights observedIdsAndWeights=predicateManager.getAllObservedWeights();
  ProbabilisticSoftLogicProblem.Builder builder=new ProbabilisticSoftLogicProblem.Builder(observedIdsAndWeights.Ids,observedIdsAndWeights.Weights,predicateManager.size() - observedIdsAndWeights.Ids.length);
  try {
    ProblemSerializer serializer=new ProblemSerializer(outputStream,builder);
    Rule.addGroundingsToBuilder(rules,serializer,predicateManager,logicManager,variableType,groundingMode);
    serializer.addRule(new int[]{-1},new int[]{-1},new boolean[]{false},new boolean[]{false},Double.NaN,Double.NaN);
  }
 catch (  UnsupportedOperationException e) {
    if (e.getMessage() != null && e.getMessage().equals("String_Node_Str")) {
      throw (IOException)e.getCause();
    }
  }
  return builder;
}

Fixed version (ground truth):
public static Builder write(OutputStream outputStream,List<Rule> rules,ProbabilisticSoftLogicPredicateManager predicateManager,LogicManager<Integer,Double> logicManager,VariableType<Integer> variableType,GroundingMode groundingMode) throws IOException {
  ObjectOutputStream objectOutputStream=new ObjectOutputStream(outputStream);
  objectOutputStream.writeObject(predicateManager);
  ProbabilisticSoftLogicPredicateManager.IdWeights observedIdsAndWeights=predicateManager.getAllObservedWeights();
  int[] observedIndexes=new int[logicManager.getNumberOfGroundedPredicates()];
  double[] observedWeights=new double[logicManager.getNumberOfGroundedPredicates()];
  for (int index=0; index < logicManager.getNumberOfGroundedPredicates(); index++) {
    observedIndexes[index]=(int)logicManager.getGroundedPredicates().get(index).getIdentifier();
    observedWeights[index]=(double)logicManager.getGroundedPredicates().get(index).getValue();
  }
  ProbabilisticSoftLogicProblem.Builder builder=new ProbabilisticSoftLogicProblem.Builder(observedIndexes,observedWeights,predicateManager.size() - observedIdsAndWeights.Ids.length);
  try {
    ProblemSerializer serializer=new ProblemSerializer(outputStream,builder);
    Rule.addGroundingsToBuilder(rules,serializer,predicateManager,logicManager,variableType,groundingMode);
  }
 catch (  UnsupportedOperationException e) {
    if (e.getMessage() != null && e.getMessage().equals("String_Node_Str")) {
      throw (IOException)e.getCause();
    }
  }
  return builder;
}
Program: 144019
Project: 144019
Buggy source:
public GroundedPredicate<T,R> getGroundedPredicate(Predicate<T> predicate,List<T> argumentAssignments){
  if (!predicateGroundings.containsKey(predicate.getIdentifier()))   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  if (!predicateGroundings.get(predicate.getIdentifier()).containsKey(argumentAssignments))   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  return predicateGroundings.get(predicate.getIdentifier()).get(argumentAssignments);
}

Fixed version (ground truth):
public GroundedPredicate<T,R> getGroundedPredicate(Predicate<T> predicate,List<T> argumentAssignments){
  if (!groundedPredicates.containsKey(predicate.getIdentifier()))   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  if (!groundedPredicates.get(predicate.getIdentifier()).containsKey(argumentAssignments))   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  return groundedPredicates.get(predicate.getIdentifier()).get(argumentAssignments);
}
Program: 144020
Project: 144020
Buggy source:
/** 
 * Note that this method returns null if there is no value stored for the provided arguments assignment.
 * @param predicate
 * @param argumentAssignments
 * @return
 */
public R getPredicateAssignmentTruthValue(Predicate<T> predicate,List<T> argumentAssignments){
  if (!predicateGroundings.containsKey(predicate.getIdentifier()))   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  if (!predicateGroundings.get(predicate.getIdentifier()).containsKey(argumentAssignments))   if (closedPredicateIdentifiers.contains(predicate.getIdentifier()))   return logic.falseValue();
 else   return null;
  return predicateGroundings.get(predicate.getIdentifier()).get(argumentAssignments).getValue();
}

Fixed version (ground truth):
/** 
 * Note that this method returns null if there is no value stored for the provided arguments assignment.
 * @param predicate
 * @param argumentAssignments
 * @return
 */
public R getPredicateAssignmentTruthValue(Predicate<T> predicate,List<T> argumentAssignments){
  if (!groundedPredicates.containsKey(predicate.getIdentifier()))   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  if (!groundedPredicates.get(predicate.getIdentifier()).containsKey(argumentAssignments))   if (closedPredicateIdentifiers.contains(predicate.getIdentifier()))   return logic.falseValue();
 else   return null;
  return groundedPredicates.get(predicate.getIdentifier()).get(argumentAssignments).getValue();
}
Program: 144021
Project: 144021
Buggy source:
public GroundedPredicate<T,R> addGroundedPredicate(Predicate<T> predicate,List<T> argumentAssignments,R value){
  if (!predicateGroundings.containsKey(predicate.getIdentifier()))   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  if (predicateGroundings.get(predicate.getIdentifier()).containsKey(argumentAssignments)) {
    GroundedPredicate<T,R> groundedPredicate=predicateGroundings.get(predicate.getIdentifier()).get(argumentAssignments);
    if (!groundedPredicate.getValue().equals(value))     throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
 else {
      return groundedPredicate;
    }
  }
 else {
    GroundedPredicate<T,R> groundedPredicate=new GroundedPredicate<>(newPredicateGroundingIdentifier++,predicate,argumentAssignments,value);
    predicateGroundings.get(predicate.getIdentifier()).put(argumentAssignments,groundedPredicate);
    return groundedPredicate;
  }
}

Fixed version (ground truth):
public GroundedPredicate<T,R> addGroundedPredicate(Predicate<T> predicate,List<T> argumentAssignments,R value){
  if (!groundedPredicates.containsKey(predicate.getIdentifier()))   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  if (groundedPredicates.get(predicate.getIdentifier()).containsKey(argumentAssignments)) {
    GroundedPredicate<T,R> groundedPredicate=groundedPredicates.get(predicate.getIdentifier()).get(argumentAssignments);
    if (!groundedPredicate.getValue().equals(value))     throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
 else {
      return groundedPredicate;
    }
  }
 else {
    GroundedPredicate<T,R> groundedPredicate=new GroundedPredicate<>(newPredicateGroundingIdentifier++,predicate,argumentAssignments,value);
    groundedPredicates.get(predicate.getIdentifier()).put(argumentAssignments,groundedPredicate);
    return groundedPredicate;
  }
}
Program: 144022
Project: 144022
Buggy source:
public Predicate<T> addPredicate(String name,List<VariableType<T>> argumentTypes,boolean closed){
  Predicate<T> predicate=new Predicate<>(newPredicateIdentifier,argumentTypes).setName(name);
  predicates.put(newPredicateIdentifier,predicate);
  predicateGroundings.put(newPredicateIdentifier,new HashMap<>());
  if (closed)   closedPredicateIdentifiers.add(newPredicateIdentifier);
  newPredicateIdentifier++;
  return predicate;
}

Fixed version (ground truth):
public Predicate<T> addPredicate(String name,List<VariableType<T>> argumentTypes,boolean closed){
  Predicate<T> predicate=new Predicate<>(newPredicateIdentifier,argumentTypes).setName(name);
  predicates.put(newPredicateIdentifier,predicate);
  groundedPredicates.put(newPredicateIdentifier,new HashMap<>());
  if (closed)   closedPredicateIdentifiers.add(newPredicateIdentifier);
  newPredicateIdentifier++;
  return predicate;
}
Program: 144024
Project: 144024
Buggy source:
public static void addGroundingsToBuilderByExtension(List<Rule> rules,ProbabilisticSoftLogicProblem.Builder builder,ProbabilisticSoftLogicPredicateManager predicateManager){
  HashSet<Integer> newPredicates=new HashSet<>();
  List<HashSet<String>> groundingsAlreadyAdded=new ArrayList<>();
  for (int i=0; i < rules.size(); ++i) {
    groundingsAlreadyAdded.add(new HashSet<>());
  }
  for (  String predicateName : predicateManager.getPredicateNames()) {
    for (    int id : predicateManager.getIdsForPredicateName(predicateName)) {
      newPredicates.add(id);
    }
  }
  while (!newPredicates.isEmpty()) {
    HashSet<Integer> currentPredicates=newPredicates;
    newPredicates=new HashSet<>();
    for (    int predicateId : currentPredicates) {
      for (int indexRule=0; indexRule < rules.size(); ++indexRule) {
        rules.get(indexRule).extendGroundingsAndAddToBuilder(predicateManager.getPredicateFromId(predicateId),builder,predicateManager,groundingsAlreadyAdded.get(indexRule),newPredicates);
      }
    }
  }
}

Fixed version (ground truth):
public static void addGroundingsToBuilderByExtension(List<Rule> rules,ProbabilisticSoftLogicProblem.Builder builder,ProbabilisticSoftLogicPredicateManager predicateManager){
  HashSet<Integer> newPredicates=new HashSet<>();
  List<HashSet<String>> groundingsAlreadyAdded=new ArrayList<>();
  for (int i=0; i < rules.size(); ++i) {
    groundingsAlreadyAdded.add(new HashSet<>());
  }
  for (  String predicateName : predicateManager.getPredicateNames()) {
    for (    int id : predicateManager.getIdsForPredicateName(predicateName)) {
      newPredicates.add(id);
    }
  }
  while (!newPredicates.isEmpty()) {
    HashSet<Integer> currentPredicates=newPredicates;
    newPredicates=new HashSet<>();
    for (int indexRule=0; indexRule < rules.size(); ++indexRule) {
      for (      int predicateId : currentPredicates) {
        rules.get(indexRule).extendGroundingsAndAddToBuilder(predicateManager.getPredicateFromId(predicateId),builder,predicateManager,groundingsAlreadyAdded.get(indexRule),newPredicates);
      }
    }
  }
}
Program: 144028
Project: 144028
Buggy source:
private ProbabilisticSoftLogicProblem(Builder builder){
  externalToInternalIndexesMapping=HashBiMap.create(builder.externalToInternalIndexesMapping);
  SumFunction.Builder sumFunctionBuilder=new SumFunction.Builder(externalToInternalIndexesMapping.size());
  for (  Builder.FunctionTerm function : builder.functionTerms) {
    MaxFunction.Builder maxFunctionBuilder=new MaxFunction.Builder(externalToInternalIndexesMapping.size());
    maxFunctionBuilder.addConstantTerm(0);
    maxFunctionBuilder.addFunctionTerm(function.linearFunction);
    sumFunctionBuilder.addTerm(new ProbabilisticSoftLogicSumFunctionTerm(maxFunctionBuilder.build(),function.power,function.weight),function.variableIndexes);
  }
  objectiveFunction=new ProbabilisticSoftLogicFunction(sumFunctionBuilder);
  constraints=ImmutableSet.copyOf(builder.constraints);
  subProblemSelectionMethod=builder.subProblemSelectionMethod;
  numberOfSubProblemSamples=builder.numberOfSubProblemSamples;
  subProblemCholeskyFactors=new CholeskyDecomposition[objectiveFunction.getNumberOfTerms()];
  int temporaryIndex=0;
  for (  AbstractFunction term : objectiveFunction.getTerms()) {
    ProbabilisticSoftLogicSumFunctionTerm objectiveTerm=(ProbabilisticSoftLogicSumFunctionTerm)term;
    Vector coefficients=objectiveTerm.getLinearFunction().getA();
    subProblemCholeskyFactors[temporaryIndex++]=new CholeskyDecomposition(coefficients.outer(coefficients).multiply(2 * objectiveTerm.weight).add(Matrix.generateIdentityMatrix(coefficients.size())));
  }
}

Fixed version (ground truth):
private ProbabilisticSoftLogicProblem(Builder builder){
  externalToInternalIndexesMapping=HashBiMap.create(builder.externalToInternalIndexesMapping);
  SumFunction.Builder sumFunctionBuilder=new SumFunction.Builder(externalToInternalIndexesMapping.size());
  for (  Builder.FunctionTerm function : builder.functionTerms) {
    MaxFunction.Builder maxFunctionBuilder=new MaxFunction.Builder(externalToInternalIndexesMapping.size());
    maxFunctionBuilder.addConstantTerm(0);
    maxFunctionBuilder.addFunctionTerm(function.linearFunction);
    sumFunctionBuilder.addTerm(new ProbabilisticSoftLogicSumFunctionTerm(maxFunctionBuilder.build(),function.power,function.weight),function.variableIndexes);
  }
  objectiveFunction=new ProbabilisticSoftLogicFunction(sumFunctionBuilder);
  constraints=ImmutableSet.copyOf(builder.constraints);
  subProblemSelectionMethod=builder.subProblemSelectionMethod;
  numberOfSubProblemSamples=builder.numberOfSubProblemSamples;
  for (int subProblemIndex=0; subProblemIndex < objectiveFunction.getNumberOfTerms(); subProblemIndex++) {
    ProbabilisticSoftLogicSumFunctionTerm objectiveTerm=(ProbabilisticSoftLogicSumFunctionTerm)objectiveFunction.getTerm(subProblemIndex);
    Vector coefficients=objectiveTerm.getLinearFunction().getA();
    if (objectiveTerm.getPower() == 2 && coefficients.size() > 2)     subProblemCholeskyFactors.put(subProblemIndex,new CholeskyDecomposition(coefficients.outer(coefficients).multiply(2 * objectiveTerm.weight).add(Matrix.generateIdentityMatrix(coefficients.size()))));
  }
}
Program: 144029
Project: 144029
Buggy source:
public static int[] sampleWithReplacement(int[] array,double[] probabilities,int numberOfSamples){
  if (array.length != probabilities.length)   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  double[] cumulativeDensityFunction=new double[probabilities.length];
  cumulativeDensityFunction[0]=probabilities[0];
  for (int index=1; index < probabilities.length; index++)   cumulativeDensityFunction[index]=cumulativeDensityFunction[index - 1] + probabilities[index];
  int[] resultArray=new int[numberOfSamples];
  for (int index=0; index < numberOfSamples; index++) {
    double number=random.nextDouble();
    int elementIndex=Arrays.binarySearch(cumulativeDensityFunction,number);
    if (elementIndex < 0) {
      elementIndex=-elementIndex - 1;
      if (elementIndex == probabilities.length)       elementIndex--;
    }
    resultArray[index]=array[elementIndex];
  }
  return resultArray;
}

Fixed version (ground truth):
/** 
 * Randomly samples a specified number of elements from an integer array with replacement, while assigning a probability proportional to the provided weight for each element of that array. This method does not modify the provided array.
 * @param array           The array from which we randomly sample elements.
 * @param weights         The weights to use for each element in the provided array.
 * @param numberOfSamples The number of elements to sample from the given array.
 * @return                  A new integer array containing the sampled elements.
 * @throws IllegalArgumentException    The length of the array with the elements must match the length of the arraywith the weights of those elements.
 */
public static int[] sampleWithReplacement(int[] array,double[] weights,int numberOfSamples){
  if (array.length != weights.length)   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  double weightsSum=weights[0];
  for (int index=1; index < weights.length; index++)   weightsSum+=weights[index];
  double[] cumulativeDensityFunction=new double[weights.length];
  cumulativeDensityFunction[0]=weights[0] / weightsSum;
  for (int index=1; index < weights.length; index++)   cumulativeDensityFunction[index]=cumulativeDensityFunction[index - 1] + (weights[index] / weightsSum);
  int[] resultArray=new int[numberOfSamples];
  for (int index=0; index < numberOfSamples; index++) {
    double number=random.nextDouble();
    int elementIndex=Arrays.binarySearch(cumulativeDensityFunction,number);
    if (elementIndex < 0) {
      elementIndex=-elementIndex - 1;
      if (elementIndex == weights.length)       elementIndex--;
    }
    resultArray[index]=array[elementIndex];
  }
  return resultArray;
}
Program: 144030
Project: 144030
Buggy source:
/** 
 * Randomly samples a specified number of elements from a list without replacement. Note that this method modifies the provided list (i.e., it shuffles the order of its elements).
 * @param list            The list from which we randomly sample elements.
 * @param numberOfSamples The number of elements to sample from the given list.
 * @param random          The random number generator to use for the shuffling.
 * @return                  A new {@link java.util.ArrayList} containing the sampled elements.
 */
public static <T>List<T> sampleWithoutReplacement(List<T> list,int numberOfSamples,Random random){
  shuffle(list,random);
  return new ArrayList<>(list.subList(0,numberOfSamples));
}

Fixed version (ground truth):
/** 
 * Randomly samples a specified number of elements from an integer array without replacement, while assigning a probability proportional to the provided weight for each element of that array. This method does not modify the provided array.
 * @param array           The array from which we randomly sample elements.
 * @param weights         The weights to use for each element in the provided array.
 * @param numberOfSamples The number of elements to sample from the given array.
 * @return                  A new integer array containing the sampled elements.
 * @throws IllegalArgumentException    The length of the array with the elements must match the length of the arraywith the weights of those elements.
 */
public static int[] sampleWithoutReplacement(int[] array,double[] weights,int numberOfSamples){
  if (array.length != weights.length)   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  PriorityQueue<WeightedElement> priorityQueue=new PriorityQueue<>(array.length,(element1,element2) -> (int)Math.signum(element2.weight - element1.weight));
  for (int index=0; index < array.length; index++)   priorityQueue.add(new WeightedElement(array[index],Math.pow(random.nextDouble(),1 / weights[index])));
  int[] resultArray=new int[numberOfSamples];
  for (int index=0; index < numberOfSamples; index++)   resultArray[index]=priorityQueue.poll().element;
  return resultArray;
}
Program: 144031
Project: 144031
Buggy source:
private static void solveProbabilisticSoftLogicSubProblem(ConsensusAlternatingDirectionsMethodOfMultipliersSolver.SubProblem subProblem){
  ProbabilisticSoftLogicSumFunctionTerm objectiveTerm=(ProbabilisticSoftLogicSumFunctionTerm)subProblem.objectiveTerm;
  if (objectiveTerm.getLinearFunction().getValue(subProblem.variables) > 0) {
    subProblem.variables.set(new NewtonSolver.Builder(new ConsensusAlternatingDirectionsMethodOfMultipliersSolver.SubProblemObjectiveFunction(objectiveTerm.getSubProblemObjectiveFunction(),subProblem.consensusVariables,subProblem.multipliers,subProblem.augmentedLagrangianParameter),subProblem.variables).build().solve());
    if (objectiveTerm.getLinearFunction().getValue(subProblem.variables) < 0) {
      subProblem.variables.set(objectiveTerm.getLinearFunction().projectToHyperplane(subProblem.consensusVariables));
    }
  }
}

Fixed version (ground truth):
private static void solveProbabilisticSoftLogicSubProblem(ConsensusAlternatingDirectionsMethodOfMultipliersSolver.SubProblem subProblem){
  ProbabilisticSoftLogicSumFunctionTerm objectiveTerm=(ProbabilisticSoftLogicSumFunctionTerm)subProblem.objectiveTerm;
  if (objectiveTerm.getLinearFunction().getValue(subProblem.variables) > 0) {
    subProblem.variables.set(new NewtonSolver.Builder(new ConsensusAlternatingDirectionsMethodOfMultipliersSolver.SubProblemObjectiveFunction(objectiveTerm.getSubProblemObjectiveFunction(),subProblem.consensusVariables,subProblem.multipliers,subProblem.augmentedLagrangianParameter),subProblem.variables).lineSearch(new NoLineSearch(1)).maximumNumberOfIterations(1).build().solve());
    if (objectiveTerm.getLinearFunction().getValue(subProblem.variables) < 0) {
      subProblem.variables.set(objectiveTerm.getLinearFunction().projectToHyperplane(subProblem.consensusVariables));
    }
  }
}
Program: 144032
Project: 144032
Buggy source:
@Override public Matrix computeHessian(Vector point){
  if (power > 1) {
    Vector a=linearFunction.computeGradient(point);
    return Matrix.generateDiagonalMatrix(a.multElementwise(a).getDenseArray()).multiply(weight * power * (power - 1)* Math.pow(linearFunction.computeValue(point),power - 2));
  }
 else {
    return new Matrix(point.size(),point.size());
  }
}

Fixed version (ground truth):
@Override public Matrix computeHessian(Vector point){
  if (power > 1) {
    Vector a=linearFunction.computeGradient(point);
    return a.outer(a).multiply(weight * power * (power - 1)* Math.pow(linearFunction.computeValue(point),power - 2));
  }
 else {
    return new Matrix(point.size(),point.size());
  }
}
Program: 144033
Project: 144033
Buggy source:
@Override protected Vector computeGradient(Vector point) throws NonSmoothFunctionException {
  return subProblemObjectiveFunction.getGradient(point).add(point.sub(consensusVariables).add(lagrangeMultipliers.div(augmentedLagrangianParameter)).mult(augmentedLagrangianParameter));
}

Fixed version (ground truth):
@Override protected Vector computeGradient(Vector point) throws NonSmoothFunctionException {
  return subProblemObjectiveFunction.getGradient(point).add(point.sub(consensusVariables).add(lagrangeMultipliers.div(penaltyParameter)).mult(penaltyParameter));
}
Program: 144035
Project: 144035
Buggy source:
@Override public boolean checkTerminationConditions(){
  if (super.checkTerminationConditions())   return true;
  if (currentIteration > 0) {
    if (checkForPrimalResidualConvergence || checkForPrimalAndDualResidualConvergence) {
      if (penaltyParameterSettingMethod != PenaltyParameterSettingMethod.ADAPTIVE) {
        primalResidualSquared=0;
        for (int subProblemIndex=0; subProblemIndex < objective.getNumberOfTerms(); subProblemIndex++) {
          primalResidualSquared+=variableCopies.get(subProblemIndex).sub(currentPoint.get(objective.getTermVariables(subProblemIndex))).norm(VectorNorm.L2_SQUARED);
        }
        for (int constraintIndex=0; constraintIndex < constraints.size(); constraintIndex++) {
          primalResidualSquared+=variableCopies.get(objective.getNumberOfTerms() + constraintIndex).sub(currentPoint.get(constraintsVariablesIndexes.get(constraintIndex))).norm(VectorNorm.L2_SQUARED);
        }
      }
      primalResidualConverged=primalResidualSquared <= primalResidualTolerance;
    }
    if (checkForDualResidualConvergence || checkForPrimalAndDualResidualConvergence) {
      if (penaltyParameterSettingMethod != PenaltyParameterSettingMethod.ADAPTIVE)       dualResidualSquared=objective.getNumberOfTerms() * Math.pow(penaltyParameter,2) * currentPoint.sub(previousPoint).norm(VectorNorm.L2_SQUARED);
      dualResidualConverged=dualResidualSquared <= dualResidualTolerance;
    }
    return (checkForPrimalResidualConvergence && primalResidualConverged) || (checkForDualResidualConvergence && dualResidualConverged) || (checkForPrimalAndDualResidualConvergence && primalResidualConverged && dualResidualConverged);
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean checkTerminationConditions(){
  if (super.checkTerminationConditions())   return true;
  if (currentIteration > 0 && checkForPrimalAndDualResidualConvergence) {
    primalTolerance=absoluteTolerance + relativeTolerance * Math.max(Math.sqrt(primalToleranceSquaredTerms.sum()),Math.sqrt(currentPoint.map(x -> x * x).multElementwise(variableCopiesCounts).sum()));
    dualTolerance=absoluteTolerance + relativeTolerance * Math.sqrt(dualToleranceSquaredTerms.sum());
    primalResidualConverged=primalResidual <= primalTolerance;
    dualResidualConverged=dualResidual <= dualTolerance;
    return primalResidualConverged && dualResidualConverged;
  }
 else {
    return false;
  }
}
Program: 144036
Project: 144036
Buggy source:
private void processConstraint(int constraintIndex,int[] variableIndexes,Vector variableCopiesSum,int numberOfObjectiveTerms){
  Vector variables=variableCopies.get(numberOfObjectiveTerms + constraintIndex);
  Vector multipliers=lagrangeMultipliers.get(numberOfObjectiveTerms + constraintIndex);
  Vector consensusVariables=Vectors.build(variableIndexes.length,currentPoint.type());
  consensusVariables.set(currentPoint.get(variableIndexes));
  multipliers.addInPlace(variables.sub(consensusVariables).mult(penaltyParameter));
  try {
    variables.set(constraints.get(constraintIndex).project(consensusVariables));
  }
 catch (  SingularMatrixException e) {
    logger.error("String_Node_Str");
  }
  Vector termPoint=Vectors.build(currentPoint.size(),currentPoint.type());
  termPoint.set(variableIndexes,variables.add(multipliers.div(penaltyParameter)));
synchronized (lock) {
    variableCopiesSum.addInPlace(termPoint);
  }
}

Fixed version (ground truth):
private void processConstraint(int constraintIndex,int[] variableIndexes,Vector variableCopiesSum,int numberOfObjectiveTerms){
  Vector variables=variableCopies.get(numberOfObjectiveTerms + constraintIndex);
  Vector multipliers=lagrangeMultipliers.get(numberOfObjectiveTerms + constraintIndex);
  Vector consensusVariables=Vectors.build(variableIndexes.length,currentPoint.type());
  consensusVariables.set(currentPoint.get(variableIndexes));
  multipliers.addInPlace(variables.sub(consensusVariables).mult(penaltyParameter));
  try {
    variables.set(constraints.get(constraintIndex).project(consensusVariables));
  }
 catch (  SingularMatrixException e) {
    logger.error("String_Node_Str");
  }
  Vector termPoint=Vectors.build(currentPoint.size(),currentPoint.type());
  termPoint.set(variableIndexes,variables.add(multipliers.div(penaltyParameter)));
synchronized (lock) {
    variableCopiesSum.addInPlace(termPoint);
  }
  if (penaltyParameterSettingMethod == PenaltyParameterSettingMethod.ADAPTIVE || checkForPrimalAndDualResidualConvergence) {
    primalResidualSquaredTerms.set(numberOfObjectiveTerms + constraintIndex,variables.sub(consensusVariables).norm(VectorNorm.L2_SQUARED));
    if (checkForPrimalAndDualResidualConvergence) {
      primalToleranceSquaredTerms.set(numberOfObjectiveTerms + constraintIndex,variables.norm(VectorNorm.L2_SQUARED));
      dualToleranceSquaredTerms.set(numberOfObjectiveTerms + constraintIndex,multipliers.norm(VectorNorm.L2_SQUARED));
    }
  }
}
Program: 144037
Project: 144037
Buggy source:
@Override public void printTerminationMessage(){
  super.printTerminationMessage();
  if (primalResidualConverged)   logger.info("String_Node_Str",DECIMAL_FORMAT.format(primalResidualSquared),DECIMAL_FORMAT.format(primalResidualTolerance));
  if (dualResidualConverged)   logger.info("String_Node_Str",DECIMAL_FORMAT.format(dualResidualSquared),DECIMAL_FORMAT.format(dualResidualTolerance));
}

Fixed version (ground truth):
@Override public void printTerminationMessage(){
  super.printTerminationMessage();
  if (primalResidualConverged)   logger.info("String_Node_Str",DECIMAL_FORMAT.format(primalResidual),DECIMAL_FORMAT.format(primalTolerance));
  if (dualResidualConverged)   logger.info("String_Node_Str",DECIMAL_FORMAT.format(dualResidual),DECIMAL_FORMAT.format(dualTolerance));
}
Program: 144038
Project: 144038
Buggy source:
@Override protected double computeValue(Vector point){
  return subProblemObjectiveFunction.getValue(point) + augmentedLagrangianParameter * Math.pow(point.sub(consensusVariables).add(lagrangeMultipliers.div(augmentedLagrangianParameter)).norm(VectorNorm.L2_FAST),2) / 2;
}

Fixed version (ground truth):
@Override protected double computeValue(Vector point){
  return subProblemObjectiveFunction.getValue(point) + penaltyParameter * Math.pow(point.sub(consensusVariables).add(lagrangeMultipliers.div(penaltyParameter)).norm(VectorNorm.L2_FAST),2) / 2;
}
Program: 144039
Project: 144039
Buggy source:
private void processSubProblem(int subProblemIndex,int[] variableIndexes,Vector variableCopiesSum){
  Vector variables=variableCopies.get(subProblemIndex);
  Vector multipliers=lagrangeMultipliers.get(subProblemIndex);
  Vector consensusVariables=Vectors.build(variableIndexes.length,currentPoint.type());
  consensusVariables.set(currentPoint.get(variableIndexes));
  multipliers.addInPlace(variables.sub(consensusVariables).mult(penaltyParameter));
  variables.set(consensusVariables.sub(multipliers.div(penaltyParameter)));
  SubProblem subProblem=new SubProblem(variables,multipliers,consensusVariables,objective.getTerm(subProblemIndex),penaltyParameter);
  if (subProblemSolver != null)   subProblemSolver.accept(subProblem);
 else   solveSubProblem(subProblem);
  Vector termPoint=Vectors.build(currentPoint.size(),currentPoint.type());
  termPoint.set(variableIndexes,variables.add(multipliers.div(penaltyParameter)));
synchronized (lock) {
    variableCopiesSum.addInPlace(termPoint);
  }
}

Fixed version (ground truth):
private void processSubProblem(int subProblemIndex,int[] variableIndexes,Vector variableCopiesSum){
  Vector variables=variableCopies.get(subProblemIndex);
  Vector multipliers=lagrangeMultipliers.get(subProblemIndex);
  Vector consensusVariables=Vectors.build(variableIndexes.length,currentPoint.type());
  consensusVariables.set(currentPoint.get(variableIndexes));
  multipliers.addInPlace(variables.sub(consensusVariables).mult(penaltyParameter));
  variables.set(consensusVariables.sub(multipliers.div(penaltyParameter)));
  SubProblem subProblem=new SubProblem(variables,multipliers,consensusVariables,objective.getTerm(subProblemIndex),penaltyParameter);
  if (subProblemSolver != null)   subProblemSolver.accept(subProblem);
 else   solveSubProblem(subProblem);
  Vector termPoint=Vectors.build(currentPoint.size(),currentPoint.type());
  termPoint.set(variableIndexes,variables.add(multipliers.div(penaltyParameter)));
synchronized (lock) {
    variableCopiesSum.addInPlace(termPoint);
  }
  if (penaltyParameterSettingMethod == PenaltyParameterSettingMethod.ADAPTIVE || checkForPrimalAndDualResidualConvergence) {
    primalResidualSquaredTerms.set(subProblemIndex,variables.sub(consensusVariables).norm(VectorNorm.L2_SQUARED));
    if (checkForPrimalAndDualResidualConvergence) {
      primalToleranceSquaredTerms.set(subProblemIndex,variables.norm(VectorNorm.L2_SQUARED));
      dualToleranceSquaredTerms.set(subProblemIndex,multipliers.norm(VectorNorm.L2_SQUARED));
    }
  }
}
Program: 144040
Project: 144040
Buggy source:
@Override protected Matrix computeHessian(Vector point) throws NonSmoothFunctionException {
  return subProblemObjectiveFunction.getHessian(point).add(Matrix.generateIdentityMatrix(point.size()).multiply(augmentedLagrangianParameter));
}

Fixed version (ground truth):
@Override protected Matrix computeHessian(Vector point) throws NonSmoothFunctionException {
  return subProblemObjectiveFunction.getHessian(point).add(Matrix.generateIdentityMatrix(point.size()).multiply(penaltyParameter));
}
Program: 144041
Project: 144041
Buggy source:
public SubProblemObjectiveFunction(AbstractFunction subProblemObjectiveFunction,Vector consensusVariables,Vector lagrangeMultipliers,double augmentedLagrangianParameter){
  this.subProblemObjectiveFunction=subProblemObjectiveFunction;
  this.consensusVariables=consensusVariables;
  this.lagrangeMultipliers=lagrangeMultipliers;
  this.augmentedLagrangianParameter=augmentedLagrangianParameter;
}

Fixed version (ground truth):
public SubProblemObjectiveFunction(AbstractFunction subProblemObjectiveFunction,Vector consensusVariables,Vector lagrangeMultipliers,double penaltyParameter){
  this.subProblemObjectiveFunction=subProblemObjectiveFunction;
  this.consensusVariables=consensusVariables;
  this.lagrangeMultipliers=lagrangeMultipliers;
  this.penaltyParameter=penaltyParameter;
}
Program: 144043
Project: 144043
Buggy source:
@Override public void handleBoxConstraints(){
  if (lowerBound != null)   if (lowerBound.size() > 1)   currentPoint.maxElementwise(lowerBound);
 else   currentPoint.maxElementwise(lowerBound.get(0));
  if (upperBound != null)   if (upperBound.size() > 1)   currentPoint.minElementwise(upperBound);
 else   currentPoint.minElementwise(upperBound.get(0));
}

Fixed version (ground truth):
@Override public void handleBoxConstraints(){
  if (lowerBound != null)   if (lowerBound.size() > 1)   currentPoint.maxElementwiseInPlace(lowerBound);
 else   currentPoint.maxElementwiseInPlace(lowerBound.get(0));
  if (upperBound != null)   if (upperBound.size() > 1)   currentPoint.minElementwiseInPlace(upperBound);
 else   currentPoint.minElementwiseInPlace(upperBound.get(0));
}
Program: 144044
Project: 144044
Buggy source:
private void solveSubProblem(SubProblem subProblem){
  subProblem.variables.set(0,subProblem.variables.size() - 1,new QuasiNewtonSolver.Builder(new SubProblemObjectiveFunction(subProblem.objectiveTerm,subProblem.consensusVariables,subProblem.multipliers,augmentedLagrangianParameter),subProblem.variables).build().solve());
}

Fixed version (ground truth):
private void solveSubProblem(SubProblem subProblem){
  subProblem.variables.set(new QuasiNewtonSolver.Builder(new SubProblemObjectiveFunction(subProblem.objectiveTerm,subProblem.consensusVariables,subProblem.multipliers,augmentedLagrangianParameter),subProblem.variables).build().solve());
}
Program: 144045
Project: 144045
Buggy source:
private NewtonSolver(AbstractBuilder<?> builder){
  super(builder);
  if (builder.linearEqualityConstraints.size() > 0) {
    linearEqualityConstraint=builder.linearEqualityConstraints.get(0);
    for (int constraintIndex=1; constraintIndex < builder.linearEqualityConstraints.size(); constraintIndex++)     linearEqualityConstraint=linearEqualityConstraint.append(builder.linearEqualityConstraints.get(constraintIndex));
  }
  try {
    currentPoint=linearEqualityConstraint.project(currentPoint);
    currentGradient=objective.getGradient(currentPoint);
    previousPoint=currentPoint;
    previousGradient=currentGradient;
  }
 catch (  SingularMatrixException e) {
    throw new IllegalArgumentException("String_Node_Str");
  }
catch (  NonSmoothFunctionException e) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  currentObjectiveValue=objective.getValue(currentPoint);
}

Fixed version (ground truth):
private NewtonSolver(AbstractBuilder<?> builder){
  super(builder);
  if (builder.linearEqualityConstraints.size() > 0) {
    linearEqualityConstraint=builder.linearEqualityConstraints.get(0);
    for (int constraintIndex=1; constraintIndex < builder.linearEqualityConstraints.size(); constraintIndex++)     linearEqualityConstraint=linearEqualityConstraint.append(builder.linearEqualityConstraints.get(constraintIndex));
    try {
      currentPoint=linearEqualityConstraint.project(currentPoint);
      currentGradient=objective.getGradient(currentPoint);
    }
 catch (    SingularMatrixException e) {
      throw new IllegalArgumentException("String_Node_Str");
    }
catch (    NonSmoothFunctionException e) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    previousPoint=currentPoint;
    previousGradient=currentGradient;
    currentObjectiveValue=objective.getValue(currentPoint);
  }
}
Program: 144046
Project: 144046
Buggy source:
@Override public Vector project(Vector point) throws SingularMatrixException {
  if (linearSystemMatrixSingularValueDecomposition == null) {
    Matrix linearSystemMatrix=new Matrix(A.getRowDimension() + A.getColumnDimension(),A.getRowDimension() + A.getColumnDimension());
    linearSystemMatrix.setSubMatrix(0,A.getColumnDimension() - 1,0,A.getColumnDimension() - 1,Matrix.generateIdentityMatrix(A.getColumnDimension()));
    linearSystemMatrix.setSubMatrix(0,A.getColumnDimension() - 1,A.getColumnDimension(),linearSystemMatrix.getColumnDimension() - 1,A.transpose());
    linearSystemMatrix.setSubMatrix(A.getColumnDimension(),linearSystemMatrix.getRowDimension() - 1,0,A.getColumnDimension() - 1,A);
    linearSystemMatrixSingularValueDecomposition=new QRDecomposition(linearSystemMatrix);
  }
  Vector linearSystemVector=Vectors.build(point.size() + A.getRowDimension(),point.type());
  linearSystemVector.set(0,point.size() - 1,point);
  linearSystemVector.set(point.size(),linearSystemVector.size() - 1,b);
  return linearSystemMatrixSingularValueDecomposition.solve(linearSystemVector).get(0,point.size() - 1);
}

Fixed version (ground truth):
@Override public Vector project(Vector point) throws SingularMatrixException {
  if (linearSystemMatrixQRDecomposition == null) {
    Matrix linearSystemMatrix=new Matrix(A.getRowDimension() + A.getColumnDimension(),A.getRowDimension() + A.getColumnDimension());
    linearSystemMatrix.setSubMatrix(0,A.getColumnDimension() - 1,0,A.getColumnDimension() - 1,Matrix.generateIdentityMatrix(A.getColumnDimension()));
    linearSystemMatrix.setSubMatrix(0,A.getColumnDimension() - 1,A.getColumnDimension(),linearSystemMatrix.getColumnDimension() - 1,A.transpose());
    linearSystemMatrix.setSubMatrix(A.getColumnDimension(),linearSystemMatrix.getRowDimension() - 1,0,A.getColumnDimension() - 1,A);
    linearSystemMatrixQRDecomposition=new QRDecomposition(linearSystemMatrix);
  }
  Vector linearSystemVector=Vectors.build(point.size() + A.getRowDimension(),point.type());
  linearSystemVector.set(0,point.size() - 1,point);
  linearSystemVector.set(point.size(),linearSystemVector.size() - 1,b);
  return linearSystemMatrixQRDecomposition.solve(linearSystemVector).get(0,point.size() - 1);
}
Program: 144047
Project: 144047
Buggy source:
@Override protected double computeValue(Vector point){
  double value=0;
  for (int term=0; term < functionTerms.size(); term++) {
    Vector termPoint=Vectors.build(functionTermVariables.get(term).length,point.type());
    termPoint.set(0,functionTermVariables.get(term).length - 1,point.get(functionTermVariables.get(term)));
    value=Math.max(value,functionTerms.get(term).computeValue(termPoint));
  }
  for (  Double constantTerm : constantTerms)   value=Math.max(value,constantTerm);
  return value;
}

Fixed version (ground truth):
@Override protected double computeValue(Vector point){
  double value=-Double.MAX_VALUE;
  for (int term=0; term < functionTerms.size(); term++) {
    Vector termPoint=Vectors.build(functionTermVariables.get(term).length,point.type());
    termPoint.set(0,functionTermVariables.get(term).length - 1,point.get(functionTermVariables.get(term)));
    value=Math.max(value,functionTerms.get(term).computeValue(termPoint));
  }
  for (  Double constantTerm : constantTerms)   value=Math.max(value,constantTerm);
  return value;
}
Program: 144048
Project: 144048
Buggy source:
@Override public void updatePoint(){
  currentPoint=previousPoint.add(currentDirection.mult(currentStepSize));
  if (lowerBound != null)   if (lowerBound.size() > 1)   currentPoint.maxElementwise(lowerBound);
 else   currentPoint.maxElementwise(lowerBound.get(0));
  if (upperBound != null)   if (upperBound.size() > 1)   currentPoint.minElementwise(upperBound);
 else   currentPoint.minElementwise(upperBound.get(0));
}

Fixed version (ground truth):
@Override public void updatePoint(){
  currentPoint=previousPoint.add(currentDirection.mult(currentStepSize));
  if (lowerBound != null)   if (lowerBound.size() > 1)   currentPoint.maxElementwiseInPlace(lowerBound);
 else   currentPoint.maxElementwiseInPlace(lowerBound.get(0));
  if (upperBound != null)   if (upperBound.size() > 1)   currentPoint.minElementwiseInPlace(upperBound);
 else   currentPoint.minElementwiseInPlace(upperBound.get(0));
}
Program: 144049
Project: 144049
Buggy source:
@Override public void handleBoxConstraints(){
  if (lowerBound != null)   if (lowerBound.size() > 1)   currentPoint.maxElementwise(lowerBound);
 else   currentPoint.maxElementwise(lowerBound.get(0));
  if (upperBound != null)   if (upperBound.size() > 1)   currentPoint.minElementwise(upperBound);
 else   currentPoint.minElementwise(upperBound.get(0));
}

Fixed version (ground truth):
@Override public void handleBoxConstraints(){
  if (lowerBound != null)   if (lowerBound.size() > 1)   currentPoint.maxElementwiseInPlace(lowerBound);
 else   currentPoint.maxElementwiseInPlace(lowerBound.get(0));
  if (upperBound != null)   if (upperBound.size() > 1)   currentPoint.minElementwiseInPlace(upperBound);
 else   currentPoint.minElementwiseInPlace(upperBound.get(0));
}
Program: 144050
Project: 144050
Buggy source:
private void solveSubProblem(SubProblem subProblem){
  subProblem.variables.set(0,subProblem.variables.size() - 1,new NewtonSolver.Builder(new SubProblemObjectiveFunction(subProblem.objectiveTerm,subProblem.consensusVariables,subProblem.multipliers,augmentedLagrangianParameter),subProblem.variables).build().solve());
}

Fixed version (ground truth):
private void solveSubProblem(SubProblem subProblem){
  subProblem.variables.set(0,subProblem.variables.size() - 1,new QuasiNewtonSolver.Builder(new SubProblemObjectiveFunction(subProblem.objectiveTerm,subProblem.consensusVariables,subProblem.multipliers,augmentedLagrangianParameter),subProblem.variables).build().solve());
}
Program: 144051
Project: 144051
Buggy source:
@Test public void testSaxpyPlusConstant(){
  DenseVector vector1=new DenseVector(new double[]{0.53,0.32,0.91,0.05,0.01,5.63});
  DenseVector vector2=new DenseVector(new double[]{0.33,0.64,1.97,0.56,0.04});
  double alpha=2.5;
  DenseVector expectedVector=new DenseVector(new double[]{0.53 + alpha * 0.33,0.32 + alpha * 0.64,0.91 + alpha * 1.97,0.05 + alpha * 0.56,0.01 + alpha * 0.04,5.63});
  DenseVector actualVector=vector1.saxpyPlusConstant(alpha,vector2);
  Assert.assertTrue(expectedVector.equals(actualVector));
}

Fixed version (ground truth):
@Test public void testSaxpyPlusConstant(){
  DenseVector vector1=new DenseVector(new double[]{0.53,0.32,0.91,0.05,0.01,5.63});
  DenseVector vector2=new DenseVector(new double[]{0.33,0.64,1.97,0.56,0.04});
  double alpha=2.5;
  DenseVector expectedVector=new DenseVector(new double[]{0.53 + alpha * 0.33,0.32 + alpha * 0.64,0.91 + alpha * 1.97,0.05 + alpha * 0.56,0.01 + alpha * 0.04,5.63 + alpha});
  DenseVector actualVector=vector1.saxpyPlusConstant(alpha,vector2);
  Assert.assertTrue(expectedVector.equals(actualVector));
}
Program: 144052
Project: 144052
Buggy source:
private void projectOnConstraint(int constraintIndex,int numberOfObjectiveTerms,int[] variableIndexes,Vector variableCopiesSum){
  Vector variables=variableCopies.get(numberOfObjectiveTerms + constraintIndex);
  Vector multipliers=lagrangeMultipliers.get(numberOfObjectiveTerms + constraintIndex);
  Vector consensusVariables=Vectors.build(variableIndexes.length,currentPoint.type());
  consensusVariables.set(0,variableIndexes.length - 1,currentPoint.get(variableIndexes));
  multipliers.addInPlace(variables.sub(consensusVariables).mult(augmentedLagrangianParameter));
  try {
    variables=constraints.get(constraintIndex).project(consensusVariables);
  }
 catch (  NonSymmetricMatrixException e) {
    logger.error("String_Node_Str");
  }
catch (  NonPositiveDefiniteMatrixException e) {
    logger.error("String_Node_Str");
  }
  Vector termPoint=Vectors.build(currentPoint.size(),currentPoint.type());
  termPoint.set(variableIndexes,variables.add(multipliers.div(augmentedLagrangianParameter)));
  variableCopiesSum.addInPlace(termPoint);
}

Fixed version (ground truth):
private void projectOnConstraint(int constraintIndex,int numberOfObjectiveTerms,int[] variableIndexes,Vector variableCopiesSum){
  Vector variables=variableCopies.get(numberOfObjectiveTerms + constraintIndex);
  Vector multipliers=lagrangeMultipliers.get(numberOfObjectiveTerms + constraintIndex);
  Vector consensusVariables=Vectors.build(variableIndexes.length,currentPoint.type());
  consensusVariables.set(0,variableIndexes.length - 1,currentPoint.get(variableIndexes));
  multipliers.addInPlace(variables.sub(consensusVariables).mult(augmentedLagrangianParameter));
  try {
    variables.set(0,variables.size() - 1,constraints.get(constraintIndex).project(consensusVariables));
  }
 catch (  NonSymmetricMatrixException e) {
    logger.error("String_Node_Str");
  }
catch (  NonPositiveDefiniteMatrixException e) {
    logger.error("String_Node_Str");
  }
  Vector termPoint=Vectors.build(currentPoint.size(),currentPoint.type());
  termPoint.set(variableIndexes,variables.add(multipliers.div(augmentedLagrangianParameter)));
synchronized (lock) {
    variableCopiesSum.addInPlace(termPoint);
  }
}
Program: 144053
Project: 144053
Buggy source:
private void solveSubProblem(int subProblemIndex,int[] variableIndexes,Vector variableCopiesSum){
  Vector variables=variableCopies.get(subProblemIndex);
  Vector multipliers=lagrangeMultipliers.get(subProblemIndex);
  Vector consensusVariables=Vectors.build(variableIndexes.length,currentPoint.type());
  consensusVariables.set(0,variableIndexes.length - 1,currentPoint.get(variableIndexes));
  multipliers.addInPlace(variables.sub(consensusVariables).mult(augmentedLagrangianParameter));
  variables.set(0,variables.size() - 1,consensusVariables.sub(multipliers.div(augmentedLagrangianParameter)));
  if (objective.getValue(variables,subProblemIndex) > 0) {
    variables=new NewtonSolver.Builder(new SubProblemObjectiveFunction(objective.getTerm(subProblemIndex),consensusVariables,multipliers),variables).build().solve();
    if (objective.getValue(variables,subProblemIndex) < 0) {
      variables=((LinearFunction)objective.getTerm(subProblemIndex)).projectToHyperplane(consensusVariables);
    }
  }
  Vector termPoint=Vectors.build(currentPoint.size(),currentPoint.type());
  termPoint.set(variableIndexes,variables.add(multipliers.div(augmentedLagrangianParameter)));
  variableCopiesSum.addInPlace(termPoint);
}

Fixed version (ground truth):
private void solveSubProblem(int subProblemIndex,int[] variableIndexes,Vector variableCopiesSum){
  Vector variables=variableCopies.get(subProblemIndex);
  Vector multipliers=lagrangeMultipliers.get(subProblemIndex);
  Vector consensusVariables=Vectors.build(variableIndexes.length,currentPoint.type());
  consensusVariables.set(0,variableIndexes.length - 1,currentPoint.get(variableIndexes));
  multipliers.addInPlace(variables.sub(consensusVariables).mult(augmentedLagrangianParameter));
  variables.set(0,variables.size() - 1,consensusVariables.sub(multipliers.div(augmentedLagrangianParameter)));
  if (objective.getValue(variables,subProblemIndex) > 0) {
    variables.set(0,variables.size() - 1,new NewtonSolver.Builder(new SubProblemObjectiveFunction(objective.getTerm(subProblemIndex),consensusVariables,multipliers),variables).build().solve());
    if (objective.getValue(variables,subProblemIndex) < 0) {
      variables.set(0,variables.size() - 1,((LinearFunction)objective.getTerm(subProblemIndex)).projectToHyperplane(consensusVariables));
    }
  }
  Vector termPoint=Vectors.build(currentPoint.size(),currentPoint.type());
  termPoint.set(variableIndexes,variables.add(multipliers.div(augmentedLagrangianParameter)));
synchronized (lock) {
    variableCopiesSum.addInPlace(termPoint);
  }
}