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.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/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.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo')
4 files changed, 21 insertions, 106 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/CostObjective.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/CostObjective.xtend index 43b2902f..3a8688e9 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/CostObjective.xtend +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/CostObjective.xtend | |||
@@ -1,13 +1,13 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo | 1 | package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo |
2 | 2 | ||
3 | //import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric | 3 | import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric |
4 | // | 4 | |
5 | //class CostObjective extends MetricBasedGuidanceFunction { | 5 | class CostObjective extends MetricBasedGuidanceFunction { |
6 | // new() { | 6 | new() { |
7 | // super(CostMetric.instance) | 7 | super(CostMetric.instance) |
8 | // } | 8 | } |
9 | // | 9 | |
10 | // override getName() { | 10 | override getName() { |
11 | // "Cost" | 11 | "Cost" |
12 | // } | 12 | } |
13 | //} | 13 | } |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/ExcludedOptimisationInterpreter.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/ExcludedOptimisationInterpreter.xtend deleted file mode 100644 index ddf5748e..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/ExcludedOptimisationInterpreter.xtend +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.satellite.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 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend index c5a30f94..58034c43 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend | |||
@@ -9,7 +9,7 @@ import org.eclipse.emf.ecore.EPackage | |||
9 | import org.eclipse.emf.ecore.resource.Resource | 9 | import org.eclipse.emf.ecore.resource.Resource |
10 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | 10 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl |
11 | import satellite.SatellitePackage | 11 | import satellite.SatellitePackage |
12 | import uk.ac.kcl.inf.mdeoptimiser.languages.MoptStandaloneSetup | 12 | import uk.ac.kcl.inf.mdeoptimiser.interfaces.cli.Run |
13 | 13 | ||
14 | class SatelliteMdeOptimiserMain { | 14 | class SatelliteMdeOptimiserMain { |
15 | static val PROJECT_PATH = "." | 15 | static val PROJECT_PATH = "." |
@@ -25,8 +25,7 @@ class SatelliteMdeOptimiserMain { | |||
25 | EPackage.Registry.INSTANCE.put(SatellitePackage.eNS_URI, SatellitePackage.eINSTANCE) | 25 | EPackage.Registry.INSTANCE.put(SatellitePackage.eNS_URI, SatellitePackage.eINSTANCE) |
26 | fixupHenshinModel("model/satellite.henshin", "model/satellite_fixup.henshin", | 26 | fixupHenshinModel("model/satellite.henshin", "model/satellite_fixup.henshin", |
27 | #{"satellite.ecore" -> SatellitePackage.eNS_URI}) | 27 | #{"satellite.ecore" -> SatellitePackage.eNS_URI}) |
28 | val injector = new MoptStandaloneSetup().createInjectorAndDoEMFRegistration(); | 28 | Run.main(#["-p", PROJECT_PATH, "-m", MOPT_PATH]) |
29 | injector.getInstance(ExcludedRun).run(PROJECT_PATH, MOPT_PATH) | ||
30 | } | 29 | } |
31 | 30 | ||
32 | private def static void fixupHenshinModel(String originalPath, String outputPath, Map<String, String> remapMap) { | 31 | private def static void fixupHenshinModel(String originalPath, String outputPath, Map<String, String> remapMap) { |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt index 138ea309..e9bd1a64 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt | |||
@@ -10,13 +10,14 @@ goal { | |||
10 | } | 10 | } |
11 | 11 | ||
12 | search { | 12 | search { |
13 | mutate using <satellite_fixup.henshin> unit "addCubeSat3U" | 13 | // mutate using <satellite_fixup.henshin> unit "addCubeSat3U" |
14 | // mutate { "CubeSat3U" } | 14 | mutate { "CubeSat3U" } |
15 | // mutate { "CubeSat6U" } | 15 | mutate { "CubeSat6U" } |
16 | // mutate { "SmallSat" } | 16 | mutate { "SmallSat" } |
17 | // mutate { "InterferometryPayload" } | 17 | mutate { "InterferometryPayload" } |
18 | // mutate { "CommSubsystem" } | 18 | mutate { "UHFCommSubsystem" } |
19 | // mutate { "DirectedCommunicationLink" } | 19 | mutate { "XCommSubsystem" } |
20 | mutate { "KaCommSubsystem" } | ||
20 | } | 21 | } |
21 | 22 | ||
22 | solver { | 23 | solver { |