Author: erans Date: Sun Jul 25 12:29:43 2010 New Revision: 979032 URL: http://svn.apache.org/viewvc?rev=979032&view=rev Log: MATH-393 Fixed inconsistent definition of "getResult". Modified associated test accordingly.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java commons/proper/math/trunk/src/site/xdoc/changes.xml commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizerTest.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java?rev=979032&r1=979031&r2=979032&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java Sun Jul 25 12:29:43 2010 @@ -89,12 +89,12 @@ public class MultiStartUnivariateRealOpt /** {...@inheritdoc} */ public double getFunctionValue() { - return optimizer.getFunctionValue(); + return optimaValues[0]; } /** {...@inheritdoc} */ public double getResult() { - return optimizer.getResult(); + return optima[0]; } /** {...@inheritdoc} */ @@ -315,5 +315,4 @@ public class MultiStartUnivariateRealOpt throws ConvergenceException, FunctionEvaluationException { return optimize(f, goalType, min, max); } - } Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java?rev=979032&r1=979031&r2=979032&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/UnivariateRealOptimizer.java Sun Jul 25 12:29:43 2010 @@ -36,7 +36,7 @@ public interface UnivariateRealOptimizer void setMaxEvaluations(int maxEvaluations); /** Get the maximal number of functions evaluations. - * @return maximal number of functions evaluations + * @return the maximal number of functions evaluations. */ int getMaxEvaluations(); @@ -46,7 +46,7 @@ public interface UnivariateRealOptimizer * {...@link #optimize(UnivariateRealFunction, GoalType, double, double) optimize} * method. It is 0 if the method has not been called yet. * </p> - * @return number of evaluations of the objective function + * @return the number of evaluations of the objective function. */ int getEvaluations(); @@ -57,16 +57,16 @@ public interface UnivariateRealOptimizer * </p> * @param f the function to optimize. * @param goalType type of optimization goal: either {...@link GoalType#MAXIMIZE} - * or {...@link GoalType#MINIMIZE} + * or {...@link GoalType#MINIMIZE}. * @param min the lower bound for the interval. * @param max the upper bound for the interval. - * @return a value where the function is optimum + * @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 + * function. * @throws IllegalArgumentException if min > max or the endpoints do not - * satisfy the requirements specified by the optimizer + * satisfy the requirements specified by the optimizer. */ double optimize(UnivariateRealFunction f, GoalType goalType, double min, double max) @@ -79,17 +79,17 @@ public interface UnivariateRealOptimizer * </p> * @param f the function to optimize. * @param goalType type of optimization goal: either {...@link GoalType#MAXIMIZE} - * or {...@link GoalType#MINIMIZE} + * or {...@link GoalType#MINIMIZE}. * @param min the lower bound for the interval. * @param max the upper bound for the interval. - * @param startValue the start value to use - * @return a value where the function is optimum + * @param startValue the start value to use. + * @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 + * function. * @throws IllegalArgumentException if min > max or the arguments do not - * satisfy the requirements specified by the optimizer + * satisfy the requirements specified by the optimizer. */ double optimize(UnivariateRealFunction f, GoalType goalType, double min, double max, double startValue) @@ -98,7 +98,7 @@ public interface UnivariateRealOptimizer /** * Get the result of the last run of the optimizer. * - * @return the last result. + * @return the optimum. * @throws IllegalStateException if there is no result available, either * because no result was yet computed or the last attempt failed. */ @@ -107,10 +107,9 @@ public interface UnivariateRealOptimizer /** * Get the result of the last run of the optimizer. * - * @return the value of the function at the last result. + * @return the value of the function at the optimum. * @throws IllegalStateException if there is no result available, either * because no result was yet computed or the last attempt failed. */ double getFunctionValue(); - } Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=979032&r1=979031&r2=979032&view=diff ============================================================================== --- commons/proper/math/trunk/src/site/xdoc/changes.xml (original) +++ commons/proper/math/trunk/src/site/xdoc/changes.xml Sun Jul 25 12:29:43 2010 @@ -52,6 +52,9 @@ The <action> type attribute can be add,u If the output is not quite correct, check for invisible trailing spaces! --> <release version="2.2" date="TBD" description="TBD"> + <action dev="erans" type="fix" issue="MATH-393"> + Fixed inconsistency in return values in "MultiStartUnivariateRealOptimizer". + </action> <action dev="erans" type="update" issue="MATH-389"> Refactoring of some classes in package "optimization.general" to remove code duplication and to allow the implementation of optimization algorithms Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizerTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizerTest.java?rev=979032&r1=979031&r2=979032&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizerTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizerTest.java Sun Jul 25 12:29:43 2010 @@ -83,8 +83,8 @@ public class MultiStartUnivariateRealOpt } assertEquals(-0.27195612846834, minimizer.optimize(f, GoalType.MINIMIZE, -0.3, -0.2), 1.0e-13); - assertEquals(-0.27194301946870, minimizer.getResult(), 1.0e-13); - assertEquals(-0.04433426940878, minimizer.getFunctionValue(), 1.0e-13); + assertEquals(-0.27195612846834, minimizer.getResult(), 1.0e-13); + assertEquals(-0.04433426954946, minimizer.getFunctionValue(), 1.0e-13); double[] optima = minimizer.getOptima(); double[] optimaValues = minimizer.getOptimaValues();