diff options
author | 2019-06-09 15:13:00 -0400 | |
---|---|---|
committer | 2019-06-09 15:13:00 -0400 | |
commit | cd63ccf6fba2a812a9b115635bbd209c92cebad0 (patch) | |
tree | 6f2a04b6fd274dffe6bb72c1afdf87989c0ba6db /Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo | |
parent | Simplify satellite metamodel further (diff) | |
download | VIATRA-Generator-cd63ccf6fba2a812a9b115635bbd209c92cebad0.tar.gz VIATRA-Generator-cd63ccf6fba2a812a9b115635bbd209c92cebad0.tar.zst VIATRA-Generator-cd63ccf6fba2a812a9b115635bbd209c92cebad0.zip |
Bump MDEOptimizer version
https://github.com/mde-optimiser/mde_optimiser/issues/49
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo')
2 files changed, 2 insertions, 88 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 459c6ab7..4a4b7a87 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 | |||
@@ -11,7 +11,7 @@ import org.eclipse.emf.common.util.URI | |||
11 | import org.eclipse.emf.ecore.EPackage | 11 | import org.eclipse.emf.ecore.EPackage |
12 | import org.eclipse.emf.ecore.resource.Resource | 12 | import org.eclipse.emf.ecore.resource.Resource |
13 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | 13 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl |
14 | import uk.ac.kcl.inf.mdeoptimiser.languages.MoptStandaloneSetup | 14 | import uk.ac.kcl.inf.mdeoptimiser.interfaces.cli.Run |
15 | 15 | ||
16 | class CpsMdeOptimiserMain { | 16 | class CpsMdeOptimiserMain { |
17 | static val PROJECT_PATH = "." | 17 | static val PROJECT_PATH = "." |
@@ -31,8 +31,7 @@ class CpsMdeOptimiserMain { | |||
31 | problem.eResource.URI = URI.createFileURI(PROBLEM_PATH) | 31 | problem.eResource.URI = URI.createFileURI(PROBLEM_PATH) |
32 | problem.eResource.save(emptyMap) | 32 | problem.eResource.save(emptyMap) |
33 | fixupHenshinModel("model/cps.henshin", "model/cps_fixup.henshin", #{"cps.ecore" -> CpsPackage.eNS_URI}) | 33 | fixupHenshinModel("model/cps.henshin", "model/cps_fixup.henshin", #{"cps.ecore" -> CpsPackage.eNS_URI}) |
34 | val injector = new MoptStandaloneSetup().createInjectorAndDoEMFRegistration(); | 34 | Run.main(#["-p", PROJECT_PATH, "-m", MOPT_PATH]) |
35 | injector.getInstance(ExcludedRun).run(PROJECT_PATH, MOPT_PATH) | ||
36 | } | 35 | } |
37 | 36 | ||
38 | private def static void fixupHenshinModel(String originalPath, String outputPath, Map<String, String> remapMap) { | 37 | private def static void fixupHenshinModel(String originalPath, String outputPath, Map<String, String> remapMap) { |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/ExcludedOptimisationInterpreter.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/ExcludedOptimisationInterpreter.xtend deleted file mode 100644 index 1e9c5adf..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/ExcludedOptimisationInterpreter.xtend +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo | ||
2 | |||
3 | import java.util.Properties | ||
4 | import org.moeaframework.Executor | ||
5 | import org.moeaframework.Instrumenter | ||
6 | import org.moeaframework.algorithm.PeriodicAction | ||
7 | import org.moeaframework.core.TerminationCondition | ||
8 | import org.moeaframework.core.spi.AlgorithmFactory | ||
9 | import uk.ac.kcl.inf.mdeoptimiser.interfaces.cli.Run | ||
10 | import uk.ac.kcl.inf.mdeoptimiser.languages.mopt.Optimisation | ||
11 | import uk.ac.kcl.inf.mdeoptimiser.languages.mopt.SolverSpec | ||
12 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.OptimisationInterpreter | ||
13 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.executor.SolutionGenerator | ||
14 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.moea.MoeaOptimisation | ||
15 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.moea.algorithms.MoeaOptimisationAlgorithmProvider | ||
16 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.moea.instrumentation.PopulationCollector | ||
17 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.moea.problem.MoeaOptimisationProblem | ||
18 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.operators.adaptation.MutationStepSizeStrategyFactory | ||
19 | import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.output.MDEOBatch | ||
20 | |||
21 | class ExcludedMoeaOptimisation extends MoeaOptimisation { | ||
22 | SolutionGenerator solutionGenerator | ||
23 | Instrumenter algorithmStepSizeInstrumenter | ||
24 | |||
25 | override execute(SolverSpec solverSpec, SolutionGenerator solutionGenerator) { | ||
26 | this.solutionGenerator = solutionGenerator | ||
27 | super.execute(solverSpec, solutionGenerator) | ||
28 | } | ||
29 | |||
30 | override Instrumenter runOptimisation(SolverSpec solverSpec, Properties optimisationProperties) { | ||
31 | val algorithmFactory = new AlgorithmFactory | ||
32 | algorithmFactory.addProvider(new MoeaOptimisationAlgorithmProvider) | ||
33 | |||
34 | algorithmStepSizeInstrumenter = new Instrumenter().addExcludedPackage("org.eclipse").withProblemClass( | ||
35 | MoeaOptimisationProblem, solutionGenerator).attachApproximationSetCollector().attachElapsedTimeCollector(). | ||
36 | attachPopulationSizeCollector.attach(new PopulationCollector()).withFrequency(1).withFrequencyType( | ||
37 | PeriodicAction.FrequencyType.STEPS) | ||
38 | |||
39 | var stepSizeStrategy = new MutationStepSizeStrategyFactory(solverSpec.algorithm, algorithmStepSizeInstrumenter). | ||
40 | strategy | ||
41 | |||
42 | solutionGenerator.setMutationStepSizeStrategy(stepSizeStrategy) | ||
43 | |||
44 | // TODO: Place this in a better location. | ||
45 | // Exclude JDK packages from Instrumenter | ||
46 | this.algorithmStepSizeInstrumenter.addExcludedPackage("jdk") | ||
47 | |||
48 | new Executor().usingAlgorithmFactory(algorithmFactory).withAlgorithm(solverSpec.algorithm.name) // Initialize problem with our solution generator | ||
49 | .withProblemClass(MoeaOptimisationProblem, solutionGenerator).withProperties(optimisationProperties). | ||
50 | withInstrumenter(algorithmStepSizeInstrumenter).withTerminationCondition( | ||
51 | optimisationProperties.get("terminationCondition") as TerminationCondition).run() | ||
52 | |||
53 | return algorithmStepSizeInstrumenter | ||
54 | } | ||
55 | } | ||
56 | |||
57 | class ExcludedOptimisationInterpreter extends OptimisationInterpreter { | ||
58 | val Optimisation model | ||
59 | |||
60 | new(String projectPath, Optimisation model) { | ||
61 | super(projectPath, model) | ||
62 | this.model = model | ||
63 | } | ||
64 | |||
65 | override start() { | ||
66 | // This model provider loads the model given by the user in the DSL | ||
67 | var solutionGenerator = new SolutionGenerator(model, getBreedingOperators, getMutationOperators, | ||
68 | getModelProvider, getMetamodel); | ||
69 | |||
70 | return new ExcludedMoeaOptimisation().execute(model.solver, solutionGenerator) | ||
71 | } | ||
72 | |||
73 | } | ||
74 | |||
75 | class ExcludedRun extends Run { | ||
76 | override runBatch(String moptProjectPath, Optimisation optimisationModel, Integer batch, boolean singleBatch) { | ||
77 | val optimisationInterpreter = new ExcludedOptimisationInterpreter(moptProjectPath, optimisationModel); | ||
78 | val startTime = System.nanoTime(); | ||
79 | val optimisationOutcome = optimisationInterpreter.start(); | ||
80 | val endTime = System.nanoTime(); | ||
81 | val experimentDuration = ((endTime - startTime) / 1000000); | ||
82 | val generatedRules = optimisationInterpreter.getRulegenOperators(); | ||
83 | return new MDEOBatch(batch, experimentDuration, optimisationOutcome, generatedRules, singleBatch); | ||
84 | } | ||
85 | } | ||