-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHyFlexRunner.java
More file actions
94 lines (82 loc) · 3.3 KB
/
Copy pathHyFlexRunner.java
File metadata and controls
94 lines (82 loc) · 3.3 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
88
89
90
91
92
93
94
package runner.examples;
import AbstractClasses.ProblemDomain;
import BinPacking.BinPacking;
import FlowShop.FlowShop;
import PersonnelScheduling.PersonnelScheduling;
import SAT.SAT;
import VRP.VRP;
import dynheurset.DynHeurSet;
import dynheurset.RunStat;
import dynheurset.measure.ImprMeasure;
import dynheurset.measure.Measure;
import dynheurset.update.PhaseDominanceUpdate;
import dynheurset.update.Update;
import dynheurset.update.remove.NoRemove;
import dynheurset.update.remove.Remove;
import dynheurset.update.reset.NoReset;
import dynheurset.update.reset.Reset;
import hyperheuristic.HyperHeuristicIntrf;
import hyperheuristic.examples.hyflex.HyFlexExampleHyperHeuristic1;
import runner.GenericRunner;
import travelingSalesmanProblem.TSP;
/**
* A subclass of <code>GenericRunner</code> that is used to create:
* <ul>
* <li>A hyper-heuristic
* <li>A problem that will be solved by the hyper-heuristic
* <li>A dynamic set to integrate into the hyper-heuristic
* </ul>
* <p>
* The class uses HyFlex and creates one dynamic set to manage all low-level
* heuristics regardless of their type.
* In {@link HyFlexRunner2}, two dynamic sets are used. One for managing the
* perturbative heuristics and the other one for managing the local searches.
*
* @see HyFlexRunner2
* @author Ahmed Hassan (ahmedhassan@aims.ac.za)
*/
public class HyFlexRunner extends GenericRunner{
protected final long timeLimit;
public HyFlexRunner(long seed, long timeLimit){
super(seed);
this.timeLimit = timeLimit;
}
@Override
protected ProblemDomain createHyFlexProblem() {
//create a ProblemDomain object with a seed for the random number generator
//ProblemDomain problem = new SAT(rng.nextLong()); //boolean satisfiability
/* Uncomment on of the following line if you want to play with another problem */
//ProblemDomain problem = new BinPacking(rng.nextLong()); //bin packing
//ProblemDomain problem = new PersonnelScheduling(rng.nextLong()); //personnel scheduling
//ProblemDomain problem = new FlowShop(rng.nextLong()); //permutation flow shop
//ProblemDomain problem = new TSP(rng.nextLong()); //traveling salesman
ProblemDomain problem = new VRP(rng.nextLong()); //vehicle routing
//Load a problem instance to solve
problem.loadInstance(5);
return problem;
}
@Override
protected HyperHeuristicIntrf createHyperHeuristic() {
HyperHeuristicIntrf hyperHeur = new HyFlexExampleHyperHeuristic1(rng.nextLong());
hyperHeur.setTimeLimit(timeLimit);
return hyperHeur;
}
@Override
protected DynHeurSet createDynHeurSet() {
RunStat runStat = new RunStat();
DynHeurSet dynSet = new DynHeurSet();
dynSet.setRunStat(runStat);
//Create an update strategy
Update update = new PhaseDominanceUpdate(100);
update.setRunStat(runStat);
Measure measure = new ImprMeasure();
update.setMeasure(measure);
Remove remove = new NoRemove();
update.setRemove(remove);
Reset reset = new NoReset();
update.setReset(reset);
//Now, our update strategy is all set, load it into the dynamic set
dynSet.setUpdate(update);
return dynSet;
}
}