diff options
author | 2017-06-10 19:01:08 +0200 | |
---|---|---|
committer | 2017-06-10 19:01:08 +0200 | |
commit | d4f03121e36bce42ce611e97ffee6e697162228e (patch) | |
tree | bcda6a5e8d0a9d9fdc1dc8620a816e7f429f5d9a /Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphInconsistencyDetector.xtend | |
parent | Initial commit (diff) | |
download | VIATRA-Generator-d4f03121e36bce42ce611e97ffee6e697162228e.tar.gz VIATRA-Generator-d4f03121e36bce42ce611e97ffee6e697162228e.tar.zst VIATRA-Generator-d4f03121e36bce42ce611e97ffee6e697162228e.zip |
Initial commit, migrating from SVN
Diffstat (limited to 'Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphInconsistencyDetector.xtend')
-rw-r--r-- | Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphInconsistencyDetector.xtend | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphInconsistencyDetector.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphInconsistencyDetector.xtend new file mode 100644 index 00000000..3a7c5041 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphInconsistencyDetector.xtend | |||
@@ -0,0 +1,82 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod | ||
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethodBasedGlobalConstraint | ||
6 | import org.eclipse.viatra.dse.base.ThreadContext | ||
7 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | ||
8 | |||
9 | class SGraphInconsistencyDetector extends ModelGenerationMethodBasedGlobalConstraint { | ||
10 | |||
11 | var PartialInterpretation partialInterpretation | ||
12 | var ViatraQueryMatcher<?> noEntry | ||
13 | var ViatraQueryMatcher<?> entryHasNoOutgoing | ||
14 | var ViatraQueryMatcher<?> synchronizationHasNoOutgoing | ||
15 | var ViatraQueryMatcher<?> noSynch | ||
16 | var ViatraQueryMatcher<?> synchronizedSiblingRegions | ||
17 | var ViatraQueryMatcher<?> noStateInRegion | ||
18 | |||
19 | new(ModelGenerationMethod method) { | ||
20 | super(method) | ||
21 | } | ||
22 | |||
23 | override getName() { | ||
24 | return SGraphInconsistencyDetector.simpleName | ||
25 | } | ||
26 | |||
27 | override init(ThreadContext context) { | ||
28 | partialInterpretation = context.model as PartialInterpretation | ||
29 | |||
30 | try{ | ||
31 | this.noEntry = method.unfinishedWF.filter[ | ||
32 | it.fullyQualifiedName.equals("unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_noEntryInRegion") | ||
33 | ].head.getMatcher(context.queryEngine) | ||
34 | |||
35 | this.entryHasNoOutgoing = method.unfinishedWF.filter[ | ||
36 | it.fullyQualifiedName.equals("unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_noOutgoingTransitionFromEntry") | ||
37 | ].head.getMatcher(context.queryEngine) | ||
38 | |||
39 | this.synchronizationHasNoOutgoing = method.unfinishedWF.filter[ | ||
40 | it.fullyQualifiedName.equals("unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_hasNoOutgoing") | ||
41 | ].head.getMatcher(context.queryEngine) | ||
42 | |||
43 | this.noSynch = method.unfinishedWF.filter[ | ||
44 | it.fullyQualifiedName.equals("unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_noSynch") | ||
45 | ].head.getMatcher(context.queryEngine) | ||
46 | |||
47 | this.synchronizedSiblingRegions = method.unfinishedWF.filter[ | ||
48 | it.fullyQualifiedName.equals("unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_SynchronizedRegionDoesNotHaveMultipleRegions") | ||
49 | ].head.getMatcher(context.queryEngine) | ||
50 | |||
51 | this.noStateInRegion = method.unfinishedWF.filter[ | ||
52 | it.fullyQualifiedName.equals("unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_noStateInRegion") | ||
53 | ].head.getMatcher(context.queryEngine) | ||
54 | } catch(Exception e) { } | ||
55 | } | ||
56 | |||
57 | override checkGlobalConstraint(ThreadContext context) { | ||
58 | if(noEntry !== null) { | ||
59 | val requiredNewObjects = | ||
60 | noEntry.countMatches*2 + | ||
61 | entryHasNoOutgoing.countMatches + | ||
62 | synchronizationHasNoOutgoing.countMatches + | ||
63 | noSynch.countMatches*2 + | ||
64 | synchronizedSiblingRegions.countMatches*4 | ||
65 | noStateInRegion.countMatches | ||
66 | val availableNewObjects = partialInterpretation.maxNewElements | ||
67 | val res = availableNewObjects >= requiredNewObjects | ||
68 | //println('''[«availableNewObjects» >= «requiredNewObjects»] = «res»''') | ||
69 | return res | ||
70 | } else { | ||
71 | true | ||
72 | } | ||
73 | |||
74 | } | ||
75 | override createNew() { | ||
76 | return new SGraphInconsistencyDetector(this.method) | ||
77 | } | ||
78 | // | ||
79 | // def hasSynchronization() { | ||
80 | // this.partialInterpretation.partialtypeinterpratation. | ||
81 | // } | ||
82 | } \ No newline at end of file | ||