Changeset 1757eb594b in tspsg for src/tspsolver.cpp


Ignore:
Timestamp:
Jan 12, 2010, 3:11:24 PM (14 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
Children:
fcd8c1e4c1
Parents:
64f288c0f8
Message:

+ Added Fractional accuracy (in decimail places) to settings.
+ Created defaults.h file. Moved all default defines there.

  • Replaced all double types with qreal.
  • Replaced all calls to trUtf8() with tr() as we use setCodecForTr() to set UTF-8 encoding as default and tr() is enough.
  • Replaced all 2009 with 2010 in copyrights.
  • Fixed an error when loading .zkt file with less than 5 cities.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tspsolver.cpp

    r64f288c0f8 r1757eb594b  
    11/*
    22 *  TSPSG: TSP Solver and Generator
    3  *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 *  Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
     
    4040
    4141int i = 0; // We start from City 1
    42 QString path = trUtf8("City %1").arg(1) + " -> ";
     42QString path = tr("City %1").arg(1) + " -> ";
    4343        while ((i = route[i]) != 0) {
    44                 path += trUtf8("City %1").arg(i + 1) + " -> ";
     44                path += tr("City %1").arg(i + 1) + " -> ";
    4545        }
    4646        // And finish in City 1, too
    47         path += trUtf8("City %1").arg(1);
     47        path += tr("City %1").arg(1);
    4848
    4949        return path;
     
    8989QProgressBar *pb = new QProgressBar(&pd);
    9090        pb->setAlignment(Qt::AlignCenter);
    91         pb->setFormat(trUtf8("%v of %m parts found"));
     91        pb->setFormat(tr("%v of %m parts found"));
    9292        pd.setBar(pb);
    9393        pd.setMaximum(nCities);
    9494        pd.setMinimumDuration(1000);
    95         pd.setLabelText(trUtf8("Calculating optimal route..."));
    96         pd.setWindowTitle(trUtf8("Solution Progress"));
     95        pd.setLabelText(tr("Calculating optimal route..."));
     96        pd.setWindowTitle(tr("Solution Progress"));
    9797        pd.setWindowModality(Qt::ApplicationModal);
    9898        pd.setValue(0);
     
    106106int nRow, nCol;
    107107bool firstStep = true;
    108 double check;
     108qreal check;
    109109        while (this->route.size() < nCities) {
    110110//              forbidden.clear();
     
    168168        if (!root && !pd.wasCanceled()) {
    169169                pd.reset();
    170                 QMessageBox(QMessageBox::Warning,trUtf8("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();
    171171        }
    172172
     
    188188/* Privates **********************************************************/
    189189
    190 double CTSPSolver::align(TMatrix &matrix)
    191 {
    192 double r = 0;
    193 double min;
     190qreal CTSPSolver::align(TMatrix &matrix)
     191{
     192qreal r = 0;
     193qreal min;
    194194        for (int k = 0; k < nCities; k++) {
    195195                min = findMinInRow(k,matrix);
     
    240240QList<SCandidate> alts;
    241241SCandidate cand;
    242 double h = -1;
    243 double sum;
     242qreal h = -1;
     243qreal sum;
    244244        for (int r = 0; r < nCities; r++)
    245245                for (int c = 0; c < nCities; c++)
     
    261261}
    262262
    263 double CTSPSolver::findMinInCol(int nCol, const TMatrix &matrix, int exr) const
    264 {
    265 double min = INFINITY;
     263qreal CTSPSolver::findMinInCol(int nCol, const TMatrix &matrix, int exr) const
     264{
     265qreal min = INFINITY;
    266266        for (int k = 0; k < nCities; k++)
    267267                if ((k != exr) && (min > matrix.at(k).at(nCol)))
     
    270270}
    271271
    272 double CTSPSolver::findMinInRow(int nRow, const TMatrix &matrix, int exc) const
    273 {
    274 double min = INFINITY;
     272qreal CTSPSolver::findMinInRow(int nRow, const TMatrix &matrix, int exc) const
     273{
     274qreal min = INFINITY;
    275275        for (int k = 0; k < nCities; k++)
    276276                if (((k != exc)) && (min > matrix.at(nRow).at(k)))
     
    293293}
    294294
    295 void CTSPSolver::subCol(TMatrix &matrix, int nCol, double val)
     295void CTSPSolver::subCol(TMatrix &matrix, int nCol, qreal val)
    296296{
    297297        for (int k = 0; k < nCities; k++)
     
    300300}
    301301
    302 void CTSPSolver::subRow(TMatrix &matrix, int nRow, double val)
     302void CTSPSolver::subRow(TMatrix &matrix, int nRow, qreal val)
    303303{
    304304        for (int k = 0; k < nCities; k++)
Note: See TracChangeset for help on using the changeset viewer.