-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadhoc_GA.java
More file actions
35 lines (26 loc) · 782 Bytes
/
adhoc_GA.java
File metadata and controls
35 lines (26 loc) · 782 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
package ga;
import java.io.*;
import java.util.Scanner;
public class adhoc_GA {
public static void main(String[] args) {
Test t = new Test();
Thread r = new Thread(t);
r.run();
long startTime = System.nanoTime();
Network net = new Network(50, true);
System.out.println("Initial distance: " + net.getFittest().getDistance());
net = GA.evolveNetwork(net);
for (int i = 0; i < 100; i++)
{
net = GA.evolveNetwork(net);
}
System.out.println("Finished");
System.out.println("Final distance: " + net.getFittest().getDistance());
System.out.println("Solution:");
System.out.println(net.getFittest());
long endTime = System.nanoTime();
long totalTime = endTime - startTime;
System.out.println(totalTime+" nanosecond");
System.out.println(totalTime/1000000000.0+" second");
}
}