diff --git a/src/main/java/org/apache/commons/math3/optim/linear/SimplexTableau.java b/src/main/java/org/apache/commons/math3/optim/linear/SimplexTableau.java index 06ab424c9..e80c9c411 100644 --- a/src/main/java/org/apache/commons/math3/optim/linear/SimplexTableau.java +++ b/src/main/java/org/apache/commons/math3/optim/linear/SimplexTableau.java @@ -447,7 +447,7 @@ class SimplexTableau implements Serializable { Integer negativeVarBasicRow = negativeVarColumn > 0 ? getBasicRow(negativeVarColumn) : null; double mostNegative = negativeVarBasicRow == null ? 0 : getEntry(negativeVarBasicRow, getRhsOffset()); - final Set basicRows = new HashSet(); + final Set usedBasicRows = new HashSet(); final double[] coefficients = new double[getOriginalNumDecisionVariables()]; for (int i = 0; i < coefficients.length; i++) { int colIndex = columnLabels.indexOf("x" + i); @@ -461,12 +461,12 @@ class SimplexTableau implements Serializable { // set the coefficient to 0 -> this case handles unconstrained // variables that are still part of the objective function coefficients[i] = 0; - } else if (basicRows.contains(basicRow)) { + } else if (usedBasicRows.contains(basicRow)) { // if multiple variables can take a given value // then we choose the first and set the rest equal to 0 coefficients[i] = 0 - (restrictToNonNegative ? 0 : mostNegative); } else { - basicRows.add(basicRow); + usedBasicRows.add(basicRow); coefficients[i] = (basicRow == null ? 0 : getEntry(basicRow, getRhsOffset())) - (restrictToNonNegative ? 0 : mostNegative);