private static bool IsIndexedColumn(ILogFileColumn column)
 {
     return(IndexedColumns.Contains(column));
 }
 private static bool IsIndexedColumn(IColumnDescriptor column)
 {
     return(IndexedColumns.Contains(column));
 }
Beispiel #3
0
        public static List <Maintainance> Fixation(List <Maintainance> schedules)
        {
            //List<ColumnRank> cImproved = null;
            //while (cImproved == null || cImproved.Count > 0)
            //{
            //    cImproved = GetRankedColumns(schedules).Where(f => f.MustImprove).ToList();
            //    if (cImproved.Count != 0)
            //    {
            //        for (int i = 0; i < schedules.Count; i++)
            //        {
            //            List<ColumnRank> iColRank = GetRankedColumns(schedules);
            //            schedules[i] = SwapSlot(schedules[i], cImproved, iColRank);
            //        }
            //    }

            //}

            List <KeyValuePair <int, Air> > cLog = new List <KeyValuePair <int, Air> >();
            int count = 0;

            foreach (Maintainance i in schedules)
            {
                for (int j = 0; j < i.Slot.Length; j++)
                {
                    if (IndexedColumns.Contains(j) && i.Slot[j] != null)
                    {
                        IndexedColumns.Remove(j);
                    }
                    else
                    {
                        if (i.Slot[j] != null)
                        {
                            cLog.Add(new KeyValuePair <int, Air>(
                                         count,
                                         Program.Clone(i.Slot[j])
                                         ));
                            i.Slot[j] = null;
                        }
                    }
                }
                count++;
            }

            while (IndexedColumns.Count != 0 || cLog.Count != 0)
            {
                if (IndexedColumns.Count == 0)
                {
                    break;
                }
                int ran = IndexedColumns[0];
                foreach (var i in cLog)
                {
                    schedules[i.Key].Slot[ran] = i.Value;
                    IndexedColumns.Remove(ran);
                    break;
                }
                if (cLog.Count > 0)
                {
                    cLog.RemoveAt(0);
                }
            }


            List <int> cRandom = new List <int>();

            for (int i = 0; i < Program.MAX_AIR; i++)
            {
                cRandom.Add(i);
            }
            cRandom = new List <int>(RandomizeInt(cRandom.ToArray()));


            foreach (var i in schedules)
            {
                if (cRandom.Count != 0)
                {
                    for (int j = 0; j < i.Slot.Length; j++)
                    {
                        Air jAir            = i.Slot[j];
                        int jNewPosition    = cRandom[0];
                        Air jNewAirPosition = i.Slot[jNewPosition];
                        if (jAir != null && j != jNewPosition && jNewAirPosition != null)
                        {
                            i.Slot[jNewPosition] = Program.Clone(jAir);
                            i.Slot[j]            = null;
                            cRandom.Remove(jNewPosition);
                            break;
                        }
                        else if (j == jNewPosition)
                        {
                            cRandom.Remove(j);
                            break;
                        }
                    }
                }
            }



            return(schedules);
        }