commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r807929 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
Date Wed, 26 Aug 2009 08:54:43 GMT
Author: luc
Date: Wed Aug 26 08:54:42 2009
New Revision: 807929

URL: http://svn.apache.org/viewvc?rev=807929&view=rev
Log:
fixed weird spacing as per last patch from Ben

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java?rev=807929&r1=807928&r2=807929&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
Wed Aug 26 08:54:42 2009
@@ -136,50 +136,51 @@
         matrix[zIndex][zIndex] = maximize ? 1 : -1;
         RealVector objectiveCoefficients =
             maximize ? f.getCoefficients().mapMultiply(-1) : f.getCoefficients();
-            copyArray(objectiveCoefficients.getData(), matrix[zIndex], getNumObjectiveFunctions());
-            matrix[zIndex][width - 1] =
-                maximize ? f.getConstantTerm() : -1 * f.getConstantTerm();
-
-                if (!restrictToNonNegative) {
-                    matrix[zIndex][getSlackVariableOffset() - 1] =
-                        getInvertedCoeffiecientSum(objectiveCoefficients);
-                }
-
-                // initialize the constraint rows
-                int slackVar = 0;
-                int artificialVar = 0;
-                for (int i = 0; i < constraints.size(); i++) {
-                    LinearConstraint constraint = constraints.get(i);
-                    int row = getNumObjectiveFunctions() + i;
-
-                    // decision variable coefficients
-                    copyArray(constraint.getCoefficients().getData(), matrix[row], 1);
-
-                    // x-
-                    if (!restrictToNonNegative) {
-                        matrix[row][getSlackVariableOffset() - 1] =
-                            getInvertedCoeffiecientSum(constraint.getCoefficients());
-                    }
-
-                    // RHS
-                    matrix[row][width - 1] = constraint.getValue();
-
-                    // slack variables
-                    if (constraint.getRelationship() == Relationship.LEQ) {
-                        matrix[row][getSlackVariableOffset() + slackVar++] = 1;  // slack
-                    } else if (constraint.getRelationship() == Relationship.GEQ) {
-                        matrix[row][getSlackVariableOffset() + slackVar++] = -1; // excess
-                    }
-
-                    // artificial variables
-                    if ((constraint.getRelationship() == Relationship.EQ) ||
-                        (constraint.getRelationship() == Relationship.GEQ)) {
-                        matrix[0][getArtificialVariableOffset() + artificialVar] = 1; 
-                        matrix[row][getArtificialVariableOffset() + artificialVar++] = 1;

-                    }
-                }
+        copyArray(objectiveCoefficients.getData(), matrix[zIndex], getNumObjectiveFunctions());
+        matrix[zIndex][width - 1] =
+            maximize ? f.getConstantTerm() : -1 * f.getConstantTerm();
+
+        if (!restrictToNonNegative) {
+            matrix[zIndex][getSlackVariableOffset() - 1] =
+                getInvertedCoeffiecientSum(objectiveCoefficients);
+        }
+
+        // initialize the constraint rows
+        int slackVar = 0;
+        int artificialVar = 0;
+        for (int i = 0; i < constraints.size(); i++) {
+            LinearConstraint constraint = constraints.get(i);
+            int row = getNumObjectiveFunctions() + i;
+
+            // decision variable coefficients
+            copyArray(constraint.getCoefficients().getData(), matrix[row], 1);
+
+            // x-
+            if (!restrictToNonNegative) {
+                matrix[row][getSlackVariableOffset() - 1] =
+                    getInvertedCoeffiecientSum(constraint.getCoefficients());
+            }
+
+            // RHS
+            matrix[row][width - 1] = constraint.getValue();
+
+            // slack variables
+            if (constraint.getRelationship() == Relationship.LEQ) {
+                matrix[row][getSlackVariableOffset() + slackVar++] = 1;  // slack
+            } else if (constraint.getRelationship() == Relationship.GEQ) {
+                matrix[row][getSlackVariableOffset() + slackVar++] = -1; // excess
+            }
+
+            // artificial variables
+            if ((constraint.getRelationship() == Relationship.EQ) ||
+                    (constraint.getRelationship() == Relationship.GEQ)) {
+                matrix[0][getArtificialVariableOffset() + artificialVar] = 1; 
+                matrix[row][getArtificialVariableOffset() + artificialVar++] = 1; 
+            }
+        }
+
+        return matrix;
 
-                return matrix;
     }
 
     /** Get the number of variables.



Mime
View raw message