Changeset 394216e468 in tspsg for src/tspsolver.h


Ignore:
Timestamp:
Mar 22, 2010, 9:45:16 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:
1babbd6ba3
Parents:
e2abfd326f
Message:
  • Fixed a bug when a solution couldn't be found for some tasks while the task had at least one solution (mostly, tasks with a lot of restrictions).
  • Fixed a bug when Save As dialog always appeared (even for non-Untitled files) when selecting Save in Unsaved Changes dialog.
  • Improved the solution algorithm.
  • Moved progress dialog from CTSPSolver to MainWindow?. CTSPSolver doesn't contain any GUI related code now.

+ Added routePartFound() signal to CTSPSolver which is emitted once every time a part of the route is found.
+ Added cancel() slot and wasCanceled() public function to CTSPSolver to be able to cancel a solution process and to know whether it was canceled.
+ Progress is now shown when generating a solution output.
+ Check for updates functionality (only in Windows version at this moment).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tspsolver.h

    re2abfd326f r394216e468  
    7878 * \author Copyright &copy; 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    7979 */
    80 class CTSPSolver
     80class CTSPSolver: public QObject
    8181{
    82         Q_DECLARE_TR_FUNCTIONS(CTSPSolver)
     82        Q_OBJECT
    8383
    8484public:
    85         CTSPSolver();
     85        static QString getVersionId();
     86
     87        CTSPSolver(QObject *parent = NULL);
     88        void cleanup(bool processEvents = false);
    8689        QString getSortedPath() const;
    87         static QString getVersionId();
    8890        bool isOptimal() const;
    89         SStep *solve(int numCities, TMatrix task, QWidget *parent = 0);
     91        SStep *solve(int numCities, const TMatrix &task);
     92        bool wasCanceled() const;
    9093        ~CTSPSolver();
    9194
     95public slots:
     96        void cancel();
     97
     98signals:
     99        /*!
     100         * \brief This signal is emitted once every time a part of the route is found.
     101         * \param n Indicates the number of the route parts found.
     102         */
     103        void routePartFound(int n);
     104
    92105private:
    93         bool mayNotBeOptimal;
     106        bool mayNotBeOptimal, canceled;
    94107        int nCities;
    95108        SStep *root;
    96109        QHash<int,int> route;
    97 //      QHash<int,int> forbidden;
     110        mutable QMutex mutex;
    98111
    99112        double align(TMatrix &matrix);
    100         void cleanup();
    101         void deleteTree(SStep *&root);
     113        void deleteTree(SStep *&root, bool processEvents = false);
     114        void denormalize(TMatrix &matrix) const;
    102115        QList<SCandidate> findCandidate(const TMatrix &matrix, int &nRow, int &nCol) const;
    103116        double findMinInCol(int nCol, const TMatrix &matrix, int exr = -1) const;
    104117        double findMinInRow(int nRow, const TMatrix &matrix, int exc = -1) const;
    105118        bool hasSubCycles(int nRow, int nCol) const;
     119        void normalize(TMatrix &matrix) const;
    106120        void subCol(TMatrix &matrix, int nCol, double val);
    107121        void subRow(TMatrix &matrix, int nRow, double val);
     
    110124#ifdef DEBUG
    111125QDebug operator<<(QDebug dbg, const TMatrix &matrix);
    112 #endif
     126QDebug operator<<(QDebug dbg, const SCandidate &candidate);
     127#endif // DEBUG
    113128
    114129#endif // TSPSOLVER_H
Note: See TracChangeset for help on using the changeset viewer.