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
9
* http://www.apache.org/licenses/LICENSE-2.0
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.
17
package org.apache.commons.math;
21
* Interface for algorithms handling convergence settings.
23
* This interface only deals with convergence parameters setting, not
24
* execution of the algorithms per se.
26
* @see ConvergenceException
27
* @version $Revision: 785473 $ $Date: 2009-06-17 00:02:35 -0400 (Wed, 17 Jun 2009) $
30
public interface ConvergingAlgorithm {
33
* Set the upper limit for the number of iterations.
35
* Usually a high iteration count indicates convergence problems. However,
36
* the "reasonable value" varies widely for different algorithms. Users are
37
* advised to use the default value supplied by the algorithm.</p>
39
* A {@link ConvergenceException} will be thrown if this number
42
* @param count maximum number of iterations
44
public abstract void setMaximalIterationCount(int count);
47
* Get the upper limit for the number of iterations.
49
* @return the actual upper limit
51
public abstract int getMaximalIterationCount();
54
* Reset the upper limit for the number of iterations to the default.
56
* The default value is supplied by the algorithm implementation.</p>
58
* @see #setMaximalIterationCount(int)
60
public abstract void resetMaximalIterationCount();
63
* Set the absolute accuracy.
65
* The default is usually chosen so that results in the interval
66
* -10..-0.1 and +0.1..+10 can be found with a reasonable accuracy. If the
67
* expected absolute value of your results is of much smaller magnitude, set
68
* this to a smaller value.</p>
70
* Algorithms are advised to do a plausibility check with the relative
71
* accuracy, but clients should not rely on this.</p>
73
* @param accuracy the accuracy.
74
* @throws IllegalArgumentException if the accuracy can't be achieved by
75
* the solver or is otherwise deemed unreasonable.
77
public abstract void setAbsoluteAccuracy(double accuracy);
80
* Get the actual absolute accuracy.
82
* @return the accuracy
84
public abstract double getAbsoluteAccuracy();
87
* Reset the absolute accuracy to the default.
89
* The default value is provided by the algorithm implementation.</p>
91
public abstract void resetAbsoluteAccuracy();
94
* Set the relative accuracy.
96
* This is used to stop iterations if the absolute accuracy can't be
97
* achieved due to large values or short mantissa length.</p>
99
* If this should be the primary criterion for convergence rather then a
100
* safety measure, set the absolute accuracy to a ridiculously small value,
101
* like {@link org.apache.commons.math.util.MathUtils#SAFE_MIN MathUtils.SAFE_MIN}.</p>
103
* @param accuracy the relative accuracy.
104
* @throws IllegalArgumentException if the accuracy can't be achieved by
105
* the algorithm or is otherwise deemed unreasonable.
107
public abstract void setRelativeAccuracy(double accuracy);
110
* Get the actual relative accuracy.
111
* @return the accuracy
113
public abstract double getRelativeAccuracy();
116
* Reset the relative accuracy to the default.
117
* The default value is provided by the algorithm implementation.
119
public abstract void resetRelativeAccuracy();
122
* Get the number of iterations in the last run of the algorithm.
124
* This is mainly meant for testing purposes. It may occasionally
125
* help track down performance problems: if the iteration count
126
* is notoriously high, check whether the problem is evaluated
127
* properly, and whether another algorithm is more amenable to the
130
* @return the last iteration count.
131
* @throws IllegalStateException if there is no result available, either
132
* because no result was yet computed or the last attempt failed.
134
public abstract int getIterationCount();
b'\\ No newline at end of file'