This class solves Travelling Salesman Problem task. More...
#include <tspsolver.h>
Public Slots | |
void | cancel () |
Cancels the solution process. | |
Signals | |
void | routePartFound (int n) |
This signal is emitted once every time a part of the route is found. | |
Public Member Functions | |
CTSPSolver (QObject *parent=NULL) | |
Constructs CTSPSolver object. | |
void | cleanup (bool processEvents=false) |
Cleans up the object and frees up memory used by the solution tree. | |
QString | getSortedPath () const |
Returns the sorted optimal path, starting from City 1. | |
bool | isOptimal () const |
Indicates whether or not the solution is definitely optimal. | |
SStep * | solve (int numCities, const TMatrix &task) |
Solves the given task. | |
bool | wasCanceled () const |
Indicates whether or not the solution process was canceled. | |
Static Public Member Functions | |
static QString | getVersionId () |
Returns CTSPSolver's version ID. |
This class solves Travelling Salesman Problem task.
CTSPSolver::CTSPSolver | ( | QObject * | parent = NULL |
) |
Constructs CTSPSolver object.
parent | A parent object. |
void CTSPSolver::cleanup | ( | bool | processEvents = false |
) |
Cleans up the object and frees up memory used by the solution tree.
processEvents | If set to true then QApplication::processEvents(QEventLoop::ExcludeUserInputEvents) will be called from time to time while cleaning up. |
QString CTSPSolver::getSortedPath | ( | ) | const |
Returns the sorted optimal path, starting from City 1.
QString CTSPSolver::getVersionId | ( | ) | [static] |
Returns CTSPSolver's version ID.
bool CTSPSolver::isOptimal | ( | ) | const |
Indicates whether or not the solution is definitely optimal.
true
if the solution is definitely optimal, otherwise false
.The solution may need some further iterations to determine whether or not it is optimal. In such cases this function returns false
.
void CTSPSolver::routePartFound | ( | int | n | ) | [signal] |
This signal is emitted once every time a part of the route is found.
n | Indicates the number of the route parts found. |
Solves the given task.
numCities | Number of cities in the task. | |
task | The matrix of city-to-city travel costs. |
bool CTSPSolver::wasCanceled | ( | ) | const |
Indicates whether or not the solution process was canceled.
true
if the solution process was canceled, otherwise false
.