Program: 73433
Project: 73433
Buggy source:
/** 
 * Derive a map of base dimensions to lists of units that represents the given component units map and dimension map.
 * @param componentUnitsMap The map of dimensions to lists of units fromwhich the base component units map will be derived.
 * @param dimensionMap The map of dimensions to exponents from whichbase dimension map will be derived.
 * @param baseDimensionMap The map of base dimensions to exponents neededfor creating the base component units map.
 * @return The map of base dimensions to exponents that composes the givendimension map.
 * @throws IllegalActionException Thrown if an invalid dimension conceptis found.
 */
public static Map<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>> deriveComponentBaseUnitsMap(Map<DimensionRepresentativeConcept,List<UnitConcept>> componentUnitsMap,Map<DimensionRepresentativeConcept,Integer> dimensionMap,Map<BaseDimensionRepresentativeConcept,Integer> baseDimensionMap) throws IllegalActionException {
  Map<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>> baseComponentUnits=new HashMap<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>>();
  Map<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>[]> baseComponentUnitsSeparateExponents=_deriveComponentBaseUnitsSeparateExponentsMap(componentUnitsMap,dimensionMap,baseDimensionMap);
  for (  BaseDimensionRepresentativeConcept baseDimension : baseDimensionMap.keySet()) {
    int exponent=baseDimensionMap.get(baseDimension).intValue();
    List<BaseUnitConcept> positiveExponentUnitList=baseComponentUnitsSeparateExponents.get(baseDimension)[POSITIVE_EXPONENT_INDEX];
    List<BaseUnitConcept> negativeExponentUnitList=baseComponentUnitsSeparateExponents.get(baseDimension)[NEGATIVE_EXPONENT_INDEX];
    List<BaseUnitConcept> composedUnitList=null;
    if (exponent > 0) {
      composedUnitList=_removeMatchingListElements(positiveExponentUnitList,negativeExponentUnitList);
    }
 else     if (exponent < 0) {
      composedUnitList=_removeMatchingListElements(negativeExponentUnitList,positiveExponentUnitList);
    }
 else {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    }
    if (composedUnitList.size() == Math.abs(exponent)) {
      Collections.sort(composedUnitList,new BaseUnitComparator());
      baseComponentUnits.put(baseDimension,composedUnitList);
    }
 else {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + baseDimension + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ composedUnitList.size()+ "String_Node_Str"+ exponent);
    }
  }
  return baseComponentUnits;
}

Fixed version (ground truth):
/** 
 * Derive a map of base dimensions to lists of units that represents the given component units map and dimension map.
 * @param componentUnitsMap The map of dimensions to lists of units fromwhich the base component units map will be derived.
 * @param dimensionMap The map of dimensions to exponents from whichbase dimension map will be derived.
 * @param baseDimensionMap The map of base dimensions to exponents neededfor creating the base component units map.
 * @return The map of base dimensions to exponents that composes the givendimension map.
 * @throws IllegalActionException Thrown if an invalid dimension conceptis found.
 */
public static Map<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>> deriveComponentBaseUnitsMap(Map<DimensionRepresentativeConcept,List<UnitConcept>> componentUnitsMap,Map<DimensionRepresentativeConcept,Integer> dimensionMap,Map<BaseDimensionRepresentativeConcept,Integer> baseDimensionMap) throws IllegalActionException {
  Map<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>> baseComponentUnits=new HashMap<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>>();
  Map<BaseDimensionRepresentativeConcept,List<BaseUnitConcept>[]> baseComponentUnitsSeparateExponents=_deriveComponentBaseUnitsSeparateExponentsMap(componentUnitsMap,dimensionMap,baseDimensionMap);
  for (  Map.Entry<BaseDimensionRepresentativeConcept,Integer> baseDimensionMapEntry : baseDimensionMap.entrySet()) {
    BaseDimensionRepresentativeConcept baseDimension=baseDimensionMapEntry.getKey();
    int exponent=baseDimensionMapEntry.getValue().intValue();
    List<BaseUnitConcept> positiveExponentUnitList=baseComponentUnitsSeparateExponents.get(baseDimension)[POSITIVE_EXPONENT_INDEX];
    List<BaseUnitConcept> negativeExponentUnitList=baseComponentUnitsSeparateExponents.get(baseDimension)[NEGATIVE_EXPONENT_INDEX];
    List<BaseUnitConcept> composedUnitList=null;
    if (exponent > 0) {
      composedUnitList=_removeMatchingListElements(positiveExponentUnitList,negativeExponentUnitList);
    }
 else     if (exponent < 0) {
      composedUnitList=_removeMatchingListElements(negativeExponentUnitList,positiveExponentUnitList);
    }
 else {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    }
    if (composedUnitList.size() == Math.abs(exponent)) {
      Collections.sort(composedUnitList,new BaseUnitComparator());
      baseComponentUnits.put(baseDimension,composedUnitList);
    }
 else {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + baseDimension + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ composedUnitList.size()+ "String_Node_Str"+ exponent);
    }
  }
  return baseComponentUnits;
}