Changeset 87 in tspsg-svn for trunk/src/tspsolver.cpp
- Timestamp:
- Jan 12, 2010, 3:11:24 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tspsolver.cpp
r79 r87 1 1 /* 2 2 * TSPSG: TSP Solver and Generator 3 * Copyright (C) 2007-20 09Lёppa <contacts[at]oleksii[dot]name>3 * Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name> 4 4 * 5 5 * $Id$ … … 40 40 41 41 int i = 0; // We start from City 1 42 QString path = tr Utf8("City %1").arg(1) + " -> ";42 QString path = tr("City %1").arg(1) + " -> "; 43 43 while ((i = route[i]) != 0) { 44 path += tr Utf8("City %1").arg(i + 1) + " -> ";44 path += tr("City %1").arg(i + 1) + " -> "; 45 45 } 46 46 // And finish in City 1, too 47 path += tr Utf8("City %1").arg(1);47 path += tr("City %1").arg(1); 48 48 49 49 return path; … … 89 89 QProgressBar *pb = new QProgressBar(&pd); 90 90 pb->setAlignment(Qt::AlignCenter); 91 pb->setFormat(tr Utf8("%v of %m parts found"));91 pb->setFormat(tr("%v of %m parts found")); 92 92 pd.setBar(pb); 93 93 pd.setMaximum(nCities); 94 94 pd.setMinimumDuration(1000); 95 pd.setLabelText(tr Utf8("Calculating optimal route..."));96 pd.setWindowTitle(tr Utf8("Solution Progress"));95 pd.setLabelText(tr("Calculating optimal route...")); 96 pd.setWindowTitle(tr("Solution Progress")); 97 97 pd.setWindowModality(Qt::ApplicationModal); 98 98 pd.setValue(0); … … 106 106 int nRow, nCol; 107 107 bool firstStep = true; 108 doublecheck;108 qreal check; 109 109 while (this->route.size() < nCities) { 110 110 // forbidden.clear(); … … 168 168 if (!root && !pd.wasCanceled()) { 169 169 pd.reset(); 170 QMessageBox(QMessageBox::Warning,tr Utf8("Solution Result"),trUtf8("Unable to find solution.\nMaybe, this task has no solutions."),QMessageBox::Ok,parent).exec();170 QMessageBox(QMessageBox::Warning,tr("Solution Result"),tr("Unable to find solution.\nMaybe, this task has no solutions."),QMessageBox::Ok,parent).exec(); 171 171 } 172 172 … … 188 188 /* Privates **********************************************************/ 189 189 190 doubleCTSPSolver::align(TMatrix &matrix)191 { 192 doubler = 0;193 doublemin;190 qreal CTSPSolver::align(TMatrix &matrix) 191 { 192 qreal r = 0; 193 qreal min; 194 194 for (int k = 0; k < nCities; k++) { 195 195 min = findMinInRow(k,matrix); … … 240 240 QList<SCandidate> alts; 241 241 SCandidate cand; 242 doubleh = -1;243 doublesum;242 qreal h = -1; 243 qreal sum; 244 244 for (int r = 0; r < nCities; r++) 245 245 for (int c = 0; c < nCities; c++) … … 261 261 } 262 262 263 doubleCTSPSolver::findMinInCol(int nCol, const TMatrix &matrix, int exr) const264 { 265 doublemin = INFINITY;263 qreal CTSPSolver::findMinInCol(int nCol, const TMatrix &matrix, int exr) const 264 { 265 qreal min = INFINITY; 266 266 for (int k = 0; k < nCities; k++) 267 267 if ((k != exr) && (min > matrix.at(k).at(nCol))) … … 270 270 } 271 271 272 doubleCTSPSolver::findMinInRow(int nRow, const TMatrix &matrix, int exc) const273 { 274 doublemin = INFINITY;272 qreal CTSPSolver::findMinInRow(int nRow, const TMatrix &matrix, int exc) const 273 { 274 qreal min = INFINITY; 275 275 for (int k = 0; k < nCities; k++) 276 276 if (((k != exc)) && (min > matrix.at(nRow).at(k))) … … 293 293 } 294 294 295 void CTSPSolver::subCol(TMatrix &matrix, int nCol, doubleval)295 void CTSPSolver::subCol(TMatrix &matrix, int nCol, qreal val) 296 296 { 297 297 for (int k = 0; k < nCities; k++) … … 300 300 } 301 301 302 void CTSPSolver::subRow(TMatrix &matrix, int nRow, doubleval)302 void CTSPSolver::subRow(TMatrix &matrix, int nRow, qreal val) 303 303 { 304 304 for (int k = 0; k < nCities; k++)
Note: See TracChangeset
for help on using the changeset viewer.