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
This commit is contained in:
Thomas Neidhart 2012-09-16 16:19:55 +00:00
parent 0a900fa692
commit 75fe8b8b99
9 changed files with 56 additions and 54 deletions

View File

@ -27,11 +27,12 @@ import org.apache.commons.math3.optimization.PointValuePair;
/** /**
* Base class for implementing linear optimizers. * Base class for implementing linear optimizers.
* <p>This base class handles the boilerplate methods associated to thresholds * <p>
* settings and iterations counters.</p> * This base class handles the boilerplate methods associated to thresholds
* settings and iterations counters.
*
* @version $Id$ * @version $Id$
* @since 2.0 * @since 2.0
*
*/ */
public abstract class AbstractLinearOptimizer implements LinearOptimizer { public abstract class AbstractLinearOptimizer implements LinearOptimizer {
@ -68,7 +69,8 @@ public abstract class AbstractLinearOptimizer implements LinearOptimizer {
/** Number of iterations already performed. */ /** Number of iterations already performed. */
private int iterations; private int iterations;
/** Simple constructor with default settings. /**
* Simple constructor with default settings.
* <p>The maximal number of evaluation is set to its default value.</p> * <p>The maximal number of evaluation is set to its default value.</p>
*/ */
protected AbstractLinearOptimizer() { protected AbstractLinearOptimizer() {
@ -118,9 +120,9 @@ public abstract class AbstractLinearOptimizer implements LinearOptimizer {
return iterations; return iterations;
} }
/** Increment the iterations counter by 1. /**
* @exception MaxCountExceededException if the maximal number * Increment the iterations counter by 1.
* of iterations is exceeded * @exception MaxCountExceededException if the maximal number of iterations is exceeded
*/ */
protected void incrementIterationsCounter() protected void incrementIterationsCounter()
throws MaxCountExceededException { throws MaxCountExceededException {
@ -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 * @return the point/value pair giving the optimal value for objective function
* @exception MathIllegalStateException if no solution fulfilling the constraints * @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
*/ */
protected abstract PointValuePair doOptimize() protected abstract PointValuePair doOptimize() throws MathIllegalStateException;
throws MathIllegalStateException;
} }

View File

@ -184,7 +184,6 @@ public class LinearConstraint implements Serializable {
return value; return value;
} }
/** {@inheritDoc} */
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
@ -201,7 +200,6 @@ public class LinearConstraint implements Serializable {
return false; return false;
} }
/** {@inheritDoc} */
@Override @Override
public int hashCode() { public int hashCode() {
return relationship.hashCode() ^ return relationship.hashCode() ^
@ -209,7 +207,8 @@ public class LinearConstraint implements Serializable {
coefficients.hashCode(); coefficients.hashCode();
} }
/** Serialize the instance. /**
* Serialize the instance.
* @param oos stream where object should be written * @param oos stream where object should be written
* @throws IOException if object cannot be written to stream * @throws IOException if object cannot be written to stream
*/ */
@ -219,7 +218,8 @@ public class LinearConstraint implements Serializable {
MatrixUtils.serializeRealVector(coefficients, oos); MatrixUtils.serializeRealVector(coefficients, oos);
} }
/** Deserialize the instance. /**
* Deserialize the instance.
* @param ois stream from which the object should be read * @param ois stream from which the object should be read
* @throws ClassNotFoundException if a class in the stream cannot be found * @throws ClassNotFoundException if a class in the stream cannot be found
* @throws IOException if object cannot be read from the stream * @throws IOException if object cannot be read from the stream

View File

@ -101,7 +101,6 @@ public class LinearObjectiveFunction implements Serializable {
return coefficients.dotProduct(point) + constantTerm; return coefficients.dotProduct(point) + constantTerm;
} }
/** {@inheritDoc} */
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
@ -117,13 +116,13 @@ public class LinearObjectiveFunction implements Serializable {
return false; return false;
} }
/** {@inheritDoc} */
@Override @Override
public int hashCode() { public int hashCode() {
return Double.valueOf(constantTerm).hashCode() ^ coefficients.hashCode(); return Double.valueOf(constantTerm).hashCode() ^ coefficients.hashCode();
} }
/** Serialize the instance. /**
* Serialize the instance.
* @param oos stream where object should be written * @param oos stream where object should be written
* @throws IOException if object cannot be written to stream * @throws IOException if object cannot be written to stream
*/ */
@ -133,7 +132,8 @@ public class LinearObjectiveFunction implements Serializable {
MatrixUtils.serializeRealVector(coefficients, oos); MatrixUtils.serializeRealVector(coefficients, oos);
} }
/** Deserialize the instance. /**
* Deserialize the instance.
* @param ois stream from which the object should be read * @param ois stream from which the object should be read
* @throws ClassNotFoundException if a class in the stream cannot be found * @throws ClassNotFoundException if a class in the stream cannot be found
* @throws IOException if object cannot be read from the stream * @throws IOException if object cannot be read from the stream

View File

@ -52,17 +52,20 @@ import org.apache.commons.math3.optimization.PointValuePair;
*/ */
public interface LinearOptimizer { 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 * @param maxIterations maximal number of function calls
*/ */
void setMaxIterations(int maxIterations); 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 * @return maximal number of iterations
*/ */
int getMaxIterations(); int getMaxIterations();
/** Get the number of iterations realized by the algorithm. /**
* Get the number of iterations realized by the algorithm.
* <p> * <p>
* The number of evaluations corresponds to the last call to the * The number of evaluations corresponds to the last call to the
* {@link #optimize(LinearObjectiveFunction, Collection, GoalType, boolean) optimize} * {@link #optimize(LinearObjectiveFunction, Collection, GoalType, boolean) optimize}
@ -72,18 +75,17 @@ public interface LinearOptimizer {
*/ */
int getIterations(); int getIterations();
/** Optimizes an objective function. /**
* Optimizes an objective function.
* @param f linear objective function * @param f linear objective function
* @param constraints linear constraints * @param constraints linear constraints
* @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}
* or {@link GoalType#MINIMIZE}
* @param restrictToNonNegative whether to restrict the variables to non-negative values * @param restrictToNonNegative whether to restrict the variables to non-negative values
* @return point/value pair giving the optimal value for objective function * @return point/value pair giving the optimal value for objective function
* @exception MathIllegalStateException if no solution fulfilling the constraints * @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<LinearConstraint> constraints, PointValuePair optimize(LinearObjectiveFunction f, Collection<LinearConstraint> constraints,
GoalType goalType, boolean restrictToNonNegative) GoalType goalType, boolean restrictToNonNegative) throws MathIllegalStateException;
throws MathIllegalStateException;
} }

View File

@ -21,8 +21,8 @@ import org.apache.commons.math3.exception.MathIllegalStateException;
import org.apache.commons.math3.exception.util.LocalizedFormats; import org.apache.commons.math3.exception.util.LocalizedFormats;
/** /**
* This class represents exceptions thrown by optimizers when no solution * This class represents exceptions thrown by optimizers when no solution fulfills the constraints.
* fulfills the constraints. *
* @version $Id$ * @version $Id$
* @since 2.0 * @since 2.0
*/ */

View File

@ -43,7 +43,6 @@ public enum Relationship {
this.stringValue = stringValue; this.stringValue = stringValue;
} }
/** {@inheritDoc} */
@Override @Override
public String toString() { public String toString() {
return stringValue; return stringValue;

View File

@ -27,6 +27,7 @@ import org.apache.commons.math3.util.Precision;
/** /**
* Solves a linear problem using the Two-Phase Simplex Method. * Solves a linear problem using the Two-Phase Simplex Method.
*
* @version $Id$ * @version $Id$
* @since 2.0 * @since 2.0
*/ */

View File

@ -110,8 +110,7 @@ class SimplexTableau implements Serializable {
* Build a tableau for a linear problem. * Build a tableau for a linear problem.
* @param f linear objective function * @param f linear objective function
* @param constraints linear constraints * @param constraints linear constraints
* @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}
* or {@link GoalType#MINIMIZE}
* @param restrictToNonNegative whether to restrict the variables to non-negative values * @param restrictToNonNegative whether to restrict the variables to non-negative values
* @param epsilon amount of error to accept when checking for optimality * @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. * Build a tableau for a linear problem.
* @param f linear objective function * @param f linear objective function
* @param constraints linear constraints * @param constraints linear constraints
* @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}
* or {@link GoalType#MINIMIZE}
* @param restrictToNonNegative whether to restrict the variables to non-negative values * @param restrictToNonNegative whether to restrict the variables to non-negative values
* @param epsilon amount of error to accept when checking for optimality * @param epsilon amount of error to accept when checking for optimality
* @param maxUlps amount of error to accept in floating point comparisons * @param maxUlps amount of error to accept in floating point comparisons
@ -397,7 +395,6 @@ class SimplexTableau implements Serializable {
/** /**
* Get the current solution. * Get the current solution.
*
* @return current solution * @return current solution
*/ */
protected PointValuePair getSolution() { protected PointValuePair getSolution() {
@ -437,8 +434,8 @@ class SimplexTableau implements Serializable {
* Subtracts a multiple of one row from another. * Subtracts a multiple of one row from another.
* <p> * <p>
* After application of this operation, the following will hold: * After application of this operation, the following will hold:
* minuendRow = minuendRow - multiple * subtrahendRow * <pre>minuendRow = minuendRow - multiple * subtrahendRow</pre>
* </p> *
* @param dividendRow index of the row * @param dividendRow index of the row
* @param divisor value of the divisor * @param divisor value of the divisor
*/ */
@ -452,8 +449,8 @@ class SimplexTableau implements Serializable {
* Subtracts a multiple of one row from another. * Subtracts a multiple of one row from another.
* <p> * <p>
* After application of this operation, the following will hold: * After application of this operation, the following will hold:
* minuendRow = minuendRow - multiple * subtrahendRow * <pre>minuendRow = minuendRow - multiple * subtrahendRow</pre>
* </p> *
* @param minuendRow row index * @param minuendRow row index
* @param subtrahendRow row index * @param subtrahendRow row index
* @param multiple multiplication factor * @param multiple multiplication factor
@ -486,7 +483,8 @@ class SimplexTableau implements Serializable {
return tableau.getRowDimension(); return tableau.getRowDimension();
} }
/** Get an entry of the tableau. /**
* Get an entry of the tableau.
* @param row row index * @param row row index
* @param column column index * @param column column index
* @return entry at (row, column) * @return entry at (row, column)
@ -495,7 +493,8 @@ class SimplexTableau implements Serializable {
return tableau.getEntry(row, column); return tableau.getEntry(row, column);
} }
/** Set an entry of the tableau. /**
* Set an entry of the tableau.
* @param row row index * @param row row index
* @param column column index * @param column column index
* @param value for the entry * @param value for the entry
@ -532,10 +531,9 @@ class SimplexTableau implements Serializable {
/** /**
* Get the number of decision variables. * Get the number of decision variables.
* <p> * <p>
* If variables are not restricted to positive values, this will include 1 * If variables are not restricted to positive values, this will include 1 extra decision variable to represent
* extra decision variable to represent the absolute value of the most * the absolute value of the most negative variable.
* negative variable. *
* </p>
* @return number of decision variables * @return number of decision variables
* @see #getOriginalNumDecisionVariables() * @see #getOriginalNumDecisionVariables()
*/ */
@ -576,7 +574,6 @@ class SimplexTableau implements Serializable {
return tableau.getData(); return tableau.getData();
} }
/** {@inheritDoc} */
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
@ -599,7 +596,6 @@ class SimplexTableau implements Serializable {
return false; return false;
} }
/** {@inheritDoc} */
@Override @Override
public int hashCode() { public int hashCode() {
return Boolean.valueOf(restrictToNonNegative).hashCode() ^ return Boolean.valueOf(restrictToNonNegative).hashCode() ^
@ -613,7 +609,8 @@ class SimplexTableau implements Serializable {
tableau.hashCode(); tableau.hashCode();
} }
/** Serialize the instance. /**
* Serialize the instance.
* @param oos stream where object should be written * @param oos stream where object should be written
* @throws IOException if object cannot be written to stream * @throws IOException if object cannot be written to stream
*/ */
@ -623,7 +620,8 @@ class SimplexTableau implements Serializable {
MatrixUtils.serializeRealMatrix(tableau, oos); MatrixUtils.serializeRealMatrix(tableau, oos);
} }
/** Deserialize the instance. /**
* Deserialize the instance.
* @param ois stream from which the object should be read * @param ois stream from which the object should be read
* @throws ClassNotFoundException if a class in the stream cannot be found * @throws ClassNotFoundException if a class in the stream cannot be found
* @throws IOException if object cannot be read from the stream * @throws IOException if object cannot be read from the stream

View File

@ -21,8 +21,8 @@ import org.apache.commons.math3.exception.MathIllegalStateException;
import org.apache.commons.math3.exception.util.LocalizedFormats; import org.apache.commons.math3.exception.util.LocalizedFormats;
/** /**
* This class represents exceptions thrown by optimizers when a solution * This class represents exceptions thrown by optimizers when a solution escapes to infinity.
* escapes to infinity. *
* @version $Id$ * @version $Id$
* @since 2.0 * @since 2.0
*/ */