Changeset 430bd7f7e9 in tspsg for src/tspsolver.h


Ignore:
Timestamp:
Jul 31, 2009, 8:23:07 PM (15 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
Children:
ec54b4490b
Parents:
b5c9bcb585
Message:

+ Finished solving algorithm (needs thorough testing).
+ Solution can be saved to HTML or OpenDocument? format.
+ Added VERSIONINFO resource for windows builds.

  • Updated translations to have unified terminology everywhere.

NB: This will be the first public alpha build.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tspsolver.h

    rb5c9bcb585 r430bd7f7e9  
    11/*
    2  *  TSPSG - TSP Solver and Generator
     2 *  TSPSG: TSP Solver and Generator
    33 *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
    44 *
     
    2727#include "globals.h"
    2828
    29 typedef QList<double *> tMatrix;
     29typedef QList<QList<double>> tMatrix;
    3030
    3131// This structure represents one step of solving
    3232// The tree of such elements will represent the solving process
    3333struct 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
    3940};
    4041
     
    4243class CTSPSolver
    4344{
     45        Q_DECLARE_TR_FUNCTIONS(CTSPSolver)
     46
    4447public:
    4548        CTSPSolver();
    46         sStep *solve(int, tMatrix);
     49        sStep *solve(int, tMatrix, QWidget *parent = 0);
     50
    4751private:
    4852        int nCities;
    4953        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);
    5264};
    5365
Note: See TracChangeset for help on using the changeset viewer.