Exemplo n.º 1
0
 public void InsertAfterTourStop(TourStop ts)
 {
     ts.Owner = this;
     if (currentTourstopIndex > -1 || currentTourstopIndex < TourStops.Count)
     {
         TourStops.Insert(currentTourstopIndex + 1, ts);
     }
     else
     {
         TourStops.Add(ts);
         currentTourstopIndex = tourStops.Count - 1;
     }
     TourDirty = true;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Insert Stop at least expensive edge of TourStops
        /// </summary>
        /// <param name="stopToAdd"></param>
        public void InsertAtLeastExpensiveEdge(Stop stopToAdd)
        {
            float currentMinInsertionCost = float.MaxValue;
            int   insertionIndexCandidate = -1;

            //Iterate through every pair of the tour eg 0+1,1+2..
            for (int i = 0; i < TourStops.Count - 1; i++)
            {
                var leftCandidate  = TourStops.ElementAt(i);
                var rightCandidate = TourStops.ElementAt(i + 1);

                var insertionCost = MinFunction(leftCandidate.Id, stopToAdd.Id, rightCandidate.Id);
                if (insertionCost < currentMinInsertionCost)
                {
                    currentMinInsertionCost = insertionCost;
                    insertionIndexCandidate = i + 1;
                }
            }

            TourStops.Insert(insertionIndexCandidate, stopToAdd);
        }