Changeset e664262f7d in tspsg for src/tspsolver.cpp
- Timestamp:
- Oct 21, 2007, 3:07:21 PM (17 years ago)
- Branches:
- 0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
- Children:
- 2f915f19f2
- Parents:
- 67e53c96d7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tspsolver.cpp
r67e53c96d7 re664262f7d 24 24 #include "tspsolver.h" 25 25 26 // Temoporary matrix for testing algorithm27 double testmatrix[] = {28 infinity, 6, 7, 3, 4,29 9, infinity, 6, 9, 10,30 6, 9, infinity, 5, 3,31 3, 10, 4, infinity, 2,32 5, 1, 1, 9, infinity33 };34 35 36 26 CTSPSolver::CTSPSolver() 37 27 { 38 28 } 39 29 40 sStep *CTSPSolver::solve(int numCities, double *task) 30 double CTSPSolver::findMinInRow(int nRow, tMatrix matrix) 31 { 32 double min = infinity; 33 for (int k = 0; k < nCities; k++) 34 if (min > matrix[nRow][k]) 35 min = matrix[nRow][k]; 36 return min == infinity ? 0 : min; 37 } 38 39 double CTSPSolver::findMinInCol(int nCol, tMatrix matrix) 40 { 41 double min = infinity; 42 for (int k = 0; k < nCities; k++) 43 if (min > matrix[k][nCol]) 44 min = matrix[k][nCol]; 45 return min == infinity ? 0 : min; 46 } 47 48 sStep *CTSPSolver::solve(int numCities, tMatrix task) 41 49 { 42 50 if (numCities <= 1) 43 51 return NULL; 44 // Temporary debug code :-) 45 task = &testmatrix[0]; 46 numCities = 5; 47 //*/ 48 sStep step; 49 step.matrix = new double(numCities * numCities); 50 memcpy(step.matrix,task,sizeof(double) * numCities * numCities); 52 nCities = numCities; 53 sStep *step = new sStep(); 54 step->matrix = task; 55 root = step; 51 56 52 return NULL;57 return step; 53 58 } 54 59
Note: See TracChangeset
for help on using the changeset viewer.