diff options
author | Kristóf Marussy <marussy@mit.bme.hu> | 2020-08-28 18:58:37 +0200 |
---|---|---|
committer | Kristóf Marussy <marussy@mit.bme.hu> | 2020-08-28 18:58:37 +0200 |
commit | 4fe7fce97aedbd516109ef81afc33e00112b7b68 (patch) | |
tree | 7eaa7c4e9b31b2a1488e49de48721b4dbad31fae /Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java | |
parent | MoDeS3 unit propagation WIP (diff) | |
download | VIATRA-Generator-4fe7fce97aedbd516109ef81afc33e00112b7b68.tar.gz VIATRA-Generator-4fe7fce97aedbd516109ef81afc33e00112b7b68.tar.zst VIATRA-Generator-4fe7fce97aedbd516109ef81afc33e00112b7b68.zip |
Must unit propagation
Diffstat (limited to 'Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java')
-rw-r--r-- | Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java index c7364257..f32a7172 100644 --- a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java | |||
@@ -12,7 +12,9 @@ import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | |||
12 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsFactory; | 12 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsFactory; |
13 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsPackage; | 13 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsPackage; |
14 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion; | 14 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion; |
15 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; | ||
15 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder; | 16 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder; |
17 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.SolutionScope; | ||
16 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; | 18 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; |
17 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes; | 19 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes; |
18 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.VariableContext; | 20 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.VariableContext; |
@@ -48,6 +50,7 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.par | |||
48 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RelationLink; | 50 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RelationLink; |
49 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; | 51 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; |
50 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; | 52 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; |
53 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.DebugConfiguration; | ||
51 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.StateCoderStrategy; | 54 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.StateCoderStrategy; |
52 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; | 55 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; |
53 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; | 56 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; |
@@ -57,12 +60,13 @@ import java.util.Collections; | |||
57 | import java.util.List; | 60 | import java.util.List; |
58 | import java.util.Map; | 61 | import java.util.Map; |
59 | import java.util.Set; | 62 | import java.util.Set; |
60 | import java.util.function.Consumer; | ||
61 | import java.util.function.Predicate; | 63 | import java.util.function.Predicate; |
62 | import modes3.Modes3Factory; | 64 | import modes3.Modes3Factory; |
63 | import modes3.Modes3ModelRoot; | 65 | import modes3.Modes3ModelRoot; |
64 | import modes3.Modes3Package; | 66 | import modes3.Modes3Package; |
65 | import modes3.queries.Modes3Queries; | 67 | import modes3.queries.Modes3Queries; |
68 | import modes3.run.Modes3TypeScopeHint; | ||
69 | import modes3.run.Modes3UnitPropagationGenerator; | ||
66 | import org.eclipse.emf.common.util.EList; | 70 | import org.eclipse.emf.common.util.EList; |
67 | import org.eclipse.emf.common.util.URI; | 71 | import org.eclipse.emf.common.util.URI; |
68 | import org.eclipse.emf.ecore.EAttribute; | 72 | import org.eclipse.emf.ecore.EAttribute; |
@@ -175,29 +179,47 @@ public class Modes3ModelGenerator { | |||
175 | it_1.minNewElements = this.modelSize; | 179 | it_1.minNewElements = this.modelSize; |
176 | it_1.maxNewElements = this.modelSize; | 180 | it_1.maxNewElements = this.modelSize; |
177 | final Procedure1<Map<Type, Integer>> _function_4 = (Map<Type, Integer> it_2) -> { | 181 | final Procedure1<Map<Type, Integer>> _function_4 = (Map<Type, Integer> it_2) -> { |
178 | it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTurnout()), Integer.valueOf(1)); | ||
179 | }; | 182 | }; |
180 | ObjectExtensions.<Map<Type, Integer>>operator_doubleArrow( | 183 | ObjectExtensions.<Map<Type, Integer>>operator_doubleArrow( |
181 | it_1.minNewElementsByType, _function_4); | 184 | it_1.minNewElementsByType, _function_4); |
182 | final Procedure1<Map<Type, Integer>> _function_5 = (Map<Type, Integer> it_2) -> { | 185 | final Procedure1<Map<Type, Integer>> _function_5 = (Map<Type, Integer> it_2) -> { |
183 | it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTrain()), Integer.valueOf(5)); | 186 | it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTrain()), Integer.valueOf(5)); |
187 | it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTurnout()), Integer.valueOf(5)); | ||
184 | }; | 188 | }; |
185 | ObjectExtensions.<Map<Type, Integer>>operator_doubleArrow( | 189 | ObjectExtensions.<Map<Type, Integer>>operator_doubleArrow( |
186 | it_1.maxNewElementsByType, _function_5); | 190 | it_1.maxNewElementsByType, _function_5); |
187 | }; | 191 | }; |
188 | ObjectExtensions.<TypeScopes>operator_doubleArrow( | 192 | ObjectExtensions.<TypeScopes>operator_doubleArrow( |
189 | it.typeScopes, _function_3); | 193 | it.typeScopes, _function_3); |
190 | it.solutionScope.numberOfRequiredSolutions = 1; | 194 | final Procedure1<SolutionScope> _function_4 = (SolutionScope it_1) -> { |
195 | it_1.numberOfRequiredSolutions = 1; | ||
196 | }; | ||
197 | ObjectExtensions.<SolutionScope>operator_doubleArrow( | ||
198 | it.solutionScope, _function_4); | ||
199 | it.scopeWeight = 5; | ||
191 | it.nameNewElements = false; | 200 | it.nameNewElements = false; |
192 | it.typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis; | 201 | it.typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis; |
193 | it.stateCoderStrategy = StateCoderStrategy.Neighbourhood; | 202 | it.stateCoderStrategy = StateCoderStrategy.PairwiseNeighbourhood; |
194 | ScopePropagatorStrategy.Polyhedral _polyhedral = new ScopePropagatorStrategy.Polyhedral( | 203 | ScopePropagatorStrategy.Polyhedral _polyhedral = new ScopePropagatorStrategy.Polyhedral( |
195 | PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp); | 204 | PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp); |
196 | it.scopePropagatorStrategy = _polyhedral; | 205 | it.scopePropagatorStrategy = _polyhedral; |
197 | it.debugConfiguration.partialInterpretatioVisualiser = null; | 206 | Ecore2Logic_Trace _trace = metamodelLogic.getTrace(); |
207 | Modes3TypeScopeHint _modes3TypeScopeHint = new Modes3TypeScopeHint(this.ecore2Logic, _trace); | ||
208 | it.hints.add(_modes3TypeScopeHint); | ||
209 | Ecore2Logic_Trace _trace_1 = metamodelLogic.getTrace(); | ||
210 | Modes3UnitPropagationGenerator _modes3UnitPropagationGenerator = new Modes3UnitPropagationGenerator(this.ecore2Logic, _trace_1); | ||
211 | it.unitPropagationPatternGenerators.add(_modes3UnitPropagationGenerator); | ||
212 | final Procedure1<DebugConfiguration> _function_5 = (DebugConfiguration it_1) -> { | ||
213 | GraphvizVisualiser _graphvizVisualiser = new GraphvizVisualiser(); | ||
214 | it_1.partialInterpretatioVisualiser = _graphvizVisualiser; | ||
215 | }; | ||
216 | ObjectExtensions.<DebugConfiguration>operator_doubleArrow( | ||
217 | it.debugConfiguration, _function_5); | ||
218 | it.documentationLevel = DocumentationLevel.NORMAL; | ||
198 | }; | 219 | }; |
199 | final ViatraReasonerConfiguration config = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function_2); | 220 | final ViatraReasonerConfiguration config = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function_2); |
200 | final FileSystemWorkspace workspace = new FileSystemWorkspace("output/", ""); | 221 | final FileSystemWorkspace workspace = new FileSystemWorkspace("output/", ""); |
222 | workspace.writeModel(logic.getOutput(), "problem.logicproblem"); | ||
201 | final LogicResult solution = this.solver.solve(logic.getOutput(), config, workspace); | 223 | final LogicResult solution = this.solver.solve(logic.getOutput(), config, workspace); |
202 | URI _xifexpression = null; | 224 | URI _xifexpression = null; |
203 | if ((solution instanceof ModelResult)) { | 225 | if ((solution instanceof ModelResult)) { |
@@ -226,27 +248,23 @@ public class Modes3ModelGenerator { | |||
226 | boolean _lessThan = (_size_1 < 160); | 248 | boolean _lessThan = (_size_1 < 160); |
227 | if (_lessThan) { | 249 | if (_lessThan) { |
228 | if ((representation instanceof PartialInterpretation)) { | 250 | if ((representation instanceof PartialInterpretation)) { |
229 | final Consumer<Type> _function_3 = (Type it) -> { | 251 | final Function1<Type, Boolean> _function_3 = (Type it) -> { |
230 | InputOutput.<String>println(it.getName()); | ||
231 | }; | ||
232 | ((PartialInterpretation)representation).getProblem().getTypes().forEach(_function_3); | ||
233 | final Function1<Type, Boolean> _function_4 = (Type it) -> { | ||
234 | String _name_2 = it.getName(); | 252 | String _name_2 = it.getName(); |
235 | return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class DefinedPart")); | 253 | return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class DefinedPart")); |
236 | }; | 254 | }; |
237 | Type _findFirst = IterableExtensions.<Type>findFirst(((PartialInterpretation)representation).getProblem().getTypes(), _function_4); | 255 | Type _findFirst = IterableExtensions.<Type>findFirst(((PartialInterpretation)representation).getProblem().getTypes(), _function_3); |
238 | final TypeDefinition rootType = ((TypeDefinition) _findFirst); | 256 | final TypeDefinition rootType = ((TypeDefinition) _findFirst); |
239 | final Function1<PartialComplexTypeInterpretation, Boolean> _function_5 = (PartialComplexTypeInterpretation it) -> { | 257 | final Function1<PartialComplexTypeInterpretation, Boolean> _function_4 = (PartialComplexTypeInterpretation it) -> { |
240 | String _name_2 = it.getInterpretationOf().getName(); | 258 | String _name_2 = it.getInterpretationOf().getName(); |
241 | return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class")); | 259 | return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class")); |
242 | }; | 260 | }; |
243 | final PartialComplexTypeInterpretation rootIntepretation = IterableExtensions.<PartialComplexTypeInterpretation>findFirst(Iterables.<PartialComplexTypeInterpretation>filter(((PartialInterpretation)representation).getPartialtypeinterpratation(), | 261 | final PartialComplexTypeInterpretation rootIntepretation = IterableExtensions.<PartialComplexTypeInterpretation>findFirst(Iterables.<PartialComplexTypeInterpretation>filter(((PartialInterpretation)representation).getPartialtypeinterpratation(), |
244 | PartialComplexTypeInterpretation.class), _function_5); | 262 | PartialComplexTypeInterpretation.class), _function_4); |
245 | rootIntepretation.getElements().removeAll(rootType.getElements()); | 263 | rootIntepretation.getElements().removeAll(rootType.getElements()); |
246 | ((PartialInterpretation)representation).getProblem().getElements().removeAll(rootType.getElements()); | 264 | ((PartialInterpretation)representation).getProblem().getElements().removeAll(rootType.getElements()); |
247 | EList<PartialRelationInterpretation> _partialrelationinterpretation = ((PartialInterpretation)representation).getPartialrelationinterpretation(); | 265 | EList<PartialRelationInterpretation> _partialrelationinterpretation = ((PartialInterpretation)representation).getPartialrelationinterpretation(); |
248 | for (final PartialRelationInterpretation relationInterpretation : _partialrelationinterpretation) { | 266 | for (final PartialRelationInterpretation relationInterpretation : _partialrelationinterpretation) { |
249 | final Predicate<RelationLink> _function_6 = (RelationLink link) -> { | 267 | final Predicate<RelationLink> _function_5 = (RelationLink link) -> { |
250 | boolean _xifexpression_1 = false; | 268 | boolean _xifexpression_1 = false; |
251 | if ((link instanceof BinaryElementRelationLink)) { | 269 | if ((link instanceof BinaryElementRelationLink)) { |
252 | _xifexpression_1 = (rootType.getElements().contains(((BinaryElementRelationLink)link).getParam1()) || rootType.getElements().contains(((BinaryElementRelationLink)link).getParam2())); | 270 | _xifexpression_1 = (rootType.getElements().contains(((BinaryElementRelationLink)link).getParam1()) || rootType.getElements().contains(((BinaryElementRelationLink)link).getParam2())); |
@@ -255,7 +273,7 @@ public class Modes3ModelGenerator { | |||
255 | } | 273 | } |
256 | return _xifexpression_1; | 274 | return _xifexpression_1; |
257 | }; | 275 | }; |
258 | relationInterpretation.getRelationlinks().removeIf(_function_6); | 276 | relationInterpretation.getRelationlinks().removeIf(_function_5); |
259 | } | 277 | } |
260 | rootType.getElements().clear(); | 278 | rootType.getElements().clear(); |
261 | } | 279 | } |
@@ -349,13 +367,7 @@ public class Modes3ModelGenerator { | |||
349 | Viatra2LogicAnnotationsPackage.eINSTANCE.getClass(); | 367 | Viatra2LogicAnnotationsPackage.eINSTANCE.getClass(); |
350 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | 368 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); |
351 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | 369 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); |
352 | _extensionToFactoryMap.put("ecore", _xMIResourceFactoryImpl); | 370 | _xblockexpression = _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl); |
353 | Map<String, Object> _extensionToFactoryMap_1 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
354 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_1 = new XMIResourceFactoryImpl(); | ||
355 | _extensionToFactoryMap_1.put("logicproblem", _xMIResourceFactoryImpl_1); | ||
356 | Map<String, Object> _extensionToFactoryMap_2 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
357 | XMIResourceFactoryImpl _xMIResourceFactoryImpl_2 = new XMIResourceFactoryImpl(); | ||
358 | _xblockexpression = _extensionToFactoryMap_2.put("partialinterpretation", _xMIResourceFactoryImpl_2); | ||
359 | } | 371 | } |
360 | return _xblockexpression; | 372 | return _xblockexpression; |
361 | } | 373 | } |