Repository navigation
Expand file tree
/
Copy pathMDPExperiment.java
More file actions
61 lines (46 loc) · 2.28 KB
/
Copy pathMDPExperiment.java
File metadata and controls
61 lines (46 loc) · 2.28 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
package mdp;
import java.io.IOException;
import jmh.algorithm.Objective;
import jmh.algorithm.Solution;
import jmh.experiment.ExperimentManager;
import jmh.instance.FormatException;
import mdp.algorithm.ScatterSearch;
import mdp.algorithm.ScatterSearch.SSConfig;
import mdp.algorithm.constructive.RandomConstructive;
import mdp.instance.MDPInstance;
import mdp.instance.MDPInstancesManager;
/**
* Runs the Maximum Diversity experiment: for the first instances it compares a
* random constructive against three Scatter Search configurations and reports
* the results. MDP is a maximization problem.
*
* <p>Unlike the three "simple" problems, MDP is solved with Scatter Search
* (its own algorithm stack), not the shared multi-start local search. What it
* reuses from the framework is the instance layer, the {@link Objective} and the
* {@link ExperimentManager}.
*
* <p>(In {@code no-shared-code} this entry point declared {@code main} as an
* instance method, so it could not be launched directly; here it is a proper
* {@code static} entry point.)
*/
public class MDPExperiment {
private static final long TIMEOUT_MILLIS = 2 * 1000;
public static void main(String[] args) throws IOException, FormatException {
var instancesManager = new MDPInstancesManager();
var instances = instancesManager.getInstances(0, 2);
var manager = new ExperimentManager(Objective.MAXIMIZE);
for (var instanceFile : instances) {
MDPInstance instance = instanceFile.loadInstance();
Solution solution;
solution = new RandomConstructive(instance).createSolution(TIMEOUT_MILLIS);
manager.addSolution(instance, "Random Constructive", solution);
solution = new ScatterSearch(instance, SSConfig.WITHOUT_INF).createSolution(TIMEOUT_MILLIS);
manager.addSolution(instance, "SS without Information", solution);
solution = new ScatterSearch(instance, SSConfig.WITH_INF).createSolution(TIMEOUT_MILLIS);
manager.addSolution(instance, "SS with Information", solution);
solution = new ScatterSearch(instance, SSConfig.WITH_MEMORY).createSolution(TIMEOUT_MILLIS);
manager.addSolution(instance, "SS with Memory", solution);
}
manager.experimentFinished();
}
}