1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /*
19 * This is not the original file distributed by the Apache Software Foundation
20 * It has been modified by the Hipparchus project
21 */
22 package org.hipparchus.optim.nonlinear.vector.leastsquares;
23
24 /**
25 * An algorithm that can be applied to a non-linear least squares problem.
26 */
27 public interface LeastSquaresOptimizer {
28
29 /**
30 * Solve the non-linear least squares problem.
31 *
32 *
33 * @param leastSquaresProblem the problem definition, including model function and
34 * convergence criteria.
35 * @return The optimum.
36 */
37 Optimum optimize(LeastSquaresProblem leastSquaresProblem);
38
39 /**
40 * The optimum found by the optimizer. This object contains the point, its value, and
41 * some metadata.
42 */
43 interface Optimum extends LeastSquaresProblem.Evaluation {
44
45 /**
46 * Get the number of times the model was evaluated in order to produce this
47 * optimum.
48 *
49 * @return the number of model (objective) function evaluations
50 */
51 int getEvaluations();
52
53 /**
54 * Get the number of times the algorithm iterated in order to produce this
55 * optimum. In general least squares it is common to have one {@link
56 * #getEvaluations() evaluation} per iterations.
57 *
58 * @return the number of iterations
59 */
60 int getIterations();
61
62 /**
63 * Create a new optimum from an evaluation and the values of the counters.
64 *
65 * @param value the function value
66 * @param evaluations number of times the function was evaluated
67 * @param iterations number of iterations of the algorithm
68 * @return a new optimum based on the given data.
69 */
70 static Optimum of(final LeastSquaresProblem.Evaluation value,
71 final int evaluations,
72 final int iterations) {
73 return new OptimumImpl(value, evaluations, iterations);
74 }
75
76 }
77
78 }