-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.cs
More file actions
executable file
·77 lines (76 loc) · 2.06 KB
/
Map.cs
File metadata and controls
executable file
·77 lines (76 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System.IO;
namespace GeneticAlgorithm4TSP
{
class Map
{
public static double intervalX;
public static double intervalY;
public static City[] Cities { get; set; }
public static void PickMap(string filename, int Size)
{
Cities = new City[Size];
using (TextReader reader = File.OpenText(filename))
{
string text;
for (int i = 0; i < Size; i++)
{
text = reader.ReadLine();
string[] cordinates = text.Split(' ');
double x = double.Parse(cordinates[0]);
double y = double.Parse(cordinates[1]);
Cities[i] = new City(x, y, i);
}
}
intervalX = maxX() - minX() / 5;
intervalY = maxY() - minY() / 5;
}
public static double minX()
{
double x = Cities[0].x;
for (int i = 1; i < GA.numCities; i++)
{
if (Cities[i].x < x)
{
x = Cities[i].x;
}
}
return x;
}
public static double minY()
{
double y = Cities[0].y;
for (int i = 1; i < GA.numCities; i++)
{
if (Cities[i].y < y)
{
y = Cities[i].y;
}
}
return y;
}
public static double maxX()
{
double x = Cities[0].x;
for (int i = 1; i < GA.numCities; i++)
{
if (Cities[i].x > x)
{
x = Cities[i].x;
}
}
return x;
}
public static double maxY()
{
double y = Cities[0].y;
for (int i = 1; i < GA.numCities; i++)
{
if (Cities[i].y > y)
{
y = Cities[i].y;
}
}
return y;
}
}
}