-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetwork.java
More file actions
51 lines (41 loc) · 917 Bytes
/
Network.java
File metadata and controls
51 lines (41 loc) · 917 Bytes
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
package ga;
public class Network {
Routes[] tours;
public Network(int networkSize, boolean initialise)
{
tours = new Routes[networkSize];
if (initialise)
{
for (int i = 0; i < networkSize(); i++)
{
Routes newRoutes = new Routes();
newRoutes.generateIndividual();
saveRoutes(i, newRoutes);
}
}
}
public void saveRoutes(int index, Routes tour)
{
tours[index] = tour;
}
public Routes getRoutes(int index)
{
return tours[index];
}
public Routes getFittest()
{
Routes fittest = tours[0];
for (int i = 1; i < networkSize(); i++)
{
if (fittest.getFitness() <= getRoutes(i).getFitness())
{
fittest = getRoutes(i);
}
}
return fittest;
}
public int networkSize()
{
return tours.length;
}
}