Exemple #1
0
        public Individ GetChild(Individ parentA, Individ parentB)
        {
            //step1: select randomly course Ca from parent A
            int        RandomPeriodIndex     = BasicFunctions.randomGenerator.Next(0, parentA.Representation.Length);
            List <int> ParentAselectedPeriod = parentA.Representation[RandomPeriodIndex];
            int        RandomCourseIndex     = BasicFunctions.randomGenerator.Next(0, ParentAselectedPeriod.Count);
            int        CourseID = ParentAselectedPeriod[RandomCourseIndex];
            //step 2:  remove course Ca  from parent B
            Individ    TempChildA       = RemoveCourse(parentB, CourseID);
            List <int> randomPeriodList = BasicFunctions.getRandomPeriodList(TempChildA.Representation.Length);

            return(null);
        }
        private int[] getShiftCandidateOrigine(Individ _parent, Curriculum _c)
        {
            int[]      shiftCandidate = new int[2];
            List <int> periodList     = BasicFunctions.getRandomPeriodList(_c.noPeriods);
            //List<int> periodList = BasicFunctions.getCreditLoadSortedPeriodList(parentA.PeriodCreditLoad);
            int candidatePeriod = -1;
            int candidateCourse = -1;

            while (periodList.Count > 0)
            {
                //Console.WriteLine("periodList.Count: " + periodList.Count);
                candidatePeriod = periodList[0];
                int candidatePeriodCourseLoad = _parent.Representation[candidatePeriod].Count;

                if (candidatePeriodCourseLoad - 1 >= _c.minCourses)
                {
                    int candidatePeriodCreditLoad = _parent.PeriodCreditLoad[candidatePeriod];
                    //choosing randomly a course from this period, check minPeriodCreditLoad
                    List <int> RandomListOfCourses = BasicFunctions.getRandomCourseList(_parent.Representation[candidatePeriod]);
                    int        CourseIndex;
                    for (CourseIndex = 0; CourseIndex < RandomListOfCourses.Count; CourseIndex++)
                    {
                        int tempCourseCredit = _c.courses.FirstOrDefault(a => a.ID == RandomListOfCourses[CourseIndex]).credit;
                        if ((candidatePeriodCreditLoad - tempCourseCredit) >= _c.minCredits)
                        {
                            candidateCourse = _c.courses.FirstOrDefault(a => a.ID == RandomListOfCourses[CourseIndex]).ID;
                            return(new int[] { candidatePeriod, candidateCourse });
                        }
                    }
                    if (CourseIndex == RandomListOfCourses.Count)
                    {
                        periodList.RemoveAt(0);
                    }
                }
                else
                {
                    periodList.RemoveAt(0);
                }
            }

            return(new int[] { -1, -1 });
        }