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 */ 017 018package org.apache.commons.math3.analysis.solvers; 019 020import org.apache.commons.math3.analysis.DifferentiableUnivariateFunction; 021import org.apache.commons.math3.analysis.UnivariateFunction; 022import org.apache.commons.math3.exception.TooManyEvaluationsException; 023 024/** 025 * Provide a default implementation for several functions useful to generic 026 * solvers. 027 * 028 * @since 3.0 029 * @deprecated as of 3.1, replaced by {@link AbstractUnivariateDifferentiableSolver} 030 */ 031@Deprecated 032public abstract class AbstractDifferentiableUnivariateSolver 033 extends BaseAbstractUnivariateSolver<DifferentiableUnivariateFunction> 034 implements DifferentiableUnivariateSolver { 035 /** Derivative of the function to solve. */ 036 private UnivariateFunction functionDerivative; 037 038 /** 039 * Construct a solver with given absolute accuracy. 040 * 041 * @param absoluteAccuracy Maximum absolute error. 042 */ 043 protected AbstractDifferentiableUnivariateSolver(final double absoluteAccuracy) { 044 super(absoluteAccuracy); 045 } 046 047 /** 048 * Construct a solver with given accuracies. 049 * 050 * @param relativeAccuracy Maximum relative error. 051 * @param absoluteAccuracy Maximum absolute error. 052 * @param functionValueAccuracy Maximum function value error. 053 */ 054 protected AbstractDifferentiableUnivariateSolver(final double relativeAccuracy, 055 final double absoluteAccuracy, 056 final double functionValueAccuracy) { 057 super(relativeAccuracy, absoluteAccuracy, functionValueAccuracy); 058 } 059 060 /** 061 * Compute the objective function value. 062 * 063 * @param point Point at which the objective function must be evaluated. 064 * @return the objective function value at specified point. 065 * @throws TooManyEvaluationsException if the maximal number of evaluations is exceeded. 066 */ 067 protected double computeDerivativeObjectiveValue(double point) 068 throws TooManyEvaluationsException { 069 incrementEvaluationCount(); 070 return functionDerivative.value(point); 071 } 072 073 /** 074 * {@inheritDoc} 075 */ 076 @Override 077 protected void setup(int maxEval, DifferentiableUnivariateFunction f, 078 double min, double max, double startValue) { 079 super.setup(maxEval, f, min, max, startValue); 080 functionDerivative = f.derivative(); 081 } 082}