Esempio n. 1
0
        public void RunTest()
        {
            var jobShop    = new JobShopLoader().Load("TestExamples/test2.in");
            var mockLogger = new Mock <ILogger>();

            Global.Config.MinPopulationSize          = 100;
            Global.Config.MaxPopulationSize          = 100;
            Global.Config.GenerationsCount           = 10;
            Global.Config.IterationsCount            = 1;
            Global.Config.CrossoverProbability       = 0.75f;
            Global.Config.MutationProbability        = 0.3f;
            Global.Config.MutationPerGeneProbability = 0.01f;
            Global.Config.ElitismPercent             = 0.02f;
            Global.Config.ThreadsCount = 1;

            var ga = new JobShopGeneticAlgorithm(jobShop, Global.Config.IterationsCount, mockLogger.Object, adaptive: true);

            typeof(BasicRandomization).GetField("_globalRandom", BindingFlags.Static | BindingFlags.NonPublic)
            .SetValue(null, new Random(42));
            RandomizationProvider.Current = new BasicRandomization();

            ga.Run();

            int expectedScheduleLength = 26;

            Assert.That(ga.BestSchedule.ScheduleLength, Is.EqualTo(expectedScheduleLength));
        }
Esempio n. 2
0
        public void LoadTest()
        {
            var loader  = new JobShopLoader();
            var jobShop = loader.Load("TestExamples/test1.in", false);
            var job1    = jobShop.Jobs[0];
            var job2    = jobShop.Jobs[1];

            var operation0 = job1.Operations[0];

            Assert.That(operation0.Id, Is.EqualTo(0));
            Assert.That(operation0.Cost, Is.EqualTo(2));
            Assert.That(operation0.JobId, Is.EqualTo(0));
            Assert.That(operation0.MachineId, Is.EqualTo(0));

            var operation1 = job1.Operations[1];

            Assert.That(operation1.Id, Is.EqualTo(1));
            Assert.That(operation1.Cost, Is.EqualTo(5));
            Assert.That(operation1.JobId, Is.EqualTo(0));
            Assert.That(operation1.MachineId, Is.EqualTo(1));

            var operation2 = job1.Operations[2];

            Assert.That(operation2.Id, Is.EqualTo(2));
            Assert.That(operation2.Cost, Is.EqualTo(3));
            Assert.That(operation2.JobId, Is.EqualTo(0));
            Assert.That(operation2.MachineId, Is.EqualTo(0));

            var operation5 = job2.Operations[2];

            Assert.That(operation5.Id, Is.EqualTo(5));
            Assert.That(operation5.Cost, Is.EqualTo(4));
            Assert.That(operation5.JobId, Is.EqualTo(1));
            Assert.That(operation5.MachineId, Is.EqualTo(0));
        }
        public void SetUp()
        {
            var jobShop = new JobShopLoader().Load("TestExamples/test1.in", false);

            machineChromosome = new MachineChromosome(new int[]
            {
                4, 5, 0, 2
            }.Select(x => jobShop.Operations[x]).ToArray());
        }
Esempio n. 4
0
        public void SetUp()
        {
            var jobShop    = new JobShopLoader().Load("TestExamples/ft06.in");
            var mockLogger = new Mock <ILogger>();

            Global.Config.MinPopulationSize = 100;
            Global.Config.MaxPopulationSize = 100;
            ga = new JobShopGeneticAlgorithm(jobShop, 1, mockLogger.Object, adaptive: false);
            ga.GenerationRan += AssertUnique;
        }
Esempio n. 5
0
        public void SetUp()
        {
            var jobShop = new JobShopLoader().Load("TestExamples/test1.in", false);

            chromosome = new ScheduleChromosome(jobShop);

            var machineChromosome1 = new MachineChromosome(new int[]
            {
                4, 5, 0, 2
            }.Select(x => jobShop.Operations[x]).ToArray());

            chromosome.ReplaceGene(0, new Gene(machineChromosome1));

            var machineChromosome2 = new MachineChromosome(new int[]
            {
                1, 3
            }.Select(x => jobShop.Operations[x]).ToArray());

            chromosome.ReplaceGene(1, new Gene(machineChromosome2));
        }
Esempio n. 6
0
        /// <summary>
        /// Loads <see cref="JobShop"/> from specified input path.
        /// </summary>
        /// <param name="inputPath"></param>
        /// <returns></returns>
        private static JobShop LoadJobShop(string inputPath)
        {
            JobShop jobShop = new JobShopLoader().Load(inputPath);

            return(jobShop);
        }