nus-yam/ex-repair huggingface dataset:
Program: 107759
Project: 107759
Buggy source:
/** 
 * Returns a risk summary
 * @param threshold Acceptable highest probability of re-identification for a single record
 * @param suppressed
 * @return
 */
public RiskModelSampleSummary getSampleBasedRiskSummary(double threshold,String suppressed){
  progress.value=0;
  return new RiskModelSampleSummary(handle,identifiers,threshold,suppressed,stop,progress);
}

Fixed version (ground truth):
/** 
 * Returns a risk summary
 * @param threshold Acceptable highest probability of re-identification for a single record. Please note that thisthreshold may be exceeded by up to 1% due to rounding issues.
 * @param suppressed
 * @return
 */
public RiskModelSampleSummary getSampleBasedRiskSummary(double threshold,String suppressed){
  progress.value=0;
  return new RiskModelSampleSummary(handle,identifiers,threshold,suppressed,stop,progress);
}
Program: 107760
Project: 107760
Buggy source:
/** 
 * Returns a risk summary, using wildcard matching
 * @param threshold Acceptable highest probability of re-identification for a single record
 * @param wildcard String to interpret as a wildcard
 * @return
 * @throws InterruptedException 
 */
public RiskModelSampleWildcard getSampleBasedRiskSummaryWildcard(double threshold,String wildcard) throws InterruptedException {
  try {
    return parent.getSampleBasedRiskSummaryWildcard(threshold,wildcard);
  }
 catch (  ComputationInterruptedException e) {
    throw new InterruptedException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Returns a risk summary, using wildcard matching
 * @param threshold Acceptable highest probability of re-identification for a single record. Please note that thisthreshold may be exceeded by up to 1% due to rounding issues.
 * @param wildcard String to interpret as a wildcard
 * @return
 * @throws InterruptedException 
 */
public RiskModelSampleWildcard getSampleBasedRiskSummaryWildcard(double threshold,String wildcard) throws InterruptedException {
  try {
    return parent.getSampleBasedRiskSummaryWildcard(threshold,wildcard);
  }
 catch (  ComputationInterruptedException e) {
    throw new InterruptedException("String_Node_Str");
  }
}
Program: 107761
Project: 107761
Buggy source:
/** 
 * Returns a risk summary
 * @param threshold Acceptable highest probability of re-identification for a single record
 * @param suppressed
 * @return
 * @throws InterruptedException 
 */
public RiskModelSampleSummary getSampleBasedRiskSummary(double threshold,String suppressed) throws InterruptedException {
  try {
    return parent.getSampleBasedRiskSummary(threshold,suppressed);
  }
 catch (  ComputationInterruptedException e) {
    throw new InterruptedException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Returns a risk summary
 * @param threshold Acceptable highest probability of re-identification for a single record. Please note that thisthreshold may be exceeded by up to 1% due to rounding issues.
 * @param suppressed
 * @return
 * @throws InterruptedException 
 */
public RiskModelSampleSummary getSampleBasedRiskSummary(double threshold,String suppressed) throws InterruptedException {
  try {
    return parent.getSampleBasedRiskSummary(threshold,suppressed);
  }
 catch (  ComputationInterruptedException e) {
    throw new InterruptedException("String_Node_Str");
  }
}
Program: 107762
Project: 107762
Buggy source:
@Override protected boolean isFulfilled(HashGroupifyDistribution distribution){
  boolean result=1.0d / (double)distribution.getAverageClassSize() <= getRiskThreshold();
  if (highestRisk == null || !result) {
    return result;
  }
  double fraction=0d;
  for (int size=1; size <= smallestSize; size++) {
    fraction+=distribution.getFractionOfRecordsInClassesOfSize(size);
  }
  return result && (fraction <= recordsAtRisk);
}

Fixed version (ground truth):
@Override protected boolean isFulfilled(HashGroupifyDistribution distribution){
  boolean result=1.0d / (double)distribution.getAverageClassSize() <= getRiskThreshold();
  if (highestRisk == null || !result) {
    return result;
  }
  double fraction=0d;
  for (int size=1; size < smallestSize; size++) {
    fraction+=distribution.getFractionOfRecordsInClassesOfSize(size);
  }
  return result && (fraction <= recordsAtRisk);
}
Program: 107763
Project: 107763
Buggy source:
/** 
 * Returns a minimal class size for the given risk threshold TODO: There are similar issues in multiple privacy models, e.g. in the game-theoretic model TODO: This should be fixed once and for all
 * @param threshold
 * @return
 */
private Integer getSizeThreshold(double riskThreshold){
  double size=1d / highestRisk;
  double floor=Math.floor(size);
  if ((1d / floor) - (1d / size) >= 0.01d * highestRisk) {
    floor+=1d;
  }
  return (int)floor;
}

Fixed version (ground truth):
/** 
 * Returns a minimal class size for the given risk threshold TODO: There are similar issues in multiple privacy models, e.g. in the game-theoretic model TODO: This should be fixed once and for all
 * @param threshold
 * @return
 */
private Integer getSizeThreshold(double riskThreshold){
  double size=1d / riskThreshold;
  double floor=Math.floor(size);
  if ((1d / floor) - (1d / size) >= 0.01d * riskThreshold) {
    floor+=1d;
  }
  return (int)floor;
}
Program: 107765
Project: 107765
Buggy source:
@Override public ClassificationResult classify(DataHandleInternal handle,int row){
  if (result == null) {
    result=getIndexWithMostCounts();
  }
  return new MultiClassZeroRClassificationResult(result,counts,specification.classMap);
}

Fixed version (ground truth):
@Override public ClassificationResult classify(DataHandleInternal handle,int row){
  return result;
}
Program: 107766
Project: 107766
Buggy source:
@Override public void close(){
}

Fixed version (ground truth):
@Override public void close(){
  result=new MultiClassZeroRClassificationResult(counts,specification.classMap);
  counts.clear();
}
Program: 107767
Project: 107767
Buggy source:
@Override public double[] confidences(){
  double[] result=new double[counts.size()];
  int index=0;
  for (  Integer count : counts.values()) {
    result[index]=count;
    index++;
  }
  return result;
}

Fixed version (ground truth):
@Override public double[] confidences(){
  return confidences;
}
Program: 107768
Project: 107768
Buggy source:
/** 
 * Creates a new instance
 * @param result
 * @param map
 */
MultiClassZeroRClassificationResult(Integer result,Map<Integer,Integer> counts,Map<String,Integer> map){
  this.map=map;
  this.result=result;
  this.counts=counts;
}

Fixed version (ground truth):
/** 
 * Creates a new instance
 * @param result
 * @param map
 */
MultiClassZeroRClassificationResult(Map<Integer,Integer> counts,Map<String,Integer> map){
  this.map=map;
  this.result=getIndexWithMostCounts(counts);
  this.confidences=getConfidences(counts);
}
Program: 107770
Project: 107770
Buggy source:
/** 
 * Returns the lowest score. Lower is better.
 * @return
 */
public InformationLoss<?> getLowestScore(){
  return this.minimumInformationLoss;
}

Fixed version (ground truth):
/** 
 * Returns the lowest score. Lower is better.
 * @return
 */
public InformationLoss<?> getLowestScore(){
  if (this.minimumInformationLoss == null) {
    this.estimateInformationLoss();
  }
  return this.minimumInformationLoss;
}
Program: 107771
Project: 107771
Buggy source:
/** 
 * Returns the highest score. Lower is better.
 * @return
 */
public InformationLoss<?> getHighestScore(){
  return this.maximumInformationLoss;
}

Fixed version (ground truth):
/** 
 * Returns the highest score. Lower is better.
 * @return
 */
public InformationLoss<?> getHighestScore(){
  if (this.maximumInformationLoss == null) {
    this.estimateInformationLoss();
  }
  return this.maximumInformationLoss;
}
Program: 107772
Project: 107772
Buggy source:
/** 
 * Update the performance overview on selection.
 */
private void updateOverviewSelection(String attribute){
  int index=0;
  for (  TableItem item : performancePerTargetTable.getItems()) {
    if (item.getText(0).equals(attribute)) {
      performancePerTargetTable.select(index);
      updateOverview(attribute);
      break;
    }
    index++;
  }
}

Fixed version (ground truth):
/** 
 * Update the performance overview on selection.
 */
private void updateOverviewSelection(String attribute){
  int index=0;
  for (  TableItem item : performanceTableOverview.getItems()) {
    if (item.getText(0).equals(attribute)) {
      performanceTableOverview.select(index);
      updateOverview(attribute);
      break;
    }
    index++;
  }
}
Program: 107773
Project: 107773
Buggy source:
@Override protected void doReset(){
  if (this.manager != null) {
    this.manager.stop();
  }
  performancePerTargetTable.setRedraw(false);
  for (  final TableItem i : performancePerTargetTable.getItems()) {
    i.dispose();
  }
  performancePerTargetTable.setRedraw(true);
  performancePerClassTable.setRedraw(false);
  for (  final TableItem i : performancePerClassTable.getItems()) {
    i.dispose();
  }
  performancePerClassTable.setRedraw(true);
  rocTable.setRedraw(false);
  for (  final TableItem i : rocTable.getItems()) {
    i.dispose();
  }
  rocTable.setRedraw(true);
  if (rocCombo != null && rocCombo.getItemCount() != 0)   rocCombo.select(0);
  if (rocCurves != null) {
    rocCurves.clear();
  }
  if (originalRocCurves != null) {
    originalRocCurves.clear();
  }
  if (zerorRocCurves != null) {
    zerorRocCurves.clear();
  }
  resetChart();
  setStatusEmpty();
}

Fixed version (ground truth):
@Override protected void doReset(){
  if (this.manager != null) {
    this.manager.stop();
  }
  performanceTableOverview.setRedraw(false);
  for (  final TableItem i : performanceTableOverview.getItems()) {
    i.dispose();
  }
  performanceTableOverview.setRedraw(true);
  performanceTableSensitivitySpecificity.setRedraw(false);
  for (  final TableItem i : performanceTableSensitivitySpecificity.getItems()) {
    i.dispose();
  }
  performanceTableSensitivitySpecificity.setRedraw(true);
  rocTable.setRedraw(false);
  for (  final TableItem i : rocTable.getItems()) {
    i.dispose();
  }
  rocTable.setRedraw(true);
  if (rocCombo != null && rocCombo.getItemCount() != 0)   rocCombo.select(0);
  if (rocCurves != null) {
    rocCurves.clear();
  }
  if (originalRocCurves != null) {
    originalRocCurves.clear();
  }
  if (zerorRocCurves != null) {
    zerorRocCurves.clear();
  }
  resetChart();
  setStatusEmpty();
}
Program: 107777
Project: 107777
Buggy source:
@Override protected Control createControl(Composite parent){
  Composite root=new Composite(parent,SWT.NONE);
  root.setLayout(new FillLayout());
  ComponentTitledFolderButtonBar bar=new ComponentTitledFolderButtonBar();
  bar.add(Resources.getMessage("String_Node_Str"),getController().getResources().getManagedImage("String_Node_Str"),new Runnable(){
    public void run(){
      triggerUpdate();
    }
  }
);
  this.folder=new ComponentTitledFolder(root,null,bar,null,true,false);
  Composite item1=folder.createItem(Resources.getMessage("String_Node_Str"),getController().getResources().getManagedImage("String_Node_Str"));
  item1.setLayoutData(SWTUtil.createFillGridData());
  this.createOverviewControl(item1);
  Composite item2=folder.createItem(Resources.getMessage("String_Node_Str"),getController().getResources().getManagedImage("String_Node_Str"));
  item2.setLayoutData(SWTUtil.createFillGridData());
  this.createROCControl(item2);
  this.folder.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent arg0){
      if (other != null) {
        other.setSelectionIndex(folder.getSelectionIndex());
      }
    }
  }
);
  return root;
}

Fixed version (ground truth):
@Override protected Control createControl(Composite parent){
  Composite root=new Composite(parent,SWT.NONE);
  root.setLayout(new FillLayout());
  ComponentTitledFolderButtonBar bar=new ComponentTitledFolderButtonBar();
  bar.add(Resources.getMessage("String_Node_Str"),getController().getResources().getManagedImage("String_Node_Str"),new Runnable(){
    public void run(){
      triggerUpdate();
    }
  }
);
  this.folder=new ComponentTitledFolder(root,null,bar,null,true,false);
  Composite item1=folder.createItem(Resources.getMessage("String_Node_Str"),getController().getResources().getManagedImage("String_Node_Str"));
  item1.setLayoutData(SWTUtil.createFillGridData());
  this.createOverviewControl(item1);
  Composite item2=folder.createItem(Resources.getMessage("String_Node_Str"),getController().getResources().getManagedImage("String_Node_Str"));
  item2.setLayoutData(SWTUtil.createFillGridData());
  this.createROCControl(item2);
  this.folder.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent arg0){
      if (other != null) {
        other.setSelectionIndex(folder.getSelectionIndex());
      }
    }
  }
);
  this.folder.setSelection(0);
  return root;
}
Program: 107778
Project: 107778
Buggy source:
/** 
 * Updates the combo box to the selected target variable, the roc table with according auc values and the chart according to the selected class.
 */
private void updateROCSelection(String classValue){
  String selectedTarget=getModel().getSelectedAttribute();
  for (int i=0; i < rocCombo.getItemCount(); i++) {
    if (rocCombo.getItem(i).equals(selectedTarget)) {
      rocCombo.select(i);
      updateROC(selectedTarget,classValue);
      break;
    }
  }
  int index=0;
  for (  TableItem item : rocTable.getItems()) {
    if (item.getText(0).equals(classValue)) {
      rocTable.select(index);
      if (item.getData() != null) {
        rocSetChartSeries((ROCCurve[])item.getData());
      }
      break;
    }
    index++;
  }
}

Fixed version (ground truth):
/** 
 * Updates the combo box to the selected target variable, the roc table with according auc values and the chart according to the selected class.
 */
private void updateROCSelection(String classValue){
  if (rocCombo.getItemCount() == 0) {
    return;
  }
  final String[] targetVariables=getModel().getSelectedClasses().toArray(new String[0]);
  String targetVariable=getModel().getSelectedAttribute();
  int targetIndex=getIndexOf(targetVariables,targetVariable);
  rocCombo.select(targetIndex);
  updateROC(rocCombo.getItem(targetIndex),classValue);
  int index=0;
  for (  TableItem item : rocTable.getItems()) {
    if (item.getText(0).equals(classValue)) {
      rocTable.select(index);
      if (item.getData() != null) {
        rocSetChartSeries((ROCCurve[])item.getData());
      }
      break;
    }
    index++;
  }
}
Program: 107780
Project: 107780
Buggy source:
@Override public void onFinish(){
  if (stopped || !isEnabled() || getModel().getSelectedFeatures().isEmpty()|| getModel().getSelectedClasses().isEmpty()) {
    setStatusEmpty();
    return;
  }
  for (  final TableItem i : performancePerTargetTable.getItems()) {
    i.dispose();
  }
  for (int i=0; i < targetVariables.length; i++) {
    TableItem item=new TableItem(performancePerTargetTable,SWT.NONE);
    item.setText(0,targetVariables[i]);
    for (int j=0; j < values.get(i).size(); j++) {
      item.setData(String.valueOf(1 + j),values.get(i).get(j));
    }
  }
  String targetVariable=getModel().getSelectedAttribute();
  int targetIndex=getIndexOf(targetVariables,targetVariable);
  performancePerTargetTable.setFocus();
  performancePerTargetTable.select(targetIndex);
  updateOverview(performancePerTargetTable.getItem(targetIndex).getText());
  performanceRoot.layout();
  performanceSash.setWeights(new int[]{2,2});
  rocCombo.setItems(targetVariables);
  rocCombo.select(targetIndex);
  rocRoot.layout();
  rocSash.setWeights(new int[]{2,2});
  setStatusDone();
  folder.setSelection(0);
  if (performancePerTargetTable.getItemCount() != 0) {
    updateOverviewSelection(performancePerTargetTable.getItem(targetIndex).getText());
  }
  if (performancePerClassTable.getItemCount() != 0) {
    updateROCSelection(performancePerClassTable.getItem(0).getText(0));
  }
}

Fixed version (ground truth):
@Override public void onFinish(){
  if (stopped || !isEnabled() || getModel().getSelectedFeatures().isEmpty()|| getModel().getSelectedClasses().isEmpty()) {
    setStatusEmpty();
    return;
  }
  for (  final TableItem i : performanceTableOverview.getItems()) {
    i.dispose();
  }
  for (int i=0; i < targetVariables.length; i++) {
    TableItem item=new TableItem(performanceTableOverview,SWT.NONE);
    item.setText(0,targetVariables[i]);
    for (int j=0; j < values.get(i).size(); j++) {
      item.setData(String.valueOf(1 + j),values.get(i).get(j));
    }
  }
  String targetVariable=getModel().getSelectedAttribute();
  int targetIndex=getIndexOf(targetVariables,targetVariable);
  performanceTableOverview.setFocus();
  performanceTableOverview.select(targetIndex);
  updateOverview(performanceTableOverview.getItem(targetIndex).getText());
  performanceRoot.layout();
  performanceSash.setWeights(new int[]{2,2});
  rocCombo.setItems(targetVariables);
  rocCombo.select(targetIndex);
  rocRoot.layout();
  rocSash.setWeights(new int[]{2,2});
  setStatusDone();
  if (performanceTableOverview.getItemCount() != 0) {
    updateOverviewSelection(performanceTableOverview.getItem(targetIndex).getText());
  }
  String[] classValues=new String[performanceTableSensitivitySpecificity.getItems().length];
  for (int i=0; i < classValues.length; i++) {
    classValues[i]=performanceTableSensitivitySpecificity.getItem(i).getText(0);
  }
  int classIndex=getIndexOf(classValues,getModel().getSelectedClassValue());
  if (performanceTableSensitivitySpecificity.getItemCount() != 0) {
    updateROCSelection(performanceTableSensitivitySpecificity.getItem(classIndex).getText(0));
  }
}
Program: 107781
Project: 107781
Buggy source:
/** 
 * Converts to double, returns null if not valid
 * @return
 */
private Double getHeuristicSearchTimeLimit(){
  double value=0d;
  try {
    value=Double.valueOf(txtHeuristicSearchTimeLimit.getText());
  }
 catch (  Exception e) {
    return null;
  }
  if (((int)value) > 0d) {
    return value;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Converts to double, returns null if not valid
 * @return
 */
private Double getHeuristicSearchTimeLimit(){
  double value=0d;
  try {
    value=Double.valueOf(txtHeuristicSearchTimeLimit.getText());
  }
 catch (  Exception e) {
    return null;
  }
  if (value > 0d) {
    return value;
  }
 else {
    return null;
  }
}
Program: 107783
Project: 107783
Buggy source:
@Override public void modifyText(ModifyEvent arg0){
  radio22.setSelection(true);
  result.transformationType=TransformationType.LOCAL;
  checkValidity();
}

Fixed version (ground truth):
@Override public void modifyText(ModifyEvent arg0){
  radio22.setSelection(true);
  radio21.setSelection(false);
  result.transformationType=TransformationType.LOCAL;
  checkValidity();
}
Program: 107784
Project: 107784
Buggy source:
/** 
 * Converts to int, returns null if not valid
 * @return
 */
private Integer getHeuristicSearchStepLimit(){
  int value=0;
  try {
    value=Integer.valueOf(txtHeuristicSearchStepLimit.getText());
  }
 catch (  Exception e) {
    return null;
  }
  if (((int)value) > 0d) {
    return value;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Converts to int, returns null if not valid
 * @return
 */
private Integer getHeuristicSearchStepLimit(){
  int value=0;
  try {
    value=Integer.valueOf(txtHeuristicSearchStepLimit.getText());
  }
 catch (  Exception e) {
    return null;
  }
  if (value > 0d) {
    return value;
  }
 else {
    return null;
  }
}
Program: 107785
Project: 107785
Buggy source:
@Override protected void initializeInternal(DataManager manager,DataDefinition definition,Data input,GeneralizationHierarchy[] hierarchies,ARXConfiguration config){
  super.initializeInternal(manager,definition,input,hierarchies,config);
  List<Integer> indices=new ArrayList<>();
  for (  String variable : definition.getResponseVariables()) {
    int index=manager.getDataAnalyzed().getIndexOf(variable);
    if (index != -1) {
      indices.add(index);
    }
  }
  Collections.sort(indices);
  this.responseVariables=new int[indices.size()];
  for (int i=0; i < indices.size(); i++) {
    responseVariables[i]=indices.get(i);
  }
  this.responseVariablesNotAnalyzed=definition.getResponseVariables().size() - responseVariables.length;
  penaltySuppressed=super.getSuppressionFactor();
  penaltyInfrequentResponse=super.getGeneralizationFactor();
  penaltyNoMajorityResponse=super.getGeneralizationSuppressionFactor();
}

Fixed version (ground truth):
@Override protected void initializeInternal(DataManager manager,DataDefinition definition,Data input,GeneralizationHierarchy[] hierarchies,ARXConfiguration config){
  super.initializeInternal(manager,definition,input,hierarchies,config);
  this.responseVariablesNonQI=getIndices(definition,manager.getDataAnalyzed());
  this.responseVariablesQI=getIndices(definition,manager.getDataGeneralized());
  if (this.responseVariablesQI.length != 0) {
    throw new UnsupportedOperationException();
  }
  penaltySuppressed=super.getGeneralizationSuppressionFactor();
  penaltyInfrequentResponse=super.getGeneralizationFactor();
  penaltyNoMajorityResponse=super.getSuppressionFactor();
  penaltyMax=Math.max(penaltySuppressed,Math.max(penaltyInfrequentResponse,penaltyNoMajorityResponse)) * super.getNumTuples();
}
Program: 107786
Project: 107786
Buggy source:
@Override protected ILSingleDimensionalWithBound getInformationLossInternal(Transformation node,HashGroupifyEntry m){
  if (m.count > 0) {
    return createInformationLoss(getPenalty(m));
  }
 else {
    return createInformationLoss(0d);
  }
}

Fixed version (ground truth):
@Override protected ILSingleDimensionalWithBound getInformationLossInternal(Transformation node,HashGroupifyEntry m){
  if (m.count > 0) {
    return createInformationLoss(getPenaltyNonQI(m));
  }
 else {
    return createInformationLoss(0d);
  }
}
Program: 107787
Project: 107787
Buggy source:
@Override public ILSingleDimensional createMaxInformationLoss(){
  Double rows=getNumTuples();
  if (rows == null) {
    throw new IllegalStateException("String_Node_Str");
  }
 else {
    double max=rows * responseVariablesNotAnalyzed * penaltySuppressed;
    double maxPenalty=Math.max(penaltySuppressed,Math.max(penaltyInfrequentResponse,penaltyNoMajorityResponse));
    max+=rows * responseVariables.length * maxPenalty;
    return new ILSingleDimensional(max);
  }
}

Fixed version (ground truth):
@Override public ILSingleDimensional createMaxInformationLoss(){
  return new ILSingleDimensional(1d);
}
Program: 107789
Project: 107789
Buggy source:
/** 
 * Returns whether local recoding can be applied to the given handle
 * @param handle
 * @return
 */
public boolean isOptimizable(DataHandle handle){
  if (!(handle instanceof DataHandleOutput)) {
    return false;
  }
  DataHandleOutput output=(DataHandleOutput)handle;
  if (output.getInputBuffer() == null || !output.getInputBuffer().equals(this.manager.getDataGeneralized().getArray())) {
    return false;
  }
  for (  PrivacyCriterion c : config.getPrivacyModels()) {
    if (!c.isLocalRecodingSupported()) {
      return false;
    }
  }
  int outliers=0;
  for (int row=0; row < output.getNumRows(); row++) {
    if (output.isOutlier(row)) {
      outliers++;
    }
  }
  if (config.getMinimalGroupSize() != Integer.MAX_VALUE && outliers < config.getMinimalGroupSize()) {
    return false;
  }
  if (outliers == 0) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns whether local recoding can be applied to the given handle
 * @param handle
 * @return
 */
public boolean isOptimizable(DataHandle handle){
  if (!(handle instanceof DataHandleOutput)) {
    return false;
  }
  DataHandleOutput output=(DataHandleOutput)handle;
  if (output.getInputBuffer() == null || !output.getInputBuffer().equals(this.manager.getDataGeneralized().getArray())) {
    return false;
  }
  for (  PrivacyCriterion c : config.getPrivacyModels()) {
    if (!c.isLocalRecodingSupported()) {
      return false;
    }
  }
  RowSet baselineRowSet=config.getSubset() == null ? null : config.getSubset().getSet();
  int outliers=0;
  for (int row=0; row < output.getNumRows(); row++) {
    if (output.isOutlier(row) && (baselineRowSet == null || baselineRowSet.contains(row))) {
      outliers++;
    }
  }
  if (config.getMinimalGroupSize() != Integer.MAX_VALUE && outliers < config.getMinimalGroupSize()) {
    return false;
  }
  if (outliers == 0) {
    return false;
  }
  return true;
}
Program: 107792
Project: 107792
Buggy source:
/** 
 * Constructor.
 * @param solutions The solution space
 * @param complete Is the solution space characterized by an optimal algorithm
 * @param optimum The optimum
 * @param header The header
 * @param config The config
 */
ARXLattice(final SolutionSpace solutions,final boolean complete,final Transformation optimum,final String[] header,final ARXConfigurationInternal config){
  this.solutions=solutions;
  this.metric=config.getQualityModel();
  this.setMonotonicity(config.isSuppressionAlwaysEnabled(),config.getAbsoluteMaxOutliers());
  this.complete=complete;
  this.virtualSize=solutions.getSize();
  this.uncertainty=config.isPracticalMonotonicity();
  final Map<String,Integer> headermap=new HashMap<String,Integer>();
  int index=0;
  for (int i=0; i < header.length; i++) {
    headermap.put(header[i],index++);
  }
  if (complete) {
    buildComplete(optimum,headermap);
  }
 else {
    buildIncomplete(optimum,headermap);
  }
  outer:   for (int i=0; i < this.levels.length; i++) {
    final ARXNode[] level=this.levels[i];
    for (int j=0; j < level.length; j++) {
      final ARXNode node=level[j];
      if (node != null) {
        this.bottom=node;
        break outer;
      }
    }
  }
  outer:   for (int i=this.levels.length - 1; i >= 0; i--) {
    final ARXNode[] level=this.levels[i];
    for (int j=0; j < level.length; j++) {
      final ARXNode node=level[j];
      if (node != null) {
        this.top=node;
        break outer;
      }
    }
  }
  estimateInformationLoss();
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param solutions The solution space
 * @param complete Is the solution space characterized by an optimal algorithm
 * @param optimum The optimum
 * @param header The header
 * @param config The config
 */
ARXLattice(final SolutionSpace solutions,final boolean complete,final Transformation optimum,final String[] header,final ARXConfigurationInternal config){
  this.solutions=solutions;
  this.metric=config.getQualityModel();
  this.setMonotonicity(config.isSuppressionAlwaysEnabled(),config.getAbsoluteSuppressionLimit());
  this.complete=complete;
  this.virtualSize=solutions.getSize();
  this.uncertainty=config.isPracticalMonotonicity();
  final Map<String,Integer> headermap=new HashMap<String,Integer>();
  int index=0;
  for (int i=0; i < header.length; i++) {
    headermap.put(header[i],index++);
  }
  if (complete) {
    buildComplete(optimum,headermap);
  }
 else {
    buildIncomplete(optimum,headermap);
  }
  outer:   for (int i=0; i < this.levels.length; i++) {
    final ARXNode[] level=this.levels[i];
    for (int j=0; j < level.length; j++) {
      final ARXNode node=level[j];
      if (node != null) {
        this.bottom=node;
        break outer;
      }
    }
  }
  outer:   for (int i=this.levels.length - 1; i >= 0; i--) {
    final ARXNode[] level=this.levels[i];
    for (int j=0; j < level.length; j++) {
      final ARXNode node=level[j];
      if (node != null) {
        this.top=node;
        break outer;
      }
    }
  }
  estimateInformationLoss();
}
Program: 107795
Project: 107795
Buggy source:
/** 
 * Marks all outliers in the output dataset
 */
public void performSuppression(){
  for (int row=0; row < dataOutput.getNumRows(); row++) {
    if (privacyModelDefinesSubset == null || privacyModelDefinesSubset.contains(row)) {
      final int hash=dataOutput.hashCode(row);
      final int index=hash & (hashTableBuckets.length - 1);
      HashGroupifyEntry m=hashTableBuckets[index];
      while ((m != null) && ((m.hashcode != hash) || !dataOutput.equalsIgnoringOutliers(row,m.row))) {
        m=m.next;
      }
      if (m == null) {
        throw new RuntimeException("String_Node_Str");
      }
      if (!m.isNotOutlier) {
        dataOutput.or(row,Data.OUTLIER_MASK);
      }
    }
 else {
      dataOutput.or(row,Data.OUTLIER_MASK);
    }
  }
}

Fixed version (ground truth):
/** 
 * Suppresses all records in the output dataset which <br> (a) do not satisfy privacy requirements, or <br> (b) are not included in the research subset
 */
public void performSuppression(){
  for (int row=0; row < dataOutput.getNumRows(); row++) {
    if (privacyModelDefinesSubset == null || privacyModelDefinesSubset.contains(row)) {
      final int hash=dataOutput.hashCode(row);
      final int index=hash & (hashTableBuckets.length - 1);
      HashGroupifyEntry m=hashTableBuckets[index];
      while ((m != null) && ((m.hashcode != hash) || !dataOutput.equalsIgnoringOutliers(row,m.row))) {
        m=m.next;
      }
      if (m == null) {
        throw new RuntimeException("String_Node_Str");
      }
      if (!m.isNotOutlier) {
        dataOutput.or(row,Data.OUTLIER_MASK);
      }
    }
 else {
      dataOutput.or(row,Data.OUTLIER_MASK);
    }
  }
}
Program: 107797
Project: 107797
Buggy source:
/** 
 * Performs a depth first search (without backtracking) starting from the the given transformation
 * @param queue
 * @param transformation
 */
private void dfs(PriorityQueue<Long> queue,Transformation transformation){
  if (mustStop()) {
    return;
  }
  Transformation next=expand(queue,transformation);
  if (next != null) {
    queue.remove(next);
    dfs(queue,next);
  }
}

Fixed version (ground truth):
/** 
 * Performs a depth first search (without backtracking) starting from the the given transformation
 * @param queue
 * @param transformation
 */
private void dfs(PriorityQueue<Long> queue,Transformation transformation){
  if (mustStop()) {
    return;
  }
  Transformation next=expand(queue,transformation);
  if (next != null) {
    queue.remove(next.getIdentifier());
    dfs(queue,next);
  }
}
Program: 107798
Project: 107798
Buggy source:
/** 
 * Returns whether we can prune this Transformation
 * @param transformation
 * @return
 */
private boolean prune(Transformation transformation){
  if (transformation.hasProperty(propertyExpanded) || transformation.hasProperty(propertyInsufficientUtility)) {
    return true;
  }
  Transformation optimum=getGlobalOptimum();
  if (optimum != null) {
    InformationLoss<?> bound=transformation.getLowerBound();
    if (bound.compareTo(optimum.getInformationLoss()) >= 0) {
      transformation.setProperty(propertyInsufficientUtility);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Returns whether we can prune this Transformation
 * @param transformation
 * @return
 */
private boolean prune(Transformation transformation){
  if (transformation.hasProperty(propertyExpanded) || transformation.hasProperty(propertyInsufficientUtility)) {
    return true;
  }
  Transformation optimum=getGlobalOptimum();
  if (optimum != null) {
    InformationLoss<?> bound=transformation.getLowerBound();
    if (bound != null && bound.compareTo(optimum.getInformationLoss()) >= 0) {
      transformation.setProperty(propertyInsufficientUtility);
      return true;
    }
  }
  return false;
}
Program: 107799
Project: 107799
Buggy source:
@Override public void mouseDown(MouseEvent e){
  Point pt=new Point(e.x,e.y);
  int index=table.getTopIndex();
  while (index < table.getItemCount()) {
    TableItem item=table.getItem(index);
    for (int i=0; i < 5; i++) {
      Rectangle rect=item.getBounds(i);
      if (rect.contains(pt)) {
        if ((i == 2 || i == 3) && e.button == SWT.BUTTON3) {
          menu.setLocation(table.toDisplay(e.x,e.y));
          menu.setVisible(true);
          return;
        }
 else         if (i == 4 && e.button == SWT.BUTTON1) {
          String attribute=model.getInputConfig().getInput().getHandle().getAttributeName(index);
          boolean isResponseVariable=!model.getInputDefinition().isResponseVariable(attribute);
          model.getInputDefinition().setResponseVariable(attribute,isResponseVariable);
          item.setImage(0,controller.getResources().getImage(model.getInputDefinition().getAttributeType(attribute),isResponseVariable));
          item.setImage(4,isResponseVariable ? IMAGE_ENABLED : IMAGE_DISABLED);
          controller.update(new ModelEvent(this,ModelPart.RESPONSE_VARIABLES,attribute));
          return;
        }
      }
    }
    index++;
  }
}

Fixed version (ground truth):
@Override public void mouseDown(MouseEvent e){
  Point pt=new Point(e.x,e.y);
  int index=table.getTopIndex();
  while (index < table.getItemCount()) {
    TableItem item=table.getItem(index);
    for (int i=0; i < 5; i++) {
      Rectangle rect=item.getBounds(i);
      if (rect.contains(pt)) {
        if ((i == 2 || i == 3) && e.button == 3) {
          menu.setLocation(table.toDisplay(e.x,e.y));
          menu.setVisible(true);
          return;
        }
 else         if (i == 4 && e.button == 1) {
          String attribute=model.getInputConfig().getInput().getHandle().getAttributeName(index);
          boolean isResponseVariable=!model.getInputDefinition().isResponseVariable(attribute);
          model.getInputDefinition().setResponseVariable(attribute,isResponseVariable);
          item.setImage(0,controller.getResources().getImage(model.getInputDefinition().getAttributeType(attribute),isResponseVariable));
          item.setImage(4,isResponseVariable ? IMAGE_ENABLED : IMAGE_DISABLED);
          controller.update(new ModelEvent(this,ModelPart.RESPONSE_VARIABLES,attribute));
          return;
        }
      }
    }
    index++;
  }
}
Program: 107801
Project: 107801
Buggy source:
/** 
 * Kept only for backwards compatibility
 * @return
 */
boolean _legacySearchedWithFlash(){
  return complete;
}

Fixed version (ground truth):
/** 
 * Kept only for backwards compatibility
 * @return
 */
boolean _legacySearchedWithFlash(){
  return complete == null ? true : complete;
}
Program: 107805
Project: 107805
Buggy source:
/** 
 * Returns whether local recoding can be applied to the given handle
 * @param handle
 * @return
 */
public boolean isOptimizable(DataHandle handle){
  if (!(handle instanceof DataHandleOutput)) {
    return false;
  }
  DataHandleOutput output=(DataHandleOutput)handle;
  if (output.getInputBuffer() == null || !output.getInputBuffer().equals(this.checker.getInputBuffer())) {
    return false;
  }
  for (  PrivacyCriterion c : config.getPrivacyModels()) {
    if (!c.isLocalRecodingSupported()) {
      return false;
    }
  }
  int outliers=0;
  for (int row=0; row < output.getNumRows(); row++) {
    if (output.isOutlier(row)) {
      outliers++;
    }
  }
  if (config.getMinimalGroupSize() != Integer.MAX_VALUE && outliers < config.getMinimalGroupSize()) {
    return false;
  }
  if (outliers == 0) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns whether local recoding can be applied to the given handle
 * @param handle
 * @return
 */
public boolean isOptimizable(DataHandle handle){
  if (!(handle instanceof DataHandleOutput)) {
    return false;
  }
  DataHandleOutput output=(DataHandleOutput)handle;
  if (output.getInputBuffer() == null || !output.getInputBuffer().equals(this.manager.getDataGeneralized())) {
    return false;
  }
  for (  PrivacyCriterion c : config.getPrivacyModels()) {
    if (!c.isLocalRecodingSupported()) {
      return false;
    }
  }
  int outliers=0;
  for (int row=0; row < output.getNumRows(); row++) {
    if (output.isOutlier(row)) {
      outliers++;
    }
  }
  if (config.getMinimalGroupSize() != Integer.MAX_VALUE && outliers < config.getMinimalGroupSize()) {
    return false;
  }
  if (outliers == 0) {
    return false;
  }
  return true;
}
Program: 107806
Project: 107806
Buggy source:
/** 
 * Creates a new instance.
 * @param anonymizer
 * @param registry
 * @param manager
 * @param checker
 * @param definition
 * @param config
 * @param lattice
 * @param duration
 * @param solutionSpace
 */
protected ARXResult(ARXAnonymizer anonymizer,DataRegistry registry,DataManager manager,TransformationChecker checker,DataDefinition definition,ARXConfiguration config,ARXLattice lattice,long duration,SolutionSpace solutionSpace){
  this.anonymizer=anonymizer;
  this.registry=registry;
  this.manager=manager;
  this.checker=checker;
  this.definition=definition;
  this.config=config;
  this.lattice=lattice;
  this.optimalNode=lattice.getOptimum();
  this.duration=duration;
  this.solutionSpace=solutionSpace;
}

Fixed version (ground truth):
/** 
 * Creates a new instance.
 * @param anonymizer
 * @param registry
 * @param manager
 * @param checker
 * @param definition
 * @param config
 * @param lattice
 * @param duration
 * @param solutionSpace
 */
protected ARXResult(ARXAnonymizer anonymizer,DataRegistry registry,DataManager manager,TransformationChecker checker,DataDefinition definition,ARXConfiguration config,ARXLattice lattice,long duration,SolutionSpace solutionSpace){
  this.anonymizer=anonymizer;
  this.registry=registry;
  this.manager=manager;
  this.buffer=checker.getOutputBuffer();
  this.definition=definition;
  this.config=config;
  this.lattice=lattice;
  this.optimalNode=lattice.getOptimum();
  this.duration=duration;
  this.solutionSpace=solutionSpace;
}
Program: 107807
Project: 107807
Buggy source:
@Override public void traverse(){
  FLASHPhaseConfiguration outerLoopConfiguration;
  if (config.isBinaryPhaseRequired()) {
    outerLoopConfiguration=config.getBinaryPhaseConfiguration();
  }
 else {
    outerLoopConfiguration=config.getLinearPhaseConfiguration();
  }
  checker.getHistory().setStorageStrategy(config.getSnapshotStorageStrategy());
  PriorityQueue<Integer> queue=new PriorityQueue<Integer>(solutionSpace.getTop().getLevel() + 1,strategy);
  Transformation bottom=solutionSpace.getBottom();
  Transformation top=solutionSpace.getTop();
  TransformationChecker.Result result=checker.check(bottom);
  bottom.setProperty(solutionSpace.getPropertyForceSnapshot());
  bottom.setData(result);
  for (int level=bottom.getLevel(); level <= top.getLevel(); level++) {
    for (    int id : getSortedUnprocessedNodes(level,outerLoopConfiguration.getTriggerSkip())) {
      Transformation transformation=solutionSpace.getTransformation(id);
      if (config.isBinaryPhaseRequired()) {
        binarySearch(transformation,queue);
      }
 else {
        linearSearch(transformation);
      }
    }
  }
  computeUtilityForMonotonicMetrics(bottom);
  computeUtilityForMonotonicMetrics(top);
  bottom.setData(null);
  if (potentiallyInsufficientUtility != null) {
    potentiallyInsufficientUtility.clear();
  }
}

Fixed version (ground truth):
@Override public void traverse(){
  FLASHPhaseConfiguration outerLoopConfiguration;
  if (config.isBinaryPhaseRequired()) {
    outerLoopConfiguration=config.getBinaryPhaseConfiguration();
  }
 else {
    outerLoopConfiguration=config.getLinearPhaseConfiguration();
  }
  checker.getHistory().setStorageStrategy(config.getSnapshotStorageStrategy());
  PriorityQueue<Integer> queue=new PriorityQueue<Integer>(solutionSpace.getTop().getLevel() + 1,strategy);
  Transformation bottom=solutionSpace.getBottom();
  Transformation top=solutionSpace.getTop();
  TransformationResult result=checker.check(bottom);
  bottom.setProperty(solutionSpace.getPropertyForceSnapshot());
  bottom.setData(result);
  for (int level=bottom.getLevel(); level <= top.getLevel(); level++) {
    for (    int id : getSortedUnprocessedNodes(level,outerLoopConfiguration.getTriggerSkip())) {
      Transformation transformation=solutionSpace.getTransformation(id);
      if (config.isBinaryPhaseRequired()) {
        binarySearch(transformation,queue);
      }
 else {
        linearSearch(transformation);
      }
    }
  }
  computeUtilityForMonotonicMetrics(bottom);
  computeUtilityForMonotonicMetrics(top);
  bottom.setData(null);
  if (potentiallyInsufficientUtility != null) {
    potentiallyInsufficientUtility.clear();
  }
}
Program: 107808
Project: 107808
Buggy source:
@Override public void initialize(DataManager manager,ARXConfiguration config){
  this.shares=manager.getDomainShares();
  this.config=config.getCostBenefitConfiguration();
  this.riskModel=new RiskModelCostBenefit(this.config);
  this.aggregation=manager.getMicroAggregationData();
  this.maxIL=MetricSDNMEntropyBasedInformationLoss.getMaximalEntropyBasedInformationLoss(this.shares,this.aggregation);
}

Fixed version (ground truth):
@Override public void initialize(DataManager manager,ARXConfiguration config){
  this.shares=manager.getDomainShares();
  this.config=config.getCostBenefitConfiguration();
  this.riskModel=new RiskModelCostBenefit(this.config);
  this.aggregation=manager.getAggregationInformation();
  this.maxIL=MetricSDNMEntropyBasedInformationLoss.getMaximalEntropyBasedInformationLoss(this.shares,this.aggregation);
}
Program: 107810
Project: 107810
Buggy source:
/** 
 * Returns whether local recoding can be applied to the given handle
 * @param handle
 * @return
 */
public boolean isOptimizable(DataHandle handle){
  if (!(handle instanceof DataHandleOutput)) {
    return false;
  }
  DataHandleOutput output=(DataHandleOutput)handle;
  if (output.getInputBuffer() == null || !output.getInputBuffer().equals(this.manager.getDataGeneralized())) {
    return false;
  }
  for (  PrivacyCriterion c : config.getPrivacyModels()) {
    if (!c.isLocalRecodingSupported()) {
      return false;
    }
  }
  int outliers=0;
  for (int row=0; row < output.getNumRows(); row++) {
    if (output.isOutlier(row)) {
      outliers++;
    }
  }
  if (config.getMinimalGroupSize() != Integer.MAX_VALUE && outliers < config.getMinimalGroupSize()) {
    return false;
  }
  if (outliers == 0) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns whether local recoding can be applied to the given handle
 * @param handle
 * @return
 */
public boolean isOptimizable(DataHandle handle){
  if (!(handle instanceof DataHandleOutput)) {
    return false;
  }
  DataHandleOutput output=(DataHandleOutput)handle;
  if (output.getInputBuffer() == null || !output.getInputBuffer().equals(this.manager.getDataGeneralized().getArray())) {
    return false;
  }
  for (  PrivacyCriterion c : config.getPrivacyModels()) {
    if (!c.isLocalRecodingSupported()) {
      return false;
    }
  }
  int outliers=0;
  for (int row=0; row < output.getNumRows(); row++) {
    if (output.isOutlier(row)) {
      outliers++;
    }
  }
  if (config.getMinimalGroupSize() != Integer.MAX_VALUE && outliers < config.getMinimalGroupSize()) {
    return false;
  }
  if (outliers == 0) {
    return false;
  }
  return true;
}
Program: 107811
Project: 107811
Buggy source:
/** 
 * Sets the selected attribute.
 * @param attribute
 */
public void setSelectedAttribute(String attribute){
  int index=-1;
  if (context.getHandle() != null) {
    index=context.getHandle().getColumnIndexOf(attribute);
  }
  this.context.setSelectedIndex(index);
  if (index == -1 || index == 0) {
    this.getViewportLayer().setOriginX(0);
    return;
  }
  int width=this.table.getBounds().width - this.table.getVerticalBar().getSize().x;
  int rowHeaderWidth=gridLayer.getRowHeaderLayer().getClientAreaProvider().getClientArea().width;
  int originX=this.getViewportLayer().getOrigin().getX();
  int columnPositionX=this.getViewportLayer().getStartXOfColumnPosition(this.getViewportLayer().getColumnPositionByIndex(index + 1));
  int positionX=originX + (columnPositionX + rowHeaderWidth);
  if (positionX < originX || positionX > originX + width) {
    this.getViewportLayer().setOriginX(positionX - rowHeaderWidth);
  }
  this.redraw();
}

Fixed version (ground truth):
/** 
 * Sets the selected attribute.
 * @param attribute
 */
public void setSelectedAttribute(String attribute){
  int index=-1;
  if (context.getHandle() != null) {
    index=context.getHandle().getColumnIndexOf(attribute);
  }
  this.context.setSelectedIndex(index);
  if (index == -1 || index == 0) {
    this.getViewportLayer().setOriginX(0);
    this.redraw();
    return;
  }
  int width=this.table.getBounds().width - this.table.getVerticalBar().getSize().x;
  int rowHeaderWidth=gridLayer.getRowHeaderLayer().getClientAreaProvider().getClientArea().width;
  int originX=this.getViewportLayer().getOrigin().getX();
  int columnPositionX=this.getViewportLayer().getStartXOfColumnPosition(this.getViewportLayer().getColumnPositionByIndex(index + 1));
  int positionX=originX + (columnPositionX + rowHeaderWidth);
  if (positionX < originX || positionX > originX + width) {
    this.getViewportLayer().setOriginX(positionX - rowHeaderWidth);
  }
  this.redraw();
}
Program: 107812
Project: 107812
Buggy source:
/** 
 * Performs a depth first search (without backtracking) starting from the the given transformation
 * @param queue
 * @param transformation
 */
private void dfs(PriorityQueue<Long> queue,Transformation transformation){
  if (mustStop()) {
    return;
  }
  Transformation next=expand(queue,transformation);
  if (next != null) {
    queue.remove(next);
    dfs(queue,next);
  }
}

Fixed version (ground truth):
/** 
 * Performs a depth first search (without backtracking) starting from the the given transformation
 * @param queue
 * @param transformation
 */
private void dfs(PriorityQueue<Long> queue,Transformation transformation){
  if (mustStop()) {
    return;
  }
  Transformation next=expand(queue,transformation);
  if (next != null) {
    queue.remove(next.getIdentifier());
    dfs(queue,next);
  }
}
Program: 107816
Project: 107816
Buggy source:
/** 
 * Creates a new instance with the given format string and the given locale.
 * @param format
 * @param locale
 * @return
 */
public abstract DataType<T> newInstance(String format,Locale locale);

Fixed version (ground truth):
/** 
 * Creates a new instance with default format and the given locale.
 * @param locale
 * @return
 */
public DataType<T> newInstance(Locale locale){
  return newInstance(null,locale);
}
Program: 107819
Project: 107819
Buggy source:
/** 
 * Returns the penalty for the given entry
 * @param entry
 * @return
 */
private double getPenalty(HashGroupifyEntry entry){
  double result=0d;
  if (!entry.isNotOutlier) {
    result+=entry.count * (responseVariablesNotAnalyzed + responseVariables.length) * penaltySuppressed;
  }
 else {
    for (    int index : this.responseVariables) {
      int top1=-1;
      int top2=-1;
      Distribution distribution=entry.distributions[index];
      int[] buckets=distribution.getBuckets();
      for (int i=0; i < buckets.length; i+=2) {
        int frequency=buckets[i + 1];
        boolean largerThanTop1=frequency > top1;
        boolean largerThanTop2=frequency > top2;
        top2=largerThanTop1 ? top1 : top2;
        top1=largerThanTop1 ? frequency : top1;
        top2=largerThanTop2 && frequency != top1 ? frequency : top2;
      }
      if (top1 != top2) {
        result+=(entry.count - top1) * penaltyInfrequentResponse;
      }
 else {
        result+=(entry.count - top1) * penaltyNoMajorityResponse;
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Returns the penalty for the given entry
 * @param entry
 * @return
 */
private double getPenalty(HashGroupifyEntry entry){
  double result=0d;
  if (!entry.isNotOutlier) {
    result+=entry.count * (responseVariablesNotAnalyzed + responseVariables.length) * penaltySuppressed;
  }
 else {
    for (    int index : this.responseVariables) {
      int top1=-1;
      int top2=-1;
      Distribution distribution=entry.distributions[index];
      int[] buckets=distribution.getBuckets();
      for (int i=0; i < buckets.length; i+=2) {
        int frequency=buckets[i + 1];
        boolean largerThanTop1=frequency > top1;
        boolean largerThanTop2=frequency > top2;
        top2=largerThanTop1 ? top1 : top2;
        top1=largerThanTop1 ? frequency : top1;
        top2=largerThanTop2 && frequency != top1 ? frequency : top2;
      }
      if (top1 != top2) {
        result+=(entry.count - top1) * penaltyInfrequentResponse;
      }
 else {
        result+=entry.count * penaltyNoMajorityResponse;
      }
    }
  }
  return result;
}