CTSPSolver Class Reference

This class solves Travelling Salesman Problem task. More...

#include <tspsolver.h>

Inheritance diagram for CTSPSolver:
Inheritance graph
[legend]
Collaboration diagram for CTSPSolver:
Collaboration graph
[legend]

List of all members.

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.
SStepsolve (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.

Detailed Description

This class solves Travelling Salesman Problem task.

Author:
Copyright © 2007-2010 Lёppa <contacts[at]oleksii[dot]name>

Constructor & Destructor Documentation

CTSPSolver::CTSPSolver ( QObject parent = NULL  ) 

Constructs CTSPSolver object.

Parameters:
parent A parent object.

Member Function Documentation

void CTSPSolver::cleanup ( bool  processEvents = false  ) 

Cleans up the object and frees up memory used by the solution tree.

Parameters:
processEvents If set to true then QApplication::processEvents(QEventLoop::ExcludeUserInputEvents) will be called from time to time while cleaning up.
Warning:
After call to this function a solution tree returned by the solve() function is no longer valid.
Note:
It is not required to call this function manually. This function is always called by solve() at the beginning of the solution process.
See also:
solve()

Here is the call graph for this function:

Here is the caller graph for this function:

QString CTSPSolver::getSortedPath (  )  const

Returns the sorted optimal path, starting from City 1.

Returns:
A string, containing sorted optimal path.

Here is the call graph for this function:

QString CTSPSolver::getVersionId (  )  [static]

Returns CTSPSolver's version ID.

Returns:
A string: $Id: tspsolver.cpp 99 2010-03-22 20:45:16Z laleppa $.
bool CTSPSolver::isOptimal (  )  const

Indicates whether or not the solution is definitely optimal.

Returns:
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.

Parameters:
n Indicates the number of the route parts found.

Here is the caller graph for this function:

SStep * CTSPSolver::solve ( int  numCities,
const TMatrix task 
)

Solves the given task.

Parameters:
numCities Number of cities in the task.
task The matrix of city-to-city travel costs.
Returns:
Pointer to the root of the solution tree.
Todo:
TODO: Comment the algorithm.

Here is the call graph for this function:

bool CTSPSolver::wasCanceled (  )  const

Indicates whether or not the solution process was canceled.

Returns:
true if the solution process was canceled, otherwise false.

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Defines

Generated on Fri Apr 9 00:25:38 2010 for TSPSG: TSP Solver and Generator by  doxygen 1.6.1