/// <summary> /// GET THE FREQUENCIES /// Find the Disabled(Barrier) frequencies and save it in "SenderWithFrequencies List". /// </summary> private static void FindFrequencies() { // Temporal "tempSender Instance" for Frequencies comparation. Sender tempSender = new Sender(); foreach (Sender sender in SenderCollection.senderCollection) { if (sender.frequency == 0) { if (sender.disabled.Count > tempSender.disabled.Count) tempSender = sender; // Phase 1 --> Choose the Sender with the most Overlaps ( 1. die meisten Überschneidungen) else if (sender.overlaps.Count > tempSender.overlaps.Count) tempSender = sender; else if (sender.overlaps.Count == tempSender.overlaps.Count) { // Phase 2 --> Choose the Sender where X have the lowest coordinate ( 2. den westlichsten (kleinste x-Koordinate)) if (sender.x < tempSender.x) tempSender = sender; else if (sender.x == tempSender.x) { // Phase 3 --> Choose the Sender where Y have the lowest coordinate ( 3. den südlichsten (kleinste y-Koordinate)) if (sender.y < tempSender.y) tempSender = sender; } } } } for (int i = SenderIDCount; i > 0; i--) { // Get and Asing the most low Frequencie to the Sender if (!tempSender.disabled.Contains(i)) tempSender.frequency = i; } // Save the obteined frequencies in the "SenderwithFrequencies List". SenderCollection.SenderWithFrequencies.Add(tempSender); DisableFrequencies(tempSender.frequency, tempSender.overlaps); }
/// <summary> /// Read the Data from Text File. /// </summary> private static void Start() { Console.WriteLine("Please introduce the Path of the file and press ENTER"); ReadFile = new StreamReader(Console.ReadLine()); Console.WriteLine(Environment.NewLine); while (!ReadFile.EndOfStream) { string[] lines = ReadFile.ReadLine().Split(' '); if (Char.IsNumber(lines[0], 0)) { Sender sender = new Sender() { nr = SenderIDCount, x = double.Parse(lines[0], CultureInfo.InvariantCulture), y = double.Parse(lines[1], CultureInfo.InvariantCulture), r = double.Parse(lines[2], CultureInfo.InvariantCulture) }; SenderIDCount++; SenderCollection.senderCollection.Add(sender); } } CalculateOverlaps(); for (int i = 1; i != SenderIDCount; i++) FindFrequencies(); Output(); }