-
Notifications
You must be signed in to change notification settings - Fork 0
/
Configuration.java
115 lines (93 loc) · 3.08 KB
/
Configuration.java
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//testing github branch
package CVRP;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
// The values here are overwritten if a configuration file is given.
public class Configuration {
public static int EMPLOYED_BEE_NUM =25;//25
public static int ONLOOKER_BEE_NUM=25;
public static int ITERATION_LIM=12450;//249*50=12450
public static long EPOCH_LIM=2000000000;
public static int RUNTIME_LIM=60;//minute
public static double ALPHA = 300;//weight for the violation of capacity in the fitness function
public static int CAPACITY_REDUNDANCY =0;
public static double RANDOM_EXPLORE_RATE=0.5;//0.5
public static double INSERT_DEPOT_RATE=0.1;//25
public static double REMOVE_DEPOT_RATE=0.3;
public Configuration(String fileName) {
try {
FileReader fr = new FileReader(fileName);
BufferedReader br = new BufferedReader(fr);
String line;
while ((line = br.readLine()) != null) {
String[] lineSplit = line.split("=");
try {
if (lineSplit[0].equals("EMPLOYED_BEE_NUM")) {
EMPLOYED_BEE_NUM = Integer.parseInt(lineSplit[1]);
} else if (lineSplit[0].equals("ONLOOKER_BEE_NUM")) {
ONLOOKER_BEE_NUM = Integer.parseInt(lineSplit[1]);
} else if (lineSplit[0].equals("ITERATION_LIM")) {
ITERATION_LIM = Integer.parseInt(lineSplit[1]);
} else if (lineSplit[0].equals("EPOCH_LIM")) {
EPOCH_LIM = Long.parseLong(lineSplit[1]);
} else {
printError(line);
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
br.close();
} catch (IOException e) {
System.out.println("Could not read config file");
}
}
// Default configuration
public Configuration() {
}
private void printError(String line) {
System.out.println("Error reading config file. " + line + " not understood");
}
/*
public boolean getGraphics() {
return graphics;
}
public int getMaxJourneys() {
return maxJourneys;
}
public int getMaxGenerations() {
return maxGenerations;
}
public int getPopulationSize() {
return populationSize;
}
public int getMaxSwaps() {
return maxSwaps;
}
public double getCrossoverRate() {
return crossoverRate;
}
public double getMutationRate() {
return mutationRate;
}
public double getMixRate() {
return mixRate;
}
public double getMoveRate() {
return moveRate;
}
public int getSearchLength() {
return searchLength;
}
public boolean getNearestNeighbour() {
return nearestNeighbour;
}
public int getGenerationsBeforeReset() {
return generationsBeforeReset;
}
public long getMaxTime() {
return maxTime;
}
*/
}