diff options
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.xtend | 49 |
1 files changed, 49 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..ef5b779e --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend | |||
@@ -0,0 +1,49 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator | ||
8 | |||
9 | class SatelliteHint extends Ecore2LogicTraceBasedHint { | ||
10 | static val INTERFEROMETY_PAYLOAD = "hint_interferometryPayload" | ||
11 | static val REMAINING_CONTENTS_KA_COMM_SUBSYSTEM = "hint_kaCommSubsystem" | ||
12 | |||
13 | new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { | ||
14 | super(ecore2Logic, trace) | ||
15 | } | ||
16 | |||
17 | override getAdditionalPatterns(PatternGenerator it) ''' | ||
18 | pattern «INTERFEROMETY_PAYLOAD»(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement) { | ||
19 | find interpretation(problem, interpretation); | ||
20 | find mustExist(problem, interpretation, object); | ||
21 | «typeIndexer.referInstanceOf("InterferometryPayload".type, Modality.MUST, "object")» | ||
22 | } | ||
23 | |||
24 | private pattern «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»_helper(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement, remainingContents:java Integer) { | ||
25 | find remainingContents_commSubsystem_reference_CommunicatingElement_helper(problem, interpretation, object, remainingContents); | ||
26 | «typeIndexer.referInstanceOf("SmallSat".type, Modality.MUST, "object")» | ||
27 | } | ||
28 | |||
29 | pattern «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»(problem:LogicProblem, interpretation:PartialInterpretation, remainingContents:java Integer) { | ||
30 | find interpretation(problem, interpretation); | ||
31 | remainingContents == sum find «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»_helper(problem, interpretation, _, #_); | ||
32 | } | ||
33 | ''' | ||
34 | |||
35 | override createConstraintUpdater(LinearTypeExpressionBuilderFactory it) { | ||
36 | val interferometryPayloadCount = createBuilder.add(1, "InterferometryPayload".type).build | ||
37 | val kaCommSubsystemWithoutSmallSatCount = createBuilder.add(1, "KaCommSubsystem".type).add(-2, "SmallSat".type). | ||
38 | build | ||
39 | |||
40 | val interferometryPayloadMatcher = createMatcher(INTERFEROMETY_PAYLOAD) | ||
41 | val kaCommSubsystemRemainingContentsMatcher = createMatcher(REMAINING_CONTENTS_KA_COMM_SUBSYSTEM) | ||
42 | |||
43 | return [ p | | ||
44 | interferometryPayloadCount.tightenLowerBound(2 - interferometryPayloadMatcher.countMatches(p)) | ||
45 | kaCommSubsystemWithoutSmallSatCount.tightenUpperBound(kaCommSubsystemRemainingContentsMatcher.getCount(p)) | ||
46 | ] | ||
47 | } | ||
48 | |||
49 | } | ||