-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHH_Runner_Visual.java
More file actions
87 lines (65 loc) · 2.46 KB
/
Copy pathHH_Runner_Visual.java
File metadata and controls
87 lines (65 loc) · 2.46 KB
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
package com.aim.project.ssp.runners;
import java.awt.Color;
import com.aim.project.ssp.SightseeingProblemDomain;
import com.aim.project.ssp.instance.Location;
import com.aim.project.ssp.solution.SSPSolution;
import com.aim.project.ssp.visualiser.SSPView;
import AbstractClasses.HyperHeuristic;
/**
* @author Warren G. Jackson
* @since 17/03/2025
*
* Runs a hyper-heuristic using a default configuration then displays the best solution found.
*/
public abstract class HH_Runner_Visual {
public HH_Runner_Visual() {
}
public void run() {
long seed = 17032025L;
long timeLimit = 346000L; // 5 Nominal Minutes according to the benchmark
SightseeingProblemDomain problem = new SightseeingProblemDomain(seed);
// Run a Set Instance
problem.loadInstance(0);
problem.printObjectiveValueOfTheInitialSolution();
problem.printInitialSolution();
// Show the initial solution
new SSPView(problem.m_oInstance, problem, Color.WHITE, Color.gray);
// Run the HH
HyperHeuristic hh = getHyperHeuristic(seed);
hh.setTimeLimit(timeLimit);
hh.loadProblemDomain(problem);
hh.run();
System.out.println("f(s_best) = " + hh.getBestSolutionValue());
problem.printBestSolutionFound();
// Show the best solution
new SSPView(problem.m_oInstance, problem, Color.WHITE, Color.GREEN);
// Run HH for all instances
/*for (int i = 0; i < problem.getNumberOfInstances(); i++) {
problem.loadInstance(i);
System.out.println("Current Instance: " + i);
problem.printObjectiveValueOfTheInitialSolution();
// Show the initial solution
new SSPView(problem.m_oInstance, problem, Color.WHITE, Color.gray);
// Run the HH
HyperHeuristic hh = getHyperHeuristic(seed);
hh.setTimeLimit(timeLimit);
hh.loadProblemDomain(problem);
hh.run();
System.out.println("f(s_best) = " + hh.getBestSolutionValue());
// Show the best solution
new SSPView(problem.m_oInstance, problem, Color.WHITE, Color.GREEN);
}*/
}
/**
* Transforms the best solution found, represented as an SSPSolution, into an ordering of Location's
* which the visualiser tool uses to draw the tour.
*/
protected Location[] transformSolution(SSPSolution solution, SightseeingProblemDomain problem) {
return problem.getRouteOrderedByLocations();
}
/**
* Allows a general visualiser runner by making the HyperHeuristic abstract.
* You can sub-class this class to run any hyper-heuristic that you want.
*/
protected abstract HyperHeuristic getHyperHeuristic(long seed);
}