diff options
Diffstat (limited to 'Metrics/Metrics-Calculation/RealisticRunner/src/ca/mcgill/dslreasoner/runner/Main.java')
-rw-r--r-- | Metrics/Metrics-Calculation/RealisticRunner/src/ca/mcgill/dslreasoner/runner/Main.java | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Metrics/Metrics-Calculation/RealisticRunner/src/ca/mcgill/dslreasoner/runner/Main.java b/Metrics/Metrics-Calculation/RealisticRunner/src/ca/mcgill/dslreasoner/runner/Main.java new file mode 100644 index 00000000..12492645 --- /dev/null +++ b/Metrics/Metrics-Calculation/RealisticRunner/src/ca/mcgill/dslreasoner/runner/Main.java | |||
@@ -0,0 +1,77 @@ | |||
1 | package ca.mcgill.dslreasoner.runner; | ||
2 | |||
3 | import java.io.File; | ||
4 | import java.io.IOException; | ||
5 | import java.util.Arrays; | ||
6 | import java.util.Collections; | ||
7 | import java.util.List; | ||
8 | import java.util.logging.Level; | ||
9 | |||
10 | import org.eclipse.emf.common.util.URI; | ||
11 | import org.eclipse.emf.ecore.EObject; | ||
12 | import org.eclipse.emf.ecore.impl.EcorePackageImpl; | ||
13 | import org.eclipse.emf.ecore.resource.Resource; | ||
14 | import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; | ||
15 | import org.eclipse.emf.ecore.xmi.XMIResource; | ||
16 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine; | ||
17 | |||
18 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app.Domain; | ||
19 | import fr.inria.atlanmod.instantiator.GenerationException; | ||
20 | import fr.obeo.emf.specimen.SpecimenGenerator; | ||
21 | import github.impl.GithubPackageImpl; | ||
22 | import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl.YakindummPackageImpl; | ||
23 | |||
24 | public class Main { | ||
25 | public static void main(String[] args) throws IllegalArgumentException, GenerationException, IOException { | ||
26 | Domain d = Domain.valueOf(args[0]); | ||
27 | |||
28 | org.apache.log4j.Logger.getRootLogger(); | ||
29 | RandomEMFRunner.LOGGER.setLevel(Level.OFF); | ||
30 | SpecimenGenerator.LOGGER.setLevel(Level.OFF); | ||
31 | ReteEngine.class.getClass(); | ||
32 | |||
33 | if(d == Domain.Yakindumm){ | ||
34 | YakindummPackageImpl.eINSTANCE.eClass(); | ||
35 | }else if (d == Domain.Ecore){ | ||
36 | EcorePackageImpl.eINSTANCE.eClass(); | ||
37 | }else if (d == Domain.Github){ | ||
38 | GithubPackageImpl.eINSTANCE.eClass(); | ||
39 | } | ||
40 | |||
41 | |||
42 | |||
43 | long start = System.nanoTime(); | ||
44 | BestKRunner bestSelectorRunner = new BestKRunner(100, 3600000, d, 100); | ||
45 | IGeneratorRunner runner = args[1].equals("RandomEMF")?new RandomEMFRunner(Arrays.copyOfRange(args, 2, args.length)) : new ViatraRunner(args[2], args[3]); | ||
46 | bestSelectorRunner.setRunner(runner); | ||
47 | |||
48 | List<EObject> roots = bestSelectorRunner.generate(); | ||
49 | System.out.println((System.nanoTime() - start) / 1000000); | ||
50 | |||
51 | |||
52 | |||
53 | ResourceSetImpl resourceSet = new ResourceSetImpl(); | ||
54 | System.out.println("Size is " + roots.size()); | ||
55 | for(int i = 0; i < roots.size(); i++) { | ||
56 | System.out.println(i); | ||
57 | Resource resource = resourceSet.createResource(formatURI("output/" + args[1] + "/", d.toString(), 30, i)); | ||
58 | resource.getContents().add(roots.get(i)); | ||
59 | resource.save(Collections.emptyMap()); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | protected static URI formatURI(String path, String modelPrefix, long maxElement, int index) { | ||
64 | StringBuilder builder = new StringBuilder(); | ||
65 | builder.append(path); | ||
66 | builder.append(File.separator); | ||
67 | builder.append(modelPrefix); | ||
68 | builder.append(File.separator); | ||
69 | builder.append("result"); | ||
70 | builder.append(maxElement); | ||
71 | builder.append("_"); | ||
72 | builder.append(index); | ||
73 | builder.append("."); | ||
74 | builder.append(XMIResource.XMI_NS);; | ||
75 | return URI.createFileURI(builder.toString()); | ||
76 | } | ||
77 | } | ||