SimplexTableau implements Serializable { protected void dropPhase1Objective() { if (getNumObjectiveFunctions() == 1) { return; } Set<Integer> columnsToDrop = new TreeSet<Integer>(); columnsToDrop.add(0); for (int i = getNumObjectiveFunctions(); i < getArtificialVariableOffset(); i++) { final double entry = tableau.getEntry(0, i); if (Precision.compareTo(entry, 0d, epsilon) > 0) { columnsToDrop.add(i); } } for (int i = 0; i < getNumArtificialVariables(); i++) { int col = i + getArtificialVariableOffset(); if (getBasicRow(col) == null) { columnsToDrop.add(col); } } double[][] matrix = new double[getHeight() - 1][getWidth() - columnsToDrop.size()]; for (int i = 1; i < getHeight(); i++) { int col = 0; for (int j = 0; j < getWidth(); j++) { if (!columnsToDrop.contains(j)) { matrix[i - 1][col++] = tableau.getEntry(i, j); } } } Integer[] drop = columnsToDrop.toArray(new Integer[columnsToDrop.size()]); for (int i = drop.length - 1; i >= 0; i--) { columnLabels.remove((int) drop[i]); } this.tableau = new Array2DRowRealMatrix(matrix); this.numArtificialVariables = 0; } SimplexTableau(final LinearObjectiveFunction f,
                   final Collection<LinearConstraint> constraints,
                   final GoalType goalType, final boolean restrictToNonNegative,
                   final double epsilon);   SimplexTableau(final LinearObjectiveFunction f,
                   final Collection<LinearConstraint> constraints,
                   final GoalType goalType, final boolean restrictToNonNegative,
                   final double epsilon,
                   final int maxUlps); List<LinearConstraint> normalizeConstraints(Collection<LinearConstraint> originalConstraints); @Override boolean equals(Object other); @Override int hashCode();  }
@Test public void testDropPhase1Objective() { LinearObjectiveFunction f = createFunction(); Collection<LinearConstraint> constraints = createConstraints(); SimplexTableau tableau = new SimplexTableau(f, constraints, GoalType.MAXIMIZE, false, 1.0e-6); double[][] expectedTableau = { { 1, -15, -10, 0, 0, 0, 0}, { 0, 1, 0, 1, 0, 0, 2}, { 0, 0, 1, 0, 1, 0, 3}, { 0, 1, 1, 0, 0, 1, 4} }; tableau.dropPhase1Objective(); assertMatrixEquals(expectedTableau, tableau.getData()); }