Exemple #1
0
 public TabuSearch(AdjacencyMatrix matrix, int iterations, int timeOfLife)
 {
     _matrix        = matrix;
     _maxIterations = iterations;
     verticles      = _matrix.fMatrix.GetLength(0);
     tabuMap        = new TabuMap(timeOfLife, verticles);
     costs          = new List <float>();
 }
        public DynamicTSP(AdjacencyMatrix givenMatrix, int startingNode)
        {
            costMatrix   = givenMatrix;
            vertexNumber = costMatrix.matrix.GetLength(0);
            int nSquare = (int)Math.Pow(2, vertexNumber);

            memo              = new double[vertexNumber, nSquare];
            END_STATE         = (1 << vertexNumber) - 1; //binary end state
            this.startingNode = startingNode;
        }
Exemple #3
0
        public override void SetVariables(AdjacencyMatrix matrix)
        {
            cost = Int32.MaxValue;;

            bestpath    = new List <int>();
            this.matrix = matrix;
            size        = matrix.matrix.GetLength(0);
            finalPath   = new int[size + 1];
            visited     = new bool[size];
        }
        public override void SetVariables(AdjacencyMatrix givenMatrix)
        {
            costMatrix   = givenMatrix;
            vertexNumber = costMatrix.matrix.GetLength(0);
            int nSquare = (int)Math.Pow(2, vertexNumber);

            memo        = new double[vertexNumber, nSquare];
            END_STATE   = (1 << vertexNumber) - 1; //binary end state
            tour        = new List <int>();
            minTourCost = Double.PositiveInfinity;
        }
        static void testfunction()
        {
            int verticles = 15;

            _matrix = new AdjacencyMatrix(verticles);
            timeCounter   timemaster = new timeCounter(100);
            DynamicTSP    tester     = new DynamicTSP(_matrix, 0);
            TspBruteForce brute      = new TspBruteForce(_matrix);

            timemaster.measureSolver(tester, verticles);
            timemaster.measureSolver(brute, verticles);
        }
        public double measureSolver(TspSolver tsp, int verticles)
        {
            for (int i = 0; i < measureTab.Length; i++)
            {
                AdjacencyMatrix newMatrix = new AdjacencyMatrix(verticles);
                newMatrix.GenerateRandomMatrix();
                tsp.SetVariables(newMatrix);
                Stopwatch watch = new Stopwatch();
                watch.Start();
                tsp.Solve();
                watch.Stop();
                Console.WriteLine(watch.Elapsed);

                measureTab[i] = watch.Elapsed;
            }
            //  showMeasures();
            return(countEndValue());
        }
 public abstract void SetVariables(AdjacencyMatrix matrix);
Exemple #8
0
 public override void SetVariables(AdjacencyMatrix matrix)
 {
     throw new NotImplementedException();
 }
Exemple #9
0
 public SimulatedAnnealing(AdjacencyMatrix matrix)
 {
     costMatrix = matrix;
     verticles  = matrix.fMatrix.GetLength(0);
     random     = new Random();
 }
 private static void CreateTestMatrix(int verticles)
 {
     _matrix = new AdjacencyMatrix(verticles);
     _matrix.setTestMatrix();
     _matrix.print();
 }
 private static void CreateMatrix(int verticles)
 {
     _matrix = new AdjacencyMatrix(verticles);
     _matrix.GenerateRandomMatrix();
     _matrix.print();
 }
 public static void MatrixGenerator(int verticles)
 {
     _matrix = new AdjacencyMatrix(verticles);
     _matrix.GenerateRandomMatrix();
 }
 public static void CreateMatrixFromFile(string fileName)
 {
     _matrix = new AdjacencyMatrix(fileName);
 }
        internal static void CreateMatrixFromXMLFile(string fileName)
        {
            XDocument doc = XDocument.Load(fileName);

            _matrix = new AdjacencyMatrix(doc);
        }
 public override void SetVariables(AdjacencyMatrix matrix)
 {
     adMatrix = matrix;
 }
 public TspBruteForce(AdjacencyMatrix matrix)
 {
     adMatrix     = matrix;
     smallestCost = Int32.MaxValue;
 }