/** * Selects the best of two points. * * @param a Point and value. * @param b Point and value. * @param isMinim {@code true} if the selected point must be the one with * the lowest value. * @return the best point, or {@code null} if {@code a} and {@code b} are * both {@code null}. When {@code a} and {@code b} have the same function * value, {@code a} is returned. */ private UnivariatePointValuePair best(UnivariatePointValuePair a, UnivariatePointValuePair b, boolean isMinim) { if (a == null) { return b; } if (b == null) { return a; } if (isMinim) { return a.getValue() <= b.getValue() ? a : b; } else { return a.getValue() >= b.getValue() ? a : b; } } }
/** {@inheritDoc} */ public int compare(final UnivariatePointValuePair o1, final UnivariatePointValuePair o2) { if (o1 == null) { return (o2 == null) ? 0 : 1; } else if (o2 == null) { return -1; } final double v1 = o1.getValue(); final double v2 = o2.getValue(); return (goal == GoalType.MINIMIZE) ? Double.compare(v1, v2) : Double.compare(v2, v1); } });
/** * Selects the best of two points. * * @param a Point and value. * @param b Point and value. * @param isMinim {@code true} if the selected point must be the one with * the lowest value. * @return the best point, or {@code null} if {@code a} and {@code b} are * both {@code null}. When {@code a} and {@code b} have the same function * value, {@code a} is returned. */ private UnivariatePointValuePair best(UnivariatePointValuePair a, UnivariatePointValuePair b, boolean isMinim) { if (a == null) { return b; } if (b == null) { return a; } if (isMinim) { return a.getValue() <= b.getValue() ? a : b; } else { return a.getValue() >= b.getValue() ? a : b; } }
/** * Selects the best of two points. * * @param a Point and value. * @param b Point and value. * @param isMinim {@code true} if the selected point must be the one with * the lowest value. * @return the best point, or {@code null} if {@code a} and {@code b} are * both {@code null}. When {@code a} and {@code b} have the same function * value, {@code a} is returned. */ private UnivariatePointValuePair best(UnivariatePointValuePair a, UnivariatePointValuePair b, boolean isMinim) { if (a == null) { return b; } if (b == null) { return a; } if (isMinim) { return a.getValue() <= b.getValue() ? a : b; } else { return a.getValue() >= b.getValue() ? a : b; } } }
/** {@inheritDoc} */ public int compare(final UnivariatePointValuePair o1, final UnivariatePointValuePair o2) { if (o1 == null) { return (o2 == null) ? 0 : 1; } else if (o2 == null) { return -1; } final double v1 = o1.getValue(); final double v2 = o2.getValue(); return (goal == GoalType.MINIMIZE) ? Double.compare(v1, v2) : Double.compare(v2, v1); } });
/** {@inheritDoc} */ public int compare(final UnivariatePointValuePair o1, final UnivariatePointValuePair o2) { if (o1 == null) { return (o2 == null) ? 0 : 1; } else if (o2 == null) { return -1; } final double v1 = o1.getValue(); final double v2 = o2.getValue(); return (goal == GoalType.MINIMIZE) ? Double.compare(v1, v2) : Double.compare(v2, v1); } });
logger.fine("Found minimum value: " + optimalMin.getValue() + " @ " + optimalMin.getPoint());
double retVal = solution.getValue();