/* 120: */ /* 121: */ public PointValuePair doOptimize() /* 122: */ throws MaxCountExceededException, UnboundedSolutionException, NoFeasibleSolutionException /* 123: */ { /* 124:187 */ SimplexTableau tableau = new SimplexTableau( getFunction(), getConstraints(), getGoalType(), restrictToNonNegative(), this.epsilon, this.maxUlps); /* 125: */ /* 126: */ /* 127: */ /* 128: */ /* 129: */ /* 130: */ /* 131: */ /* 132:195 */ solvePhase1(tableau); /* 133:196 */ tableau.dropPhase1Objective(); /* 134:198 */ while (!tableau.isOptimal()) { /* 135:199 */ doIteration(tableau); /* 136: */ } /* 137:201 */ return tableau.getSolution(); /* 138: */ }
/* 106: */ /* 107: */ protected void solvePhase1(SimplexTableau tableau) /* 108: */ throws MaxCountExceededException, UnboundedSolutionException, NoFeasibleSolutionException /* 109: */ { /* 110:169 */ if (tableau.getNumArtificialVariables() == 0) { /* 111:170 */ return; /* 112: */ } /* 113:173 */ while (!tableau.isOptimal()) { /* 114:174 */ doIteration(tableau); /* 115: */ } /* 116:178 */ if (!Precision.equals( tableau.getEntry(0, tableau.getRhsOffset()), 0.0D, this.epsilon)) { /* 117:179 */ throw new NoFeasibleSolutionException(); /* 118: */ } /* 119: */ }
/** * Solves Phase 1 of the Simplex method. * * @param tableau Simple tableau for the problem. * @throws TooManyIterationsException if the allowed number of iterations has been exhausted. * @throws UnboundedSolutionException if the model is found not to have a bounded solution. * @throws NoFeasibleSolutionException if there is no feasible solution? */ protected void solvePhase1(final SimplexTableau tableau) throws TooManyIterationsException, UnboundedSolutionException, NoFeasibleSolutionException { // make sure we're in Phase 1 if (tableau.getNumArtificialVariables() == 0) { return; } while (!tableau.isOptimal()) { doIteration(tableau); } // if W is not zero then we have no feasible solution if (!Precision.equals(tableau.getEntry(0, tableau.getRhsOffset()), 0d, epsilon)) { throw new NoFeasibleSolutionException(); } }
/** {@inheritDoc} */ @Override public PointValuePair doOptimize() throws MaxCountExceededException, UnboundedSolutionException, NoFeasibleSolutionException { final SimplexTableau tableau = new SimplexTableau( getFunction(), getConstraints(), getGoalType(), restrictToNonNegative(), epsilon, maxUlps); solvePhase1(tableau); tableau.dropPhase1Objective(); while (!tableau.isOptimal()) { doIteration(tableau); } return tableau.getSolution(); }