Variable visibility: "protected" -> "private". Added getter methods.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1296553 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f8efb929f4
commit
d27bfd83d6
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.commons.math3.optimization.linear;
|
package org.apache.commons.math3.optimization.linear;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
import org.apache.commons.math3.exception.MathIllegalStateException;
|
import org.apache.commons.math3.exception.MathIllegalStateException;
|
||||||
import org.apache.commons.math3.exception.MaxCountExceededException;
|
import org.apache.commons.math3.exception.MaxCountExceededException;
|
||||||
|
@ -41,25 +42,25 @@ public abstract class AbstractLinearOptimizer implements LinearOptimizer {
|
||||||
* Linear objective function.
|
* Linear objective function.
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
protected LinearObjectiveFunction function;
|
private LinearObjectiveFunction function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Linear constraints.
|
* Linear constraints.
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
protected Collection<LinearConstraint> linearConstraints;
|
private Collection<LinearConstraint> linearConstraints;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}.
|
* Type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}.
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
protected GoalType goal;
|
private GoalType goal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to restrict the variables to non-negative values.
|
* Whether to restrict the variables to non-negative values.
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
protected boolean nonNegative;
|
private boolean nonNegative;
|
||||||
|
|
||||||
/** Maximal number of iterations allowed. */
|
/** Maximal number of iterations allowed. */
|
||||||
private int maxIterations;
|
private int maxIterations;
|
||||||
|
@ -74,6 +75,34 @@ public abstract class AbstractLinearOptimizer implements LinearOptimizer {
|
||||||
setMaxIterations(DEFAULT_MAX_ITERATIONS);
|
setMaxIterations(DEFAULT_MAX_ITERATIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@code true} if the variables are restricted to non-negative values.
|
||||||
|
*/
|
||||||
|
protected boolean restrictToNonNegative() {
|
||||||
|
return nonNegative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the optimization type.
|
||||||
|
*/
|
||||||
|
protected GoalType getGoalType() {
|
||||||
|
return goal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the optimization type.
|
||||||
|
*/
|
||||||
|
protected LinearObjectiveFunction getFunction() {
|
||||||
|
return function;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the optimization type.
|
||||||
|
*/
|
||||||
|
protected Collection<LinearConstraint> getConstraints() {
|
||||||
|
return Collections.unmodifiableCollection(linearConstraints);
|
||||||
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void setMaxIterations(int maxIterations) {
|
public void setMaxIterations(int maxIterations) {
|
||||||
this.maxIterations = maxIterations;
|
this.maxIterations = maxIterations;
|
||||||
|
|
|
@ -185,8 +185,12 @@ public class SimplexSolver extends AbstractLinearOptimizer {
|
||||||
public PointValuePair doOptimize()
|
public PointValuePair doOptimize()
|
||||||
throws MaxCountExceededException, UnboundedSolutionException, NoFeasibleSolutionException {
|
throws MaxCountExceededException, UnboundedSolutionException, NoFeasibleSolutionException {
|
||||||
final SimplexTableau tableau =
|
final SimplexTableau tableau =
|
||||||
new SimplexTableau(function, linearConstraints, goal, nonNegative,
|
new SimplexTableau(getFunction(),
|
||||||
epsilon, maxUlps);
|
getConstraints(),
|
||||||
|
getGoalType(),
|
||||||
|
restrictToNonNegative(),
|
||||||
|
epsilon,
|
||||||
|
maxUlps);
|
||||||
|
|
||||||
solvePhase1(tableau);
|
solvePhase1(tableau);
|
||||||
tableau.dropPhase1Objective();
|
tableau.dropPhase1Objective();
|
||||||
|
|
Loading…
Reference in New Issue