Changeset 430bd7f7e9 in tspsg for src/tspsolver.h
- Timestamp:
- Jul 31, 2009, 8:23:07 PM (15 years ago)
- Branches:
- 0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
- Children:
- ec54b4490b
- Parents:
- b5c9bcb585
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tspsolver.h
rb5c9bcb585 r430bd7f7e9 1 1 /* 2 * TSPSG -TSP Solver and Generator2 * TSPSG: TSP Solver and Generator 3 3 * Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name> 4 4 * … … 27 27 #include "globals.h" 28 28 29 typedef QList< double *> tMatrix;29 typedef QList<QList<double>> tMatrix; 30 30 31 31 // This structure represents one step of solving 32 32 // The tree of such elements will represent the solving process 33 33 struct sStep { 34 tMatrix matrix; 35 double price; 36 struct {unsigned int x; unsigned int y;} pos; 37 sStep *plNode, *prNode; 38 sStep() { price = pos.x = pos.y = 0; plNode = prNode = NULL; } 34 tMatrix matrix; // Steps's matrix 35 double price; // Price of travel to this step 36 struct {unsigned int nRow; unsigned int nCol;} candidate; // Candiadate for branching in current matrix 37 bool alts; // This matrix has alternative candidates 38 sStep *plNode, *prNode; // Pointers to left and right branch steps 39 sStep() { price = candidate.nRow = candidate.nCol = -1; alts = false; plNode = prNode = NULL; } // Default values 39 40 }; 40 41 … … 42 43 class CTSPSolver 43 44 { 45 Q_DECLARE_TR_FUNCTIONS(CTSPSolver) 46 44 47 public: 45 48 CTSPSolver(); 46 sStep *solve(int, tMatrix); 49 sStep *solve(int, tMatrix, QWidget *parent = 0); 50 47 51 private: 48 52 int nCities; 49 53 sStep *root; 50 double findMinInRow(int, tMatrix); 51 double findMinInCol(int, tMatrix); 54 QHash<int,int> route; 55 QHash<int,int> forbidden; 56 double align(tMatrix &); 57 void cleanup(); 58 bool findCandidate(tMatrix, int &, int &, double &); 59 double findMinInRow(int, tMatrix, int exc = -1); 60 double findMinInCol(int, tMatrix, int exr = -1); 61 bool hasSubCycles(int, int); 62 void subCol(tMatrix &, int, double); 63 void subRow(tMatrix &, int, double); 52 64 }; 53 65
Note: See TracChangeset
for help on using the changeset viewer.