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.math3.fitting.leastsquares;
018
019import org.apache.commons.math3.linear.RealVector;
020import org.apache.commons.math3.optim.ConvergenceChecker;
021import org.apache.commons.math3.util.Incrementor;
022
023/**
024 * An adapter that delegates to another implementation of {@link LeastSquaresProblem}.
025 *
026 * @since 3.3
027 */
028public class LeastSquaresAdapter implements LeastSquaresProblem {
029
030    /** the delegate problem */
031    private final LeastSquaresProblem problem;
032
033    /**
034     * Delegate the {@link LeastSquaresProblem} interface to the given implementation.
035     *
036     * @param problem the delegate
037     */
038    public LeastSquaresAdapter(final LeastSquaresProblem problem) {
039        this.problem = problem;
040    }
041
042    /** {@inheritDoc} */
043    public RealVector getStart() {
044        return problem.getStart();
045    }
046
047    /** {@inheritDoc} */
048    public int getObservationSize() {
049        return problem.getObservationSize();
050    }
051
052    /** {@inheritDoc} */
053    public int getParameterSize() {
054        return problem.getParameterSize();
055    }
056
057    /** {@inheritDoc}
058     * @param point*/
059    public Evaluation evaluate(final RealVector point) {
060        return problem.evaluate(point);
061    }
062
063    /** {@inheritDoc} */
064    public Incrementor getEvaluationCounter() {
065        return problem.getEvaluationCounter();
066    }
067
068    /** {@inheritDoc} */
069    public Incrementor getIterationCounter() {
070        return problem.getIterationCounter();
071    }
072
073    /** {@inheritDoc} */
074    public ConvergenceChecker<Evaluation> getConvergenceChecker() {
075        return problem.getConvergenceChecker();
076    }
077}