|
27 | 27 |
|
28 | 28 | public class ListCompression extends Chromosome<ListCompression> {
|
29 | 29 |
|
| 30 | +private static final List<String> ORIGINAL_LIST = List.of("Michael", "Sarah", "Joshua", "Narine", |
| 31 | +"David", "Sajid", "Melanie", "Daniel", "Wei", "Dean", "Brian", "Murat", "Lisa"); |
30 | 32 | private List<String> myList;
|
31 | 33 | private Random random;
|
32 | 34 |
|
@@ -36,8 +38,7 @@ public ListCompression(List<String> list) {
|
36 | 38 | }
|
37 | 39 |
|
38 | 40 | public static ListCompression randomInstance() {
|
39 |
| -ArrayList<String> tempList = new ArrayList<>(List.of("Michael", "Sarah", "Joshua", "Narine", "David", "Sajid", |
40 |
| -"Melanie", "Daniel", "Wei", "Dean", "Brian", "Murat", "Lisa")); |
| 41 | +ArrayList<String> tempList = new ArrayList<>(ORIGINAL_LIST); |
41 | 42 | Collections.shuffle(tempList);
|
42 | 43 | return new ListCompression(tempList);
|
43 | 44 | }
|
@@ -96,9 +97,7 @@ public String toString() {
|
96 | 97 | }
|
97 | 98 |
|
98 | 99 | public static void main(String[] args) {
|
99 |
| -ListCompression originalOrder = new ListCompression( |
100 |
| -List.of("Michael", "Sarah", "Joshua", "Narine", "David", "Sajid", |
101 |
| -"Melanie", "Daniel", "Wei", "Dean", "Brian", "Murat", "Lisa")); |
| 100 | +ListCompression originalOrder = new ListCompression(ORIGINAL_LIST); |
102 | 101 | System.out.println(originalOrder);
|
103 | 102 | ArrayList<ListCompression> initialPopulation = new ArrayList<>();
|
104 | 103 | final int POPULATION_SIZE = 100;
|
|
0 commit comments