int main(int argc, char ** argv) { printf ("c Pseudoflow algorithm for parametric min cut (version 1.0)\n"); readDimacsFileCreateList (); #ifdef PROGRESS printf ("c Finished reading file.\n"); fflush (stdout); #endif simpleInitialization (); #ifdef PROGRESS printf ("c Finished initialization.\n"); fflush (stdout); #endif pseudoflowPhase1 (); #ifdef PROGRESS printf ("c Finished phase 1.\n"); fflush (stdout); #endif #ifdef RECOVER_FLOW recoverFlow(); checkOptimality (); #endif printf ("c Number of nodes : %d\n", numNodes); printf ("c Number of arcs : %d\n", numArcs); #ifdef STATS printf ("c Number of arc scans : %lld\n", numArcScans); printf ("c Number of mergers : %d\n", numMergers); printf ("c Number of pushes : %lld\n", numPushes); printf ("c Number of relabels : %d\n", numRelabels); printf ("c Number of gaps : %d\n", numGaps); #endif #ifdef BREAKPOINTS displayBreakpoints (); #endif freeMemory (); return 0; }
void Simplex::findSolution() { //search solution bool flag = true; //whether to continue the search and rebuild matrix bool step = true; //which step search (find first solution) / (optimal solution) bool solution = false;//whether the solution point mainElem = { 0, 0 }; while (flag) { if (step)//find first solution { mainElem = checkAdmissibility();// element against which the matrix rebuild if (!mainElem.K) step = false; //checking whether a given matrix is a solution and move to the next step if it's true else if (!mainElem.L)//check whether there is a solution at all { cout << "there is no solution\n"; flag = false; } } if (!step) { mainElem = checkOptimality();//tunable element against which the matrix if (matrix[0][mainElem.L]>-0.0001) //checking whether a given matrix is the best solution and the search is completed if it's true { flag = false; solution = true; } else if (matrix[mainElem.K][mainElem.L]<-0.0001)//many solutions { cout << "function unlimited\n"; flag = false; } } if (flag) ñhangeTheRules(mainElem);//whether to rebuild a matrix } if (solution) //if there is a solution to bring it { for (int i = 1; i < M; i++) if (basicx[i]) cout << "x" << basicx[i] << "=" << matrix[i][N - 1] << " "; cout << "\nother variables = 0\n"; cout << "funcion = " << matrix[0][N - 1] << endl; } }