diff options
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries')
-rw-r--r-- | Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | 300 |
1 files changed, 300 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql new file mode 100644 index 00000000..7ca948cc --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql | |||
@@ -0,0 +1,300 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.domains.satellite.queries | ||
2 | |||
3 | import "http://www.example.org/satellite" | ||
4 | |||
5 | @Constraint(severity = "error", key = {Link}, | ||
6 | message = "Communication links must start from the containing element.") | ||
7 | pattern communicationLinkDoesNotStartAtContainingElement(Link : DirectedCommunicationLink) { | ||
8 | CommunicatingElement.communicationLink(Element, Link); | ||
9 | DirectedCommunicationLink.source(Link, SourceComm); | ||
10 | CommunicatingElement.commSubsystem(SourceElement, SourceComm); | ||
11 | Element != SourceElement; | ||
12 | } | ||
13 | |||
14 | // At least two spacecraft must have the interferometry payload configured | ||
15 | |||
16 | //@Constraint(severity = "error", key = {Mission}, | ||
17 | // message = "Interferometry mission needs at least two spacecraft configured with the interferometry payload.") | ||
18 | pattern notEnoughInterferometryPayloads(Mission : InterferometryMission) { | ||
19 | InterferometryMission(Mission); | ||
20 | neg find atLeastTwoInterferometryPayloads(Mission); | ||
21 | } | ||
22 | |||
23 | private pattern atLeastTwoInterferometryPayloads(Mission : InterferometryMission) { | ||
24 | find spacecraftWithInterferometryPayload(Mission, Spacecraft1); | ||
25 | find spacecraftWithInterferometryPayload(Mission, Spacecraft2); | ||
26 | Spacecraft1 != Spacecraft2; | ||
27 | } | ||
28 | |||
29 | private pattern spacecraftWithInterferometryPayload(Mission : ConstellationMission, Spacecraft : Spacecraft) { | ||
30 | ConstellationMission.spacecraft(Mission, Spacecraft); | ||
31 | Spacecraft.payload(Spacecraft, Payload); | ||
32 | InterferometryPayload(Payload); | ||
33 | } | ||
34 | |||
35 | // All spacecraft must have some communication path to the ground station | ||
36 | |||
37 | @Constraint(severity = "error", key = {Spacecraft}, | ||
38 | message = "Spacecraft has no communication path to the ground station.") | ||
39 | pattern noLinkToGroundStation(Spacecraft : Spacecraft) { | ||
40 | ConstellationMission.groundStationNetwork(Mission, GroundStation); | ||
41 | ConstellationMission.spacecraft(Mission, Spacecraft); | ||
42 | neg find indirectCommunicationLink(Spacecraft, GroundStation); | ||
43 | } | ||
44 | |||
45 | // No communication loops may exist | ||
46 | // No spacecraft may directly communicate with itself | ||
47 | |||
48 | @Constraint(severity = "error", key = {Element}, | ||
49 | message = "Communication loop.") | ||
50 | pattern communicationLoop(Element : CommunicatingElement) { | ||
51 | find indirectCommunicationLink(Element, Element); | ||
52 | } | ||
53 | |||
54 | private pattern indirectCommunicationLink(Source : CommunicatingElement, Target : CommunicatingElement) { | ||
55 | find directCommunicationLink+(Source, Target); | ||
56 | } | ||
57 | |||
58 | private pattern directCommunicationLink(Source : CommunicatingElement, Target : CommunicatingElement) { | ||
59 | DirectedCommunicationLink.source(Link, SourceSubsystem); | ||
60 | DirectedCommunicationLink.target(Link, TargetSubsystem); | ||
61 | CommunicatingElement.commSubsystem(Source, SourceSubsystem); | ||
62 | CommunicatingElement.commSubsystem(Target, TargetSubsystem); | ||
63 | } | ||
64 | |||
65 | // Source and target communication systems must be compatible. | ||
66 | |||
67 | @Constraint(severity = "error", key = {Link}, | ||
68 | message = "Two ends of a communication link must use the same band.") | ||
69 | pattern incompatibleSourceAndTargetBand(Link : DirectedCommunicationLink) { | ||
70 | DirectedCommunicationLink.source(Link, SourceSubsystem); | ||
71 | DirectedCommunicationLink.target(Link, TargetSubsystem); | ||
72 | CommSubsystem.band(SourceSubsystem, Band); | ||
73 | neg find commSubsystemBand(TargetSubsystem, Band); | ||
74 | } | ||
75 | |||
76 | private pattern commSubsystemBand(Comm : CommSubsystem, Band : TransceiverBand) { | ||
77 | CommSubsystem.band(Comm, Band); | ||
78 | } | ||
79 | |||
80 | @Constraint(severity = "error", key = {Link}, | ||
81 | message = "Two ends of a communication link must use the same antenna gain.") | ||
82 | pattern incompatibleSourceAndTargetGain(Link : DirectedCommunicationLink) { | ||
83 | DirectedCommunicationLink.source(Link, SourceSubsystem); | ||
84 | DirectedCommunicationLink.target(Link, TargetSubsystem); | ||
85 | CommSubsystem.gain(SourceSubsystem, Gain); | ||
86 | neg find commSubsystemGain(TargetSubsystem, Gain); | ||
87 | } | ||
88 | |||
89 | private pattern commSubsystemGain(Comm : CommSubsystem, Gain : AntennaGain) { | ||
90 | CommSubsystem.gain(Comm, Gain); | ||
91 | } | ||
92 | |||
93 | // UHF-band transmitters may only be combined with a low gain antenna | ||
94 | |||
95 | @Constraint(severity = "error", key = {Comm}, | ||
96 | message = "UHF transceiver must be combined with a low gain antenna.") | ||
97 | pattern uhfAntennaGainNotLow(Comm : CommSubsystem) { | ||
98 | CommSubsystem.band(Comm, TransceiverBand::UHF); | ||
99 | // VIATRA will fail to infer a type constraint for the virtual variable introduced | ||
100 | // when an enum literal appears in a negative pattern call, so we use a helper pattern | ||
101 | // instead of neg find commSubsystemGain(Comm, AntennaGain::LOW); | ||
102 | neg find commSubsystemGainLow(Comm); | ||
103 | } | ||
104 | |||
105 | private pattern commSubsystemGainLow(Comm : CommSubsystem) { | ||
106 | CommSubsystem.gain(Comm, AntennaGain::LOW); | ||
107 | } | ||
108 | |||
109 | // X-band transmitters may only be combined with a medium gain antenna | ||
110 | |||
111 | @Constraint(severity = "error", key = {Comm}, | ||
112 | message = "X-band transceiver must be combined with a medium gain antenna.") | ||
113 | pattern xAntennaGainNotMedium(Comm : CommSubsystem) { | ||
114 | CommSubsystem.band(Comm, TransceiverBand::X); | ||
115 | neg find commSubsystemGainMedium(Comm); | ||
116 | } | ||
117 | |||
118 | private pattern commSubsystemGainMedium(Comm : CommSubsystem) { | ||
119 | CommSubsystem.gain(Comm, AntennaGain::MEDIUM); | ||
120 | } | ||
121 | |||
122 | // Ka-band transmitters may only be combined with a medium or high gain antenna | ||
123 | |||
124 | @Constraint(severity = "error", key = {Comm}, | ||
125 | message = "Ka-band transceiver must be combined with a medium or high gain antenna.") | ||
126 | pattern kaAntennaGainLow(Comm : CommSubsystem) { | ||
127 | CommSubsystem.band(Comm, TransceiverBand::Ka); | ||
128 | CommSubsystem.gain(Comm, AntennaGain::LOW); | ||
129 | } | ||
130 | |||
131 | // 3U CubeSats are assumed to only be able to downlink to Earth using an X-band trasmitter, | ||
132 | // but cross-link using UHF | ||
133 | |||
134 | @Constraint(severity = "error", key = {Sat}, | ||
135 | message = "3U CubeSats can only cross-link using UHF.") | ||
136 | pattern threeUCubeSatWithNonUhfCrossLink(Sat : Spacecraft) { | ||
137 | Spacecraft.kind(Sat, SpacecraftKind::CubeSat3U); | ||
138 | CommunicatingElement.commSubsystem(Sat, SourceComm); | ||
139 | neg find commSubsystemBandUhf(SourceComm); | ||
140 | DirectedCommunicationLink.source(Link, SourceComm); | ||
141 | DirectedCommunicationLink.target(Link, TargetComm); | ||
142 | CommunicatingElement.commSubsystem(Target, TargetComm); | ||
143 | neg find groundStationNetwork(Target); | ||
144 | } | ||
145 | |||
146 | private pattern commSubsystemBandUhf(Comm : CommSubsystem) { | ||
147 | CommSubsystem.band(Comm, TransceiverBand::UHF); | ||
148 | } | ||
149 | |||
150 | private pattern groundStationNetwork(Network : GroundStationNetwork) { | ||
151 | GroundStationNetwork(Network); | ||
152 | } | ||
153 | |||
154 | // Only a Small Satellite can be configured with a Ka-band communication system | ||
155 | |||
156 | @Constraint(severity = "error", key = {Spacecraft}, | ||
157 | message = "Only a Small Satellite can be configured with a Ka-band communication system.") | ||
158 | pattern cubeSatWithKaAntenna(Spacecraft : Spacecraft) { | ||
159 | CommunicatingElement.commSubsystem.band(Spacecraft, TransceiverBand::Ka); | ||
160 | neg find smallSat(Spacecraft); | ||
161 | } | ||
162 | |||
163 | private pattern smallSat(Sat : Spacecraft) { | ||
164 | Spacecraft.kind(Sat, SpacecraftKind::SmallSat); | ||
165 | } | ||
166 | |||
167 | // | ||
168 | // Metrics | ||
169 | // | ||
170 | |||
171 | // Coverage | ||
172 | |||
173 | pattern coverageMetric(Coverage : java Double) { | ||
174 | Coverage == sum find missionCoverage(_, #_); | ||
175 | } | ||
176 | |||
177 | private pattern missionCoverage(Mission : InterferometryMission, Coverage : java Double) { | ||
178 | InterferometryMission.observationTime(Mission, ObservationTime); | ||
179 | ObserverCount == count find spacecraftWithInterferometryPayload(Mission, _); | ||
180 | Coverage == eval(Math.pow(1 - 2.0 / ObserverCount, 1 + 9 * (1.0 / ObservationTime)) + 0.05 * ObservationTime / 3); | ||
181 | } | ||
182 | |||
183 | // Time | ||
184 | |||
185 | pattern timeMetric(Time : java Double) { | ||
186 | Time == sum find missionTime(_, #_); | ||
187 | } | ||
188 | |||
189 | private pattern missionTime(Mission : InterferometryMission, Time : java Double) { | ||
190 | InterferometryMission.observationTime(Mission, ObservationTime); | ||
191 | TrasmitTime == sum find transmitTime(Mission, _, #_); | ||
192 | Time == eval(TrasmitTime + 60.0 * ObservationTime); | ||
193 | } | ||
194 | |||
195 | private pattern transmitTime(Mission : InterferometryMission, Spacecraft : Spacecraft, TransmitTime : java Double) { | ||
196 | ConstellationMission.spacecraft(Mission, Spacecraft); | ||
197 | find scienceData(Spacecraft, ScienceData); | ||
198 | IncomingData == sum find incomingData(Spacecraft, _, #_); | ||
199 | find transmitRate(Spacecraft, TransmitRate); | ||
200 | TransmitTime == eval((ScienceData + IncomingData) / (7.5 * TransmitRate)); | ||
201 | } | ||
202 | |||
203 | private pattern incomingData(Spacecraft : Spacecraft, Source : Spacecraft, Data : java Double) { | ||
204 | find indirectCommunicationLink(Source, Spacecraft); | ||
205 | find scienceData(Source, Data); | ||
206 | } | ||
207 | |||
208 | private pattern scienceData(Spacecraft : Spacecraft, Data : java Double) { | ||
209 | ConstellationMission.spacecraft(Mission, Spacecraft); | ||
210 | InterferometryMission.observationTime(Mission, ObservationTime); | ||
211 | Data == eval(12.0 * ObservationTime); | ||
212 | } | ||
213 | |||
214 | private pattern transmitRate(Spacecraft : Spacecraft, TransmitRate : java Double) { | ||
215 | find spacecraftUplink(Spacecraft, TransceiverBand::UHF, Target); | ||
216 | Spacecraft(Target); | ||
217 | TransmitRate == 5.0; | ||
218 | } or { | ||
219 | find spacecraftUplink(Spacecraft, TransceiverBand::X, Target); | ||
220 | Spacecraft(Target); | ||
221 | TransmitRate == 1.6; | ||
222 | } or { | ||
223 | find spacecraftUplink(Spacecraft, TransceiverBand::X, Target); | ||
224 | GroundStationNetwork(Target); | ||
225 | TransmitRate == 0.7; | ||
226 | } or { | ||
227 | find spacecraftUplink(Spacecraft, TransceiverBand::Ka, Target); | ||
228 | Spacecraft(Target); | ||
229 | TransmitRate == 220.0; | ||
230 | } or { | ||
231 | find spacecraftUplink(Spacecraft, TransceiverBand::Ka, Target); | ||
232 | GroundStationNetwork(Target); | ||
233 | TransmitRate == 80.0; | ||
234 | } | ||
235 | |||
236 | private pattern spacecraftUplink(Spacecraft : Spacecraft, Band : TransceiverBand, Target : CommunicatingElement) { | ||
237 | CommunicatingElement.communicationLink(Spacecraft, Link); | ||
238 | DirectedCommunicationLink.source.band(Link, Band); | ||
239 | DirectedCommunicationLink.target(Link, TargetSubsystem); | ||
240 | CommunicatingElement.commSubsystem(Target, TargetSubsystem); | ||
241 | } | ||
242 | |||
243 | // Cost | ||
244 | |||
245 | pattern costMetric(Cost : java Double) { | ||
246 | Cost == sum find missionCost(_, #_); | ||
247 | } | ||
248 | |||
249 | private pattern missionCost(Mission : InterferometryMission, Cost : java Double) { | ||
250 | InterferometryMission.observationTime(Mission, ObservationTime); | ||
251 | SpacecraftCost == sum find spacecraftCost(Mission, _, #_); | ||
252 | Cost == eval(SpacecraftCost + 100000.0 * ObservationTime); | ||
253 | } | ||
254 | |||
255 | private pattern spacecraftCost(Mission : InterferometryMission, Spacecraft : Spacecraft, Cost : java Double) { | ||
256 | ConstellationMission.spacecraft(Mission, Spacecraft); | ||
257 | Spacecraft.kind(Spacecraft, Kind); | ||
258 | KindCount == count find spacecraftOfKind(_, Kind); | ||
259 | find basePrice(Spacecraft, BasePrice); | ||
260 | find interferometryPayloadCost(Spacecraft, InterferometryPayloadCost); | ||
261 | find additionalCommSubsystemCost(Spacecraft, AdditionalCommSubsystemCost); | ||
262 | Cost == eval(BasePrice * Math.pow(KindCount, -0.25) + InterferometryPayloadCost + AdditionalCommSubsystemCost); | ||
263 | } | ||
264 | |||
265 | private pattern spacecraftOfKind(Spacecraft : Spacecraft, Kind : SpacecraftKind) { | ||
266 | Spacecraft.kind(Spacecraft, Kind); | ||
267 | } | ||
268 | |||
269 | private pattern basePrice(Spacecraft : Spacecraft, BasePrice : java Double) { | ||
270 | Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat3U); | ||
271 | BasePrice == 250000.0; | ||
272 | } or { | ||
273 | Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat6U); | ||
274 | BasePrice == 750000.0; | ||
275 | } or { | ||
276 | Spacecraft.kind(Spacecraft, SpacecraftKind::SmallSat); | ||
277 | BasePrice == 3000000.0; | ||
278 | } | ||
279 | |||
280 | private pattern interferometryPayloadCost(Spacecraft : Spacecraft, Cost : java Double) { | ||
281 | find spacecraftWithInterferometryPayload(_, Spacecraft); | ||
282 | Cost == 50000.0; | ||
283 | } or { | ||
284 | neg find spacecraftWithInterferometryPayload(_, Spacecraft); | ||
285 | Cost == 0.0; | ||
286 | } | ||
287 | |||
288 | private pattern additionalCommSubsystemCost(Spacecraft : Spacecraft, Cost : java Double) { | ||
289 | find spacecraftWithTwoCommSubsystems(Spacecraft); | ||
290 | Cost == 100000.0; | ||
291 | } or { | ||
292 | neg find spacecraftWithTwoCommSubsystems(Spacecraft); | ||
293 | Cost == 0.0; | ||
294 | } | ||
295 | |||
296 | private pattern spacecraftWithTwoCommSubsystems(Spacecraft : Spacecraft) { | ||
297 | Spacecraft.commSubsystem(Spacecraft, Subsystem1); | ||
298 | Spacecraft.commSubsystem(Spacecraft, Subsystem2); | ||
299 | Subsystem1 != Subsystem2; | ||
300 | } | ||