You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2012/03/03 02:52:07 UTC

svn commit: r1296553 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/linear: AbstractLinearOptimizer.java SimplexSolver.java

Author: erans
Date: Sat Mar  3 01:52:06 2012
New Revision: 1296553

URL: http://svn.apache.org/viewvc?rev=1296553&view=rev
Log:
Variable visibility: "protected" -> "private". Added getter methods.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/linear/AbstractLinearOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/linear/SimplexSolver.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/linear/AbstractLinearOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/linear/AbstractLinearOptimizer.java?rev=1296553&r1=1296552&r2=1296553&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/linear/AbstractLinearOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/linear/AbstractLinearOptimizer.java Sat Mar  3 01:52:06 2012
@@ -18,6 +18,7 @@
 package org.apache.commons.math3.optimization.linear;
 
 import java.util.Collection;
+import java.util.Collections;
 
 import org.apache.commons.math3.exception.MathIllegalStateException;
 import org.apache.commons.math3.exception.MaxCountExceededException;
@@ -41,25 +42,25 @@ public abstract class AbstractLinearOpti
      * Linear objective function.
      * @since 2.1
      */
-    protected LinearObjectiveFunction function;
+    private LinearObjectiveFunction function;
 
     /**
      * Linear constraints.
      * @since 2.1
      */
-    protected Collection<LinearConstraint> linearConstraints;
+    private Collection<LinearConstraint> linearConstraints;
 
     /**
      * Type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}.
      * @since 2.1
      */
-    protected GoalType goal;
+    private GoalType goal;
 
     /**
      * Whether to restrict the variables to non-negative values.
      * @since 2.1
      */
-    protected boolean nonNegative;
+    private boolean nonNegative;
 
     /** Maximal number of iterations allowed. */
     private int maxIterations;
@@ -74,6 +75,34 @@ public abstract class AbstractLinearOpti
         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} */
     public void setMaxIterations(int maxIterations) {
         this.maxIterations = maxIterations;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/linear/SimplexSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/linear/SimplexSolver.java?rev=1296553&r1=1296552&r2=1296553&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/linear/SimplexSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/linear/SimplexSolver.java Sat Mar  3 01:52:06 2012
@@ -185,8 +185,12 @@ public class SimplexSolver extends Abstr
     public PointValuePair doOptimize()
         throws MaxCountExceededException, UnboundedSolutionException, NoFeasibleSolutionException {
         final SimplexTableau tableau =
-            new SimplexTableau(function, linearConstraints, goal, nonNegative,
-                               epsilon, maxUlps);
+            new SimplexTableau(getFunction(),
+                               getConstraints(),
+                               getGoalType(),
+                               restrictToNonNegative(),
+                               epsilon,
+                               maxUlps);
 
         solvePhase1(tableau);
         tableau.dropPhase1Objective();