1 package geneticalgorithm;
2
3 public class Tour implements Comparable<Tour>{
4 private int [] tour;
5 private double distance;
6
7 public Tour(int [] t, double dist) {
8 tour = t;
9 distance = dist;
10 }
11
12 public int [] getTour() {
13 return tour;
14 }
15
16 public double getDistance() {
17 return distance;
18 }
19
20 public int compareTo(Tour other) {
22 if(distance == other.distance) {
23 return 0;
24 } else if(distance >= other.distance) {
25 return 1;
26 } else {
27 return -1;
28 }
29 }
30
31 }
32