aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend')
-rw-r--r--Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend51
1 files changed, 51 insertions, 0 deletions
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend
new file mode 100644
index 00000000..28954d60
--- /dev/null
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend
@@ -0,0 +1,51 @@
1package hu.bme.mit.inf.dslreasoner.run
2
3import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic
4import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
5import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality
6import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory
7import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator
8import java.util.Map
9import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery
10
11class SatelliteHint extends Ecore2LogicTraceBasedHint {
12 static val INTERFEROMETY_PAYLOAD = "hint_interferometryPayload"
13 static val REMAINING_CONTENTS_KA_COMM_SUBSYSTEM = "hint_kaCommSubsystem"
14
15 new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
16 super(ecore2Logic, trace)
17 }
18
19 override getAdditionalPatterns(PatternGenerator it, Map<String, PQuery> fqnToPQuery) '''
20 pattern «INTERFEROMETY_PAYLOAD»(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement) {
21 find interpretation(problem, interpretation);
22 find mustExist(problem, interpretation, object);
23 «typeIndexer.referInstanceOf("InterferometryPayload".type, Modality.MUST, "object")»
24 }
25
26 private pattern «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»_helper(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement, remainingContents:java Integer) {
27 find remainingContents_commSubsystem_reference_CommunicatingElement_helper(problem, interpretation, object, remainingContents);
28 «typeIndexer.referInstanceOf("SmallSat".type, Modality.MUST, "object")»
29 }
30
31 pattern «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»(problem:LogicProblem, interpretation:PartialInterpretation, remainingContents:java Integer) {
32 find interpretation(problem, interpretation);
33 remainingContents == sum find «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»_helper(problem, interpretation, _, #_);
34 }
35 '''
36
37 override createConstraintUpdater(LinearTypeExpressionBuilderFactory it) {
38 val interferometryPayloadCount = createBuilder.add(1, "InterferometryPayload".type).build
39 val kaCommSubsystemWithoutSmallSatCount = createBuilder.add(1, "KaCommSubsystem".type).add(-2, "SmallSat".type).
40 build
41
42 val interferometryPayloadMatcher = createMatcher(INTERFEROMETY_PAYLOAD)
43 val kaCommSubsystemRemainingContentsMatcher = createMatcher(REMAINING_CONTENTS_KA_COMM_SUBSYSTEM)
44
45 return [ p |
46 interferometryPayloadCount.tightenLowerBound(2 - interferometryPayloadMatcher.countMatches(p))
47 kaCommSubsystemWithoutSmallSatCount.tightenUpperBound(kaCommSubsystemRemainingContentsMatcher.getCount(p))
48 ]
49 }
50
51}