aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend
blob: ef5b779e02ae4a5c61fdb7203592c5c345bd1a01 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package hu.bme.mit.inf.dslreasoner.run

import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic
import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator

class SatelliteHint extends Ecore2LogicTraceBasedHint {
	static val INTERFEROMETY_PAYLOAD = "hint_interferometryPayload"
	static val REMAINING_CONTENTS_KA_COMM_SUBSYSTEM = "hint_kaCommSubsystem"

	new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
		super(ecore2Logic, trace)
	}

	override getAdditionalPatterns(PatternGenerator it) '''
		pattern «INTERFEROMETY_PAYLOAD»(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement) {
			find interpretation(problem, interpretation);
			find mustExist(problem, interpretation, object);
			«typeIndexer.referInstanceOf("InterferometryPayload".type, Modality.MUST, "object")»
		}
		
		private pattern «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»_helper(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement, remainingContents:java Integer) {
			find remainingContents_commSubsystem_reference_CommunicatingElement_helper(problem, interpretation, object, remainingContents);
			«typeIndexer.referInstanceOf("SmallSat".type, Modality.MUST, "object")»
		}
		
		pattern «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»(problem:LogicProblem, interpretation:PartialInterpretation, remainingContents:java Integer) {
			find interpretation(problem, interpretation);
			remainingContents == sum find «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»_helper(problem, interpretation, _, #_);
		}
	'''

	override createConstraintUpdater(LinearTypeExpressionBuilderFactory it) {
		val interferometryPayloadCount = createBuilder.add(1, "InterferometryPayload".type).build
		val kaCommSubsystemWithoutSmallSatCount = createBuilder.add(1, "KaCommSubsystem".type).add(-2, "SmallSat".type).
			build

		val interferometryPayloadMatcher = createMatcher(INTERFEROMETY_PAYLOAD)
		val kaCommSubsystemRemainingContentsMatcher = createMatcher(REMAINING_CONTENTS_KA_COMM_SUBSYSTEM)

		return [ p |
			interferometryPayloadCount.tightenLowerBound(2 - interferometryPayloadMatcher.countMatches(p))
			kaCommSubsystemWithoutSmallSatCount.tightenUpperBound(kaCommSubsystemRemainingContentsMatcher.getCount(p))
		]
	}

}