Program: 45347
Project: 45347
Buggy source:
private boolean isNodeSuitableForEfficientDistributionCheck(Node node,TaskLookup taskLookup){
  boolean isSuitable=true;
  float alpha=Preferences.ALPHA_MIN;
  float beta=Preferences.BETA;
  float gama=Preferences.GAMA;
  float weight=beta;
  BattreyInfo oldBattreyInfo=null;
  float lastAvgNodeLoad;
  Queue<BattreyInfo> nodeBattreyLoadInfo=battreyLoadInfo.get(node.getName());
  if (nodeBattreyLoadInfo == null) {
    nodeBattreyLoadInfo=new LinkedList<BattreyInfo>();
    battreyLoadInfo.put(node.getName(),nodeBattreyLoadInfo);
  }
  if (nodeBattreyLoadInfo.size() >= Preferences.NODE_BATTERY_INFO_QUEUE_SIZE) {
    oldBattreyInfo=nodeBattreyLoadInfo.remove();
  }
  advReplyTotalCount++;
  if (advReplyCount > 1) {
    double stdDevNodeLoad=Math.sqrt(varianceNodeLoad / advReplyCount);
    if (oldBattreyInfo != null) {
      advReplyCount--;
      lastAvgNodeLoad=avgNodeLoad;
      avgNodeLoad=avgNodeLoad - (oldBattreyInfo.getWeight() * ((oldBattreyInfo.getBattreyLoad() - avgNodeLoad) / advReplyCount));
      varianceNodeLoad=varianceNodeLoad - (oldBattreyInfo.getWeight() * ((oldBattreyInfo.getBattreyLoad() - lastAvgNodeLoad) * (oldBattreyInfo.getBattreyLoad() - avgNodeLoad)));
    }
    if (advReplyTotalCount < Preferences.NUMBER_PACKETS_NETWORK_STABLIZE) {
      alpha=Preferences.ALPHA_MIN + (((Preferences.NUMBER_PACKETS_NETWORK_STABLIZE - advReplyTotalCount) / (Preferences.NUMBER_PACKETS_NETWORK_STABLIZE * 1.0f)) * (Preferences.ALPHA_MAX - Preferences.ALPHA_MIN));
    }
    if (Math.abs(node.getBatteryLevel() - avgNodeLoad) > alpha * stdDevNodeLoad) {
      isSuitable=false;
    }
  }
  advReplyCount++;
  lastAvgNodeLoad=avgNodeLoad;
  if (!isSuitable) {
    weight=gama;
  }
  nodeBattreyLoadInfo.add(new BattreyInfo(node.getBatteryLevel(),weight));
  avgNodeLoad=avgNodeLoad + weight * ((node.getBatteryLevel() - avgNodeLoad) / advReplyCount);
  if (advReplyCount == 1) {
    varianceNodeLoad=0;
  }
 else {
    varianceNodeLoad=varianceNodeLoad + weight * ((node.getBatteryLevel() - lastAvgNodeLoad) * (node.getBatteryLevel() - avgNodeLoad));
  }
  return isSuitable;
}

Fixed version (ground truth):
private boolean isNodeSuitableForEfficientDistributionCheck(Node node,TaskLookup taskLookup){
  boolean isSuitable=true;
  float alpha=Preferences.ALPHA_MIN;
  float beta=Preferences.BETA;
  float gama=Preferences.GAMA;
  float weight=beta;
  BattreyInfo oldBattreyInfo=null;
  float lastAvgNodeLoad;
  Queue<BattreyInfo> nodeBattreyLoadInfo=battreyLoadInfo.get(node.getName());
  if (nodeBattreyLoadInfo == null) {
    nodeBattreyLoadInfo=new LinkedList<BattreyInfo>();
    battreyLoadInfo.put(node.getName(),nodeBattreyLoadInfo);
  }
  if (nodeBattreyLoadInfo.size() >= Preferences.NODE_BATTERY_INFO_QUEUE_SIZE) {
    oldBattreyInfo=nodeBattreyLoadInfo.remove();
  }
  advReplyTotalCount++;
  if (advReplyCount > 1) {
    double stdDevNodeLoad=Math.sqrt(varianceNodeLoad / advReplyCount);
    if (oldBattreyInfo != null) {
      advReplyCount--;
      lastAvgNodeLoad=avgNodeLoad;
      avgNodeLoad=avgNodeLoad - (oldBattreyInfo.getWeight() * ((oldBattreyInfo.getBattreyLoad() - avgNodeLoad) / advReplyCount));
      varianceNodeLoad=varianceNodeLoad - (oldBattreyInfo.getWeight() * ((oldBattreyInfo.getBattreyLoad() - lastAvgNodeLoad) * (oldBattreyInfo.getBattreyLoad() - avgNodeLoad)));
    }
    if (advReplyTotalCount < Preferences.NUMBER_PACKETS_NETWORK_STABLIZE) {
      alpha=Preferences.ALPHA_MIN + (((Preferences.NUMBER_PACKETS_NETWORK_STABLIZE - advReplyTotalCount) / (Preferences.NUMBER_PACKETS_NETWORK_STABLIZE * 1.0f)) * (Preferences.ALPHA_MAX - Preferences.ALPHA_MIN));
    }
    alpha=alpha + (22 - nodes.size()) * (Preferences.ALPHA_SAFE - Preferences.ALPHA_MIN) / 20.0f;
    if ((node.getBatteryLevel() - avgNodeLoad) > (Preferences.ALPHA_POSITIVE_RANGE * stdDevNodeLoad)) {
      isSuitable=true;
    }
 else     if (Math.abs(node.getBatteryLevel() - avgNodeLoad) > (alpha * stdDevNodeLoad)) {
      isSuitable=false;
    }
    System.out.println("String_Node_Str" + node.getName() + "String_Node_Str"+ node.getBatteryLevel()+ "String_Node_Str"+ avgNodeLoad+ "String_Node_Str"+ stdDevNodeLoad+ "String_Node_Str"+ alpha+ "String_Node_Str"+ isSuitable);
  }
  advReplyCount++;
  lastAvgNodeLoad=avgNodeLoad;
  if (!isSuitable) {
    weight=gama;
  }
  nodeBattreyLoadInfo.add(new BattreyInfo(node.getBatteryLevel(),weight));
  avgNodeLoad=avgNodeLoad + weight * ((node.getBatteryLevel() - avgNodeLoad) / advReplyCount);
  if (advReplyCount == 1) {
    varianceNodeLoad=0;
  }
 else {
    varianceNodeLoad=varianceNodeLoad + weight * ((node.getBatteryLevel() - lastAvgNodeLoad) * (node.getBatteryLevel() - avgNodeLoad));
  }
  return isSuitable;
}