Added checks for "null".
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@991164 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a21faeae6e
commit
9f631fecc8
|
@ -50,6 +50,7 @@ public interface BaseMultivariateRealOptimizer<FUNC extends MultivariateRealFunc
|
||||||
* @throws DimensionMismatchException if the start point dimension is wrong.
|
* @throws DimensionMismatchException if the start point dimension is wrong.
|
||||||
* @throws TooManyEvaluationsException if the maximal number of evaluations is
|
* @throws TooManyEvaluationsException if the maximal number of evaluations is
|
||||||
* exceeded.
|
* exceeded.
|
||||||
|
* @throws NullArgumentException if any argument is {@code null}.
|
||||||
*/
|
*/
|
||||||
RealPointValuePair optimize(FUNC f, GoalType goalType, double[] startPoint)
|
RealPointValuePair optimize(FUNC f, GoalType goalType, double[] startPoint)
|
||||||
throws FunctionEvaluationException;
|
throws FunctionEvaluationException;
|
||||||
|
|
|
@ -52,6 +52,7 @@ public interface BaseMultivariateVectorialOptimizer<FUNC extends MultivariateVec
|
||||||
* @throws DimensionMismatchException if the start point dimension is wrong.
|
* @throws DimensionMismatchException if the start point dimension is wrong.
|
||||||
* @throws TooManyEvaluationsException if the maximal number of evaluations is
|
* @throws TooManyEvaluationsException if the maximal number of evaluations is
|
||||||
* exceeded.
|
* exceeded.
|
||||||
|
* @throws NullArgumentException if any argument is {@code null}.
|
||||||
*/
|
*/
|
||||||
VectorialPointValuePair optimize(FUNC f, double[] target, double[] weight,
|
VectorialPointValuePair optimize(FUNC f, double[] target, double[] weight,
|
||||||
double[] startPoint)
|
double[] startPoint)
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.commons.math.FunctionEvaluationException;
|
||||||
import org.apache.commons.math.util.Incrementor;
|
import org.apache.commons.math.util.Incrementor;
|
||||||
import org.apache.commons.math.exception.MaxCountExceededException;
|
import org.apache.commons.math.exception.MaxCountExceededException;
|
||||||
import org.apache.commons.math.exception.TooManyEvaluationsException;
|
import org.apache.commons.math.exception.TooManyEvaluationsException;
|
||||||
|
import org.apache.commons.math.exception.NullArgumentException;
|
||||||
import org.apache.commons.math.analysis.MultivariateRealFunction;
|
import org.apache.commons.math.analysis.MultivariateRealFunction;
|
||||||
import org.apache.commons.math.optimization.BaseMultivariateRealOptimizer;
|
import org.apache.commons.math.optimization.BaseMultivariateRealOptimizer;
|
||||||
import org.apache.commons.math.optimization.GoalType;
|
import org.apache.commons.math.optimization.GoalType;
|
||||||
|
@ -124,6 +125,17 @@ public abstract class BaseAbstractScalarOptimizer<T extends MultivariateRealFunc
|
||||||
GoalType goalType,
|
GoalType goalType,
|
||||||
double[] startPoint)
|
double[] startPoint)
|
||||||
throws FunctionEvaluationException {
|
throws FunctionEvaluationException {
|
||||||
|
// Checks.
|
||||||
|
if (f == null) {
|
||||||
|
throw new NullArgumentException();
|
||||||
|
}
|
||||||
|
if (goalType == null) {
|
||||||
|
throw new NullArgumentException();
|
||||||
|
}
|
||||||
|
if (startPoint == null) {
|
||||||
|
throw new NullArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
// Reset.
|
// Reset.
|
||||||
evaluations.resetCount();
|
evaluations.resetCount();
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.commons.math.util.Incrementor;
|
||||||
import org.apache.commons.math.exception.MaxCountExceededException;
|
import org.apache.commons.math.exception.MaxCountExceededException;
|
||||||
import org.apache.commons.math.exception.TooManyEvaluationsException;
|
import org.apache.commons.math.exception.TooManyEvaluationsException;
|
||||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||||
|
import org.apache.commons.math.exception.NullArgumentException;
|
||||||
import org.apache.commons.math.analysis.MultivariateVectorialFunction;
|
import org.apache.commons.math.analysis.MultivariateVectorialFunction;
|
||||||
import org.apache.commons.math.optimization.BaseMultivariateVectorialOptimizer;
|
import org.apache.commons.math.optimization.BaseMultivariateVectorialOptimizer;
|
||||||
import org.apache.commons.math.optimization.GoalType;
|
import org.apache.commons.math.optimization.GoalType;
|
||||||
|
@ -122,7 +123,19 @@ public abstract class BaseAbstractVectorialOptimizer<FUNC extends MultivariateVe
|
||||||
double[] target, double[] weight,
|
double[] target, double[] weight,
|
||||||
double[] startPoint)
|
double[] startPoint)
|
||||||
throws FunctionEvaluationException {
|
throws FunctionEvaluationException {
|
||||||
|
// Checks.
|
||||||
|
if (f == null) {
|
||||||
|
throw new NullArgumentException();
|
||||||
|
}
|
||||||
|
if (target == null) {
|
||||||
|
throw new NullArgumentException();
|
||||||
|
}
|
||||||
|
if (weight == null) {
|
||||||
|
throw new NullArgumentException();
|
||||||
|
}
|
||||||
|
if (startPoint == null) {
|
||||||
|
throw new NullArgumentException();
|
||||||
|
}
|
||||||
if (target.length != weight.length) {
|
if (target.length != weight.length) {
|
||||||
throw new DimensionMismatchException(target.length, weight.length);
|
throw new DimensionMismatchException(target.length, weight.length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.commons.math.FunctionEvaluationException;
|
||||||
import org.apache.commons.math.util.Incrementor;
|
import org.apache.commons.math.util.Incrementor;
|
||||||
import org.apache.commons.math.exception.MaxCountExceededException;
|
import org.apache.commons.math.exception.MaxCountExceededException;
|
||||||
import org.apache.commons.math.exception.TooManyEvaluationsException;
|
import org.apache.commons.math.exception.TooManyEvaluationsException;
|
||||||
|
import org.apache.commons.math.exception.NullArgumentException;
|
||||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||||
import org.apache.commons.math.optimization.GoalType;
|
import org.apache.commons.math.optimization.GoalType;
|
||||||
import org.apache.commons.math.optimization.ConvergenceChecker;
|
import org.apache.commons.math.optimization.ConvergenceChecker;
|
||||||
|
@ -115,6 +116,14 @@ public abstract class AbstractUnivariateRealOptimizer
|
||||||
double min, double max,
|
double min, double max,
|
||||||
double startValue)
|
double startValue)
|
||||||
throws FunctionEvaluationException {
|
throws FunctionEvaluationException {
|
||||||
|
// Checks.
|
||||||
|
if (f == null) {
|
||||||
|
throw new NullArgumentException();
|
||||||
|
}
|
||||||
|
if (goalType == null) {
|
||||||
|
throw new NullArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
// Reset.
|
// Reset.
|
||||||
searchMin = min;
|
searchMin = min;
|
||||||
searchMax = max;
|
searchMax = max;
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.commons.math.optimization.univariate;
|
||||||
|
|
||||||
import org.apache.commons.math.FunctionEvaluationException;
|
import org.apache.commons.math.FunctionEvaluationException;
|
||||||
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
import org.apache.commons.math.analysis.UnivariateRealFunction;
|
||||||
|
import org.apache.commons.math.exception.NullArgumentException;
|
||||||
import org.apache.commons.math.optimization.BaseOptimizer;
|
import org.apache.commons.math.optimization.BaseOptimizer;
|
||||||
import org.apache.commons.math.optimization.GoalType;
|
import org.apache.commons.math.optimization.GoalType;
|
||||||
|
|
||||||
|
@ -80,6 +81,7 @@ public interface BaseUnivariateRealOptimizer<FUNC extends UnivariateRealFunction
|
||||||
* function.
|
* function.
|
||||||
* @throws IllegalArgumentException if {@code min > max} or the endpoints
|
* @throws IllegalArgumentException if {@code min > max} or the endpoints
|
||||||
* do not satisfy the requirements specified by the optimizer.
|
* do not satisfy the requirements specified by the optimizer.
|
||||||
|
* @throws NullArgumentException if any argument is {@code null}.
|
||||||
*/
|
*/
|
||||||
UnivariateRealPointValuePair optimize(FUNC f, GoalType goalType,
|
UnivariateRealPointValuePair optimize(FUNC f, GoalType goalType,
|
||||||
double min, double max,
|
double min, double max,
|
||||||
|
|
Loading…
Reference in New Issue