Return the best solution between those passed as arguments. If they are equal or incomparable
one of them is chosen based on the given policy.

@return The best solution
434064
public static <S extends Solution<?>> S getBestSolution(S solution1, S solution2, Comparator<S> comparator, BinaryOperator<S> equalityPolicy) {
    S result;
    int flag = comparator.compare(solution1, solution2);
    if (flag == -1) {
      result = solution1;
    } else if (flag == 1) {
      result = solution2;
    } else {
      result = equalityPolicy.apply(solution1, solution2);
    }

    return result;
  }
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;
  }
458302
public int compare(Alternative ab) {
        if (production != ab.production) {
            throw new IllegalArgumentException();
        }
        // TODO: compare two ups
        if (resultOfs != -1 || ab.resultOfs != -1) {
            return NE;
        }
        if (argsOfs.size() == 0 && ab.argsOfs.size() == 0) {
            return EQ;
        }
        if (argsOfs.size() == 0 || ab.argsOfs.size() == 0) {
            return ALT;
        }
        if (max(argsOfs) < min(ab.argsOfs)) {
            return LT;
        }
        if (min(argsOfs) > max(ab.argsOfs)) {
            return GT;
        }
        if (argsOfs.size() != 1 || ab.argsOfs.size() != 1) {
            return NE;
        } else {
            if (argsOfs.get(0) != ab.argsOfs.get(0)) {
                throw new IllegalStateException();
            }
            return EQ;
        }
    }
970073
public com.google.api.ads.adwords.axis.v201809.cm.PolicyTopicConstraint[] getPolicyTopicConstraints() {
        return policyTopicConstraints;
    }
860439
public java.util.List<Policy> getPolicies() {
        if (policies == null) {
            policies = new com.amazonaws.internal.SdkInternalList<Policy>();
        }
        return policies;
    }
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;
   }
1139905
public static Method bestMethod(Method[] methods, Object[] args) throws AmbiguousMethodMatchException {
        return bestMethod(methods, collectArgTypes(args));
    }
1097699
private static List<IAtomContainer> getMaximum(ArrayList<IAtomContainer> graphList, boolean shouldMatchBonds)
            throws CDKException {
        List<IAtomContainer> reducedGraphList = (List<IAtomContainer>) graphList.clone();

        for (int i = 0; i < graphList.size(); i++) {
            IAtomContainer graphI = graphList.get(i);

            for (int j = i + 1; j < graphList.size(); j++) {
                IAtomContainer graphJ = graphList.get(j);

                // Gi included in Gj or Gj included in Gi then
                // reduce the irrelevant solution
                if (isSubgraph(graphJ, graphI, shouldMatchBonds)) {
                    reducedGraphList.remove(graphI);
                } else if (isSubgraph(graphI, graphJ, shouldMatchBonds)) {
                    reducedGraphList.remove(graphJ);
                }
            }
        }
        return reducedGraphList;
    }
30578
public T getMaximum() {
        Lock lock = this.lock.readLock();
        lock.lock();
        try {
            return this.maximum;
        } finally {
            lock.unlock();
        }
    }
1293209
private String getOptimization(final CommandLineCompilerConfiguration compilerConfig) {
    final String[] args = compilerConfig.getPreArguments();
    String opt = "0";
    for (final String arg : args) {
      if ("/Od".equals(arg)) {
        opt = "0";
      }
      if ("/O1".equals(arg)) {
        opt = "1";
      }
      if ("/O2".equals(arg)) {
        opt = "2";
      }
      if ("/Ox".equals(arg)) {
        opt = "3";
      }
    }
    return opt;
  }
1002867
public static function policies()
    {
        $abilities = array_values(
            (new \ReflectionClass($instance = new static))->getConstants()
        );

        return array_map(function ($constant) use ($instance) {
            $method = Str::camel(last(explode('.', $constant)).'Policy');

            if ( ! method_exists($instance, $method))
                throw new MissingPolicyException("Missing policy [$method] method in ".get_class($instance).".");

            return $method;
        }, array_combine($abilities, $abilities));
    }
1073638
public Choice<T> condition(final Predicate<? super T> predicate) {
    checkNotNull(predicate);
    final Choice<T> thisChoice = this;
    return new Choice<T>() {
      @Override
      protected Iterator<T> iterator() {
        return Iterators.filter(thisChoice.iterator(), predicate);
      }

      @Override
      public String toString() {
        return String.format("%s.condition(%s)", thisChoice, predicate);
      }
    };
  }
89012
public AbstractExpression getFirstArgument() {
        if (m_left != null) {
            assert(m_args == null);
            return m_left;
        }
        if (m_args != null && m_args.size() > 0) {
            assert(m_left == null && m_right == null);
            return m_args.get(0);
        }
        return null;
    }
470736
protected double selectBest( int length ) {
		double best = Double.MAX_VALUE;
		int index = -1;
		for( int i = minDisparity; i < length; i++ ) {
			if( score[i] < best ) {
				best = score[i];
				index = i;
			}
		}

		return index-minDisparity;
	}
1032745
public PathImpl getBestPath()
  {
    /*
    if (_bestPath != null)
      return _bestPath;
      */

    ArrayList<PathImpl> pathList = getPathList();
    for (int i = 0; i < pathList.size(); i++) {
      PathImpl path = pathList.get(i);

      if (path.exists()) {
        return path;
      }
    }

    if (pathList.size() > 0) {
      return pathList.get(0);
    }

    return new NotFoundPath(getSchemeMap(), _userPath);
  }
1046319
public BoundedAssertion getMax()
    {
    ICondition max = null;
    Iterator<ICondition> conditions = getConditions();
    for( int i = 0; i < 2; i++) max = conditions.next();
    return (BoundedAssertion) max;
    }
1092346
public static int bestMatch(Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes) throws AmbiguousSignatureMatchException {
        return bestMatch(signatures, varArgs, new JavaSignatureComparator(argTypes));
    }