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 DiscretePSOBL2OptBest42SP(instance, (int)particlesCount, prevConf, neighConf, lowerBounds, upperBounds);

            // Solving the problem and writing the best solution found.
            pso.Run(timeLimit - (int)timePenalty);
            int[,] coordinates = TwoSPUtils.BLCoordinates(instance, pso.BestPosition);
            TwoSPSolution solution = new TwoSPSolution(instance, coordinates);
            solution.Write(fileOutput);
        }
示例#2
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 DiscretePSOBL2OptBest42SP(instance, (int)particlesCount, prevConf, neighConf, lowerBounds, upperBounds);

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

            solution.Write(fileOutput);
        }