Exemple #1
0
        public void test_performing_algorithm(int maxIterations, int populationCount, Core.JobScheduling.Base.SchedulingProblem schedulingProblem)
        {
            // Arrange
            var algorithm = new GeneticAlgorithm(maxIterations, populationCount, schedulingProblem);

            // Act
            var result = algorithm.Perform();

            // Assert
            Assert.IsTrue(result.IsCorrect(schedulingProblem.Jobs));
        }
Exemple #2
0
        public void test_performing_algorithm(int maxIterations, int populationCount, float evaporationRate, Core.JobScheduling.Base.SchedulingProblem schedulingProblem, int expectedResultTimeSpan)
        {
            // Arrange
            var algorithm = new AntColonyOptimizationAlgorithm(maxIterations, populationCount, evaporationRate, schedulingProblem);

            // Act
            var result = algorithm.Perform();

            // Assert
            Assert.AreEqual(expectedResultTimeSpan, result.TimeSpan);

            if (schedulingProblem is Core.JobScheduling.OpenShop.SchedulingProblem)
            {
                return;
            }

            foreach (var job in schedulingProblem.Jobs)
            {
                var scheduledOperations = result.Machines
                                          .Select(m => m.Operations.FindLast(o => o.Operation.JobId == job.Id))
                                          .OrderBy(o => o.StartTime)
                                          .ToList();

                for (int i = 0; i < job.Operations.Count; i++)
                {
                    Assert.AreEqual(job.Operations[i].MachineId, scheduledOperations[i].Operation.MachineId);

                    if (i > 0)
                    {
                        int previousOperationEndTime = scheduledOperations[i - 1].StartTime + scheduledOperations[i - 1].Operation.ProcessingTime;
                        Assert.IsTrue(scheduledOperations[i].StartTime >= previousOperationEndTime);
                    }
                }
            }
        }
Exemple #3
0
        public void test_initializing_algorithm(int maxIterations, int populationCount, Core.JobScheduling.Base.SchedulingProblem schedulingProblem)
        {
            // Act
            var algorithm = new GeneticAlgorithm(maxIterations, populationCount, schedulingProblem);

            // Assert
            Assert.AreEqual(populationCount, algorithm.GetPopulation().Count);
        }
Exemple #4
0
        public void test_initializing_algorithm(int maxIterations, int populationCount, float evaporationRate, Core.JobScheduling.Base.SchedulingProblem schedulingProblem, int expectedNodesCount, int expectedPathsCount)
        {
            // Act
            var algorithm = new AntColonyOptimizationAlgorithm(maxIterations, populationCount, evaporationRate, schedulingProblem);

            // Assert
            Assert.AreEqual(populationCount, algorithm.GetPopulation().Count);
            Assert.AreEqual(expectedNodesCount, algorithm.GetNodes().Count);
            Assert.AreEqual(expectedPathsCount, algorithm.GetPaths().Count);
        }