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 */
017package org.apache.commons.math4.legacy.fitting.leastsquares;
018
019/**
020 * An algorithm that can be applied to a non-linear least squares problem.
021 *
022 * @since 3.3
023 */
024public interface LeastSquaresOptimizer {
025
026    /**
027     * Solve the non-linear least squares problem.
028     *
029     *
030     * @param leastSquaresProblem the problem definition, including model function and
031     *                            convergence criteria.
032     * @return The optimum.
033     */
034    Optimum optimize(LeastSquaresProblem leastSquaresProblem);
035
036    /**
037     * The optimum found by the optimizer. This object contains the point, its value, and
038     * some metadata.
039     */
040    //TODO Solution?
041    interface Optimum extends LeastSquaresProblem.Evaluation {
042
043        /**
044         * Get the number of times the model was evaluated in order to produce this
045         * optimum.
046         *
047         * @return the number of model (objective) function evaluations
048         */
049        int getEvaluations();
050
051        /**
052         * Get the number of times the algorithm iterated in order to produce this
053         * optimum. In general least squares it is common to have one {@link
054         * #getEvaluations() evaluation} per iterations.
055         *
056         * @return the number of iterations
057         */
058        int getIterations();
059    }
060}