@@ -29,21 +29,22 @@ public class Main {
29
29
private static double START_LON ;
30
30
private static int START_NODE_ID ;
31
31
private static String VEHICLE ;
32
- private static String ENABLED_VEHICLES ;
33
32
34
33
// Graph variables
34
+ private static GraphHopper hopper ;
35
35
private static Graph graph ;
36
36
private static GraphUtils graphUtils ;
37
37
private static Weighting score ;
38
38
private static FlagEncoder flagEncoder ;
39
39
40
+ private static GRBEnv env ;
40
41
private static GRBModel model ;
41
42
private static GRBVar [] arcsFwd ;
42
43
private static GRBVar [] arcsBwd ;
43
44
private static int [] arcBaseIds ;
44
45
45
46
private static void setupSolver () throws GRBException {
46
- GRBEnv env = new GRBEnv ("osm.log" );
47
+ env = new GRBEnv ("osm.log" );
47
48
model = new GRBModel (env );
48
49
49
50
AllEdgesIterator edges = graph .getAllEdges ();
@@ -159,16 +160,20 @@ private static void runSolver() throws GRBException {
159
160
System .out .println ("Start position: " + START_LAT + ", " + START_LON + " (Node " + START_NODE_ID + ")" );
160
161
161
162
model .optimize ();
163
+
164
+ env .dispose ();
165
+ model .dispose ();
166
+ hopper .close ();
162
167
}
163
168
164
169
private static void loadOSM () {
165
170
System .out .println ("---- Starting GraphHopper ----" );
166
- GraphHopper hopper = new GraphHopperOSM ();
171
+ hopper = new GraphHopperOSM ();
167
172
hopper .setDataReaderFile (GRAPH_FILE );
168
173
hopper .setGraphHopperLocation (GRAPH_FOLDER );
169
174
hopper .forDesktop ();
170
175
171
- EncodingManager encodingManager = new EncodingManager (ENABLED_VEHICLES );
176
+ EncodingManager encodingManager = new EncodingManager (VEHICLE );
172
177
hopper .setEncodingManager (encodingManager );
173
178
hopper .setCHEnabled (false );
174
179
hopper .importOrLoad ();
@@ -220,10 +225,8 @@ private static void loadParams() {
220
225
START_LON = Double .parseDouble (properties .getProperty ("startLon" ));
221
226
MAX_COST = Double .parseDouble (properties .getProperty ("maxCost" ));
222
227
VEHICLE = properties .getProperty ("vehicle" );
223
- ENABLED_VEHICLES = VEHICLE ;
224
228
}
225
229
226
-
227
230
public static void main (String [] args ) {
228
231
loadParams ();
229
232
0 commit comments