TSPSolver::CTSPSolver Class Reference

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

#include <tspsolver.h>

Inheritance diagram for TSPSolver::CTSPSolver:
Inheritance graph
[legend]
Collaboration diagram for TSPSolver::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 QString &city, const QString &separator=" -> ") const
 Returns the sorted optimal path, starting from City 1.
int getTotalSteps () const
 Returns a total number of steps in the current solution.
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

TSPSolver::CTSPSolver::CTSPSolver ( QObject parent = NULL  ) 

Constructs CTSPSolver object.

Parameters:
parent A parent object.

Member Function Documentation

void TSPSolver::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 QCoreApplication::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 TSPSolver::CTSPSolver::getSortedPath ( const QString city,
const QString separator = " -> " 
) const

Returns the sorted optimal path, starting from City 1.

Parameters:
city A string that represents city elements in the path.
separator A string that represents separators between cities in the path.
Returns:
A string, containing sorted optimal path.

The resulting path will be in the form city+separator+city+...+separator+city. %1 in city will be replaced by the city number.

Here is the call graph for this function:

int TSPSolver::CTSPSolver::getTotalSteps (  )  const

Returns a total number of steps in the current solution.

Returns:
A total number of steps or 0 if no solution.
Note:
This is not always the same as the number of cities.
QString TSPSolver::CTSPSolver::getVersionId (  )  [static]

Returns CTSPSolver's version ID.

Returns:
A string: $Id: tspsolver.cpp 110 2010-04-27 23:38:10Z laleppa $.
bool TSPSolver::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 TSPSolver::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 * TSPSolver::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 TSPSolver::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 Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on Wed Apr 28 02:47:21 2010 for TSPSG: TSP Solver and Generator by  doxygen 1.6.1