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 | 86 |
1 files changed, 86 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..e95c0c64 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend | |||
@@ -0,0 +1,86 @@ | |||
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 | static val HINT_SPACECRAFT_UHF_POSSIBLE_LINK = "hint_spacecraftWithUhfPossibleLink" | ||
13 | static val HINT_SPACECRAFT_UHF_ONLY_NO_LINK = "hint_spacecraftUhfOnlyNoLink" | ||
14 | |||
15 | new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { | ||
16 | super(ecore2Logic, trace) | ||
17 | } | ||
18 | |||
19 | override getAdditionalPatterns(PatternGenerator it) ''' | ||
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 | private pattern hint_spacecraftNotUhfOnly(problem:LogicProblem, interpretation:PartialInterpretation, spacecraft:DefinedElement) { | ||
37 | find interpretation(problem, interpretation); | ||
38 | find mustExist(problem, interpretation, spacecraft); | ||
39 | «typeIndexer.referInstanceOf("Spacecraft".type, Modality.MUST, "spacecraft")» | ||
40 | «relationDeclarationIndexer.referRelation("CommunicatingElement".relation("commSubsystem"), "spacecraft", "comm", Modality.MAY)» | ||
41 | neg «typeIndexer.referInstanceOf("UHFCommSubsystem".type, Modality.MUST, "comm")» | ||
42 | } | ||
43 | |||
44 | private pattern hint_spacecraftWithUhf(problem:LogicProblem, interpretation:PartialInterpretation, spacecraft:DefinedElement) { | ||
45 | find interpretation(problem, interpretation); | ||
46 | find mustExist(problem, interpretation, spacecraft); | ||
47 | «typeIndexer.referInstanceOf("Spacecraft".type, Modality.MUST, "spacecraft")» | ||
48 | «relationDeclarationIndexer.referRelation("CommunicatingElement".relation("commSubsystem"), "spacecraft", "comm", Modality.MUST)» | ||
49 | «typeIndexer.referInstanceOf("UHFCommSubsystem".type, Modality.MUST, "comm")» | ||
50 | } | ||
51 | |||
52 | pattern «HINT_SPACECRAFT_UHF_POSSIBLE_LINK»(problem:LogicProblem, interpretation:PartialInterpretation) { | ||
53 | find hint_spacecraftWithUhf(problem, interpretation, spacecraft); | ||
54 | find hint_spacecraftNotUhfOnly(problem, interpretation, spacecraft); | ||
55 | } | ||
56 | |||
57 | pattern «HINT_SPACECRAFT_UHF_ONLY_NO_LINK»(problem:LogicProblem, interpretation:PartialInterpretation) { | ||
58 | find interpretation(problem, interpretation); | ||
59 | find mustExist(problem, interpretation, spacecraft); | ||
60 | «typeIndexer.referInstanceOf("Spacecraft".type, Modality.MUST, "spacecraft")» | ||
61 | neg find hint_spacecraftNotUhfOnly(problem, interpretation, spacecraft); | ||
62 | find currentInRelation_pattern_hu_bme_mit_inf_dslreasoner_domains_satellite_queries_noLinkToGroundStation(problem, interpretation, spacecraft); | ||
63 | } | ||
64 | ''' | ||
65 | |||
66 | override createConstraintUpdater(LinearTypeExpressionBuilderFactory it) { | ||
67 | val interferometryPayloadCount = createBuilder.add(1, "InterferometryPayload".type).build | ||
68 | val kaCommSubsystemWithoutSmallSatCount = createBuilder.add(1, "KaCommSubsystem".type).add(-2, "SmallSat".type). | ||
69 | build | ||
70 | val uhfCommSubsystemCount = createBuilder.add(1, "UHFCommSubsystem".type).build | ||
71 | |||
72 | val interferometryPayloadMatcher = createMatcher(INTERFEROMETY_PAYLOAD) | ||
73 | val kaCommSubsystemRemainingContentsMatcher = createMatcher(REMAINING_CONTENTS_KA_COMM_SUBSYSTEM) | ||
74 | val uhfPossibleLinkMatcher = createMatcher(HINT_SPACECRAFT_UHF_POSSIBLE_LINK) | ||
75 | val uhfNoLinkMatcher = createMatcher(HINT_SPACECRAFT_UHF_ONLY_NO_LINK) | ||
76 | |||
77 | return [ p | | ||
78 | interferometryPayloadCount.tightenLowerBound(2 - interferometryPayloadMatcher.countMatches(p)) | ||
79 | kaCommSubsystemWithoutSmallSatCount.tightenUpperBound(kaCommSubsystemRemainingContentsMatcher.getCount(p)) | ||
80 | if (uhfPossibleLinkMatcher.countMatches(p) == 0 && uhfNoLinkMatcher.countMatches(p) >= 1) { | ||
81 | uhfCommSubsystemCount.tightenLowerBound(1) | ||
82 | } | ||
83 | ] | ||
84 | } | ||
85 | |||
86 | } | ||