Example #1
0
        //关于台风的极端处理
        //1.调机开始点:如果一个航班将要飞往一个台风机场如果无法降落,则视为是开始点,
        //  虽然台风允许提早,则也不一定可以起飞
        //2.第一个没有台风影响的航班作为调机终止点
        //如果没有航班,则选择下一个
        //考虑抢先做调机工作
        public static bool FixByEmptyFly(List <Airline> AirlineList, bool IsTry)
        {
            int StartIndex, EndIndex;
            var range = GetTyphoonRange(AirlineList);

            StartIndex = range.StartIndex;
            EndIndex   = range.EndIndex;
            //StartIndex 是受   台风影响的航班
            //EndIndex   是不受 台风影响的航班!
            if (EndIndex == -1 || StartIndex == -1)
            {
                return(false);
            }
            //空飞航班起点在 StartIndex,终点在 EndIndex

            bool CanEmptyFly = IsCanEmptyFly(AirlineList, ref StartIndex, ref EndIndex);

            if (!CanEmptyFly)
            {
                return(false);
            }
            //新增航班
            Airline EmptyFly = GetEmptyFly(AirlineList, StartIndex, EndIndex);

            if (!IsTry)
            {
                EmptyFlyList.Add(EmptyFly);
            }
            for (int i = StartIndex; i < EndIndex; i++)
            {
                AirlineList[i].FixMethod = enmFixMethod.Cancel;
            }
            return(CoreAlgorithm.AdjustAirLineList(AirlineList));
        }
Example #2
0
        public static bool CanEscapeTyphoonByFrontCancel(List <Airline> AirlineList)
        {
            int StartIndex, EndIndex;
            var range = GetTyphoonRange(AirlineList);

            StartIndex = range.StartIndex;
            EndIndex   = range.EndIndex;
            //StartIndex 是受   台风影响的航班
            //EndIndex   是不受 台风影响的航班!
            if (EndIndex == -1 || StartIndex == -1 || EndIndex == AirlineList.Count)
            {
                return(false);
            }
            string StartAirPort = AirlineList[EndIndex].StartAirPort;

            if (CheckCondition.TyphoonAirport.Contains(StartAirPort))
            {
                return(false);
            }
            for (int i = EndIndex - 1; i > Math.Max(1, StartIndex - 5); i--)
            {
                //如果存在开始为StartPort的航班
                if (AirlineList[i].StartAirPort.Equals(StartAirPort))
                {
                    for (int j = i; j < EndIndex; j++)
                    {
                        AirlineList[j].FixMethod = enmFixMethod.Cancel;
                    }
                    return(CoreAlgorithm.AdjustAirLineList(AirlineList));
                }
            }
            return(false);
        }
Example #3
0
        public static (int StartCancelIndex, int EndCancelIndex) GetCancelSomeSectionIndex(List <Airline> AirlineList)
        {
            int StartIndex, EndIndex;
            var range = GetTyphoonRange(AirlineList);

            StartIndex = range.StartIndex;
            EndIndex   = range.EndIndex;
            //StartIndex 是受   台风影响的航班
            //EndIndex   是不受 台风影响的航班!
            if (EndIndex == -1 || StartIndex == -1)
            {
                return(-1, -1);
            }
            var MinScore         = double.MaxValue;
            var MinStartEndIndex = (-1, -1);

            //台风外的3个,台风内的5个,进行双循环匹配
            for (int StIdx = Math.Max(1, StartIndex - 5); StIdx < StartIndex; StIdx++)
            {
                for (int EdIdx = StartIndex + 1; EdIdx < Math.Min(AirlineList.Count, StartIndex + 8); EdIdx++)
                {
                    if (AirlineList[StIdx].FixMethod == enmFixMethod.Cancel ||
                        AirlineList[EdIdx].FixMethod == enmFixMethod.Cancel)
                    {
                        continue;
                    }
                    if (AirlineList[StIdx].EndAirPort.Equals(AirlineList[EdIdx].StartAirPort))
                    {
                        if (!CheckCondition.TyphoonAirport.Contains(AirlineList[StIdx].EndAirPort))
                        {
                            var AirlineListClone = Utility.DeepCopy(AirlineList);
                            for (int CancelIdx = StIdx + 1; CancelIdx < EdIdx; CancelIdx++)
                            {
                                AirlineListClone[CancelIdx].FixMethod = enmFixMethod.Cancel;
                            }
                            if (CoreAlgorithm.AdjustAirLineList(AirlineListClone))
                            {
                                var CurrentResult = Statistics.WriteResult(AirlineListClone);
                                if (MinScore > CurrentResult)
                                {
                                    MinScore         = CurrentResult;
                                    MinStartEndIndex = (StIdx, EdIdx);
                                }
                            }
                        }
                    }
                }
            }
            return(MinStartEndIndex);
        }
Example #4
0
        public static int GetFixByEmptyFlyAdvanced(List <Airline> AirlineList)
        {
            int StartIndex, EndIndex;
            var range = GetTyphoonRange(AirlineList);

            StartIndex = range.StartIndex;
            EndIndex   = range.EndIndex;
            //StartIndex 是受   台风影响的航班
            //EndIndex   是不受 台风影响的航班!
            if (EndIndex == -1 || StartIndex == -1)
            {
                return(-1);
            }
            var MinScore    = double.MaxValue;
            var MinEndIndex = -1;

            //空飞航班起点在 StartIndex,终点在 EndIndex之前是否也可以?
            for (int NewEndIndex = StartIndex + 1; NewEndIndex < EndIndex; NewEndIndex++)
            {
                var StartIndexClone = StartIndex;
                var EndIndexClone   = NewEndIndex;
                if (IsCanEmptyFly(AirlineList, ref StartIndexClone, ref EndIndexClone))
                {
                    if (StartIndex != StartIndexClone || NewEndIndex != EndIndexClone)
                    {
                        continue;
                    }
                    //可以直飞
                    //Console.WriteLine("Try EmptyFly" + AirlineList[StartIndex].ID + "," + AirlineList[NewEndIndex].ID);
                    //尝试状态
                    var AirlineListClone = Utility.DeepCopy(AirlineList);
                    var EmptyFly         = GetEmptyFly(AirlineListClone, StartIndex, NewEndIndex);
                    for (int i = StartIndex; i < NewEndIndex; i++)
                    {
                        AirlineListClone[i].FixMethod = enmFixMethod.Cancel;
                    }
                    if (CoreAlgorithm.AdjustAirLineList(AirlineListClone))
                    {
                        var CurrentResult = Statistics.WriteResult(AirlineListClone) + Statistics.EmptyFlyParm;
                        if (MinScore > CurrentResult)
                        {
                            MinScore    = CurrentResult;
                            MinEndIndex = NewEndIndex;
                        }
                    }
                }
            }
            return(MinEndIndex);
        }
Example #5
0
        public static double FixByEmptyFlyAdvanced(List <Airline> AirlineList, int BestEndIndex, bool IsTry)
        {
            int StartIndex, NewEndIndex;
            var range = GetTyphoonRange(AirlineList);

            StartIndex  = range.StartIndex;
            NewEndIndex = BestEndIndex;
            var EmptyFly = GetEmptyFly(AirlineList, StartIndex, NewEndIndex);

            for (int i = StartIndex; i < NewEndIndex; i++)
            {
                AirlineList[i].FixMethod = enmFixMethod.Cancel;
            }
            CoreAlgorithm.AdjustAirLineList(AirlineList);
            if (!IsTry)
            {
                EmptyFlyList.Add(EmptyFly);
            }
            return(Statistics.WriteResult(AirlineList) + (IsTry ? Statistics.EmptyFlyParm : 0));
        }
Example #6
0
        public static bool CanEscapeTyphoonByCancelAdvanced(List <Airline> AirlineList)
        {
            int StartIndex, EndIndex;
            var range = GetTyphoonRange(AirlineList);

            StartIndex = range.StartIndex;
            EndIndex   = range.EndIndex;
            //StartIndex 是受   台风影响的航班
            //EndIndex   是不受 台风影响的航班!
            if (EndIndex == -1 || StartIndex == -1 || EndIndex == AirlineList.Count)
            {
                return(false);
            }
            string StartAirPort = AirlineList[StartIndex].StartAirPort;

            if (CheckCondition.TyphoonAirport.Contains(StartAirPort))
            {
                return(false);
            }
            for (int i = StartIndex; i < EndIndex; i++)
            {
                //如果存在开始为StartPort的航班
                if (AirlineList[i].StartAirPort.Equals(StartAirPort))
                {
                    //是否能够通过延迟的方式,使得航班降落
                    var CloneAirlineList = Utility.DeepCopy(AirlineList);
                    CloneAirlineList[i].Problem = GetProblem(CloneAirlineList[i]);
                    if (FixAirportProblemByChangeTakeOffTime(CloneAirlineList, i, CloneAirlineList[i]))
                    {
                        for (int j = StartIndex; j < i; j++)
                        {
                            AirlineList[j].FixMethod = enmFixMethod.Cancel;
                        }
                        return(CoreAlgorithm.AdjustAirLineList(AirlineList));
                    }
                }
            }
            return(false);
        }
Example #7
0
        public static (bool IsOK, double Score) FixAirline(List <Airline> PlaneAirlineList, bool IsTry = false)
        {
            //停机库的备份
            var CloneTyphoonAirportRemain = Utility.DeepCopy(CheckCondition.TyphoonAirportRemain);

            //多线程,防止出现异常循环体内外写不同的变量
            foreach (var airport in CloneTyphoonAirportRemain.Keys)
            {
                CheckCondition.TyphoonAirportRemain[airport] = 999;
            }
            //复杂调整
            var PlaneAirlineListCloneComplexAdjust = Utility.DeepCopy(PlaneAirlineList);
            var ScoreComplexAdjust = double.MaxValue;

            if (CoreAlgorithm.FixByComplexAdjust(PlaneAirlineListCloneComplexAdjust))
            {
                ScoreComplexAdjust = Statistics.WriteResult(PlaneAirlineListCloneComplexAdjust);
            }

            //单纯调机
            var PlaneAirlineListCloneWithEmptyFly = Utility.DeepCopy(PlaneAirlineList);
            var ScoreWithEmptyFly = double.MaxValue;

            //调机的结果
            if (CoreAlgorithm.FixByEmptyFly(PlaneAirlineListCloneWithEmptyFly, true))
            {
                //计算空飞分数正式输出的时候,是最后一起算的,所以,这里必须要补上空飞的惩罚
                ScoreWithEmptyFly = Statistics.WriteResult(PlaneAirlineListCloneWithEmptyFly) + Statistics.EmptyFlyParm;
            }

            //取消一些航班
            var PlaneAirlineListCloneCancel = Utility.DeepCopy(PlaneAirlineList);
            var ScoreCancel = double.MaxValue;

            if (CoreAlgorithm.CanEscapeTyphoonByCancel(PlaneAirlineListCloneCancel))
            {
                ScoreCancel = Statistics.WriteResult(PlaneAirlineListCloneCancel);
            }

            //取消一些航班-高级
            var PlaneAirlineListCloneCancelAdvanced = Utility.DeepCopy(PlaneAirlineList);
            var ScoreCancelAdvanced = double.MaxValue;

            if (CoreAlgorithm.CanEscapeTyphoonByCancelAdvanced(PlaneAirlineListCloneCancelAdvanced))
            {
                ScoreCancelAdvanced = Statistics.WriteResult(PlaneAirlineListCloneCancelAdvanced);
            }

            //普通调整
            var ScoreNormal = double.MaxValue;
            var PlaneAirlineListCloneNormal = Utility.DeepCopy(PlaneAirlineList);

            if (CoreAlgorithm.AdjustAirLineList(PlaneAirlineListCloneNormal))
            {
                ScoreNormal = Statistics.WriteResult(PlaneAirlineListCloneNormal);
            }

            var PlaneAirlineListCloneFrontCancel = Utility.DeepCopy(PlaneAirlineList);
            var ScoreFrontCancel = double.MaxValue;

            if (CoreAlgorithm.CanEscapeTyphoonByFrontCancel(PlaneAirlineListCloneFrontCancel))
            {
                ScoreFrontCancel = Statistics.WriteResult(PlaneAirlineListCloneFrontCancel);
            }

            var PlaneAirlineListCloneConvertToEmpty = Utility.DeepCopy(PlaneAirlineList);
            var ScoreConvertToEmpty = double.MaxValue;

            if (CoreAlgorithm.FixByConvertToEmptyFly(PlaneAirlineListCloneConvertToEmpty, true))
            {
                //计算空飞分数正式输出的时候,是最后一起算的,所以,这里必须要补上空飞的惩罚
                ScoreConvertToEmpty = Statistics.WriteResult(PlaneAirlineListCloneConvertToEmpty) + Statistics.EmptyFlyParm;
            }

            var PlaneAirlineListCloneEmptyAdvanced = Utility.DeepCopy(PlaneAirlineList);
            var ScoreEmptyAdvanced = double.MaxValue;
            int BestEndIndex       = CoreAlgorithm.GetFixByEmptyFlyAdvanced(PlaneAirlineListCloneEmptyAdvanced);

            if (BestEndIndex != -1)
            {
                ScoreEmptyAdvanced = CoreAlgorithm.FixByEmptyFlyAdvanced(PlaneAirlineListCloneEmptyAdvanced, BestEndIndex, true);
            }

            var PlaneAirlineListCloneCancelSomeSection = Utility.DeepCopy(PlaneAirlineList);
            var ScoreCancelSomeSection = double.MaxValue;
            var BestStartEndIndex      = CoreAlgorithm.GetCancelSomeSectionIndex(PlaneAirlineListCloneCancelSomeSection);

            if (BestStartEndIndex.StartCancelIndex != -1)
            {
                ScoreCancelSomeSection = CoreAlgorithm.FixByCancelSomeSection(PlaneAirlineListCloneCancelSomeSection, BestStartEndIndex);
            }


            //寻找最小的一种方式
            double MinScore = Math.Min(ScoreComplexAdjust, ScoreWithEmptyFly);

            MinScore = Math.Min(ScoreCancel, MinScore);
            MinScore = Math.Min(ScoreCancelAdvanced, MinScore);
            MinScore = Math.Min(ScoreNormal, MinScore);
            MinScore = Math.Min(ScoreFrontCancel, MinScore);
            MinScore = Math.Min(ScoreConvertToEmpty, MinScore);
            MinScore = Math.Min(ScoreEmptyAdvanced, MinScore);
            MinScore = Math.Min(ScoreCancelSomeSection, MinScore);
            if (IsTry)
            {
                return(MinScore != double.MaxValue, MinScore);
            }
            CheckCondition.TyphoonAirportRemain = CloneTyphoonAirportRemain;
            if (Math.Round(MinScore, 0) == Math.Round(ScoreComplexAdjust, 0))
            {
                Utility.Log("FixByComplexAdjust:" + PlaneAirlineList[0].ModifiedPlaneID);
                return(CoreAlgorithm.FixByComplexAdjust(PlaneAirlineList), MinScore);
            }

            if (Math.Round(MinScore, 0) == Math.Round(ScoreWithEmptyFly, 0))
            {
                Utility.Log("FixByEmptyFly:" + PlaneAirlineList[0].ModifiedPlaneID);
                return(CoreAlgorithm.FixByEmptyFly(PlaneAirlineList, false), MinScore);
            }
            if (Math.Round(MinScore, 0) == Math.Round(ScoreCancel, 0))
            {
                Utility.Log("CanEscapeTyphoonByCancel:" + PlaneAirlineList[0].ModifiedPlaneID);
                return(CoreAlgorithm.CanEscapeTyphoonByCancel(PlaneAirlineList), MinScore);
            }
            if (Math.Round(MinScore, 0) == Math.Round(ScoreCancelAdvanced, 0))
            {
                Utility.Log("CanEscapeTyphoonByCancelAdvanced:" + PlaneAirlineList[0].ModifiedPlaneID);
                return(CoreAlgorithm.CanEscapeTyphoonByCancelAdvanced(PlaneAirlineList), MinScore);
            }
            if (Math.Round(MinScore, 0) == Math.Round(ScoreNormal, 0))
            {
                //普通调整
                Utility.Log("AdjustAirLineList:" + PlaneAirlineList[0].ModifiedPlaneID);
                return(CoreAlgorithm.AdjustAirLineList(PlaneAirlineList), MinScore);
            }
            if (Math.Round(MinScore, 0) == Math.Round(ScoreFrontCancel, 0))
            {
                Utility.Log("CanEscapeTyphoonByFrontCancel:" + PlaneAirlineList[0].ModifiedPlaneID);
                return(CoreAlgorithm.CanEscapeTyphoonByFrontCancel(PlaneAirlineList), MinScore);
            }
            if (Math.Round(MinScore, 0) == Math.Round(ScoreConvertToEmpty, 0))
            {
                Utility.Log("FixByConvertToEmptyFly:" + PlaneAirlineList[0].ModifiedPlaneID);
                return(CoreAlgorithm.FixByConvertToEmptyFly(PlaneAirlineList, false), MinScore);
            }
            if (Math.Round(MinScore, 0) == Math.Round(ScoreEmptyAdvanced, 0))
            {
                Utility.Log("FixByEmptyFlyAdvanced:" + PlaneAirlineList[0].ModifiedPlaneID);
                CoreAlgorithm.FixByEmptyFlyAdvanced(PlaneAirlineList, BestEndIndex, false);
                return(true, MinScore);
            }
            if (Math.Round(MinScore, 0) == Math.Round(ScoreCancelSomeSection, 0))
            {
                Utility.Log("ScoreCancelSomeSection:" + PlaneAirlineList[0].ModifiedPlaneID);
                CoreAlgorithm.FixByCancelSomeSection(PlaneAirlineList, BestStartEndIndex);
                return(true, MinScore);
            }
            return(false, double.MaxValue);
        }
Example #8
0
        public static bool FixByComplexAdjust(List <Airline> airlineList)
        {
            //将所有的航班分组(假设没有从台风飞到台风的航班,如果有的话,暂时不处理)
            //分组的规则为,第一个是起飞是台风关联航班,最后一个结尾是台风关联航班
            var            airlinegrpList = new List <List <Airline> >();
            var            IsGroupStarted = false;
            List <Airline> CurrentGroup   = null;

            for (int i = 0; i < airlineList.Count; i++)
            {
                if (CheckCondition.TyphoonAirport.Contains(airlineList[i].StartAirPort))
                {
                    //起飞是台风航班
                    CurrentGroup = new List <Airline>();
                    airlinegrpList.Add(CurrentGroup);
                    CurrentGroup.Add(airlineList[i]);
                    IsGroupStarted = true;
                }
                else
                {
                    if (CheckCondition.TyphoonAirport.Contains(airlineList[i].EndAirPort))
                    {
                        //降落是台风航班
                        if (IsGroupStarted)
                        {
                            //分组开始状态
                            CurrentGroup.Add(airlineList[i]);
                            IsGroupStarted = false;
                        }
                        else
                        {
                            //分组未开始状态(第一个航班降落在台风机场的情况)
                            CurrentGroup = new List <Airline>();
                            airlinegrpList.Add(CurrentGroup);
                            CurrentGroup.Add(airlineList[i]);
                        }
                    }
                    else
                    {
                        //起飞降落都是台风航班
                        if (IsGroupStarted)
                        {
                            //分组开始状态
                            CurrentGroup.Add(airlineList[i]);
                        }
                        else
                        {
                            //普通航班
                            CurrentGroup = new List <Airline>();
                            airlinegrpList.Add(CurrentGroup);
                            CurrentGroup.Add(airlineList[i]);
                        }
                    }
                }
            }
            var firstTyphoonGroupId = -1;

            for (int i = 0; i < airlinegrpList.Count; i++)
            {
                foreach (var airline in airlinegrpList[i])
                {
                    //判断被台风影响的航班
                    var Problem = CheckCondition.IsExistTyphoon(airline);
                    if (Problem.DetailType == ProblemType.TyphoonLand)
                    {
                        firstTyphoonGroupId = i;
                        break;
                    }
                }
                if (firstTyphoonGroupId != -1)
                {
                    break;
                }
            }
            //索引检查
            if (firstTyphoonGroupId >= airlinegrpList.Count - 1)
            {
                return(false);
            }
            if (firstTyphoonGroupId <= 0)
            {
                return(false);
            }
            // Console.WriteLine("台风开始组号:[" + firstTyphoonGroupId + "]");
            var firstAirline = airlinegrpList[firstTyphoonGroupId + 1].First();
            var lastAirline  = airlinegrpList[firstTyphoonGroupId - 1].Last();

            //台风上一组的结束和台风下一组的开始能否衔接?
            if (lastAirline.EndAirPort != firstAirline.StartAirPort)
            {
                return(false);
            }
            //下一组的第一个航班是否可以通过提早飞行而成功?
            firstAirline.Problem = GetProblem(firstAirline);
            //检查之前,需要正确设置上一个航班的信息!
            firstAirline.PreviousAirline = lastAirline;
            if (firstAirline.Problem.DetailType == ProblemType.None || firstAirline.Problem.DetailType == ProblemType.TyphoonStay)
            {
                return(false);
            }
            if (!FixTyphoonTakeOffByChangeTakeOffTime(firstAirline))
            {
                return(false);
            }
            //尝试将第一组台风影响航班取消
            foreach (var item in airlinegrpList[firstTyphoonGroupId])
            {
                item.FixMethod = enmFixMethod.Cancel;
            }
            return(CoreAlgorithm.AdjustAirLineList(airlineList));
        }
        public static void Run()
        {
            InitAirportIdAirlineDic();

            //单位时间容量限制
            UnitCapLimit();
            return;

            //修改执飞航班
            TryChangePlane();

            CancelPairList.Clear();

            GetCancelPair();
            //按照机场和重要度进行排序
            CancelPairList.Sort((x, y) =>
            {
                if (x.StartAirPort == y.StartAirPort)
                {
                    return(y.ImportFac.CompareTo(x.ImportFac));
                }
                else
                {
                    return(x.StartAirPort.CompareTo(y.StartAirPort));
                }
            });

            GapList.Clear();
            foreach (var airportId in AirportIdAirlineDic.Keys)
            {
                PutCancelToBigGap(airportId);
            }
            //按照机场和时间进行排序
            GapList.Sort(
                (x, y) =>
            {
                if (x.AirportID == y.AirportID)
                {
                    return(x.LandTime.CompareTo(y.LandTime));
                }
                else
                {
                    return(x.AirportID.CompareTo(y.AirportID));
                }
            }
                );


            //进行匹配
            for (int i = 0; i < CancelPairList.Count; i++)
            {
                double MaxScore   = 0;
                int    MaxIndex   = -1;
                var    CancelItem = CancelPairList[i];
                for (int j = 0; j < GapList.Count; j++)
                {
                    var GapItem = GapList[j];
                    if (GapItem.IsFilled)
                    {
                        continue;
                    }

                    //Gap的机场和取消组的机场一致
                    if (CancelItem.StartAirPort != GapItem.AirportID)
                    {
                        continue;
                    }
                    //不是同一架飞机,机型相同
                    if (CancelItem.PlaneID == GapItem.PlaneID || CancelItem.PlaneType != GapItem.PlaneType)
                    {
                        continue;
                    }
                    //中间是台风,暂时不考虑
                    var ArrivalTime = GapItem.LandTime.AddMinutes(Utility.StayAtAirPortMinutes) + CancelItem.First.FlightSpan;
                    if (CheckCondition.TyphoonAirport.Contains(CancelItem.MidAirport))
                    {
                        DateTime TyphoonTime = DateTime.MinValue;
                        foreach (var item in CheckCondition.TyphoonList)
                        {
                            if (item.AirPort == CancelItem.MidAirport && item.TroubleType == "停机")
                            {
                                TyphoonTime = item.EndTime;
                                break;
                            }
                        }
                        if (ArrivalTime < TyphoonTime)
                        {
                            continue;
                        }
                    }
                    //联航不能分割
                    if (CancelItem.First.ComboAirline != null && !CancelItem.First.IsFirstCombinedVoyage)
                    {
                        continue;
                    }
                    if (CancelItem.Second.ComboAirline != null && CancelItem.Second.IsFirstCombinedVoyage)
                    {
                        continue;
                    }
                    var TakeOffEarlyTime = GapItem.LandTime.AddMinutes(Utility.StayAtAirPortMinutes);
                    if (TakeOffEarlyTime <= CancelItem.First.StartTime)
                    {
                        //取消组的开始时间暂时要求在50分钟之内
                        if (CancelItem.Second.EndTime.AddMinutes(Utility.StayAtAirPortMinutes) < GapItem.TakeOffTime)
                        {
                            //结束飞行后有充分的过站时间
                            Console.WriteLine("Cancel: " + CancelItem.PlaneID + " StartAirPort:" + CancelItem.StartAirPort + " MidAirPort:" + CancelItem.MidAirport + " " +
                                              CancelItem.First.StartTime + " " + CancelItem.Second.EndTime);
                            Console.WriteLine("Gap: " + GapItem.PlaneID + " StartAirPort:" + GapItem.AirportID + " " + GapItem.LandTime + " " + GapItem.TakeOffTime);
                        }
                    }
                    else
                    {
                        //允许延期
                        var CloneAirline = Utility.DeepCopy(Solution.PlaneIdAirlineDic[GapItem.PlaneID]);
                        //取消恢复后的可以挽回的分数:
                        var FixScore = CancelItem.ImportFac * Statistics.CancelAirlineParm;
                        //修改前分数
                        var GapBefore = Statistics.WriteResult(CloneAirline);
                        //添加取消项目到原列表中
                        var C1       = Utility.DeepCopy(CancelItem.First);
                        var C2       = Utility.DeepCopy(CancelItem.Second);
                        var TimeDiff = TakeOffEarlyTime.Subtract(CancelItem.First.StartTime);
                        C1.ModifiedStartTime = TakeOffEarlyTime;
                        C2.ModifiedStartTime = C1.ModifiedEndTime.AddMinutes(Utility.StayAtAirPortMinutes);
                        C1.FixMethod         = enmFixMethod.UnFixed;
                        C2.FixMethod         = enmFixMethod.UnFixed;
                        C1.ModifiedPlaneID   = GapItem.PlaneID;
                        C2.ModifiedPlaneID   = GapItem.PlaneID;
                        if (C2.ModifiedEndTime.AddMinutes(Utility.StayAtAirPortMinutes) > GapItem.TakeOffTime)
                        {
                            continue;
                        }
                        CloneAirline.Add(C1);
                        CloneAirline.Add(C2);
                        CloneAirline.Sort((x, y) => { return(x.ModifiedStartTime.CompareTo(y.ModifiedStartTime)); });
                        if (!CoreAlgorithm.AdjustAirLineList(CloneAirline))
                        {
                            continue;
                        }
                        var GapAfter = Statistics.WriteResult(CloneAirline);
                        var Decream  = FixScore - (GapAfter - GapBefore);
                        if (Decream > MaxScore)
                        {
                            MaxScore = Decream;
                            MaxIndex = j;
                        }
                    }
                }

                if (MaxIndex != -1)
                {
                    var GapItem = GapList[MaxIndex];
                    Console.WriteLine("Gap PlaneID:" + GapItem.PlaneID + " Max Score:" + MaxScore);
                    Console.WriteLine("Gap Land:" + GapItem.LandAirline.ToString());
                    Console.WriteLine("Gap Takeoff:" + GapItem.TakeoffAirLine.ToString());
                    var TakeOffEarlyTime = GapItem.LandTime.AddMinutes(Utility.StayAtAirPortMinutes);
                    CancelItem.First.ModifiedStartTime  = TakeOffEarlyTime;
                    CancelItem.Second.ModifiedStartTime = CancelItem.First.ModifiedEndTime.AddMinutes(Utility.StayAtAirPortMinutes);
                    CancelItem.First.ModifiedPlaneID    = GapItem.PlaneID;
                    CancelItem.Second.ModifiedPlaneID   = GapItem.PlaneID;
                    CancelItem.First.FixMethod          = enmFixMethod.UnFixed;
                    CancelItem.Second.FixMethod         = enmFixMethod.UnFixed;
                    Solution.PlaneIdAirlineDic[GapItem.PlaneID].Add(CancelItem.First);
                    Solution.PlaneIdAirlineDic[GapItem.PlaneID].Add(CancelItem.Second);
                    Solution.PlaneIdAirlineDic[GapItem.PlaneID].Sort((x, y) => { return(x.ModifiedStartTime.CompareTo(y.ModifiedStartTime)); });
                    CoreAlgorithm.AdjustAirLineList(Solution.PlaneIdAirlineDic[GapItem.PlaneID]);
                    Solution.GetAirlineDicByPlaneId();
                    GapItem.IsFilled = true;
                }
            }
        }