Java Code Examples for org.apache.commons.math3.optim.nonlinear.scalar.GoalType#MINIMIZE

The following examples show how to use org.apache.commons.math3.optim.nonlinear.scalar.GoalType#MINIMIZE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    final double[] lowerBound = getLowerBound();
    final double[] upperBound = getUpperBound();

    // Validity checks.
    setup(lowerBound, upperBound);

    isMinimize = (getGoalType() == GoalType.MINIMIZE);
    currentBest = new ArrayRealVector(getStartPoint());

    final double value = bobyqa(lowerBound, upperBound);

    return new PointValuePair(currentBest.getDataRef(),
                              isMinimize ? value : -value);
}
 
Example 2
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    final double[] lowerBound = getLowerBound();
    final double[] upperBound = getUpperBound();

    // Validity checks.
    setup(lowerBound, upperBound);

    isMinimize = (getGoalType() == GoalType.MINIMIZE);
    currentBest = new ArrayRealVector(getStartPoint());

    final double value = bobyqa(lowerBound, upperBound);

    return new PointValuePair(currentBest.getDataRef(),
                              isMinimize ? value : -value);
}
 
Example 3
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    final double[] lowerBound = getLowerBound();
    final double[] upperBound = getUpperBound();

    // Validity checks.
    setup(lowerBound, upperBound);

    isMinimize = (getGoalType() == GoalType.MINIMIZE);
    currentBest = new ArrayRealVector(getStartPoint());

    final double value = bobyqa(lowerBound, upperBound);

    return new PointValuePair(currentBest.getDataRef(),
                              isMinimize ? value : -value);
}
 
Example 4
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    final double[] lowerBound = getLowerBound();
    final double[] upperBound = getUpperBound();

    // Validity checks.
    setup(lowerBound, upperBound);

    isMinimize = (getGoalType() == GoalType.MINIMIZE);
    currentBest = new ArrayRealVector(getStartPoint());

    final double value = bobyqa(lowerBound, upperBound);

    return new PointValuePair(currentBest.getDataRef(),
                              isMinimize ? value : -value);
}
 
Example 5
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    final double[] lowerBound = getLowerBound();
    final double[] upperBound = getUpperBound();

    // Validity checks.
    setup(lowerBound, upperBound);

    isMinimize = (getGoalType() == GoalType.MINIMIZE);
    currentBest = new ArrayRealVector(getStartPoint());

    final double value = bobyqa(lowerBound, upperBound);

    return new PointValuePair(currentBest.getDataRef(),
                              isMinimize ? value : -value);
}
 
Example 6
Source File: Math_6_SimplexOptimizer_t.java    From coming with MIT License 4 votes vote down vote up
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    checkParameters();

    // Indirect call to "computeObjectiveValue" in order to update the
    // evaluations counter.
    final MultivariateFunction evalFunc
        = new MultivariateFunction() {
            public double value(double[] point) {
                return computeObjectiveValue(point);
            }
        };

    final boolean isMinim = getGoalType() == GoalType.MINIMIZE;
    final Comparator<PointValuePair> comparator
        = new Comparator<PointValuePair>() {
        public int compare(final PointValuePair o1,
                           final PointValuePair o2) {
            final double v1 = o1.getValue();
            final double v2 = o2.getValue();
            return isMinim ? Double.compare(v1, v2) : Double.compare(v2, v1);
        }
    };

    // Initialize search.
    simplex.build(getStartPoint());
    simplex.evaluate(evalFunc, comparator);

    PointValuePair[] previous = null;
    int iteration = 0;
    final ConvergenceChecker<PointValuePair> checker = getConvergenceChecker();
    while (true) {
        if (getIterations() > 0) {
            boolean converged = true;
            for (int i = 0; i < simplex.getSize(); i++) {
                PointValuePair prev = previous[i];
                converged = converged &&
                    checker.converged(iteration, prev, simplex.getPoint(i));
            }
            if (converged) {
                // We have found an optimum.
                return simplex.getPoint(0);
            }
        }

        // We still need to search.
        previous = simplex.getPoints();
        simplex.iterate(evalFunc, comparator);

        incrementIterationCount();
    }
}
 
Example 7
Source File: Math_6_SimplexOptimizer_s.java    From coming with MIT License 4 votes vote down vote up
/** {@inheritDoc} */
 @Override
 protected PointValuePair doOptimize() {
     checkParameters();

     // Indirect call to "computeObjectiveValue" in order to update the
     // evaluations counter.
     final MultivariateFunction evalFunc
         = new MultivariateFunction() {
             public double value(double[] point) {
                 return computeObjectiveValue(point);
             }
         };

     final boolean isMinim = getGoalType() == GoalType.MINIMIZE;
     final Comparator<PointValuePair> comparator
         = new Comparator<PointValuePair>() {
         public int compare(final PointValuePair o1,
                            final PointValuePair o2) {
             final double v1 = o1.getValue();
             final double v2 = o2.getValue();
             return isMinim ? Double.compare(v1, v2) : Double.compare(v2, v1);
         }
     };

     // Initialize search.
     simplex.build(getStartPoint());
     simplex.evaluate(evalFunc, comparator);

     PointValuePair[] previous = null;
     int iteration = 0;
     final ConvergenceChecker<PointValuePair> checker = getConvergenceChecker();
     while (true) {
         if (iteration > 0) {
             boolean converged = true;
             for (int i = 0; i < simplex.getSize(); i++) {
                 PointValuePair prev = previous[i];
                 converged = converged &&
                     checker.converged(iteration, prev, simplex.getPoint(i));
             }
             if (converged) {
                 // We have found an optimum.
                 return simplex.getPoint(0);
             }
         }

         // We still need to search.
         previous = simplex.getPoints();
         simplex.iterate(evalFunc, comparator);

++iteration;
     }
 }
 
Example 8
Source File: SimplexOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    checkParameters();

    // Indirect call to "computeObjectiveValue" in order to update the
    // evaluations counter.
    final MultivariateFunction evalFunc
        = new MultivariateFunction() {
            public double value(double[] point) {
                return computeObjectiveValue(point);
            }
        };

    final boolean isMinim = getGoalType() == GoalType.MINIMIZE;
    final Comparator<PointValuePair> comparator
        = new Comparator<PointValuePair>() {
        public int compare(final PointValuePair o1,
                           final PointValuePair o2) {
            final double v1 = o1.getValue();
            final double v2 = o2.getValue();
            return isMinim ? Double.compare(v1, v2) : Double.compare(v2, v1);
        }
    };

    // Initialize search.
    simplex.build(getStartPoint());
    simplex.evaluate(evalFunc, comparator);

    PointValuePair[] previous = null;
    int iteration = 0;
    final ConvergenceChecker<PointValuePair> checker = getConvergenceChecker();
    while (true) {
        if (getIterations() > 0) {
            boolean converged = true;
            for (int i = 0; i < simplex.getSize(); i++) {
                PointValuePair prev = previous[i];
                converged = converged &&
                    checker.converged(iteration, prev, simplex.getPoint(i));
            }
            if (converged) {
                // We have found an optimum.
                return simplex.getPoint(0);
            }
        }

        // We still need to search.
        previous = simplex.getPoints();
        simplex.iterate(evalFunc, comparator);

        incrementIterationCount();
    }
}
 
Example 9
Source File: SimplexOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    checkParameters();

    // Indirect call to "computeObjectiveValue" in order to update the
    // evaluations counter.
    final MultivariateFunction evalFunc
        = new MultivariateFunction() {
            public double value(double[] point) {
                return computeObjectiveValue(point);
            }
        };

    final boolean isMinim = getGoalType() == GoalType.MINIMIZE;
    final Comparator<PointValuePair> comparator
        = new Comparator<PointValuePair>() {
        public int compare(final PointValuePair o1,
                           final PointValuePair o2) {
            final double v1 = o1.getValue();
            final double v2 = o2.getValue();
            return isMinim ? Double.compare(v1, v2) : Double.compare(v2, v1);
        }
    };

    // Initialize search.
    simplex.build(getStartPoint());
    simplex.evaluate(evalFunc, comparator);

    PointValuePair[] previous = null;
    int iteration = 0;
    final ConvergenceChecker<PointValuePair> checker = getConvergenceChecker();
    while (true) {
        if (getIterations() > 0) {
            boolean converged = true;
            for (int i = 0; i < simplex.getSize(); i++) {
                PointValuePair prev = previous[i];
                converged = converged &&
                    checker.converged(iteration, prev, simplex.getPoint(i));
            }
            if (converged) {
                // We have found an optimum.
                return simplex.getPoint(0);
            }
        }

        // We still need to search.
        previous = simplex.getPoints();
        simplex.iterate(evalFunc, comparator);

        incrementIterationCount();
    }
}
 
Example 10
Source File: SimplexOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    checkParameters();

    // Indirect call to "computeObjectiveValue" in order to update the
    // evaluations counter.
    final MultivariateFunction evalFunc
        = new MultivariateFunction() {
            public double value(double[] point) {
                return computeObjectiveValue(point);
            }
        };

    final boolean isMinim = getGoalType() == GoalType.MINIMIZE;
    final Comparator<PointValuePair> comparator
        = new Comparator<PointValuePair>() {
        public int compare(final PointValuePair o1,
                           final PointValuePair o2) {
            final double v1 = o1.getValue();
            final double v2 = o2.getValue();
            return isMinim ? Double.compare(v1, v2) : Double.compare(v2, v1);
        }
    };

    // Initialize search.
    simplex.build(getStartPoint());
    simplex.evaluate(evalFunc, comparator);

    PointValuePair[] previous = null;
    int iteration = 0;
    final ConvergenceChecker<PointValuePair> checker = getConvergenceChecker();
    while (true) {
        if (getIterations() > 0) {
            boolean converged = true;
            for (int i = 0; i < simplex.getSize(); i++) {
                PointValuePair prev = previous[i];
                converged = converged &&
                    checker.converged(iteration, prev, simplex.getPoint(i));
            }
            if (converged) {
                // We have found an optimum.
                return simplex.getPoint(0);
            }
        }

        // We still need to search.
        previous = simplex.getPoints();
        simplex.iterate(evalFunc, comparator);

        incrementIterationCount();
    }
}
 
Example 11
Source File: SimplexOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    checkParameters();

    // Indirect call to "computeObjectiveValue" in order to update the
    // evaluations counter.
    final MultivariateFunction evalFunc
        = new MultivariateFunction() {
            public double value(double[] point) {
                return computeObjectiveValue(point);
            }
        };

    final boolean isMinim = getGoalType() == GoalType.MINIMIZE;
    final Comparator<PointValuePair> comparator
        = new Comparator<PointValuePair>() {
        public int compare(final PointValuePair o1,
                           final PointValuePair o2) {
            final double v1 = o1.getValue();
            final double v2 = o2.getValue();
            return isMinim ? Double.compare(v1, v2) : Double.compare(v2, v1);
        }
    };

    // Initialize search.
    simplex.build(getStartPoint());
    simplex.evaluate(evalFunc, comparator);

    PointValuePair[] previous = null;
    int iteration = 0;
    final ConvergenceChecker<PointValuePair> checker = getConvergenceChecker();
    while (true) {
        if (getIterations() > 0) {
            boolean converged = true;
            for (int i = 0; i < simplex.getSize(); i++) {
                PointValuePair prev = previous[i];
                converged = converged &&
                    checker.converged(iteration, prev, simplex.getPoint(i));
            }
            if (converged) {
                // We have found an optimum.
                return simplex.getPoint(0);
            }
        }

        // We still need to search.
        previous = simplex.getPoints();
        simplex.iterate(evalFunc, comparator);

        incrementIterationCount();
    }
}
 
Example 12
Source File: SimplexOptimizer.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    checkParameters();

    // Indirect call to "computeObjectiveValue" in order to update the
    // evaluations counter.
    final MultivariateFunction evalFunc
        = new MultivariateFunction() {
            public double value(double[] point) {
                return computeObjectiveValue(point);
            }
        };

    final boolean isMinim = getGoalType() == GoalType.MINIMIZE;
    final Comparator<PointValuePair> comparator
        = new Comparator<PointValuePair>() {
        public int compare(final PointValuePair o1,
                           final PointValuePair o2) {
            final double v1 = o1.getValue();
            final double v2 = o2.getValue();
            return isMinim ? Double.compare(v1, v2) : Double.compare(v2, v1);
        }
    };

    // Initialize search.
    simplex.build(getStartPoint());
    simplex.evaluate(evalFunc, comparator);

    PointValuePair[] previous = null;
    int iteration = 0;
    final ConvergenceChecker<PointValuePair> checker = getConvergenceChecker();
    while (true) {
        if (getIterations() > 0) {
            boolean converged = true;
            for (int i = 0; i < simplex.getSize(); i++) {
                PointValuePair prev = previous[i];
                converged = converged &&
                    checker.converged(iteration, prev, simplex.getPoint(i));
            }
            if (converged) {
                // We have found an optimum.
                return simplex.getPoint(0);
            }
        }

        // We still need to search.
        previous = simplex.getPoints();
        simplex.iterate(evalFunc, comparator);

        incrementIterationCount();
    }
}