Пример #1
0
        public static PWREncoding CreateTestPWR2()
        {
            PWREncoding   result = new PWREncoding();
            IntegerVector pwr    = new IntegerVector(new int[] { 0, 1, 1, 0, 2, 0, 1, 2, 2 });

            result.PermutationWithRepetition = pwr;
            return(result);
        }
        public void ApplyTest()
        {
            IRandom     random   = new TestRandom(new int[] { 1, 1, 0, 0, 1, 1, 0, 0, 1 }, null);
            PWREncoding parent1  = TestUtils.CreateTestPWR1();
            PWREncoding parent2  = TestUtils.CreateTestPWR2();
            PWREncoding expected = new PWREncoding();

            expected.PermutationWithRepetition = new IntegerVector(new int[] { 1, 0, 1, 0, 1, 2, 0, 2, 2 });
            PWREncoding actual;

            actual = PWRPPXCrossover.Apply(random, parent1, parent2);
            Assert.IsTrue(TestUtils.PRWEncodingEquals(expected, actual));
        }
Пример #3
0
 public static bool PRWEncodingEquals(PWREncoding expected, PWREncoding actual)
 {
     if (expected.PermutationWithRepetition.Length != actual.PermutationWithRepetition.Length)
     {
         return(false);
     }
     for (int i = 0; i < expected.PermutationWithRepetition.Length; i++)
     {
         if (expected.PermutationWithRepetition[i] != actual.PermutationWithRepetition[i])
         {
             return(false);
         }
     }
     return(true);
 }
Пример #4
0
        public static Schedule Apply(int jobs, int resources, PWREncoding pwr, ItemList <Job> jobData)
        {
            var resultingSchedule = new Schedule(jobData[0].Tasks.Count);

            foreach (int jobNr in pwr.PermutationWithRepetition)
            {
                int i = 0;
                while (jobData[jobNr].Tasks[i].IsScheduled)
                {
                    i++;
                }
                Task   currentTask = jobData[jobNr].Tasks[i];
                double startTime   = GTAlgorithmUtils.ComputeEarliestStartTime(currentTask, resultingSchedule);
                currentTask.IsScheduled = true;
                resultingSchedule.ScheduleTask(currentTask.ResourceNr, startTime, currentTask.Duration, currentTask.JobNr);
            }
            return(resultingSchedule);
        }