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 import org.hipparchus.linear.RealMatrix;
25 import org.hipparchus.linear.RealVector;
26 import org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresOptimizer.Optimum;
27 import org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresProblem.Evaluation;
28
29 /**
30 * A pedantic implementation of {@link Optimum}.
31 *
32 */
33 class OptimumImpl implements Optimum {
34
35 /** abscissa and ordinate */
36 private final Evaluation value;
37 /** number of evaluations to compute this optimum */
38 private final int evaluations;
39 /** number of iterations to compute this optimum */
40 private final int iterations;
41
42 /**
43 * Construct an optimum from an evaluation and the values of the counters.
44 *
45 * @param value the function value
46 * @param evaluations number of times the function was evaluated
47 * @param iterations number of iterations of the algorithm
48 */
49 OptimumImpl(final Evaluation value, final int evaluations, final int iterations) {
50 this.value = value;
51 this.evaluations = evaluations;
52 this.iterations = iterations;
53 }
54
55 /* auto-generated implementations */
56
57 /** {@inheritDoc} */
58 @Override
59 public int getEvaluations() {
60 return evaluations;
61 }
62
63 /** {@inheritDoc} */
64 @Override
65 public int getIterations() {
66 return iterations;
67 }
68
69 /** {@inheritDoc} */
70 @Override
71 public RealMatrix getCovariances(double threshold) {
72 return value.getCovariances(threshold);
73 }
74
75 /** {@inheritDoc} */
76 @Override
77 public RealVector getSigma(double covarianceSingularityThreshold) {
78 return value.getSigma(covarianceSingularityThreshold);
79 }
80
81 /** {@inheritDoc} */
82 @Override
83 public double getRMS() {
84 return value.getRMS();
85 }
86
87 /** {@inheritDoc} */
88 @Override
89 public RealMatrix getJacobian() {
90 return value.getJacobian();
91 }
92
93 /** {@inheritDoc} */
94 @Override
95 public double getCost() {
96 return value.getCost();
97 }
98
99 /** {@inheritDoc} */
100 @Override
101 public double getChiSquare() {
102 return value.getChiSquare();
103 }
104
105 /** {@inheritDoc} */
106 @Override
107 public double getReducedChiSquare(int n) {
108 return value.getReducedChiSquare(n);
109 }
110
111 /** {@inheritDoc} */
112 @Override
113 public RealVector getResiduals() {
114 return value.getResiduals();
115 }
116
117 /** {@inheritDoc} */
118 @Override
119 public RealVector getPoint() {
120 return value.getPoint();
121 }
122 }