You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2010/11/20 21:57:42 UTC
svn commit: r1037327 [4/7] - in /commons/proper/math/branches/MATH_2_X/src:
main/java/org/apache/commons/math/
main/java/org/apache/commons/math/analysis/
main/java/org/apache/commons/math/analysis/integration/
main/java/org/apache/commons/math/analysi...
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java Sat Nov 20 20:57:37 2010
@@ -22,7 +22,7 @@ import java.io.ObjectInput;
import java.io.ObjectOutput;
import org.apache.commons.math.MathRuntimeException;
-import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.exception.MathUserException;
/** This abstract class represents an interpolator over the last step
* during an ODE integration.
@@ -184,7 +184,7 @@ public abstract class AbstractStepInterp
}
/** {@inheritDoc} */
- public StepInterpolator copy() throws DerivativeException {
+ public StepInterpolator copy() throws MathUserException {
// finalize the step before performing copy
finalizeStep();
@@ -258,15 +258,15 @@ public abstract class AbstractStepInterp
* (theta is zero at the previous time step and one at the current time step)
* @param oneMinusThetaH time gap between the interpolated time and
* the current time
- * @throws DerivativeException this exception is propagated to the caller if the
+ * @throws MathUserException this exception is propagated to the caller if the
* underlying user function triggers one
*/
protected abstract void computeInterpolatedStateAndDerivatives(double theta,
double oneMinusThetaH)
- throws DerivativeException;
+ throws MathUserException;
/** {@inheritDoc} */
- public double[] getInterpolatedState() throws DerivativeException {
+ public double[] getInterpolatedState() throws MathUserException {
// lazy evaluation of the state
if (dirtyState) {
@@ -281,7 +281,7 @@ public abstract class AbstractStepInterp
}
/** {@inheritDoc} */
- public double[] getInterpolatedDerivatives() throws DerivativeException {
+ public double[] getInterpolatedDerivatives() throws MathUserException {
// lazy evaluation of the state
if (dirtyState) {
@@ -333,11 +333,11 @@ public abstract class AbstractStepInterp
* Therefore, subclasses are not allowed not reimplement it, they
* should rather reimplement <code>doFinalize</code>.</p>
- * @throws DerivativeException this exception is propagated to the
+ * @throws MathUserException this exception is propagated to the
* caller if the underlying user function triggers one
*/
public final void finalizeStep()
- throws DerivativeException {
+ throws MathUserException {
if (! finalized) {
doFinalize();
finalized = true;
@@ -347,11 +347,11 @@ public abstract class AbstractStepInterp
/**
* Really finalize the step.
* The default implementation of this method does nothing.
- * @throws DerivativeException this exception is propagated to the
+ * @throws MathUserException this exception is propagated to the
* caller if the underlying user function triggers one
*/
protected void doFinalize()
- throws DerivativeException {
+ throws MathUserException {
}
/** {@inheritDoc} */
@@ -395,7 +395,7 @@ public abstract class AbstractStepInterp
// finalize the step (and don't bother saving the now true flag)
try {
finalizeStep();
- } catch (DerivativeException e) {
+ } catch (MathUserException e) {
throw MathRuntimeException.createIOException(e);
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java Sat Nov 20 20:57:37 2010
@@ -21,8 +21,6 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import org.apache.commons.math.ode.DerivativeException;
-
/** This class is a step interpolator that does nothing.
*
* <p>This class is used when the {@link StepHandler "step handler"}
@@ -98,12 +96,9 @@ public class DummyStepInterpolator
* (theta is zero at the previous time step and one at the current time step)
* @param oneMinusThetaH time gap between the interpolated time and
* the current time
- * @throws DerivativeException this exception is propagated to the caller if the
- * underlying user function triggers one
*/
@Override
- protected void computeInterpolatedStateAndDerivatives(final double theta, final double oneMinusThetaH)
- throws DerivativeException {
+ protected void computeInterpolatedStateAndDerivatives(final double theta, final double oneMinusThetaH) {
System.arraycopy(currentState, 0, interpolatedState, 0, currentState.length);
System.arraycopy(currentDerivative, 0, interpolatedDerivatives, 0, currentDerivative.length);
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/FixedStepHandler.java Sat Nov 20 20:57:37 2010
@@ -17,7 +17,7 @@
package org.apache.commons.math.ode.sampling;
-import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.exception.MathUserException;
/**
* This interface represents a handler that should be called after
@@ -55,8 +55,8 @@ public interface FixedStepHandler {
* provide at the end of the integration a complete array of all
* steps), it should build a local copy store this copy.
* @param isLast true if the step is the last one
- * @throws DerivativeException if some error condition is encountered
+ * @throws MathUserException if some error condition is encountered
*/
- void handleStep(double t, double[] y, double[] yDot, boolean isLast) throws DerivativeException;
+ void handleStep(double t, double[] y, double[] yDot, boolean isLast) throws MathUserException;
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java Sat Nov 20 20:57:37 2010
@@ -22,8 +22,8 @@ import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Arrays;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.linear.Array2DRowRealMatrix;
-import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.util.FastMath;
/**
@@ -171,11 +171,11 @@ public class NordsieckStepInterpolator e
* to be preserved across several calls.</p>
* @return state vector at time {@link #getInterpolatedTime}
* @see #getInterpolatedDerivatives()
- * @throws DerivativeException if this call induces an automatic
+ * @throws MathUserException if this call induces an automatic
* step finalization that throws one
*/
public double[] getInterpolatedStateVariation()
- throws DerivativeException {
+ throws MathUserException {
// compute and ignore interpolated state
// to make sure state variation is computed as a side effect
getInterpolatedState();
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/StepHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/StepHandler.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/StepHandler.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/StepHandler.java Sat Nov 20 20:57:37 2010
@@ -17,7 +17,7 @@
package org.apache.commons.math.ode.sampling;
-import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.exception.MathUserException;
/**
* This interface represents a handler that should be called after
@@ -70,9 +70,9 @@ public interface StepHandler {
* Keeping only a reference to the interpolator and reusing it will
* result in unpredictable behavior (potentially crashing the application).
* @param isLast true if the step is the last one
- * @throws DerivativeException this exception is propagated to the
- * caller if the underlying user function triggers one
+ * @exception MathUserException if user code called from step interpolator
+ * finalization triggers one
*/
- void handleStep(StepInterpolator interpolator, boolean isLast) throws DerivativeException;
+ void handleStep(StepInterpolator interpolator, boolean isLast) throws MathUserException;
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/StepInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/StepInterpolator.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/StepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/StepInterpolator.java Sat Nov 20 20:57:37 2010
@@ -19,7 +19,7 @@ package org.apache.commons.math.ode.samp
import java.io.Externalizable;
-import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.exception.MathUserException;
/** This interface represents an interpolator over the last step
* during an ODE integration.
@@ -89,10 +89,10 @@ public interface StepInterpolator extend
* to be preserved across several calls.</p>
* @return state vector at time {@link #getInterpolatedTime}
* @see #getInterpolatedDerivatives()
- * @throws DerivativeException if this call induces an automatic
- * step finalization that throws one
+ * @exception MathUserException if user code called from step interpolator
+ * finalization triggers one
*/
- double[] getInterpolatedState() throws DerivativeException;
+ double[] getInterpolatedState() throws MathUserException;
/**
* Get the derivatives of the state vector of the interpolated point.
@@ -101,11 +101,11 @@ public interface StepInterpolator extend
* to be preserved across several calls.</p>
* @return derivatives of the state vector at time {@link #getInterpolatedTime}
* @see #getInterpolatedState()
- * @throws DerivativeException if this call induces an automatic
- * step finalization that throws one
+ * @exception MathUserException if user code called from step interpolator
+ * finalization triggers one
* @since 2.0
*/
- double[] getInterpolatedDerivatives() throws DerivativeException;
+ double[] getInterpolatedDerivatives() throws MathUserException;
/** Check if the natural integration direction is forward.
* <p>This method provides the integration direction as specified by
@@ -123,10 +123,10 @@ public interface StepInterpolator extend
* original one. Both can be used with different settings for
* interpolated time without any side effect.</p>
* @return a deep copy of the instance, which can be used independently.
- * @throws DerivativeException if this call induces an automatic
- * step finalization that throws one
+ * @exception MathUserException if user code called from step interpolator
+ * finalization triggers one
* @see #setInterpolatedTime(double)
*/
- StepInterpolator copy() throws DerivativeException;
+ StepInterpolator copy() throws MathUserException;
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java Sat Nov 20 20:57:37 2010
@@ -17,7 +17,7 @@
package org.apache.commons.math.ode.sampling;
-import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.util.FastMath;
/**
@@ -109,11 +109,11 @@ public class StepNormalizer implements S
* should build a local copy using the clone method and store this
* copy.
* @param isLast true if the step is the last one
- * @throws DerivativeException this exception is propagated to the
+ * @throws MathUserException this exception is propagated to the
* caller if the underlying user function triggers one
*/
public void handleStep(final StepInterpolator interpolator, final boolean isLast)
- throws DerivativeException {
+ throws MathUserException {
if (lastState == null) {
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java Sat Nov 20 20:57:37 2010
@@ -17,8 +17,8 @@
package org.apache.commons.math.optimization;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.analysis.MultivariateRealFunction;
+import org.apache.commons.math.exception.MathUserException;
/**
* Optimization algorithms find the input point set that either {@link GoalType
@@ -105,11 +105,10 @@ public interface BaseMultivariateRealOpt
* or {@link GoalType#MINIMIZE}.
* @param startPoint Start point for optimization.
* @return the point/value pair giving the optimal value for objective function.
- * @throws FunctionEvaluationException if the objective function throws one during
- * the search.
+ * @throws MathUserException if the objective function throws one during the search.
* @throws OptimizationException if the algorithm failed to converge.
* @throws IllegalArgumentException if the start point dimension is wrong.
*/
RealPointValuePair optimize(T f, GoalType goalType, double[] startPoint)
- throws FunctionEvaluationException, OptimizationException;
+ throws MathUserException, OptimizationException;
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/DifferentiableMultivariateVectorialOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/DifferentiableMultivariateVectorialOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/DifferentiableMultivariateVectorialOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/DifferentiableMultivariateVectorialOptimizer.java Sat Nov 20 20:57:37 2010
@@ -17,8 +17,8 @@
package org.apache.commons.math.optimization;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.analysis.DifferentiableMultivariateVectorialFunction;
+import org.apache.commons.math.exception.MathUserException;
/**
* This interface represents an optimization algorithm for {@link DifferentiableMultivariateVectorialFunction
@@ -101,7 +101,7 @@ public interface DifferentiableMultivari
* @param weights weight for the least squares cost computation
* @param startPoint the start point for optimization
* @return the point/value pair giving the optimal value for objective function
- * @exception FunctionEvaluationException if the objective function throws one during
+ * @exception MathUserException if the objective function throws one during
* the search
* @exception OptimizationException if the algorithm failed to converge
* @exception IllegalArgumentException if the start point dimension is wrong
@@ -109,6 +109,6 @@ public interface DifferentiableMultivari
VectorialPointValuePair optimize(DifferentiableMultivariateVectorialFunction f,
double[] target, double[] weights,
double[] startPoint)
- throws FunctionEvaluationException, OptimizationException, IllegalArgumentException;
+ throws MathUserException, OptimizationException, IllegalArgumentException;
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/LeastSquaresConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/LeastSquaresConverter.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/LeastSquaresConverter.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/LeastSquaresConverter.java Sat Nov 20 20:57:37 2010
@@ -17,10 +17,10 @@
package org.apache.commons.math.optimization;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.MultivariateRealFunction;
import org.apache.commons.math.analysis.MultivariateVectorialFunction;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.linear.RealMatrix;
@@ -99,7 +99,7 @@ public class LeastSquaresConverter imple
* </p>
* <p>
* The array computed by the objective function, the observations array and the
- * weights array must have consistent sizes or a {@link FunctionEvaluationException} will be
+ * weights array must have consistent sizes or a {@link MathUserException} will be
* triggered while computing the scalar objective.
* </p>
* @param function vectorial residuals function to wrap
@@ -132,7 +132,7 @@ public class LeastSquaresConverter imple
* </p>
* <p>
* The array computed by the objective function, the observations array and the
- * the scaling matrix must have consistent sizes or a {@link FunctionEvaluationException}
+ * the scaling matrix must have consistent sizes or a {@link MathUserException}
* will be triggered while computing the scalar objective.
* </p>
* @param function vectorial residuals function to wrap
@@ -157,13 +157,13 @@ public class LeastSquaresConverter imple
}
/** {@inheritDoc} */
- public double value(final double[] point) throws FunctionEvaluationException {
+ public double value(final double[] point) throws MathUserException {
// compute residuals
final double[] residuals = function.value(point);
if (residuals.length != observations.length) {
- throw new FunctionEvaluationException(point, LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
- residuals.length, observations.length);
+ throw new MathUserException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
+ residuals.length, observations.length);
}
for (int i = 0; i < residuals.length; ++i) {
residuals[i] -= observations[i];
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateRealOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateRealOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateRealOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateRealOptimizer.java Sat Nov 20 20:57:37 2010
@@ -20,9 +20,9 @@ package org.apache.commons.math.optimiza
import java.util.Arrays;
import java.util.Comparator;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.DifferentiableMultivariateRealFunction;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.random.RandomVectorGenerator;
@@ -172,7 +172,7 @@ public class MultiStartDifferentiableMul
public RealPointValuePair optimize(final DifferentiableMultivariateRealFunction f,
final GoalType goalType,
double[] startPoint)
- throws FunctionEvaluationException, OptimizationException {
+ throws MathUserException, OptimizationException {
optima = new RealPointValuePair[starts];
totalIterations = 0;
@@ -187,7 +187,7 @@ public class MultiStartDifferentiableMul
optimizer.setMaxEvaluations(maxEvaluations - totalEvaluations);
optima[i] = optimizer.optimize(f, goalType,
(i == 0) ? startPoint : generator.nextVector());
- } catch (FunctionEvaluationException fee) {
+ } catch (MathUserException fee) {
optima[i] = null;
} catch (OptimizationException oe) {
optima[i] = null;
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizer.java Sat Nov 20 20:57:37 2010
@@ -20,9 +20,9 @@ package org.apache.commons.math.optimiza
import java.util.Arrays;
import java.util.Comparator;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.DifferentiableMultivariateVectorialFunction;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.random.RandomVectorGenerator;
@@ -176,7 +176,7 @@ public class MultiStartDifferentiableMul
public VectorialPointValuePair optimize(final DifferentiableMultivariateVectorialFunction f,
final double[] target, final double[] weights,
final double[] startPoint)
- throws FunctionEvaluationException, OptimizationException, IllegalArgumentException {
+ throws MathUserException, OptimizationException, IllegalArgumentException {
optima = new VectorialPointValuePair[starts];
totalIterations = 0;
@@ -191,7 +191,7 @@ public class MultiStartDifferentiableMul
optimizer.setMaxEvaluations(maxEvaluations - totalEvaluations);
optima[i] = optimizer.optimize(f, target, weights,
(i == 0) ? startPoint : generator.nextVector());
- } catch (FunctionEvaluationException fee) {
+ } catch (MathUserException fee) {
optima[i] = null;
} catch (OptimizationException oe) {
optima[i] = null;
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartMultivariateRealOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartMultivariateRealOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartMultivariateRealOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartMultivariateRealOptimizer.java Sat Nov 20 20:57:37 2010
@@ -20,9 +20,9 @@ package org.apache.commons.math.optimiza
import java.util.Arrays;
import java.util.Comparator;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.MultivariateRealFunction;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.random.RandomVectorGenerator;
@@ -162,7 +162,7 @@ public class MultiStartMultivariateRealO
public RealPointValuePair optimize(final MultivariateRealFunction f,
final GoalType goalType,
double[] startPoint)
- throws FunctionEvaluationException, OptimizationException {
+ throws MathUserException, OptimizationException {
optima = new RealPointValuePair[starts];
totalIterations = 0;
@@ -176,7 +176,7 @@ public class MultiStartMultivariateRealO
optimizer.setMaxEvaluations(maxEvaluations - totalEvaluations);
optima[i] = optimizer.optimize(f, goalType,
(i == 0) ? startPoint : generator.nextVector());
- } catch (FunctionEvaluationException fee) {
+ } catch (MathUserException fee) {
optima[i] = null;
} catch (OptimizationException oe) {
optima[i] = null;
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java Sat Nov 20 20:57:37 2010
@@ -18,9 +18,9 @@
package org.apache.commons.math.optimization;
import org.apache.commons.math.ConvergenceException;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.random.RandomGenerator;
import org.apache.commons.math.util.FastMath;
@@ -226,8 +226,7 @@ public class MultiStartUnivariateRealOpt
/** {@inheritDoc} */
public double optimize(final UnivariateRealFunction f, final GoalType goalType,
final double min, final double max)
- throws ConvergenceException,
- FunctionEvaluationException {
+ throws ConvergenceException, MathUserException {
optima = new double[starts];
optimaValues = new double[starts];
@@ -246,7 +245,7 @@ public class MultiStartUnivariateRealOpt
FastMath.min(bound1, bound2),
FastMath.max(bound1, bound2));
optimaValues[i] = optimizer.getFunctionValue();
- } catch (FunctionEvaluationException fee) {
+ } catch (MathUserException fee) {
optima[i] = Double.NaN;
optimaValues[i] = Double.NaN;
} catch (ConvergenceException ce) {
@@ -313,7 +312,7 @@ public class MultiStartUnivariateRealOpt
/** {@inheritDoc} */
public double optimize(final UnivariateRealFunction f, final GoalType goalType,
final double min, final double max, final double startValue)
- throws ConvergenceException, FunctionEvaluationException {
+ throws ConvergenceException, MathUserException {
return optimize(f, goalType, min, max);
}
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java Sat Nov 20 20:57:37 2010
@@ -18,8 +18,8 @@ package org.apache.commons.math.optimiza
import org.apache.commons.math.ConvergenceException;
import org.apache.commons.math.ConvergingAlgorithm;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.exception.MathUserException;
/**
@@ -63,14 +63,13 @@ public interface UnivariateRealOptimizer
* @return a value where the function is optimum.
* @throws ConvergenceException if the maximum iteration count is exceeded
* or the optimizer detects convergence problems otherwise.
- * @throws FunctionEvaluationException if an error occurs evaluating the
- * function.
+ * @throws MathUserException if an error occurs evaluating the function.
* @throws IllegalArgumentException if min > max or the endpoints do not
* satisfy the requirements specified by the optimizer.
*/
double optimize(UnivariateRealFunction f, GoalType goalType,
double min, double max)
- throws ConvergenceException, FunctionEvaluationException;
+ throws ConvergenceException, MathUserException;
/**
* Find an optimum in the given interval, start at startValue.
@@ -86,14 +85,13 @@ public interface UnivariateRealOptimizer
* @return a value where the function is optimum.
* @throws ConvergenceException if the maximum iteration count is exceeded
* or the optimizer detects convergence problems otherwise.
- * @throws FunctionEvaluationException if an error occurs evaluating the
- * function.
+ * @throws MathUserException if an error occurs evaluating the function.
* @throws IllegalArgumentException if min > max or the arguments do not
* satisfy the requirements specified by the optimizer.
*/
double optimize(UnivariateRealFunction f, GoalType goalType,
double min, double max, double startValue)
- throws ConvergenceException, FunctionEvaluationException;
+ throws ConvergenceException, MathUserException;
/**
* Get the result of the last run of the optimizer.
@@ -108,8 +106,10 @@ public interface UnivariateRealOptimizer
* Get the result of the last run of the optimizer.
*
* @return the value of the function at the optimum.
+ * @throws MathUserException if an error occurs evaluating the function.
* @throws IllegalStateException if there is no result available, either
* because no result was yet computed or the last attempt failed.
*/
- double getFunctionValue();
+ double getFunctionValue() throws MathUserException;
+
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/DirectSearchOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/DirectSearchOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/DirectSearchOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/DirectSearchOptimizer.java Sat Nov 20 20:57:37 2010
@@ -20,11 +20,11 @@ package org.apache.commons.math.optimiza
import java.util.Arrays;
import java.util.Comparator;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.MaxEvaluationsExceededException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.MultivariateRealFunction;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.optimization.GoalType;
import org.apache.commons.math.optimization.MultivariateRealOptimizer;
@@ -257,8 +257,7 @@ public abstract class DirectSearchOptimi
public RealPointValuePair optimize(final MultivariateRealFunction function,
final GoalType goalType,
final double[] startPoint)
- throws FunctionEvaluationException, OptimizationException,
- IllegalArgumentException {
+ throws MathUserException, OptimizationException, IllegalArgumentException {
if ((startConfiguration == null) ||
(startConfiguration.length != startPoint.length)) {
@@ -322,28 +321,27 @@ public abstract class DirectSearchOptimi
/** Compute the next simplex of the algorithm.
* @param comparator comparator to use to sort simplex vertices from best to worst
- * @exception FunctionEvaluationException if the function cannot be evaluated at
+ * @exception MathUserException if the function cannot be evaluated at
* some point
* @exception OptimizationException if the algorithm fails to converge
* @exception IllegalArgumentException if the start point dimension is wrong
*/
protected abstract void iterateSimplex(final Comparator<RealPointValuePair> comparator)
- throws FunctionEvaluationException, OptimizationException, IllegalArgumentException;
+ throws MathUserException, OptimizationException, IllegalArgumentException;
/** Evaluate the objective function on one point.
* <p>A side effect of this method is to count the number of
* function evaluations</p>
* @param x point on which the objective function should be evaluated
* @return objective function value at the given point
- * @exception FunctionEvaluationException if no value can be computed for the
+ * @exception MathUserException if no value can be computed for the
* parameters or if the maximal number of evaluations is exceeded
* @exception IllegalArgumentException if the start point dimension is wrong
*/
protected double evaluate(final double[] x)
- throws FunctionEvaluationException, IllegalArgumentException {
+ throws MathUserException, IllegalArgumentException {
if (++evaluations > maxEvaluations) {
- throw new FunctionEvaluationException(new MaxEvaluationsExceededException(maxEvaluations),
- x);
+ throw new MathUserException(new MaxEvaluationsExceededException(maxEvaluations));
}
return f.value(x);
}
@@ -380,11 +378,11 @@ public abstract class DirectSearchOptimi
/** Evaluate all the non-evaluated points of the simplex.
* @param comparator comparator to use to sort simplex vertices from best to worst
- * @exception FunctionEvaluationException if no value can be computed for the parameters
+ * @exception MathUserException if no value can be computed for the parameters
* @exception OptimizationException if the maximal number of evaluations is exceeded
*/
protected void evaluateSimplex(final Comparator<RealPointValuePair> comparator)
- throws FunctionEvaluationException, OptimizationException {
+ throws MathUserException, OptimizationException {
// evaluate the objective function at all non-evaluated simplex points
for (int i = 0; i < simplex.length; ++i) {
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/MultiDirectional.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/MultiDirectional.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/MultiDirectional.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/MultiDirectional.java Sat Nov 20 20:57:37 2010
@@ -19,7 +19,7 @@ package org.apache.commons.math.optimiza
import java.util.Comparator;
-import org.apache.commons.math.FunctionEvaluationException;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.RealConvergenceChecker;
import org.apache.commons.math.optimization.RealPointValuePair;
@@ -59,7 +59,7 @@ public class MultiDirectional extends Di
/** {@inheritDoc} */
@Override
protected void iterateSimplex(final Comparator<RealPointValuePair> comparator)
- throws FunctionEvaluationException, OptimizationException, IllegalArgumentException {
+ throws MathUserException, OptimizationException, IllegalArgumentException {
final RealConvergenceChecker checker = getConvergenceChecker();
while (true) {
@@ -112,14 +112,13 @@ public class MultiDirectional extends Di
* @param coeff linear coefficient
* @param comparator comparator to use to sort simplex vertices from best to poorest
* @return best point in the transformed simplex
- * @exception FunctionEvaluationException if the function cannot be evaluated at
- * some point
+ * @exception MathUserException if the function cannot be evaluated at some point
* @exception OptimizationException if the maximal number of evaluations is exceeded
*/
private RealPointValuePair evaluateNewSimplex(final RealPointValuePair[] original,
final double coeff,
final Comparator<RealPointValuePair> comparator)
- throws FunctionEvaluationException, OptimizationException {
+ throws MathUserException, OptimizationException {
final double[] xSmallest = original[0].getPointRef();
final int n = xSmallest.length;
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/NelderMead.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/NelderMead.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/NelderMead.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/NelderMead.java Sat Nov 20 20:57:37 2010
@@ -19,7 +19,7 @@ package org.apache.commons.math.optimiza
import java.util.Comparator;
-import org.apache.commons.math.FunctionEvaluationException;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.RealPointValuePair;
@@ -72,7 +72,7 @@ public class NelderMead extends DirectSe
/** {@inheritDoc} */
@Override
protected void iterateSimplex(final Comparator<RealPointValuePair> comparator)
- throws FunctionEvaluationException, OptimizationException {
+ throws MathUserException, OptimizationException {
incrementIterationsCounter();
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/PowellOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/PowellOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/PowellOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/direct/PowellOptimizer.java Sat Nov 20 20:57:37 2010
@@ -17,9 +17,9 @@
package org.apache.commons.math.optimization.direct;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.optimization.GoalType;
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.RealPointValuePair;
@@ -88,7 +88,7 @@ public class PowellOptimizer
/** {@inheritDoc} */
@Override
protected RealPointValuePair doOptimize()
- throws FunctionEvaluationException,
+ throws MathUserException,
OptimizationException {
final GoalType goal = getGoalType();
final double[] guess = getStartPoint();
@@ -232,12 +232,11 @@ public class PowellOptimizer
*
* @param p Starting point.
* @param d Search direction.
- * @throws OptimizationException if function cannot be evaluated at some test point
- * or algorithm fails to converge
+ * @throws MathUserException if function cannot be evaluated at some test point
+ * @throws OptimizationException if algorithm fails to converge
*/
- public void search(final double[] p,
- final double[] d)
- throws OptimizationException {
+ public void search(final double[] p, final double[] d)
+ throws MathUserException, OptimizationException {
// Reset.
optimum = Double.NaN;
@@ -247,7 +246,7 @@ public class PowellOptimizer
final int n = p.length;
final UnivariateRealFunction f = new UnivariateRealFunction() {
public double value(double alpha)
- throws FunctionEvaluationException {
+ throws MathUserException {
final double[] x = new double[n];
for (int i = 0; i < n; i++) {
@@ -265,8 +264,6 @@ public class PowellOptimizer
bracket.getHi(),
bracket.getMid());
valueAtOptimum = optim.getFunctionValue();
- } catch (FunctionEvaluationException e) {
- throw new OptimizationException(e);
} catch (MaxIterationsExceededException e) {
throw new OptimizationException(e);
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/CurveFitter.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/CurveFitter.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/CurveFitter.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/CurveFitter.java Sat Nov 20 20:57:37 2010
@@ -20,9 +20,9 @@ package org.apache.commons.math.optimiza
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.analysis.DifferentiableMultivariateVectorialFunction;
import org.apache.commons.math.analysis.MultivariateMatrixFunction;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.optimization.DifferentiableMultivariateVectorialOptimizer;
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.VectorialPointValuePair;
@@ -118,14 +118,13 @@ public class CurveFitter {
* @param f parametric function to fit
* @param initialGuess first guess of the function parameters
* @return fitted parameters
- * @exception FunctionEvaluationException if the objective function throws one during
- * the search
+ * @exception MathUserException if the objective function throws one during the search
* @exception OptimizationException if the algorithm failed to converge
* @exception IllegalArgumentException if the start point dimension is wrong
*/
public double[] fit(final ParametricRealFunction f,
final double[] initialGuess)
- throws FunctionEvaluationException, OptimizationException, IllegalArgumentException {
+ throws MathUserException, OptimizationException, IllegalArgumentException {
// prepare least squares problem
double[] target = new double[observations.size()];
@@ -164,7 +163,7 @@ public class CurveFitter {
public MultivariateMatrixFunction jacobian() {
return new MultivariateMatrixFunction() {
public double[][] value(double[] point)
- throws FunctionEvaluationException, IllegalArgumentException {
+ throws MathUserException, IllegalArgumentException {
final double[][] jacobian = new double[observations.size()][];
@@ -180,8 +179,7 @@ public class CurveFitter {
}
/** {@inheritDoc} */
- public double[] value(double[] point)
- throws FunctionEvaluationException, IllegalArgumentException {
+ public double[] value(double[] point) throws MathUserException, IllegalArgumentException {
// compute the residuals
final double[] values = new double[observations.size()];
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/GaussianDerivativeFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/GaussianDerivativeFunction.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/GaussianDerivativeFunction.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/GaussianDerivativeFunction.java Sat Nov 20 20:57:37 2010
@@ -19,7 +19,6 @@ package org.apache.commons.math.optimiza
import java.io.Serializable;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.exception.DimensionMismatchException;
import org.apache.commons.math.exception.util.LocalizedFormats;
@@ -97,7 +96,7 @@ public class GaussianDerivativeFunction
}
/** {@inheritDoc} */
- public double value(double x) throws FunctionEvaluationException {
+ public double value(double x) {
final double xMc = x - c;
return (-b / d2) * xMc * Math.exp(-(xMc * xMc) / (2.0 * d2));
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/GaussianFitter.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/GaussianFitter.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/GaussianFitter.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/GaussianFitter.java Sat Nov 20 20:57:37 2010
@@ -17,7 +17,7 @@
package org.apache.commons.math.optimization.fitting;
-import org.apache.commons.math.FunctionEvaluationException;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.optimization.DifferentiableMultivariateVectorialOptimizer;
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.fitting.CurveFitter;
@@ -91,16 +91,13 @@ public class GaussianFitter {
*
* @return Gaussian function best fitting the observed points
*
- * @throws FunctionEvaluationException if <code>CurveFitter.fit</code>
- * throws it
+ * @throws MathUserException if <code>CurveFitter.fit</code> throws it
* @throws OptimizationException if <code>CurveFitter.fit</code> throws it
- * @throws IllegalArgumentException if <code>CurveFitter.fit</code> throws
- * it
+ * @throws IllegalArgumentException if <code>CurveFitter.fit</code> throws it
*
* @see CurveFitter
*/
- public GaussianFunction fit()
- throws FunctionEvaluationException, OptimizationException {
+ public GaussianFunction fit() throws MathUserException, OptimizationException {
return new GaussianFunction(fitter.fit(new ParametricGaussianFunction(),
createParametersGuesser(fitter.getObservations()).guess()));
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/GaussianFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/GaussianFunction.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/GaussianFunction.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/GaussianFunction.java Sat Nov 20 20:57:37 2010
@@ -19,7 +19,6 @@ package org.apache.commons.math.optimiza
import java.io.Serializable;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.exception.DimensionMismatchException;
@@ -117,7 +116,7 @@ public class GaussianFunction implements
}
/** {@inheritDoc} */
- public double value(double x) throws FunctionEvaluationException {
+ public double value(double x) {
final double xMc = x - c;
return a + b * Math.exp(-xMc * xMc / (2.0 * (d * d)));
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/HarmonicFitter.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/HarmonicFitter.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/HarmonicFitter.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/HarmonicFitter.java Sat Nov 20 20:57:37 2010
@@ -17,7 +17,6 @@
package org.apache.commons.math.optimization.fitting;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.optimization.DifferentiableMultivariateVectorialOptimizer;
@@ -78,33 +77,28 @@ public class HarmonicFitter {
* the first guess cannot be computed
*/
public HarmonicFunction fit() throws OptimizationException {
- try {
-
- // shall we compute the first guess of the parameters ourselves ?
- if (parameters == null) {
- final WeightedObservedPoint[] observations = fitter.getObservations();
- if (observations.length < 4) {
- throw new OptimizationException(LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE,
- observations.length, 4);
- }
-
- HarmonicCoefficientsGuesser guesser = new HarmonicCoefficientsGuesser(observations);
- guesser.guess();
- parameters = new double[] {
- guesser.getGuessedAmplitude(),
- guesser.getGuessedPulsation(),
- guesser.getGuessedPhase()
- };
+ // shall we compute the first guess of the parameters ourselves ?
+ if (parameters == null) {
+ final WeightedObservedPoint[] observations = fitter.getObservations();
+ if (observations.length < 4) {
+ throw new OptimizationException(LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE,
+ observations.length, 4);
}
- double[] fitted = fitter.fit(new ParametricHarmonicFunction(), parameters);
- return new HarmonicFunction(fitted[0], fitted[1], fitted[2]);
+ HarmonicCoefficientsGuesser guesser = new HarmonicCoefficientsGuesser(observations);
+ guesser.guess();
+ parameters = new double[] {
+ guesser.getGuessedAmplitude(),
+ guesser.getGuessedPulsation(),
+ guesser.getGuessedPhase()
+ };
- } catch (FunctionEvaluationException fee) {
- // this should never happen
- throw MathRuntimeException.createInternalError(fee);
}
+
+ double[] fitted = fitter.fit(new ParametricHarmonicFunction(), parameters);
+ return new HarmonicFunction(fitted[0], fitted[1], fitted[2]);
+
}
/** Parametric harmonic function. */
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/ParametricGaussianFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/ParametricGaussianFunction.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/ParametricGaussianFunction.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/ParametricGaussianFunction.java Sat Nov 20 20:57:37 2010
@@ -19,7 +19,6 @@ package org.apache.commons.math.optimiza
import java.io.Serializable;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.exception.DimensionMismatchException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.exception.ZeroException;
@@ -78,10 +77,10 @@ public class ParametricGaussianFunction
*
* @throws IllegalArgumentException if <code>parameters</code> is invalid as
* determined by {@link #validateParameters(double[])}
- * @throws FunctionEvaluationException if <code>parameters</code> values are
+ * @throws ZeroException if <code>parameters</code> values are
* invalid as determined by {@link #validateParameters(double[])}
*/
- public double value(double x, double[] parameters) throws FunctionEvaluationException {
+ public double value(double x, double[] parameters) throws ZeroException {
validateParameters(parameters);
final double a = parameters[0];
final double b = parameters[1];
@@ -119,10 +118,10 @@ public class ParametricGaussianFunction
*
* @throws IllegalArgumentException if <code>parameters</code> is invalid as
* determined by {@link #validateParameters(double[])}
- * @throws FunctionEvaluationException if <code>parameters</code> values are
+ * @throws ZeroException if <code>parameters</code> values are
* invalid as determined by {@link #validateParameters(double[])}
*/
- public double[] gradient(double x, double[] parameters) throws FunctionEvaluationException {
+ public double[] gradient(double x, double[] parameters) throws ZeroException {
validateParameters(parameters);
final double b = parameters[1];
@@ -148,10 +147,10 @@ public class ParametricGaussianFunction
* @throws IllegalArgumentException if <code>parameters</code> is
* <code>null</code> or if <code>parameters</code> does not have
* length == 4
- * @throws FunctionEvaluationException if <code>parameters[3]</code>
+ * @throws ZeroException if <code>parameters[3]</code>
* (<tt>d</tt>) is 0
*/
- private void validateParameters(double[] parameters) throws FunctionEvaluationException {
+ private void validateParameters(double[] parameters) throws ZeroException {
if (parameters == null) {
throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/ParametricRealFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/ParametricRealFunction.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/ParametricRealFunction.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/ParametricRealFunction.java Sat Nov 20 20:57:37 2010
@@ -17,7 +17,7 @@
package org.apache.commons.math.optimization.fitting;
-import org.apache.commons.math.FunctionEvaluationException;
+import org.apache.commons.math.exception.MathUserException;
/**
* An interface representing a real function that depends on one independent
@@ -32,19 +32,19 @@ public interface ParametricRealFunction
* @param x the point for which the function value should be computed
* @param parameters function parameters
* @return the value
- * @throws FunctionEvaluationException if the function evaluation fails
+ * @throws MathUserException if the function evaluation fails
*/
double value(double x, double[] parameters)
- throws FunctionEvaluationException;
+ throws MathUserException;
/**
* Compute the gradient of the function with respect to its parameters.
* @param x the point for which the function value should be computed
* @param parameters function parameters
* @return the value
- * @throws FunctionEvaluationException if the function evaluation fails
+ * @throws MathUserException if the function evaluation fails
*/
double[] gradient(double x, double[] parameters)
- throws FunctionEvaluationException;
+ throws MathUserException;
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/PolynomialFitter.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/PolynomialFitter.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/PolynomialFitter.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/fitting/PolynomialFitter.java Sat Nov 20 20:57:37 2010
@@ -17,7 +17,6 @@
package org.apache.commons.math.optimization.fitting;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math.optimization.DifferentiableMultivariateVectorialOptimizer;
@@ -71,22 +70,15 @@ public class PolynomialFitter {
* @return polynomial function best fitting the observed points
* @exception OptimizationException if the algorithm failed to converge
*/
- public PolynomialFunction fit()
- throws OptimizationException {
- try {
- return new PolynomialFunction(fitter.fit(new ParametricPolynomial(), new double[degree + 1]));
- } catch (FunctionEvaluationException fee) {
- // this should never happen
- throw MathRuntimeException.createInternalError(fee);
- }
+ public PolynomialFunction fit() throws OptimizationException {
+ return new PolynomialFunction(fitter.fit(new ParametricPolynomial(), new double[degree + 1]));
}
/** Dedicated parametric polynomial class. */
private static class ParametricPolynomial implements ParametricRealFunction {
/** {@inheritDoc} */
- public double[] gradient(double x, double[] parameters)
- throws FunctionEvaluationException {
+ public double[] gradient(double x, double[] parameters) {
final double[] gradient = new double[parameters.length];
double xn = 1.0;
for (int i = 0; i < parameters.length; ++i) {
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java Sat Nov 20 20:57:37 2010
@@ -17,20 +17,20 @@
package org.apache.commons.math.optimization.general;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MaxEvaluationsExceededException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.DifferentiableMultivariateVectorialFunction;
import org.apache.commons.math.analysis.MultivariateMatrixFunction;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.linear.InvalidMatrixException;
import org.apache.commons.math.linear.LUDecompositionImpl;
import org.apache.commons.math.linear.MatrixUtils;
import org.apache.commons.math.linear.RealMatrix;
+import org.apache.commons.math.optimization.DifferentiableMultivariateVectorialOptimizer;
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.SimpleVectorialValueChecker;
import org.apache.commons.math.optimization.VectorialConvergenceChecker;
-import org.apache.commons.math.optimization.DifferentiableMultivariateVectorialOptimizer;
import org.apache.commons.math.optimization.VectorialPointValuePair;
import org.apache.commons.math.util.FastMath;
@@ -178,15 +178,15 @@ public abstract class AbstractLeastSquar
/**
* Update the jacobian matrix.
- * @exception FunctionEvaluationException if the function jacobian
+ * @exception MathUserException if the function jacobian
* cannot be evaluated or its dimension doesn't match problem dimension
*/
- protected void updateJacobian() throws FunctionEvaluationException {
+ protected void updateJacobian() throws MathUserException {
++jacobianEvaluations;
weightedResidualJacobian = jF.value(point);
if (weightedResidualJacobian.length != rows) {
- throw new FunctionEvaluationException(point, LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
- weightedResidualJacobian.length, rows);
+ throw new MathUserException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
+ weightedResidualJacobian.length, rows);
}
for (int i = 0; i < rows; i++) {
final double[] ji = weightedResidualJacobian[i];
@@ -200,21 +200,19 @@ public abstract class AbstractLeastSquar
/**
* Update the residuals array and cost function value.
- * @exception FunctionEvaluationException if the function cannot be evaluated
+ * @exception MathUserException if the function cannot be evaluated
* or its dimension doesn't match problem dimension or maximal number of
* of evaluations is exceeded
*/
protected void updateResidualsAndCost()
- throws FunctionEvaluationException {
+ throws MathUserException {
if (++objectiveEvaluations > maxEvaluations) {
- throw new FunctionEvaluationException(new MaxEvaluationsExceededException(maxEvaluations),
- point);
+ throw new MathUserException(new MaxEvaluationsExceededException(maxEvaluations));
}
objective = function.value(point);
if (objective.length != rows) {
- throw new FunctionEvaluationException(point, LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
- objective.length, rows);
+ throw new MathUserException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, objective.length, rows);
}
cost = 0;
int index = 0;
@@ -255,13 +253,13 @@ public abstract class AbstractLeastSquar
/**
* Get the covariance matrix of optimized parameters.
* @return covariance matrix
- * @exception FunctionEvaluationException if the function jacobian cannot
+ * @exception MathUserException if the function jacobian cannot
* be evaluated
* @exception OptimizationException if the covariance matrix
* cannot be computed (singular problem)
*/
public double[][] getCovariances()
- throws FunctionEvaluationException, OptimizationException {
+ throws MathUserException, OptimizationException {
// set up the jacobian
updateJacobian();
@@ -294,13 +292,13 @@ public abstract class AbstractLeastSquar
* Guess the errors in optimized parameters.
* <p>Guessing is covariance-based, it only gives rough order of magnitude.</p>
* @return errors in optimized parameters
- * @exception FunctionEvaluationException if the function jacobian cannot b evaluated
+ * @exception MathUserException if the function jacobian cannot b evaluated
* @exception OptimizationException if the covariances matrix cannot be computed
* or the number of degrees of freedom is not positive (number of measurements
* lesser or equal to number of parameters)
*/
public double[] guessParametersErrors()
- throws FunctionEvaluationException, OptimizationException {
+ throws MathUserException, OptimizationException {
if (rows <= cols) {
throw new OptimizationException(
LocalizedFormats.NO_DEGREES_OF_FREEDOM,
@@ -319,7 +317,7 @@ public abstract class AbstractLeastSquar
public VectorialPointValuePair optimize(final DifferentiableMultivariateVectorialFunction f,
final double[] target, final double[] weights,
final double[] startPoint)
- throws FunctionEvaluationException, OptimizationException, IllegalArgumentException {
+ throws MathUserException, OptimizationException, IllegalArgumentException {
if (target.length != weights.length) {
throw new OptimizationException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
@@ -353,12 +351,12 @@ public abstract class AbstractLeastSquar
/** Perform the bulk of optimization algorithm.
* @return the point/value pair giving the optimal value for objective function
- * @exception FunctionEvaluationException if the objective function throws one during
+ * @exception MathUserException if the objective function throws one during
* the search
* @exception OptimizationException if the algorithm failed to converge
* @exception IllegalArgumentException if the start point dimension is wrong
*/
protected abstract VectorialPointValuePair doOptimize()
- throws FunctionEvaluationException, OptimizationException, IllegalArgumentException;
+ throws MathUserException, OptimizationException, IllegalArgumentException;
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/AbstractScalarDifferentiableOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/AbstractScalarDifferentiableOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/AbstractScalarDifferentiableOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/AbstractScalarDifferentiableOptimizer.java Sat Nov 20 20:57:37 2010
@@ -17,9 +17,9 @@
package org.apache.commons.math.optimization.general;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.analysis.DifferentiableMultivariateRealFunction;
import org.apache.commons.math.analysis.MultivariateVectorialFunction;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.optimization.DifferentiableMultivariateRealOptimizer;
import org.apache.commons.math.optimization.GoalType;
import org.apache.commons.math.optimization.OptimizationException;
@@ -89,10 +89,10 @@ public abstract class AbstractScalarDiff
* Compute the gradient vector.
* @param evaluationPoint point at which the gradient must be evaluated
* @return gradient at the specified point
- * @exception FunctionEvaluationException if the function gradient
+ * @exception MathUserException if the function gradient
*/
protected double[] computeObjectiveGradient(final double[] evaluationPoint)
- throws FunctionEvaluationException {
+ throws MathUserException {
++gradientEvaluations;
return gradient.value(evaluationPoint);
}
@@ -102,8 +102,7 @@ public abstract class AbstractScalarDiff
public RealPointValuePair optimize(final DifferentiableMultivariateRealFunction f,
final GoalType goalType,
final double[] startPoint)
- throws FunctionEvaluationException,
- OptimizationException {
+ throws MathUserException, OptimizationException {
// reset counters
gradientEvaluations = 0;
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/BaseAbstractScalarOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/BaseAbstractScalarOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/BaseAbstractScalarOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/BaseAbstractScalarOptimizer.java Sat Nov 20 20:57:37 2010
@@ -17,10 +17,10 @@
package org.apache.commons.math.optimization.general;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MaxEvaluationsExceededException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.MultivariateRealFunction;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.optimization.BaseMultivariateRealOptimizer;
import org.apache.commons.math.optimization.GoalType;
import org.apache.commons.math.optimization.OptimizationException;
@@ -146,24 +146,21 @@ public abstract class BaseAbstractScalar
* Compute the objective function value.
* @param evaluationPoint point at which the objective function must be evaluated
* @return objective function value at specified point
- * @throws FunctionEvaluationException if the function cannot be evaluated
+ * @throws MathUserException if the function cannot be evaluated
* or its dimension doesn't match problem dimension or the maximal number
* of iterations is exceeded
*/
protected double computeObjectiveValue(double[] evaluationPoint)
- throws FunctionEvaluationException {
+ throws MathUserException {
if (++evaluations > maxEvaluations) {
- throw new FunctionEvaluationException(new MaxEvaluationsExceededException(maxEvaluations),
- evaluationPoint);
+ throw new MathUserException(new MaxEvaluationsExceededException(maxEvaluations));
}
return function.value(evaluationPoint);
}
/** {@inheritDoc} */
- public RealPointValuePair optimize(T f,
- GoalType goalType,
- double[] startPoint)
- throws FunctionEvaluationException, OptimizationException {
+ public RealPointValuePair optimize(T f, GoalType goalType, double[] startPoint)
+ throws MathUserException, OptimizationException {
// reset counters
iterations = 0;
@@ -194,11 +191,10 @@ public abstract class BaseAbstractScalar
/**
* Perform the bulk of optimization algorithm.
* @return the point/value pair giving the optimal value for objective function
- * @throws FunctionEvaluationException if the objective function throws one during
- * the search
+ * @throws MathUserException if the objective function throws one during the search
* @throws OptimizationException if the algorithm failed to converge
* @throws IllegalArgumentException if the start point dimension is wrong
*/
protected abstract RealPointValuePair doOptimize()
- throws FunctionEvaluationException, OptimizationException;
+ throws MathUserException, OptimizationException;
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java Sat Nov 20 20:57:37 2010
@@ -17,7 +17,7 @@
package org.apache.commons.math.optimization.general;
-import org.apache.commons.math.FunctionEvaluationException;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.linear.BlockRealMatrix;
import org.apache.commons.math.linear.DecompositionSolver;
@@ -62,7 +62,7 @@ public class GaussNewtonOptimizer extend
/** {@inheritDoc} */
@Override
public VectorialPointValuePair doOptimize()
- throws FunctionEvaluationException, OptimizationException, IllegalArgumentException {
+ throws MathUserException, OptimizationException, IllegalArgumentException {
// iterate until convergence is reached
VectorialPointValuePair current = null;
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java Sat Nov 20 20:57:37 2010
@@ -18,7 +18,7 @@ package org.apache.commons.math.optimiza
import java.util.Arrays;
-import org.apache.commons.math.FunctionEvaluationException;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.VectorialPointValuePair;
@@ -240,7 +240,7 @@ public class LevenbergMarquardtOptimizer
/** {@inheritDoc} */
@Override
protected VectorialPointValuePair doOptimize()
- throws FunctionEvaluationException, OptimizationException, IllegalArgumentException {
+ throws MathUserException, OptimizationException, IllegalArgumentException {
// arrays shared with the other private methods
solvedCols = FastMath.min(rows, cols);
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizer.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizer.java Sat Nov 20 20:57:37 2010
@@ -18,10 +18,10 @@
package org.apache.commons.math.optimization.general;
import org.apache.commons.math.ConvergenceException;
-import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.analysis.solvers.BrentSolver;
import org.apache.commons.math.analysis.solvers.UnivariateRealSolver;
+import org.apache.commons.math.exception.MathUserException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.optimization.GoalType;
import org.apache.commons.math.optimization.OptimizationException;
@@ -110,7 +110,7 @@ public class NonLinearConjugateGradientO
/** {@inheritDoc} */
@Override
protected RealPointValuePair doOptimize()
- throws FunctionEvaluationException, OptimizationException, IllegalArgumentException {
+ throws MathUserException, OptimizationException, IllegalArgumentException {
try {
// initialization
if (preconditioner == null) {
@@ -217,12 +217,12 @@ public class NonLinearConjugateGradientO
* @param a lower bound of the interval
* @param h initial step to try
* @return b such that f(a) and f(b) have opposite signs
- * @exception FunctionEvaluationException if the function cannot be computed
+ * @exception MathUserException if the function cannot be computed
* @exception OptimizationException if no bracket can be found
*/
private double findUpperBound(final UnivariateRealFunction f,
final double a, final double h)
- throws FunctionEvaluationException, OptimizationException {
+ throws MathUserException, OptimizationException {
final double yA = f.value(a);
double yB = yA;
for (double step = h; step < Double.MAX_VALUE; step *= FastMath.max(2, yA / yB)) {
@@ -266,7 +266,7 @@ public class NonLinearConjugateGradientO
}
/** {@inheritDoc} */
- public double value(double x) throws FunctionEvaluationException {
+ public double value(double x) throws MathUserException {
// current point in the search direction
final double[] shiftedPoint = point.clone();
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/Preconditioner.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/Preconditioner.java?rev=1037327&r1=1037326&r2=1037327&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/Preconditioner.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/optimization/general/Preconditioner.java Sat Nov 20 20:57:37 2010
@@ -17,7 +17,7 @@
package org.apache.commons.math.optimization.general;
-import org.apache.commons.math.FunctionEvaluationException;
+import org.apache.commons.math.exception.MathUserException;
/**
* This interface represents a preconditioner for differentiable scalar
@@ -43,10 +43,10 @@ public interface Preconditioner {
* @param point current point at which the search direction was computed
* @param r raw search direction (i.e. opposite of the gradient)
* @return approximation of H<sup>-1</sup>r where H is the objective function hessian
- * @exception FunctionEvaluationException if no cost can be computed for the parameters
+ * @exception MathUserException if no cost can be computed for the parameters
* @exception IllegalArgumentException if point dimension is wrong
*/
double[] precondition(double[] point, double[] r)
- throws FunctionEvaluationException, IllegalArgumentException;
+ throws MathUserException, IllegalArgumentException;
}