OptimumImpl.java

  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.  * This is not the original file distributed by the Apache Software Foundation
  19.  * It has been modified by the Hipparchus project
  20.  */
  21. package org.hipparchus.optim.nonlinear.vector.leastsquares;

  22. import org.hipparchus.linear.RealMatrix;
  23. import org.hipparchus.linear.RealVector;
  24. import org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresOptimizer.Optimum;
  25. import org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresProblem.Evaluation;

  26. /**
  27.  * A pedantic implementation of {@link Optimum}.
  28.  *
  29.  */
  30. class OptimumImpl implements Optimum {

  31.     /** abscissa and ordinate */
  32.     private final Evaluation value;
  33.     /** number of evaluations to compute this optimum */
  34.     private final int evaluations;
  35.     /** number of iterations to compute this optimum */
  36.     private final int iterations;

  37.     /**
  38.      * Construct an optimum from an evaluation and the values of the counters.
  39.      *
  40.      * @param value       the function value
  41.      * @param evaluations number of times the function was evaluated
  42.      * @param iterations  number of iterations of the algorithm
  43.      */
  44.     OptimumImpl(final Evaluation value, final int evaluations, final int iterations) {
  45.         this.value = value;
  46.         this.evaluations = evaluations;
  47.         this.iterations = iterations;
  48.     }

  49.     /* auto-generated implementations */

  50.     /** {@inheritDoc} */
  51.     @Override
  52.     public int getEvaluations() {
  53.         return evaluations;
  54.     }

  55.     /** {@inheritDoc} */
  56.     @Override
  57.     public int getIterations() {
  58.         return iterations;
  59.     }

  60.     /** {@inheritDoc} */
  61.     @Override
  62.     public RealMatrix getCovariances(double threshold) {
  63.         return value.getCovariances(threshold);
  64.     }

  65.     /** {@inheritDoc} */
  66.     @Override
  67.     public RealVector getSigma(double covarianceSingularityThreshold) {
  68.         return value.getSigma(covarianceSingularityThreshold);
  69.     }

  70.     /** {@inheritDoc} */
  71.     @Override
  72.     public double getRMS() {
  73.         return value.getRMS();
  74.     }

  75.     /** {@inheritDoc} */
  76.     @Override
  77.     public RealMatrix getJacobian() {
  78.         return value.getJacobian();
  79.     }

  80.     /** {@inheritDoc} */
  81.     @Override
  82.     public double getCost() {
  83.         return value.getCost();
  84.     }

  85.     /** {@inheritDoc} */
  86.     @Override
  87.     public double getChiSquare() {
  88.         return value.getChiSquare();
  89.     }

  90.     /** {@inheritDoc} */
  91.     @Override
  92.     public double getReducedChiSquare(int n) {
  93.         return value.getReducedChiSquare(n);
  94.     }

  95.     /** {@inheritDoc} */
  96.     @Override
  97.     public RealVector getResiduals() {
  98.         return value.getResiduals();
  99.     }

  100.     /** {@inheritDoc} */
  101.     @Override
  102.     public RealVector getPoint() {
  103.         return value.getPoint();
  104.     }
  105. }