Пример #1
0
 /*  85:    */
 /*  86:    */ protected void doIteration(SimplexTableau tableau)
     /*  87:    */ throws MaxCountExceededException, UnboundedSolutionException
       /*  88:    */ {
   /*  89:137 */ incrementIterationsCounter();
   /*  90:    */
   /*  91:139 */ Integer pivotCol = getPivotColumn(tableau);
   /*  92:140 */ Integer pivotRow = getPivotRow(tableau, pivotCol.intValue());
   /*  93:141 */ if (pivotRow == null) {
     /*  94:142 */ throw new UnboundedSolutionException();
     /*  95:    */ }
   /*  96:146 */ double pivotVal = tableau.getEntry(pivotRow.intValue(), pivotCol.intValue());
   /*  97:147 */ tableau.divideRow(pivotRow.intValue(), pivotVal);
   /*  98:150 */ for (int i = 0; i < tableau.getHeight(); i++) {
     /*  99:151 */ if (i != pivotRow.intValue())
     /* 100:    */ {
       /* 101:152 */ double multiplier = tableau.getEntry(i, pivotCol.intValue());
       /* 102:153 */ tableau.subtractRow(i, pivotRow.intValue(), multiplier);
       /* 103:    */ }
     /* 104:    */ }
   /* 105:    */ }
Пример #2
0
  /**
   * Runs one iteration of the Simplex method on the given model.
   *
   * @param tableau simple tableau for the problem
   * @throws OptimizationException if the maximal iteration count has been exceeded or if the model
   *     is found not to have a bounded solution
   */
  protected void doIteration(final SimplexTableau tableau) throws OptimizationException {

    incrementIterationsCounter();

    Integer pivotCol = getPivotColumn(tableau);
    Integer pivotRow = getPivotRow(pivotCol, tableau);
    if (pivotRow == null) {
      throw new UnboundedSolutionException();
    }

    // set the pivot element to 1
    double pivotVal = tableau.getEntry(pivotRow, pivotCol);
    tableau.divideRow(pivotRow, pivotVal);

    // set the rest of the pivot column to 0
    for (int i = 0; i < tableau.getHeight(); i++) {
      if (i != pivotRow) {
        double multiplier = tableau.getEntry(i, pivotCol);
        tableau.subtractRow(i, pivotRow, multiplier);
      }
    }
  }