/*! \internal Does one iteration towards a better solution for the problem. See 'solveMaxHelper'. */ bool QSimplex::iterate() { // Find Pivot column int pivotColumn = findPivotColumn(); if (pivotColumn == -1) return false; // Find Pivot row for column int pivotRow = pivotRowForColumn(pivotColumn); if (pivotRow == -1) { qWarning() << "QSimplex: Unbounded problem!"; return false; } // Normalize Pivot Row qreal pivot = valueAt(pivotRow, pivotColumn); if (pivot != 1.0) combineRows(pivotRow, pivotRow, (qreal(1.0) - pivot) / pivot); // Update other rows for (int row=0; row < rows; ++row) { if (row == pivotRow) continue; combineRows(row, pivotRow, -1 * valueAt(row, pivotColumn)); } // Update first column setValueAt(pivotRow, 0, pivotColumn); // dumpMatrix(); // qDebug("------------ end of iteration --------------\n"); return true; }
Eigen::VectorXf Simplex::run() { int piv_col, piv_row; while(1){ piv_col = findPivotColumn(); //std::cout << " CHOIX PIVOT " << std::endl; //std::cout << " simplexe run piv_col : "<< piv_col << std::endl; if(piv_col < 0) { //std::cout<< " STOP " << std::endl; getBest(); // optimal return best; } piv_row = findPivotRow(piv_col); //std::cout << " simplexe run piv_row : " << piv_row << std::endl; if(piv_row < 0) { //std::cout << " Pas de solution" << std::endl; break; //caca } //std::cout << " val pivot : " << tab(piv_row,piv_col); //std::cout << " " << std::endl; pivot(piv_row, piv_col); //std::cout << tab << std::endl; } return best; }