Esempio n. 1
0
 public void Start(string inputFile, string outputFile, int timeLimit)
 {
     TSPInstance instance = new TSPInstance(inputFile);
     DiscreteSS ss = new DiscreteSS2OptBest4TSP(instance, poolSize, refSetSize, explorationFactor);
     ss.Run(timeLimit - timePenalty);
     TSPSolution solution = new TSPSolution(instance, ss.BestSolution);
     solution.Write(outputFile);
 }
Esempio n. 2
0
 public void Start(string fileInput, string fileOutput, int timeLimit)
 {
     TSPInstance instance = new TSPInstance(fileInput);
     int[] assignment = TSPUtils.GreedySolution(instance);
     TSPUtils.LocalSearch2OptFirst(instance, assignment);
     TSPSolution solution = new TSPSolution(instance, assignment);
     solution.Write(fileOutput);
 }
 public void Start(string inputFile, string outputFile, int timeLimit)
 {
     TSPInstance instance = new TSPInstance(inputFile);
     int levelLength = (int) Math.Ceiling(levelLengthFactor * (instance.NumberCities * (instance.NumberCities - 1)));
     DiscreteHMSAwGRASP2OptBest4TSP hm = new DiscreteHMSAwGRASP2OptBest4TSP(instance, rclTreshold, graspIterations, initialSolutions, levelLength, tempReduction);
     hm.Run(timeLimit - timePenalty);
     TSPSolution solution = new TSPSolution(instance, hm.BestSolution);
     solution.Write(outputFile);
 }
Esempio n. 4
0
 public void Start(string fileInput, string fileOutput, int timeLimit)
 {
     TSPInstance instance = new TSPInstance(fileInput);
     int levelLength = (int) Math.Ceiling(levelLengthFactor * (instance.NumberCities * (instance.NumberCities - 1)));
     DiscreteSA sa = new DiscreteSA4TSP(instance, initialSolutions, levelLength, tempReduction);
     sa.Run(timeLimit - timePenalty);
     TSPSolution solution = new TSPSolution(instance, sa.BestSolution);
     solution.Write(fileOutput);
 }
Esempio n. 5
0
 public void Start(string inputFile, string outputFile, int timeLimit)
 {
     TSPInstance instance = new TSPInstance(inputFile);
     MaxMinAntSystem aco = new MaxMinAntSystem2OptBest4TSP(instance, numberAnts, rho, alpha, beta, maxReinit, candidateLength, candidateWeight);
     // Solving the problem and writing the best solution found.
     aco.Run(timeLimit - timePenalty);
     TSPSolution solution = new TSPSolution(instance, aco.BestSolution);
     solution.Write(outputFile);
 }
Esempio n. 6
0
 public void Start(string inputFile, string outputFile, int timeLimit)
 {
     TSPInstance instance = new TSPInstance(inputFile);
     int neighborChecks = (int) Math.Ceiling(neighborChecksFactor * (instance.NumberCities * (instance.NumberCities - 1)));
     int tabuListLength = (int) Math.Ceiling(tabuListFactor * instance.NumberCities);
     DiscreteTS ts = new DiscreteTS4TSP(instance, rclTreshold, tabuListLength, neighborChecks);
     ts.Run(timeLimit - timePenalty);
     TSPSolution solution = new TSPSolution(instance, ts.BestSolution);
     solution.Write(outputFile);
 }
Esempio n. 7
0
        public void Start(string inputFile, string outputFile, int timeLimit)
        {
            TSPInstance instance = new TSPInstance(inputFile);
            DiscreteSS  ss       = new DiscreteSS4TSP(instance, poolSize, refSetSize, explorationFactor);

            ss.Run(timeLimit - timePenalty);
            TSPSolution solution = new TSPSolution(instance, ss.BestSolution);

            solution.Write(outputFile);
        }
Esempio n. 8
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TSPInstance instance = new TSPInstance(fileInput);

            int[] assignment = TSPUtils.GreedySolution(instance);
            TSPUtils.LocalSearch2OptFirst(instance, assignment);
            TSPSolution solution = new TSPSolution(instance, assignment);

            solution.Write(fileOutput);
        }
        public void Start(string inputFile, string outputFile, int timeLimit)
        {
            TSPInstance instance               = new TSPInstance(inputFile);
            int         levelLength            = (int)Math.Ceiling(levelLengthFactor * (instance.NumberCities * (instance.NumberCities - 1)));
            DiscreteHMSAwGRASP2OptFirst4TSP hm = new DiscreteHMSAwGRASP2OptFirst4TSP(instance, rclTreshold, graspIterations, initialSolutions, levelLength, tempReduction);

            hm.Run(timeLimit - timePenalty);
            TSPSolution solution = new TSPSolution(instance, hm.BestSolution);

            solution.Write(outputFile);
        }
Esempio n. 10
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TSPInstance instance    = new TSPInstance(fileInput);
            int         levelLength = (int)Math.Ceiling(levelLengthFactor * (instance.NumberCities * (instance.NumberCities - 1)));
            DiscreteSA  sa          = new DiscreteSA4TSP(instance, initialSolutions, levelLength, tempReduction);

            sa.Run(timeLimit - timePenalty);
            TSPSolution solution = new TSPSolution(instance, sa.BestSolution);

            solution.Write(fileOutput);
        }
Esempio n. 11
0
        public void Start(string inputFile, string outputFile, int timeLimit)
        {
            TSPInstance     instance = new TSPInstance(inputFile);
            MaxMinAntSystem aco      = new MaxMinAntSystem2OptBest4TSP(instance, numberAnts, rho, alpha, beta, maxReinit, candidateLength, candidateWeight);

            // Solving the problem and writing the best solution found.
            aco.Run(timeLimit - timePenalty);
            TSPSolution solution = new TSPSolution(instance, aco.BestSolution);

            solution.Write(outputFile);
        }
Esempio n. 12
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TSPInstance instance = new TSPInstance(fileInput);

            // Setting the parameters of the GRASP for this instance of the problem.
            DiscreteGRASP grasp = new DiscreteGRASP2OptBest4TSP(instance, rclThreshold);

            // Solving the problem and writing the best solution found.
            grasp.Run(timeLimit - (int)timePenalty, RunType.TimeLimit);
            TSPSolution solution = new TSPSolution(instance, grasp.BestSolution);
            solution.Write(fileOutput);
        }
Esempio n. 13
0
        public void Start(string inputFile, string outputFile, int timeLimit)
        {
            TSPInstance instance       = new TSPInstance(inputFile);
            int         neighborChecks = (int)Math.Ceiling(neighborChecksFactor * (instance.NumberCities * (instance.NumberCities - 1)));
            int         tabuListLength = (int)Math.Ceiling(tabuListFactor * instance.NumberCities);
            DiscreteTS  ts             = new DiscreteTS4TSP(instance, rclTreshold, tabuListLength, neighborChecks);

            ts.Run(timeLimit - timePenalty);
            TSPSolution solution = new TSPSolution(instance, ts.BestSolution);

            solution.Write(outputFile);
        }
Esempio n. 14
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TSPInstance instance = new TSPInstance(fileInput);

            // Setting the parameters of the GRASP for this instance of the problem.
            DiscreteGRASP grasp = new DiscreteGRASP2OptFirst4TSP(instance, rclThreshold);

            // Solving the problem and writing the best solution found.
            grasp.Run(timeLimit - (int)timePenalty, RunType.TimeLimit);
            TSPSolution solution = new TSPSolution(instance, grasp.BestSolution);

            solution.Write(fileOutput);
        }
Esempio n. 15
0
 public void Start(string inputFile, string outputFile, int timeLimit)
 {
     TSPInstance instance = new TSPInstance(inputFile);
     int[] lowerBounds = new int[instance.NumberCities];
     int[] upperBounds = new int[instance.NumberCities];
     for (int i = 0; i < instance.NumberCities; i++) {
         lowerBounds[i] = 0;
         upperBounds[i] = instance.NumberCities - 1;
     }
     DiscreteILS ils = new DiscreteILS2OptFirst4TSP(instance, restartIterations, lowerBounds, upperBounds);
     ils.Run(timeLimit - timePenalty);
     TSPSolution solution = new TSPSolution(instance, ils.BestSolution);
     solution.Write(outputFile);
 }
Esempio n. 16
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TSPInstance instance = new TSPInstance(fileInput);

            // Setting the parameters of the PSO for this instance of the problem.
            int[] lowerBounds = new int[instance.NumberCities];
            int[] upperBounds = new int[instance.NumberCities];
            for (int i = 0; i < instance.NumberCities; i++) {
                lowerBounds[i] = 0;
                upperBounds[i] = instance.NumberCities - 1;
            }
            DiscretePSO pso = new DiscretePSO4TSP(instance, (int)particlesCount, prevConf, neighConf, lowerBounds, upperBounds);

            // Solving the problem and writing the best solution found.
            pso.Run(timeLimit - (int)timePenalty);
            TSPSolution solution = new TSPSolution(instance, pso.BestPosition);
            solution.Write(fileOutput);
        }
Esempio n. 17
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TSPInstance instance = new TSPInstance(fileInput);

            // Setting the parameters of the MA for this instance of the problem.
            int[] lowerBounds = new int[instance.NumberCities];
            int[] upperBounds = new int[instance.NumberCities];
            for (int i = 0; i < instance.NumberCities; i++) {
                lowerBounds[i] = 0;
                upperBounds[i] = instance.NumberCities - 1;
            }
            DiscreteMA memetic = new DiscreteMA4TSP(instance, (int)popSize, mutProbability, lowerBounds, upperBounds);

            // Solving the problem and writing the best solution found.
            memetic.Run(timeLimit - (int)timePenalty);
            TSPSolution solution = new TSPSolution(instance, memetic.BestIndividual);
            solution.Write(fileOutput);
        }
        public void Start(string inputFile, string outputFile, int timeLimit)
        {
            TSPInstance instance = new TSPInstance(inputFile);

            int[] lowerBounds = new int[instance.NumberCities];
            int[] upperBounds = new int[instance.NumberCities];
            for (int i = 0; i < instance.NumberCities; i++)
            {
                lowerBounds[i] = 0;
                upperBounds[i] = instance.NumberCities - 1;
            }
            DiscreteILS ils = new DiscreteILS2OptBest4TSP(instance, restartIterations, lowerBounds, upperBounds);

            ils.Run(timeLimit - timePenalty);
            TSPSolution solution = new TSPSolution(instance, ils.BestSolution);

            solution.Write(outputFile);
        }
Esempio n. 19
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TSPInstance instance = new TSPInstance(fileInput);

            // Setting the parameters of the UMDA for this instance of the problem.
            int popSize = (int) Math.Ceiling(popFactor * instance.NumberCities);
            int[] lowerBounds = new int[instance.NumberCities];
            int[] upperBounds = new int[instance.NumberCities];
            for (int i = 0; i < instance.NumberCities; i++) {
                lowerBounds[i] = 0;
                upperBounds[i] = instance.NumberCities - 1;
            }
            DiscreteUMDA umda = new DiscreteUMDA2OptFirst4TSP(instance, popSize, truncFactor, lowerBounds, upperBounds);

            // Solving the problem and writing the best solution found.
            umda.Run(timeLimit - (int)timePenalty);
            TSPSolution solution = new TSPSolution(instance, umda.BestIndividual);
            solution.Write(fileOutput);
        }
Esempio n. 20
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TSPInstance instance = new TSPInstance(fileInput);

            // Setting the parameters of the GA for this instance of the problem.
            int[] lowerBounds = new int[instance.NumberCities];
            int[] upperBounds = new int[instance.NumberCities];
            for (int i = 0; i < instance.NumberCities; i++)
            {
                lowerBounds[i] = 0;
                upperBounds[i] = instance.NumberCities - 1;
            }
            DiscreteGA genetic = new DiscreteGA2OptFirst4TSP(instance, (int)popSize, mutProbability, lowerBounds, upperBounds);

            // Solving the problem and writing the best solution found.
            genetic.Run(timeLimit - (int)timePenalty);
            TSPSolution solution = new TSPSolution(instance, genetic.BestIndividual);

            solution.Write(fileOutput);
        }
Esempio n. 21
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TSPInstance instance = new TSPInstance(fileInput);

            // Setting the parameters of the PSO for this instance of the problem.
            int[] lowerBounds = new int[instance.NumberCities];
            int[] upperBounds = new int[instance.NumberCities];
            for (int i = 0; i < instance.NumberCities; i++)
            {
                lowerBounds[i] = 0;
                upperBounds[i] = instance.NumberCities - 1;
            }
            DiscretePSO pso = new DiscretePSO2OptFirst4TSP(instance, (int)particlesCount, prevConf, neighConf, lowerBounds, upperBounds);

            // Solving the problem and writing the best solution found.
            pso.Run(timeLimit - (int)timePenalty);
            TSPSolution solution = new TSPSolution(instance, pso.BestPosition);

            solution.Write(fileOutput);
        }
Esempio n. 22
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TSPInstance instance = new TSPInstance(fileInput);

            // Setting the parameters of the UMDA for this instance of the problem.
            int popSize = (int)Math.Ceiling(popFactor * instance.NumberCities);

            int[] lowerBounds = new int[instance.NumberCities];
            int[] upperBounds = new int[instance.NumberCities];
            for (int i = 0; i < instance.NumberCities; i++)
            {
                lowerBounds[i] = 0;
                upperBounds[i] = instance.NumberCities - 1;
            }
            DiscreteUMDA umda = new DiscreteUMDA2OptBest4TSP(instance, popSize, truncFactor, lowerBounds, upperBounds);

            // Solving the problem and writing the best solution found.
            umda.Run(timeLimit - timePenalty);
            TSPSolution solution = new TSPSolution(instance, umda.BestIndividual);

            solution.Write(fileOutput);
        }