コード例 #1
0
 public int getInstantionScore()
 {
     return(firstMachine.GetLastEndTime() + secondMachine.GetLastEndTime());
 }
コード例 #2
0
 private void FillSecondMachine(ArrayList secondMachineTasks, ArrayList secondMachineTempMaintance, Machine secondMachine, ArrayList firstMachineTasks, bool usingTable, int tableEl, AcoMaster ACO)
 {
     if (usingTable == true)
     {
         Random rnd = new Random();
         while (secondMachineTasks.Count > 0)
         {
             TimeSpan span      = new TimeSpan(0, 0, 0);
             TimeSpan perc      = (span = DateTime.Now - MyTimer.Start);
             double   ft        = span.Seconds;
             double   sc        = ACO.endVar.Seconds + (60 * ACO.endVar.Minutes);
             int      holder    = (int)((ft / sc) * 100);
             int      roultette = rnd.Next(0, 100);
             int      pos       = 0;
             if (roultette < holder)
             {
                 int a    = secondMachine.GetLastElementID();
                 int take = WhichElementIShouldTake(ACO.arrx2, a);
                 if (IsPossibleToTakeFromList(secondMachineTasks, take) == true)
                 {
                     pos = GetPositionAtList(take, secondMachineTasks);
                 }
                 else
                 {
                     take = WhichElementIShouldTake(ACO.arrx2, a);
                     if (IsPossibleToTakeFromList(secondMachineTasks, take) == true)
                     {
                         pos = GetPositionAtList(take, secondMachineTasks);
                     }
                     else
                     {
                         pos = 0;
                     }
                 }
             }
             else
             {
                 pos = 0;
             }
             Entity element = (Entity)secondMachineTasks[pos];
             bool   added   = false;
             while (!added)
             {
                 if (GetEndTimeOfPair(firstMachine.getMachineList(), element.GetOperationID()) < secondMachine.GetLastEndTime())
                 {
                     if (secondMachineTempMaintance.Count != 0 && getTimeOfNextMaintance(secondMachineTempMaintance) <= (secondMachine.GetLastEndTime() + element.GetTime()))
                     {
                         Entity maint = (Entity)secondMachineTempMaintance[0];
                         if (maint.GetStartTime() > secondMachine.GetLastEndTime())
                         {
                             Entity idle = new Entity(2, 0, 0, 1, 0, 0, 0);
                             idle.SetStartTime(secondMachine.GetLastEndTime() + 1);
                             idle.SetTime(maint.GetStartTime() - secondMachine.GetLastEndTime());
                             idle.SetEndTime(idle.GetStartTime() + idle.GetTime());
                             secondMachine.AddElement(idle);
                         }
                         secondMachine.AddElement(maint);
                         secondMachineTempMaintance.Remove(maint);
                     }
                     else
                     {
                         element.SetStartTime(secondMachine.GetLastEndTime() + 1);
                         element.SetEndTime(element.GetStartTime() + element.GetTime());
                         secondMachine.AddElement(element);
                         secondMachineTasks.Remove(element);
                         added = true;
                     }
                 }
                 else
                 {
                     if (secondMachineTempMaintance.Count != 0 &&
                         getTimeOfNextMaintance(secondMachineTempMaintance) < (element.GetTime() + GetEndTimeOfPair(firstMachine.getMachineList(), element.GetOperationID())))
                     {
                         Entity maint = (Entity)secondMachineTempMaintance[0];
                         if (maint.GetStartTime() > secondMachine.GetLastEndTime())
                         {
                             Entity idle = new Entity(2, 0, 0, 1, 0, 0, 0);
                             idle.SetStartTime(secondMachine.GetLastEndTime() + 1);
                             idle.SetTime(maint.GetStartTime() - secondMachine.GetLastEndTime());
                             idle.SetEndTime(idle.GetStartTime() + idle.GetTime());
                             secondMachine.AddElement(idle);
                         }
                         element.SetStartTime(secondMachine.GetLastEndTime() + 1);
                         element.SetEndTime(element.GetStartTime() + element.GetTime());
                         secondMachine.AddElement(maint);
                         secondMachineTempMaintance.Remove(maint);
                     }
                     else
                     {
                         if (GetEndTimeOfPair(firstMachine.getMachineList(), element.GetOperationID()) > secondMachine.GetLastEndTime())
                         {
                             Entity idle = new Entity(2, 0, 0, 1, 0, 0, 0);
                             idle.SetStartTime(secondMachine.GetLastEndTime() + 1);
                             idle.SetTime(GetEndTimeOfPair(firstMachine.getMachineList(), element.GetOperationID()) - secondMachine.GetLastEndTime());
                             idle.SetEndTime(idle.GetStartTime() + idle.GetTime());
                             secondMachine.AddElement(idle);
                         }
                         element.SetStartTime(secondMachine.GetLastEndTime() + 1);
                         element.SetEndTime(element.GetStartTime() + element.GetTime());
                         secondMachine.AddElement(element);
                         secondMachineTempMaintance.Remove(element);
                         added = true;
                     }
                 }
             }
         }
     }
     else
     {
     }
 }