public MaxMinAntSystemNPS42SP(TwoSPInstance instance, int numberAnts,
                               double rho, double alpha, double beta,
                               int maxReinit)
     : base(instance.NumberItems,
            TwoSPUtils.Fitness(instance, TwoSPUtils.NPSCoordinates(instance, TwoSPUtils.RandomSolution(instance))),
            numberAnts, rho, alpha, beta, maxReinit)
 {
     Instance = instance;
 }
예제 #2
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TwoSPInstance instance = new TwoSPInstance(fileInput);

            int[] ordering = TwoSPUtils.DecreasingArea(instance);
            int[,] coordinates = TwoSPUtils.NPSCoordinates(instance, ordering);
            TwoSPSolution solution = new TwoSPSolution(instance, coordinates);

            solution.Write(fileOutput);
        }
예제 #3
0
        public void Start(string inputFile, string outputFile, int timeLimit)
        {
            TwoSPInstance instance = new TwoSPInstance(inputFile);
            DiscreteSS    ss       = new DiscreteSSNPS42SP(instance, poolSize, refSetSize, explorationFactor);

            ss.Run(timeLimit - timePenalty);
            int[,] coordinates = TwoSPUtils.NPSCoordinates(instance, ss.BestSolution);
            TwoSPSolution solution = new TwoSPSolution(instance, coordinates);

            solution.Write(outputFile);
        }
예제 #4
0
        public void Start(string inputFile, string outputFile, int timeLimit)
        {
            TwoSPInstance   instance = new TwoSPInstance(inputFile);
            MaxMinAntSystem aco      = new MaxMinAntSystemNPS42SP(instance, numberAnts, rho, alpha, beta, maxReinit);

            // Solving the problem and writing the best solution found.
            aco.Run(timeLimit - timePenalty);
            int[,] coordinates = TwoSPUtils.NPSCoordinates(instance, aco.BestSolution);
            TwoSPSolution solution = new TwoSPSolution(instance, coordinates);

            solution.Write(outputFile);
        }
예제 #5
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TwoSPInstance instance    = new TwoSPInstance(fileInput);
            int           levelLength = (int)Math.Ceiling(levelLengthFactor * (2 * instance.NumberItems));
            DiscreteSA    sa          = new DiscreteSANPS42SP(instance, initialSolutions, levelLength, tempReduction);

            sa.Run(timeLimit - timePenalty);
            int[,] coordinates = TwoSPUtils.NPSCoordinates(instance, sa.BestSolution);
            TwoSPSolution solution = new TwoSPSolution(instance, coordinates);

            solution.Write(fileOutput);
        }
예제 #6
0
        public void Start(string inputFile, string outputFile, int timeLimit)
        {
            TwoSPInstance instance       = new TwoSPInstance(inputFile);
            int           neighborChecks = (int)Math.Ceiling(neighborChecksFactor * (2 * instance.NumberItems));
            int           tabuListLength = (int)Math.Ceiling(tabuListFactor * instance.NumberItems);
            DiscreteTS    ts             = new DiscreteTSNPS42SP(instance, tabuListLength, neighborChecks);

            ts.Run(timeLimit - timePenalty);
            int[,] coordinates = TwoSPUtils.NPSCoordinates(instance, ts.BestSolution);
            TwoSPSolution solution = new TwoSPSolution(instance, coordinates);

            solution.Write(outputFile);
        }
예제 #7
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TwoSPInstance instance = new TwoSPInstance(fileInput);

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

            // Solving the problem and writing the best solution found.
            memetic.Run(timeLimit - (int)timePenalty);
            int[,] coordinates = TwoSPUtils.NPSCoordinates(instance, memetic.BestIndividual);
            TwoSPSolution solution = new TwoSPSolution(instance, coordinates);

            solution.Write(fileOutput);
        }
예제 #8
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TwoSPInstance instance = new TwoSPInstance(fileInput);

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

            // Solving the problem and writing the best solution found.
            pso.Run(timeLimit - (int)timePenalty);
            int[,] coordinates = TwoSPUtils.NPSCoordinates(instance, pso.BestPosition);
            TwoSPSolution solution = new TwoSPSolution(instance, coordinates);

            solution.Write(fileOutput);
        }
예제 #9
0
        public void Start(string fileInput, string fileOutput, int timeLimit)
        {
            TwoSPInstance instance = new TwoSPInstance(fileInput);

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

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

            // Solving the problem and writing the best solution found.
            umda.Run(timeLimit - timePenalty);
            int[,] coordinates = TwoSPUtils.NPSCoordinates(instance, umda.BestIndividual);
            TwoSPSolution solution = new TwoSPSolution(instance, coordinates);

            solution.Write(fileOutput);
        }
예제 #10
0
 protected override double Fitness(int[] individual)
 {
     return(TwoSPUtils.Fitness(Instance, TwoSPUtils.NPSCoordinates(Instance, individual)));
 }
 protected override double Fitness(int[] solution)
 {
     return(TwoSPUtils.Fitness(Instance, TwoSPUtils.NPSCoordinates(Instance, solution)));
 }