Exemplo n.º 1
0
        /// <summary>
        /// make a deep copy of solution s to solution d
        /// </summary>
        /// <param name="s">source solution</param>
        /// <param name="d">destination solution</param>
        public static void copy(solution s, out solution d)
        {
            d     = new solution();
            d.p   = s.p;
            d.apd = new int[s.apd.Length];

            d.aps         = new int[s.aps.Length];
            d.arm         = new int[s.arm.Length];
            d.Constraints = new List <UNAVAILABILITY_CONSTRAINT>();
            for (int i = 0; i < s.Constraints.Count; i++)
            {
                UNAVAILABILITY_CONSTRAINT Constraint = new UNAVAILABILITY_CONSTRAINT();
                Constraint.CourseID   = s.Constraints[i].CourseID;
                Constraint.Day        = s.Constraints[i].Day;
                Constraint.Day_Period = s.Constraints[i].Day_Period;
                d.Constraints.Add(Constraint);
            }


            d.LC = new Dictionary <int, course>();
            foreach (var item in s.LC)
            {
                d.LC.Add(item.Key, item.Value);// its not a deep copy of s.LC
            }
            d.nd = new int[s.nd.Length];
            d.nl = new int[s.nl.Length];
            d.nr = new int[s.nr.Length];

            for (int i = 0; i < s.nl.Length; i++)
            {
                d.apd[i] = s.apd[i];
                d.aps[i] = s.aps[i];
                d.arm[i] = s.arm[i];
                d.nd[i]  = s.nd[i];
                d.nl[i]  = s.nl[i];
                d.nr[i]  = s.nr[i];
            }


            d.timeTable = new course[s.timeTable.Length][];
            for (int i = 0; i < s.timeTable.Length; i++)
            {
                d.timeTable[i] = new course[s.timeTable[i].Length];
                for (int j = 0; j < s.timeTable[i].Length; j++)
                {
                    d.timeTable[i][j] = s.timeTable[i][j];
                }
            }
        }
Exemplo n.º 2
0
        public void setApd(int Ci, int Tj)
        {
            string        cID             = LC[Ci].CourseID;
            List <string> effectedCourses = new List <string>();

            for (int i = 0; i < p.Curricula.Length; i++)
            {
                foreach (var item in p.Curricula[i].Courses)
                {
                    if (item == cID)
                    {
                        foreach (var c in p.Curricula[i].Courses)
                        {
                            if (!effectedCourses.Contains(c))
                            {
                                effectedCourses.Add(c);
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < LC.Count; i++)
            {
                for (int j = 0; j < effectedCourses.Count; j++)
                {
                    if (LC.ElementAt(i).Value.CourseID == effectedCourses[j])
                    {
                        apd[i]--;
                        UNAVAILABILITY_CONSTRAINT constraint = new UNAVAILABILITY_CONSTRAINT();
                        constraint.CourseID   = LC.ElementAt(i).Value.CourseID;
                        constraint.Day        = Tj / p.Periods_per_day;
                        constraint.Day_Period = Tj % p.Periods_per_day;
                        Constraints.Add(constraint);
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// make a deep copy of solution s to solution d
        /// </summary>
        /// <param name="s">source solution</param>
        /// <param name="d">destination solution</param>
        public static void copy(solution s, out solution d)
        {
            d = new solution();
            d.p = s.p;
            d.apd = new int[s.apd.Length];

            d.aps = new int[s.aps.Length];
            d.arm = new int[s.arm.Length];
            d.Constraints = new List<UNAVAILABILITY_CONSTRAINT>();
            for (int i = 0; i <s.Constraints.Count; i++)
            {
                UNAVAILABILITY_CONSTRAINT Constraint = new UNAVAILABILITY_CONSTRAINT();
                Constraint.CourseID = s.Constraints[i].CourseID;
                Constraint.Day = s.Constraints[i].Day;
                Constraint.Day_Period = s.Constraints[i].Day_Period;
                d.Constraints.Add(Constraint);
            }

            d.LC = new Dictionary<int, course>();
            foreach (var item in s.LC)
            {
                d.LC.Add(item.Key, item.Value);// its not a deep copy of s.LC
            }
            d.nd = new int[s.nd.Length];
            d.nl = new int[s.nl.Length];
            d.nr = new int[s.nr.Length];

            for (int i = 0; i < s.nl.Length; i++)
            {
                d.apd[i] = s.apd[i];
                d.aps[i] = s.aps[i];
                d.arm[i] = s.arm[i];
                d.nd[i] = s.nd[i];
                d.nl[i] = s.nl[i];
                d.nr[i] = s.nr[i];
            }

            d.timeTable = new course[s.timeTable.Length][];
            for (int i = 0; i < s.timeTable.Length; i++)
            {
                d.timeTable[i] = new course[s.timeTable[i].Length];
                for (int j = 0; j < s.timeTable[i].Length; j++)
                {
                    d.timeTable[i][j] = s.timeTable[i][j];
                }
            }
        }
Exemplo n.º 4
0
        public void setApd(int Ci,int Tj)
        {
            string cID=LC[Ci].CourseID;
              List<string> effectedCourses = new List<string>();
              for (int i = 0; i < p.Curricula.Length; i++)
              {
              foreach (var item in p.Curricula[i].Courses)
              {
                 if(item==cID){
                     foreach (var c in p.Curricula[i].Courses)
                     {
                         if (!effectedCourses.Contains(c))
                         {
                             effectedCourses.Add(c);
                         }
                     }
              }
              }

              }
              for (int i = 0; i < LC.Count; i++)
              {
              for (int j = 0; j < effectedCourses.Count; j++)
            {
                if (LC.ElementAt(i).Value.CourseID== effectedCourses[j])
                {
                    apd[i]--;
                    UNAVAILABILITY_CONSTRAINT constraint = new UNAVAILABILITY_CONSTRAINT();
                    constraint.CourseID = LC.ElementAt(i).Value.CourseID;
                    constraint.Day = Tj / p.Periods_per_day;
                    constraint.Day_Period = Tj % p.Periods_per_day;
                    Constraints.Add(constraint);
                }
            }

              }
        }