Changeset 9eb63a1598 in tspsg for src/tspsolver.h


Ignore:
Timestamp:
Dec 20, 2010, 9:53:45 PM (13 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
Children:
b8a2a118c4
Parents:
b59e2ea0b1
git-author:
Oleksii Serdiuk <contacts@…> (12/20/10 21:53:45)
git-committer:
Oleksii Serdiuk <contacts@…> (06/29/12 19:45:58)
Message:

Converted file formatting to have spaces instead of tabs. No code changes...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tspsolver.h

    rb59e2ea0b1 r9eb63a1598  
    4040 */
    4141#ifdef INFINITY
    42         #undef INFINITY
     42#   undef INFINITY
    4343#endif
    4444#define INFINITY std::numeric_limits<double>::infinity()
     
    6060 */
    6161struct SStep {
    62         //! A structure that represents a candidate for branching
    63         struct SCandidate {
    64                 int nRow; //!< A zero-based row number of the candidate
    65                 int nCol; //!< A zero-based column number of the candidate
     62    //! A structure that represents a candidate for branching
     63    struct SCandidate {
     64        int nRow; //!< A zero-based row number of the candidate
     65        int nCol; //!< A zero-based column number of the candidate
    6666
    67                 //! Assigns default values
    68                 SCandidate() {
    69                         nCol = nRow = -1;
    70                 }
    71                 //! An operator == implementation
    72                 bool operator ==(const SCandidate &cand) const {
    73                         return ((cand.nRow == nRow) && (cand.nCol == nCol));
    74                 }
    75         };
     67        //! Assigns default values
     68        SCandidate() {
     69            nCol = nRow = -1;
     70        }
     71        //! An operator == implementation
     72        bool operator ==(const SCandidate &cand) const {
     73            return ((cand.nRow == nRow) && (cand.nCol == nCol));
     74        }
     75    };
    7676
    77         //! An enum that describes possible selection of the next step
    78         enum NextStep {
    79                 NoNextStep, //!< No next step (end of solution)
    80                 LeftBranch, //!< Left branch was selected for the next step
    81                 RightBranch //!< Right branch was selected for the next step
    82         };
     77    //! An enum that describes possible selection of the next step
     78    enum NextStep {
     79        NoNextStep, //!< No next step (end of solution)
     80        LeftBranch, //!< Left branch was selected for the next step
     81        RightBranch //!< Right branch was selected for the next step
     82    };
    8383
    84         TMatrix matrix; //!< This step's matrix
    85         double price; //!< The price of travel to this step
     84    TMatrix matrix; //!< This step's matrix
     85    double price; //!< The price of travel to this step
    8686
    87         SCandidate candidate; //!< A candiadate for branching in the current step
    88         QList<SCandidate> alts; //!< A list of alternative branching candidates
    89         SStep *pNode; //!< Pointer to the parent step
    90         SStep *plNode; //!< Pointer to the left branch step
    91         SStep *prNode; //!< Pointer to the right branch step
    92         NextStep next; //!< Indicates what branch was selected for the next step
     87    SCandidate candidate; //!< A candiadate for branching in the current step
     88    QList<SCandidate> alts; //!< A list of alternative branching candidates
     89    SStep *pNode; //!< Pointer to the parent step
     90    SStep *plNode; //!< Pointer to the left branch step
     91    SStep *prNode; //!< Pointer to the right branch step
     92    NextStep next; //!< Indicates what branch was selected for the next step
    9393
    94         //! Assigns default values
    95         SStep() {
    96                 price = -1;
    97                 pNode = plNode = prNode = NULL;
    98                 next = NoNextStep;
    99         }
     94    //! Assigns default values
     95    SStep() {
     96        price = -1;
     97        pNode = plNode = prNode = NULL;
     98        next = NoNextStep;
     99    }
    100100};
    101101
     
    106106class CTSPSolver: public QObject
    107107{
    108         Q_OBJECT
     108    Q_OBJECT
    109109
    110110public:
    111         static QString getVersionId();
     111    static QString getVersionId();
    112112
    113         CTSPSolver(QObject *parent = NULL);
    114         void cleanup(bool processEvents = false);
    115         QString getSortedPath(const QString &city, const QString &separator = QString(" -> ")) const;
    116         int getTotalSteps() const;
    117         bool isOptimal() const;
    118         void setCleanupOnCancel(bool enable = true);
    119         SStep *solve(int numCities, const TMatrix &task);
    120         bool wasCanceled() const;
    121         ~CTSPSolver();
     113    CTSPSolver(QObject *parent = NULL);
     114    void cleanup(bool processEvents = false);
     115    QString getSortedPath(const QString &city, const QString &separator = QString(" -> ")) const;
     116    int getTotalSteps() const;
     117    bool isOptimal() const;
     118    void setCleanupOnCancel(bool enable = true);
     119    SStep *solve(int numCities, const TMatrix &task);
     120    bool wasCanceled() const;
     121    ~CTSPSolver();
    122122
    123123public slots:
    124         void cancel();
     124    void cancel();
    125125
    126126signals:
    127         /*!
    128         * \brief This signal is emitted once every time a part of the route is found.
    129         * \param n Indicates the number of the route parts found.
    130         */
    131         void routePartFound(int n);
     127    /*!
     128    * \brief This signal is emitted once every time a part of the route is found.
     129    * \param n Indicates the number of the route parts found.
     130    */
     131    void routePartFound(int n);
    132132
    133133private:
    134         bool mayNotBeOptimal, canceled, cc;
    135         int nCities, total;
    136         SStep *root;
    137         QHash<int,int> route;
    138         mutable QMutex mutex;
     134    bool mayNotBeOptimal, canceled, cc;
     135    int nCities, total;
     136    SStep *root;
     137    QHash<int,int> route;
     138    mutable QMutex mutex;
    139139
    140         double align(TMatrix &matrix);
    141         void deleteTree(SStep *&root, bool processEvents = false);
    142         void denormalize(TMatrix &matrix) const;
    143         QList<SStep::SCandidate> findCandidate(const TMatrix &matrix, int &nRow, int &nCol) const;
    144         double findMinInCol(int nCol, const TMatrix &matrix, int exr = -1) const;
    145         double findMinInRow(int nRow, const TMatrix &matrix, int exc = -1) const;
    146         void finishRoute();
    147         bool hasSubCycles(int nRow, int nCol) const;
    148         void normalize(TMatrix &matrix) const;
    149         void subCol(TMatrix &matrix, int nCol, double val);
    150         void subRow(TMatrix &matrix, int nRow, double val);
     140    double align(TMatrix &matrix);
     141    void deleteTree(SStep *&root, bool processEvents = false);
     142    void denormalize(TMatrix &matrix) const;
     143    QList<SStep::SCandidate> findCandidate(const TMatrix &matrix, int &nRow, int &nCol) const;
     144    double findMinInCol(int nCol, const TMatrix &matrix, int exr = -1) const;
     145    double findMinInRow(int nRow, const TMatrix &matrix, int exc = -1) const;
     146    void finishRoute();
     147    bool hasSubCycles(int nRow, int nCol) const;
     148    void normalize(TMatrix &matrix) const;
     149    void subCol(TMatrix &matrix, int nCol, double val);
     150    void subRow(TMatrix &matrix, int nRow, double val);
    151151};
    152152
Note: See TracChangeset for help on using the changeset viewer.