001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.math3.optimization.univariate;
019
020import org.apache.commons.math3.analysis.UnivariateFunction;
021import org.apache.commons.math3.optimization.BaseOptimizer;
022import org.apache.commons.math3.optimization.GoalType;
023
024/**
025 * This interface is mainly intended to enforce the internal coherence of
026 * Commons-Math. Users of the API are advised to base their code on
027 * the following interfaces:
028 * <ul>
029 *  <li>{@link org.apache.commons.math3.optimization.univariate.UnivariateOptimizer}</li>
030 * </ul>
031 *
032 * @param <FUNC> Type of the objective function to be optimized.
033 *
034 * @deprecated As of 3.1 (to be removed in 4.0).
035 * @since 3.0
036 */
037@Deprecated
038public interface BaseUnivariateOptimizer<FUNC extends UnivariateFunction>
039    extends BaseOptimizer<UnivariatePointValuePair> {
040    /**
041     * Find an optimum in the given interval.
042     *
043     * An optimizer may require that the interval brackets a single optimum.
044     *
045     * @param f Function to optimize.
046     * @param goalType Type of optimization goal: either
047     * {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}.
048     * @param min Lower bound for the interval.
049     * @param max Upper bound for the interval.
050     * @param maxEval Maximum number of function evaluations.
051     * @return a (point, value) pair where the function is optimum.
052     * @throws org.apache.commons.math3.exception.TooManyEvaluationsException
053     * if the maximum evaluation count is exceeded.
054     * @throws org.apache.commons.math3.exception.ConvergenceException
055     * if the optimizer detects a convergence problem.
056     * @throws IllegalArgumentException if {@code min > max} or the endpoints
057     * do not satisfy the requirements specified by the optimizer.
058     */
059    UnivariatePointValuePair optimize(int maxEval, FUNC f, GoalType goalType,
060                                          double min, double max);
061
062    /**
063     * Find an optimum in the given interval, start at startValue.
064     * An optimizer may require that the interval brackets a single optimum.
065     *
066     * @param f Function to optimize.
067     * @param goalType Type of optimization goal: either
068     * {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}.
069     * @param min Lower bound for the interval.
070     * @param max Upper bound for the interval.
071     * @param startValue Start value to use.
072     * @param maxEval Maximum number of function evaluations.
073     * @return a (point, value) pair where the function is optimum.
074     * @throws org.apache.commons.math3.exception.TooManyEvaluationsException
075     * if the maximum evaluation count is exceeded.
076     * @throws org.apache.commons.math3.exception.ConvergenceException if the
077     * optimizer detects a convergence problem.
078     * @throws IllegalArgumentException if {@code min > max} or the endpoints
079     * do not satisfy the requirements specified by the optimizer.
080     * @throws org.apache.commons.math3.exception.NullArgumentException if any
081     * argument is {@code null}.
082     */
083    UnivariatePointValuePair optimize(int maxEval, FUNC f, GoalType goalType,
084                                          double min, double max,
085                                          double startValue);
086}