-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExperimentMiner.java
More file actions
76 lines (66 loc) · 3.2 KB
/
ExperimentMiner.java
File metadata and controls
76 lines (66 loc) · 3.2 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
package com.vincentderk.acircuitminer.experiments.benchmarks;
import com.vincentderk.acircuitminer.miner.util.Utils;
import com.google.common.base.Stopwatch;
import com.vincentderk.acircuitminer.miner.Graph;
import com.vincentderk.acircuitminer.miner.Miner;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
/**
* {@link Miner Mining experiment} as shown in the results of the paper and scientific article.
*
* @author Vincent Derkinderen
* @version 2.0
*/
public class ExperimentMiner {
/**
*
* @param args the command line arguments
* @throws java.io.FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException, IOException {
System.out.println("Running ExperimentMiner");
boolean verbose = true;
String basePath = "D://Thesis//Nets Benchmark//";
//String basePath = "D://Thesis//Nets//";
String ac = "hailfinder";
String path = basePath + ac + ".net.ac";
int[] k = {17};
int maxPorts = 16;
int xBest = 10;
// Load graph
Stopwatch stopwatch = Stopwatch.createStarted();
Graph g = Utils.readACStructure(new FileReader(path));
System.out.printf("Graph loaded in %s msecs.\n", stopwatch.elapsed(TimeUnit.MILLISECONDS));
// Find patterns
stopwatch.reset().start();
Miner.executeRaw(g, k, verbose, maxPorts, xBest); //executeRaw() does not remove the overlap, execute() does
System.out.printf("Executed total algorithm (excl. graph loading) in %s secs.\n", stopwatch.elapsed(TimeUnit.SECONDS));
//Replace best in-place.
/*stopwatch.reset().start();
System.out.println("Replacing " + EdgeCanonical.printCode(best.getKey()) + " with " + best.getValue().size() + " occurrences.");
IntArrayList ignore = OperationUtils.replace(g, best.getKey(), best.getValue(), (short) (Graph.HIGHEST_OP+1));
System.out.println("Estimated savings of " + patternProfit(best.getKey(), best.getValue()));
System.out.printf("Replaced best in %s secs.\n", stopwatch.elapsed(TimeUnit.SECONDS));*/
//Write
/*stopwatch.reset().start();
String outPath = basePath + ac + "New.net.ac";
FileWriter writer = new FileWriter(outPath);
HashMap<Short, String> symbols = new HashMap();
symbols.put(Graph.PRODUCT, "*");
symbols.put(Graph.SUM, "+");
symbols.put(Graph.INPUT, "l");
symbols.put((short) 3, "n");
Int2IntMap literalMap = Utils.getLiteralMap(new FileReader(path));
OperationUtils.write(g, writer, ignore, symbols, literalMap);
System.out.printf("Wrote result in %s secs.\n", stopwatch.elapsed(TimeUnit.SECONDS));*/
//Write pattern
/*stopwatch.reset().start();
Graph patternGraph = OperationUtils.codeToGraph(best.getKey());
String patternPath = basePath + ac + "Pattern.net.ac";
writer = new FileWriter(patternPath);
OperationUtils.writePatternGraph(writer, patternGraph, new IntArrayList(), symbols);
System.out.printf("Wrote pattern in %s secs.\n", stopwatch.elapsed(TimeUnit.SECONDS));*/
}
}