From 75fe8b8b99ce0ef9c682f5b2d90727bab498e17a Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Sun, 16 Sep 2012 16:19:55 +0000 Subject: [PATCH] Javadoc cleanup of linear optimization package. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1385307 13f79535-47bb-0310-9956-ffa450edef68 --- .../linear/AbstractLinearOptimizer.java | 28 ++++++++------- .../optimization/linear/LinearConstraint.java | 8 ++--- .../linear/LinearObjectiveFunction.java | 8 ++--- .../optimization/linear/LinearOptimizer.java | 20 ++++++----- .../linear/NoFeasibleSolutionException.java | 4 +-- .../optimization/linear/Relationship.java | 1 - .../optimization/linear/SimplexSolver.java | 1 + .../optimization/linear/SimplexTableau.java | 36 +++++++++---------- .../linear/UnboundedSolutionException.java | 4 +-- 9 files changed, 56 insertions(+), 54 deletions(-) diff --git a/src/main/java/org/apache/commons/math3/optimization/linear/AbstractLinearOptimizer.java b/src/main/java/org/apache/commons/math3/optimization/linear/AbstractLinearOptimizer.java index deb7f3976..f3b0057cb 100644 --- a/src/main/java/org/apache/commons/math3/optimization/linear/AbstractLinearOptimizer.java +++ b/src/main/java/org/apache/commons/math3/optimization/linear/AbstractLinearOptimizer.java @@ -27,11 +27,12 @@ import org.apache.commons.math3.optimization.PointValuePair; /** * Base class for implementing linear optimizers. - *

This base class handles the boilerplate methods associated to thresholds - * settings and iterations counters.

+ *

+ * This base class handles the boilerplate methods associated to thresholds + * settings and iterations counters. + * * @version $Id$ * @since 2.0 - * */ public abstract class AbstractLinearOptimizer implements LinearOptimizer { @@ -68,7 +69,8 @@ public abstract class AbstractLinearOptimizer implements LinearOptimizer { /** Number of iterations already performed. */ private int iterations; - /** Simple constructor with default settings. + /** + * Simple constructor with default settings. *

The maximal number of evaluation is set to its default value.

*/ protected AbstractLinearOptimizer() { @@ -118,9 +120,9 @@ public abstract class AbstractLinearOptimizer implements LinearOptimizer { return iterations; } - /** Increment the iterations counter by 1. - * @exception MaxCountExceededException if the maximal number - * of iterations is exceeded + /** + * Increment the iterations counter by 1. + * @exception MaxCountExceededException if the maximal number of iterations is exceeded */ protected void incrementIterationsCounter() throws MaxCountExceededException { @@ -131,9 +133,9 @@ public abstract class AbstractLinearOptimizer implements LinearOptimizer { /** {@inheritDoc} */ public PointValuePair optimize(final LinearObjectiveFunction f, - final Collection constraints, - final GoalType goalType, final boolean restrictToNonNegative) - throws MathIllegalStateException { + final Collection constraints, + final GoalType goalType, final boolean restrictToNonNegative) + throws MathIllegalStateException { // store linear problem characteristics this.function = f; @@ -148,12 +150,12 @@ public abstract class AbstractLinearOptimizer implements LinearOptimizer { } - /** Perform the bulk of optimization algorithm. + /** + * Perform the bulk of optimization algorithm. * @return the point/value pair giving the optimal value for objective function * @exception MathIllegalStateException if no solution fulfilling the constraints * can be found in the allowed number of iterations */ - protected abstract PointValuePair doOptimize() - throws MathIllegalStateException; + protected abstract PointValuePair doOptimize() throws MathIllegalStateException; } diff --git a/src/main/java/org/apache/commons/math3/optimization/linear/LinearConstraint.java b/src/main/java/org/apache/commons/math3/optimization/linear/LinearConstraint.java index acf9e1b5c..6fd082a92 100644 --- a/src/main/java/org/apache/commons/math3/optimization/linear/LinearConstraint.java +++ b/src/main/java/org/apache/commons/math3/optimization/linear/LinearConstraint.java @@ -184,7 +184,6 @@ public class LinearConstraint implements Serializable { return value; } - /** {@inheritDoc} */ @Override public boolean equals(Object other) { @@ -201,7 +200,6 @@ public class LinearConstraint implements Serializable { return false; } - /** {@inheritDoc} */ @Override public int hashCode() { return relationship.hashCode() ^ @@ -209,7 +207,8 @@ public class LinearConstraint implements Serializable { coefficients.hashCode(); } - /** Serialize the instance. + /** + * Serialize the instance. * @param oos stream where object should be written * @throws IOException if object cannot be written to stream */ @@ -219,7 +218,8 @@ public class LinearConstraint implements Serializable { MatrixUtils.serializeRealVector(coefficients, oos); } - /** Deserialize the instance. + /** + * Deserialize the instance. * @param ois stream from which the object should be read * @throws ClassNotFoundException if a class in the stream cannot be found * @throws IOException if object cannot be read from the stream diff --git a/src/main/java/org/apache/commons/math3/optimization/linear/LinearObjectiveFunction.java b/src/main/java/org/apache/commons/math3/optimization/linear/LinearObjectiveFunction.java index d87b46f54..07d519003 100644 --- a/src/main/java/org/apache/commons/math3/optimization/linear/LinearObjectiveFunction.java +++ b/src/main/java/org/apache/commons/math3/optimization/linear/LinearObjectiveFunction.java @@ -101,7 +101,6 @@ public class LinearObjectiveFunction implements Serializable { return coefficients.dotProduct(point) + constantTerm; } - /** {@inheritDoc} */ @Override public boolean equals(Object other) { @@ -117,13 +116,13 @@ public class LinearObjectiveFunction implements Serializable { return false; } - /** {@inheritDoc} */ @Override public int hashCode() { return Double.valueOf(constantTerm).hashCode() ^ coefficients.hashCode(); } - /** Serialize the instance. + /** + * Serialize the instance. * @param oos stream where object should be written * @throws IOException if object cannot be written to stream */ @@ -133,7 +132,8 @@ public class LinearObjectiveFunction implements Serializable { MatrixUtils.serializeRealVector(coefficients, oos); } - /** Deserialize the instance. + /** + * Deserialize the instance. * @param ois stream from which the object should be read * @throws ClassNotFoundException if a class in the stream cannot be found * @throws IOException if object cannot be read from the stream diff --git a/src/main/java/org/apache/commons/math3/optimization/linear/LinearOptimizer.java b/src/main/java/org/apache/commons/math3/optimization/linear/LinearOptimizer.java index adba4a07b..4042733cb 100644 --- a/src/main/java/org/apache/commons/math3/optimization/linear/LinearOptimizer.java +++ b/src/main/java/org/apache/commons/math3/optimization/linear/LinearOptimizer.java @@ -52,17 +52,20 @@ import org.apache.commons.math3.optimization.PointValuePair; */ public interface LinearOptimizer { - /** Set the maximal number of iterations of the algorithm. + /** + * Set the maximal number of iterations of the algorithm. * @param maxIterations maximal number of function calls */ void setMaxIterations(int maxIterations); - /** Get the maximal number of iterations of the algorithm. + /** + * Get the maximal number of iterations of the algorithm. * @return maximal number of iterations */ int getMaxIterations(); - /** Get the number of iterations realized by the algorithm. + /** + * Get the number of iterations realized by the algorithm. *

* The number of evaluations corresponds to the last call to the * {@link #optimize(LinearObjectiveFunction, Collection, GoalType, boolean) optimize} @@ -72,18 +75,17 @@ public interface LinearOptimizer { */ int getIterations(); - /** Optimizes an objective function. + /** + * Optimizes an objective function. * @param f linear objective function * @param constraints linear constraints - * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} - * or {@link GoalType#MINIMIZE} + * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE} * @param restrictToNonNegative whether to restrict the variables to non-negative values * @return point/value pair giving the optimal value for objective function * @exception MathIllegalStateException if no solution fulfilling the constraints - * can be found in the allowed number of iterations + * can be found in the allowed number of iterations */ PointValuePair optimize(LinearObjectiveFunction f, Collection constraints, - GoalType goalType, boolean restrictToNonNegative) - throws MathIllegalStateException; + GoalType goalType, boolean restrictToNonNegative) throws MathIllegalStateException; } diff --git a/src/main/java/org/apache/commons/math3/optimization/linear/NoFeasibleSolutionException.java b/src/main/java/org/apache/commons/math3/optimization/linear/NoFeasibleSolutionException.java index 559f9e6bf..d5c6d46ff 100644 --- a/src/main/java/org/apache/commons/math3/optimization/linear/NoFeasibleSolutionException.java +++ b/src/main/java/org/apache/commons/math3/optimization/linear/NoFeasibleSolutionException.java @@ -21,8 +21,8 @@ import org.apache.commons.math3.exception.MathIllegalStateException; import org.apache.commons.math3.exception.util.LocalizedFormats; /** - * This class represents exceptions thrown by optimizers when no solution - * fulfills the constraints. + * This class represents exceptions thrown by optimizers when no solution fulfills the constraints. + * * @version $Id$ * @since 2.0 */ diff --git a/src/main/java/org/apache/commons/math3/optimization/linear/Relationship.java b/src/main/java/org/apache/commons/math3/optimization/linear/Relationship.java index 7ea47b752..aebee6d28 100644 --- a/src/main/java/org/apache/commons/math3/optimization/linear/Relationship.java +++ b/src/main/java/org/apache/commons/math3/optimization/linear/Relationship.java @@ -43,7 +43,6 @@ public enum Relationship { this.stringValue = stringValue; } - /** {@inheritDoc} */ @Override public String toString() { return stringValue; diff --git a/src/main/java/org/apache/commons/math3/optimization/linear/SimplexSolver.java b/src/main/java/org/apache/commons/math3/optimization/linear/SimplexSolver.java index 9446882c2..bb76b6608 100644 --- a/src/main/java/org/apache/commons/math3/optimization/linear/SimplexSolver.java +++ b/src/main/java/org/apache/commons/math3/optimization/linear/SimplexSolver.java @@ -27,6 +27,7 @@ import org.apache.commons.math3.util.Precision; /** * Solves a linear problem using the Two-Phase Simplex Method. + * * @version $Id$ * @since 2.0 */ diff --git a/src/main/java/org/apache/commons/math3/optimization/linear/SimplexTableau.java b/src/main/java/org/apache/commons/math3/optimization/linear/SimplexTableau.java index 370a29c9c..a1a4d2b17 100644 --- a/src/main/java/org/apache/commons/math3/optimization/linear/SimplexTableau.java +++ b/src/main/java/org/apache/commons/math3/optimization/linear/SimplexTableau.java @@ -110,8 +110,7 @@ class SimplexTableau implements Serializable { * Build a tableau for a linear problem. * @param f linear objective function * @param constraints linear constraints - * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} - * or {@link GoalType#MINIMIZE} + * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE} * @param restrictToNonNegative whether to restrict the variables to non-negative values * @param epsilon amount of error to accept when checking for optimality */ @@ -126,8 +125,7 @@ class SimplexTableau implements Serializable { * Build a tableau for a linear problem. * @param f linear objective function * @param constraints linear constraints - * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} - * or {@link GoalType#MINIMIZE} + * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE} * @param restrictToNonNegative whether to restrict the variables to non-negative values * @param epsilon amount of error to accept when checking for optimality * @param maxUlps amount of error to accept in floating point comparisons @@ -397,7 +395,6 @@ class SimplexTableau implements Serializable { /** * Get the current solution. - * * @return current solution */ protected PointValuePair getSolution() { @@ -437,8 +434,8 @@ class SimplexTableau implements Serializable { * Subtracts a multiple of one row from another. *

* After application of this operation, the following will hold: - * minuendRow = minuendRow - multiple * subtrahendRow - *

+ *
minuendRow = minuendRow - multiple * subtrahendRow
+ * * @param dividendRow index of the row * @param divisor value of the divisor */ @@ -452,8 +449,8 @@ class SimplexTableau implements Serializable { * Subtracts a multiple of one row from another. *

* After application of this operation, the following will hold: - * minuendRow = minuendRow - multiple * subtrahendRow - *

+ *
minuendRow = minuendRow - multiple * subtrahendRow
+ * * @param minuendRow row index * @param subtrahendRow row index * @param multiple multiplication factor @@ -486,7 +483,8 @@ class SimplexTableau implements Serializable { return tableau.getRowDimension(); } - /** Get an entry of the tableau. + /** + * Get an entry of the tableau. * @param row row index * @param column column index * @return entry at (row, column) @@ -495,7 +493,8 @@ class SimplexTableau implements Serializable { return tableau.getEntry(row, column); } - /** Set an entry of the tableau. + /** + * Set an entry of the tableau. * @param row row index * @param column column index * @param value for the entry @@ -532,10 +531,9 @@ class SimplexTableau implements Serializable { /** * Get the number of decision variables. *

- * If variables are not restricted to positive values, this will include 1 - * extra decision variable to represent the absolute value of the most - * negative variable. - *

+ * If variables are not restricted to positive values, this will include 1 extra decision variable to represent + * the absolute value of the most negative variable. + * * @return number of decision variables * @see #getOriginalNumDecisionVariables() */ @@ -576,7 +574,6 @@ class SimplexTableau implements Serializable { return tableau.getData(); } - /** {@inheritDoc} */ @Override public boolean equals(Object other) { @@ -599,7 +596,6 @@ class SimplexTableau implements Serializable { return false; } - /** {@inheritDoc} */ @Override public int hashCode() { return Boolean.valueOf(restrictToNonNegative).hashCode() ^ @@ -613,7 +609,8 @@ class SimplexTableau implements Serializable { tableau.hashCode(); } - /** Serialize the instance. + /** + * Serialize the instance. * @param oos stream where object should be written * @throws IOException if object cannot be written to stream */ @@ -623,7 +620,8 @@ class SimplexTableau implements Serializable { MatrixUtils.serializeRealMatrix(tableau, oos); } - /** Deserialize the instance. + /** + * Deserialize the instance. * @param ois stream from which the object should be read * @throws ClassNotFoundException if a class in the stream cannot be found * @throws IOException if object cannot be read from the stream diff --git a/src/main/java/org/apache/commons/math3/optimization/linear/UnboundedSolutionException.java b/src/main/java/org/apache/commons/math3/optimization/linear/UnboundedSolutionException.java index 8dc0e7d27..f5ecbf07b 100644 --- a/src/main/java/org/apache/commons/math3/optimization/linear/UnboundedSolutionException.java +++ b/src/main/java/org/apache/commons/math3/optimization/linear/UnboundedSolutionException.java @@ -21,8 +21,8 @@ import org.apache.commons.math3.exception.MathIllegalStateException; import org.apache.commons.math3.exception.util.LocalizedFormats; /** - * This class represents exceptions thrown by optimizers when a solution - * escapes to infinity. + * This class represents exceptions thrown by optimizers when a solution escapes to infinity. + * * @version $Id$ * @since 2.0 */