Ejemplo n.º 1
0
        /// <summary>
        /// Sorts the chromosome by future trip time
        /// </summary>
        private void SortChromosome()
        {
            var genes = GetGenes();

            //var _ = genes.ToList().OrderBy( e => ((Gene) e.Value).Aircraft.GetNextFlightTime).ToArray();

            //var _ = genes.ToList().OrderBy( e => ((Gene) e.Value).Aircraft.GetNextFlightTime()).ToArray();

            for (var i = 0; i < genes.Length; i++)
            {
                Airport.Runway rnw = null;
                var            firstGroupRunway  = new Airport.Runway[] { _airport.Runways["10L"], _airport.Runways["10R"] };
                var            secondGroupRunway = new Airport.Runway[] { _airport.Runways["28L"], _airport.Runways["28R"] };

                if (i < 7)
                {
                    rnw = firstGroupRunway[rnd.Next(firstGroupRunway.Length)];
                }
                else if (i >= 7 && i < 14)
                {
                    rnw = secondGroupRunway[rnd.Next(secondGroupRunway.Length)];
                }
                else if (i >= 14 && i < 20)
                {
                    rnw = firstGroupRunway[rnd.Next(firstGroupRunway.Length)];
                }
                else if (i >= 20 && i < 45)
                {
                    rnw = secondGroupRunway[rnd.Next(secondGroupRunway.Length)];
                }

                ((Gene)genes[i].Value).SetRunway(rnw);
            }

            ReplaceGenes(0, genes);
        }
Ejemplo n.º 2
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     foreach (Way way in airport.ways)
     {
         if(way is Runway && way.name.Equals(runwaybox.SelectedItem.ToString()))
         {
             selectedRunway = (Runway) way;
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the distance between airport and aircraft
        /// </summary>
        /// <returns>Distance in KM to the airport</returns>
        public double GetDistanceToAirport(Airport.Runway r)
        {
            var distanceToApproachRoad = r.Loc.Distance(location);

            return(distanceToApproachRoad + r.ApproachDistance);
        }