Compares two solutions.

@param solution1 Object representing the first <code>Solution</code>.
@param solution2 Object representing the second <code>Solution</code>.
@return -1, or 0, or 1 if o1 is less than, equal, or greater than o2,
respectively.
166374
@Override
  public int compare(S solution1, S solution2) {
    if (solution1 == null) {
      return 1;
    } else if (solution2 == null) {
      return -1;
    }

    double fitness1 = solutionFitness.getAttribute(solution1);
    double fitness2 = solutionFitness.getAttribute(solution2);
    if (fitness1 < fitness2) {
      return -1;
    }

    if (fitness1 > fitness2) {
      return 1;
    }

    return 0;
  }
109986
public static int invertedCompare(Solution s1, Solution s2) {
      int flag = InvertedCompareUtils.ConstraintCompare(s1, s2);

      if (flag == 0)
      {
         flag = InvertedCompareUtils.ParetoObjectiveCompare(s1, s2);
      }
      return flag;
   }
1087144
public static <T> int compareTo(Comparable<T> object1, T object2) {
		if (object1 == object2) {
			return 0;
		}
		if (object1 == null) {
			return Integer.MIN_VALUE;
		}
		if (object2 == null) {
			return Integer.MAX_VALUE;
		}
		assert object1 != null && object2 != null;
		return object1.compareTo(object2);
	}
175383
@Override
		public int compare(CDSSequence o1, CDSSequence o2) {
			if(o1.getStrand() != o2.getStrand()){
				return o1.getBioBegin() - o2.getBioBegin();
			}
			if(o1.getStrand() == Strand.NEGATIVE){
				return -1 * (o1.getBioBegin() - o2.getBioBegin());
			}

			return o1.getBioBegin() - o2.getBioBegin();
		}
863998
public static int invertedCompare(Solution s1, Solution s2) {
      int flag = InvertedCompareUtils.RankCompare(s1, s2);

      if (flag == 0)
      {
         flag = InvertedCompareUtils.CrowdingDistanceCompare(s1, s2);
      }
      return flag;
   }
137013
public int compare(final FeatureFile ff1, final FeatureFile ff2) {
		if (ff1 != null && ff2 != null) {
			return ff1.getName().compareTo(ff2.getName());
		} else {
			return -1;
		}
	}
634709
public static int ConstraintCompare(Solution solution1, Solution solution2)
   {
      double constraints1 = 0;
      int constraint_count = solution1.getConstraints().size();
      for (int i = 0; i < constraint_count; i++)
      {
         constraints1 += Math.abs(solution1.getConstraint(i));
      }

      double constraints2 = 0;
      for (int i = 0; i < constraint_count; i++)
      {
         constraints2 += Math.abs(solution2.getConstraint(i));
      }

      if ((constraints1 != 0.0) || (constraints2 != 0.0))
      {
         if (constraints1 == 0.0)
         {
            return -1;
         }
         else if (constraints2 == 0.0)
         {
            return 1;
         }
         else
         {
            return Double.compare(constraints1, constraints2);
         }
      }
      else
      {
         return 0;
      }
   }
907178
protected int compare(MethodDesc o1, MethodDesc o2) {
		final Class<?>[] paramTypes1 = o1.getParameterTypes();
		final Class<?>[] paramTypes2 = o2.getParameterTypes();

		// sort by parameter types from left to right
		for (int i = 0; i < paramTypes1.length; i++) {
			final Class<?> class1 = paramTypes1[i];
			final Class<?> class2 = paramTypes2[i];

			if (class1.equals(class2))
				continue;
			if (class1.isAssignableFrom(class2) || Void.class.equals(class2))
				return -1;
			if (class2.isAssignableFrom(class1) || Void.class.equals(class1))
				return 1;
		}

		// sort by declaring class (more specific comes first).
		if (!o1.getDeclaringClass().equals(o2.getDeclaringClass())) {
			if (o1.getDeclaringClass().isAssignableFrom(o2.getDeclaringClass()))
				return 1;
			if (o2.getDeclaringClass().isAssignableFrom(o1.getDeclaringClass()))
				return -1;
		}

		// sort by target
		final int compareTo = ((Integer) targets.indexOf(o2.target)).compareTo(targets.indexOf(o1.target));
		return compareTo;
	}
258385
public double evaluate(List<? extends Solution<?>> set1, List<? extends Solution<?>> set2) {
    double result ;
    int sum = 0 ;

    if (set2.size()==0) {
      if (set1.size()==0) {
        result = 0.0 ;
      } else {
        result = 1.0 ;
      }
    } else {
      for (Solution<?> solution : set2) {
        if (SolutionListUtils.isSolutionDominatedBySolutionList(solution, set1)) {
          sum++;
        }
      }
      result = (double)sum/set2.size() ;
    }
    return result ;
  }
123597
public int compare(final SnomedConcept o1, final SnomedConcept o2) {
        if (o1 == o2) return 0;
        if (o1 != null) {
            if (o2 == null) return 1;
                // need to use BigInteger to compare SNOMED codes since some are fantastically long
            else return new BigInteger(o1.snomedId)
                    .compareTo(new BigInteger(o2.snomedId));
        }
        return -1;
    }
15289
public int compare(Object o1, Object o2) {
        int m1 = ((int[])o1)[0];
        int m2 = ((int[])o2)[0];
        if (m1 < m2)
            return -1;
        if (m1 == m2)
            return 0;
        return 1;
    }
1322692
@SuppressWarnings("unchecked")
   public static int compare(Object o1, Object o2) {
      if (o1 == null && o2 == null) {
         return 0;
      } else if (o1 == null) {
         return 1;
      } else if (o2 == null) {
         return -1;
      }
      return Cast.<Comparable>as(o1).compareTo(o2);
   }
760922
public void evaluate(PermutationSolution<Integer> solution){
    double fitness1   ;
    double fitness2   ;

    fitness1 = 0.0 ;
    fitness2 = 0.0 ;

    for (int i = 0; i < (numberOfCities - 1); i++) {
      int x ;
      int y ;

      x = solution.getVariableValue(i) ;
      y = solution.getVariableValue(i+1) ;

      fitness1 += distanceMatrix[x][y] ;
      fitness2 += costMatrix[x][y];
    }
    int firstCity ;
    int lastCity  ;

    firstCity = solution.getVariableValue(0) ;
    lastCity = solution.getVariableValue(numberOfCities - 1) ;

    fitness1 += distanceMatrix[firstCity][lastCity] ;
    fitness2 += costMatrix[firstCity][lastCity];

    solution.setObjective(0, fitness1);
    solution.setObjective(1, fitness2);
  }
183290
public static int difference(String s1, String s2) {

        /** @todo: check if this is the standard algorithm */
        if ((s1 == null) || (s2 == null)) {
            return 0;
        }

        s1 = soundex(s1);
        s2 = soundex(s2);

        int e = 0;

        for (int i = 0; i < 4; i++) {
            if (s1.charAt(i) != s2.charAt(i)) {
                e++;
            }
        }

        return e;
    }
1047253
public void evaluate(DoubleSolution solution) {
    double[] f = new double[getNumberOfObjectives()];
    double value = solution.getVariableValue(0) ;

    f[0] = value * value;
    f[1] = (value - 2.0) * (value - 2.0);

    solution.setObjective(0, f[0]);
    solution.setObjective(1, f[1]);
  }
1080537
@SuppressWarnings("unchecked")
    public static int compare(Object a, Object b) {
        if (a == b) {
            return 0;
        }
        if (a == null) {
            return -1;
        }
        if (b == null) {
            return 1;
        }
        if (a instanceof Comparable) {
            Comparable comparable = (Comparable)a;
            return comparable.compareTo(b);
        }
        int answer = a.getClass().getName().compareTo(b.getClass().getName());
        if (answer == 0) {
            answer = a.hashCode() - b.hashCode();
        }
        return answer;
    }
738770
@SuppressWarnings("unchecked")
  public S execute(S solution) {
    int i = 0;
    int best;
    evaluations = 0;
    numberOfNonComparableSolutions = 0;

    int rounds = improvementRounds;

    while (i < rounds) {
      S mutatedSolution = mutationOperator.execute((S) solution.copy());

      problem.evaluate(mutatedSolution);
      evaluations++;

      if (problem.getNumberOfConstraints() > 0) {
        best = constraintComparator.compare(mutatedSolution, solution);
        if (best == 0) {
          best = dominanceComparator.compare(mutatedSolution, solution);
        }
      } else {
        best = dominanceComparator.compare(mutatedSolution, solution);
      }

      if (best == -1) {
        solution = mutatedSolution;
        numberOfImprovements++;
      } else if (best == 1) {
        ;
      } else {
        numberOfNonComparableSolutions++;
        archive.add(mutatedSolution);
      }
      i++;
    }
    return (S) solution.copy();
  }