source: src/main/java/agents/anac/y2019/harddealer/math3/fitting/leastsquares/LeastSquaresProblem.java

Last change on this file was 204, checked in by Katsuhide Fujita, 5 years ago

Fixed errors of ANAC2019 agents

  • Property svn:executable set to *
File size: 5.9 KB
Line 
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 * http://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 */
17package agents.anac.y2019.harddealer.math3.fitting.leastsquares;
18
19import agents.anac.y2019.harddealer.math3.linear.RealMatrix;
20import agents.anac.y2019.harddealer.math3.linear.RealVector;
21import agents.anac.y2019.harddealer.math3.optim.OptimizationProblem;
22
23/**
24 * The data necessary to define a non-linear least squares problem.
25 * <p>
26 * Includes the observed values, computed model function, and
27 * convergence/divergence criteria. Weights are implicit in {@link
28 * Evaluation#getResiduals()} and {@link Evaluation#getJacobian()}.
29 * </p>
30 * <p>
31 * Instances are typically either created progressively using a {@link
32 * LeastSquaresBuilder builder} or created at once using a {@link LeastSquaresFactory
33 * factory}.
34 * </p>
35 * @see LeastSquaresBuilder
36 * @see LeastSquaresFactory
37 * @see LeastSquaresAdapter
38 *
39 * @since 3.3
40 */
41public interface LeastSquaresProblem extends OptimizationProblem<LeastSquaresProblem.Evaluation> {
42
43 /**
44 * Gets the initial guess.
45 *
46 * @return the initial guess values.
47 */
48 RealVector getStart();
49
50 /**
51 * Get the number of observations (rows in the Jacobian) in this problem.
52 *
53 * @return the number of scalar observations
54 */
55 int getObservationSize();
56
57 /**
58 * Get the number of parameters (columns in the Jacobian) in this problem.
59 *
60 * @return the number of scalar parameters
61 */
62 int getParameterSize();
63
64 /**
65 * Evaluate the model at the specified point.
66 *
67 *
68 * @param point the parameter values.
69 * @return the model's value and derivative at the given point.
70 * @throws agents.anac.y2019.harddealer.math3.exception.TooManyEvaluationsException
71 * if the maximal number of evaluations (of the model vector function) is
72 * exceeded.
73 */
74 Evaluation evaluate(RealVector point);
75
76 /**
77 * An evaluation of a {@link LeastSquaresProblem} at a particular point. This class
78 * also computes several quantities derived from the value and its Jacobian.
79 */
80 public interface Evaluation {
81
82 /**
83 * Get the covariance matrix of the optimized parameters. <br/> Note that this
84 * operation involves the inversion of the <code>J<sup>T</sup>J</code> matrix,
85 * where {@code J} is the Jacobian matrix. The {@code threshold} parameter is a
86 * way for the caller to specify that the result of this computation should be
87 * considered meaningless, and thus trigger an exception.
88 *
89 *
90 * @param threshold Singularity threshold.
91 * @return the covariance matrix.
92 * @throws agents.anac.y2019.harddealer.math3.linear.SingularMatrixException
93 * if the covariance matrix cannot be computed (singular problem).
94 */
95 RealMatrix getCovariances(double threshold);
96
97 /**
98 * Get an estimate of the standard deviation of the parameters. The returned
99 * values are the square root of the diagonal coefficients of the covariance
100 * matrix, {@code sd(a[i]) ~= sqrt(C[i][i])}, where {@code a[i]} is the optimized
101 * value of the {@code i}-th parameter, and {@code C} is the covariance matrix.
102 *
103 *
104 * @param covarianceSingularityThreshold Singularity threshold (see {@link
105 * #getCovariances(double) computeCovariances}).
106 * @return an estimate of the standard deviation of the optimized parameters
107 * @throws agents.anac.y2019.harddealer.math3.linear.SingularMatrixException
108 * if the covariance matrix cannot be computed.
109 */
110 RealVector getSigma(double covarianceSingularityThreshold);
111
112 /**
113 * Get the normalized cost. It is the square-root of the sum of squared of
114 * the residuals, divided by the number of measurements.
115 *
116 * @return the cost.
117 */
118 double getRMS();
119
120 /**
121 * Get the weighted Jacobian matrix.
122 *
123 * @return the weighted Jacobian: W<sup>1/2</sup> J.
124 * @throws agents.anac.y2019.harddealer.math3.exception.DimensionMismatchException
125 * if the Jacobian dimension does not match problem dimension.
126 */
127 RealMatrix getJacobian();
128
129 /**
130 * Get the cost.
131 *
132 * @return the cost.
133 * @see #getResiduals()
134 */
135 double getCost();
136
137 /**
138 * Get the weighted residuals. The residual is the difference between the
139 * observed (target) values and the model (objective function) value. There is one
140 * residual for each element of the vector-valued function. The raw residuals are
141 * then multiplied by the square root of the weight matrix.
142 *
143 * @return the weighted residuals: W<sup>1/2</sup> K.
144 * @throws agents.anac.y2019.harddealer.math3.exception.DimensionMismatchException
145 * if the residuals have the wrong length.
146 */
147 RealVector getResiduals();
148
149 /**
150 * Get the abscissa (independent variables) of this evaluation.
151 *
152 * @return the point provided to {@link #evaluate(RealVector)}.
153 */
154 RealVector getPoint();
155 }
156}
Note: See TracBrowser for help on using the repository browser.