Program: 59266
Project: 59266
Buggy source:
/** 
 * Match each pixel in each row with another pixel in the next row down. All matchings are 1:1 and the total matching maximizes the sum of the energy  in pairs between the rows.  This maximization has been shown to increase  the variance, therefore it tends to produce seams that are either clearly  important or clearly not.   This is a strictly local calculation.  There are other methods (method w2 in particular) that also take into account global information. 
 * @param aggregates
 * @param energy
 * @return
 */
public static final Aggregates<Integer> matchings(Aggregates<Double> aggregates,EdgeEnergy energy){
  Aggregates<Integer> matchings=AggregateUtils.make(aggregates,Integer.MIN_VALUE);
  for (int y=aggregates.lowY(); y < aggregates.highY(); y++) {
    double F1=0, F2=0, F3=0;
    for (int x=aggregates.lowX(); x < aggregates.highX(); x++) {
      double CZ=energy.between(x,y,x,y + 1);
      double CY=energy.between(x,y,x - 1,y + 1);
      double BZ=energy.between(x - 1,y,x,y + 1);
      double AX=energy.between(x - 2,y,x - 2,y + 1);
      if (matchings.get(x - 2,y) == x - 1) {
        double FA=F1 + CZ;
        double FB=F3 + CY + BZ+ AX;
        if (FA > FB) {
          matchings.set(x,y,0);
          F3=F2;
          F2=F1;
          F1=FA;
        }
 else {
          matchings.set(x,y,-1);
          matchings.set(x - 1,y,1);
          matchings.set(x - 2,y,0);
          F3=F2;
          F2=F1;
          F1=FB;
        }
      }
 else {
        double FA=F1 + CZ;
        double FB=F2 + CY + BZ;
        if (FA > FB) {
          matchings.set(x,y,0);
          F3=F2;
          F2=F1;
          F1=FA;
        }
 else {
          matchings.set(x,y,-1);
          matchings.set(x - 1,y,1);
          F3=F2;
          F2=F1;
          F1=FB;
        }
      }
    }
  }
  return matchings;
}

Fixed version (ground truth):
public static final Aggregates<Integer> matchings(Aggregates<Double> aggregates,EdgeEnergy energy){
  Aggregates<Integer> matchings=AggregateUtils.make(aggregates,Integer.MIN_VALUE);
  for (int y=aggregates.lowY(); y < aggregates.highY(); y++) {
    double F1=0, F2=0, F3=0;
    for (int x=aggregates.lowX(); x < aggregates.highX(); x++) {
      double CZ=energy.between(x,y,x,y + 1);
      double CY=energy.between(x,y,x - 1,y + 1);
      double BZ=energy.between(x - 1,y,x,y + 1);
      double AX=energy.between(x - 2,y,x - 2,y + 1);
      if (matchings.get(x - 2,y) == x - 1) {
        double FA=F1 + CZ;
        double FB=F3 + CY + BZ+ AX;
        if (FA >= FB) {
          matchings.set(x,y,ZERO);
          F3=F2;
          F2=F1;
          F1=FA;
        }
 else {
          matchings.set(x,y,NEGATIVE_ONE);
          matchings.set(x - 1,y,ONE);
          matchings.set(x - 2,y,ZERO);
          F3=F2;
          F2=F1;
          F1=FB;
        }
      }
 else {
        double FA=F1 + CZ;
        double FB=F2 + CY + BZ;
        if (FA >= FB) {
          matchings.set(x,y,ZERO);
          F3=F2;
          F2=F1;
          F1=FA;
        }
 else {
          matchings.set(x,y,NEGATIVE_ONE);
          matchings.set(x - 1,y,ONE);
          F3=F2;
          F2=F1;
          F1=FB;
        }
      }
    }
  }
  return matchings;
}