diff options
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo')
2 files changed, 35 insertions, 6 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/CpsMdeOptimiserMain.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/CpsMdeOptimiserMain.xtend index 628d5963..459c6ab7 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/CpsMdeOptimiserMain.xtend +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/CpsMdeOptimiserMain.xtend | |||
@@ -2,6 +2,11 @@ package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo | |||
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage | 3 | import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage |
4 | import hu.bme.mit.inf.dslreasoner.domains.cps.generator.CpsGenerator | 4 | import hu.bme.mit.inf.dslreasoner.domains.cps.generator.CpsGenerator |
5 | import java.io.BufferedReader | ||
6 | import java.io.BufferedWriter | ||
7 | import java.io.FileReader | ||
8 | import java.io.FileWriter | ||
9 | import java.util.Map | ||
5 | import org.eclipse.emf.common.util.URI | 10 | import org.eclipse.emf.common.util.URI |
6 | import org.eclipse.emf.ecore.EPackage | 11 | import org.eclipse.emf.ecore.EPackage |
7 | import org.eclipse.emf.ecore.resource.Resource | 12 | import org.eclipse.emf.ecore.resource.Resource |
@@ -21,11 +26,33 @@ class CpsMdeOptimiserMain { | |||
21 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, | 26 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, |
22 | new XMIResourceFactoryImpl) | 27 | new XMIResourceFactoryImpl) |
23 | EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE) | 28 | EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE) |
24 | val generator = new CpsGenerator(1, 4, 2) | 29 | val generator = new CpsGenerator(1, 4, 1) |
25 | val problem = generator.generateCpsProblem | 30 | val problem = generator.generateCpsProblem |
26 | problem.eResource.URI = URI.createFileURI(PROBLEM_PATH) | 31 | problem.eResource.URI = URI.createFileURI(PROBLEM_PATH) |
27 | problem.eResource.save(emptyMap) | 32 | problem.eResource.save(emptyMap) |
33 | fixupHenshinModel("model/cps.henshin", "model/cps_fixup.henshin", #{"cps.ecore" -> CpsPackage.eNS_URI}) | ||
28 | val injector = new MoptStandaloneSetup().createInjectorAndDoEMFRegistration(); | 34 | val injector = new MoptStandaloneSetup().createInjectorAndDoEMFRegistration(); |
29 | injector.getInstance(ExcludedRun).run(PROJECT_PATH, MOPT_PATH) | 35 | injector.getInstance(ExcludedRun).run(PROJECT_PATH, MOPT_PATH) |
30 | } | 36 | } |
37 | |||
38 | private def static void fixupHenshinModel(String originalPath, String outputPath, Map<String, String> remapMap) { | ||
39 | val reader = new BufferedReader(new FileReader(originalPath)) | ||
40 | try { | ||
41 | val writer = new BufferedWriter(new FileWriter(outputPath)) | ||
42 | try { | ||
43 | var String line | ||
44 | while ((line = reader.readLine) !== null) { | ||
45 | for (entry : remapMap.entrySet) { | ||
46 | line = line.replace(entry.key, entry.value) | ||
47 | } | ||
48 | writer.write(line) | ||
49 | writer.write("\n") | ||
50 | } | ||
51 | } finally { | ||
52 | writer.close | ||
53 | } | ||
54 | } finally { | ||
55 | reader.close | ||
56 | } | ||
57 | } | ||
31 | } | 58 | } |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/cps.mopt b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/cps.mopt index 4c05939d..67fe7508 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/cps.mopt +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/cps.mopt | |||
@@ -16,11 +16,13 @@ goal { | |||
16 | } | 16 | } |
17 | 17 | ||
18 | search { | 18 | search { |
19 | // mutate using <cps.henshin> unit "createAppInstance" | 19 | // mutate using <cps_fixup.henshin> unit "createAppInstance" |
20 | // mutate using <cps.henshin> unit "createHostInstance" | 20 | // mutate using <cps_fixup.henshin> unit "deleteAppInstance" |
21 | // mutate using <cps.henshin> unit "allocate" | 21 | // mutate using <cps_fixup.henshin> unit "createHostInstance" |
22 | // mutate using <cps.henshin> unit "deleteAppInstance" | 22 | // mutate using <cps_fixup.henshin> unit "deleteHostInstance" |
23 | // mutate using <cps.henshin> unit "unallocate" | 23 | // mutate using <cps_fixup.henshin> unit "allocate" |
24 | // mutate using <cps_fixup.henshin> unit "unallocate" | ||
25 | // mutate using <cps_fixup.henshin> unit "reallocate" | ||
24 | mutate { "ApplicationInstance" } | 26 | mutate { "ApplicationInstance" } |
25 | mutate { "HostInstance" } | 27 | mutate { "HostInstance" } |
26 | } | 28 | } |