From b9aaa826e1e7504958b6e75f35e9dcd09086a13e Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sat, 4 May 2019 17:56:18 -0400 Subject: Metrics for satellite case study --- .../META-INF/MANIFEST.MF | 6 +- .../domains/satellite/SatelliteFactory.java | 27 - .../domains/satellite/SatellitePackage.java | 265 ++-------- .../dslreasoner/domains/satellite/Spacecraft.java | 30 ++ .../domains/satellite/SpacecraftKind.java | 241 +++++++++ .../domains/satellite/impl/CubeSat3UImpl.java | 37 -- .../domains/satellite/impl/CubeSat6UImpl.java | 37 -- .../satellite/impl/SatelliteFactoryImpl.java | 65 +-- .../satellite/impl/SatellitePackageImpl.java | 93 ++-- .../domains/satellite/impl/SmallSatImpl.java | 37 -- .../domains/satellite/impl/SpacecraftImpl.java | 71 +++ .../satellite/util/SatelliteAdapterFactory.java | 57 --- .../domains/satellite/util/SatelliteSwitch.java | 78 --- .../model/satellite.aird | 251 ++++------ .../model/satellite.ecore | 9 +- .../model/satellite.genmodel | 9 +- .../plugin.xml | 3 + .../domains/satellite/metrics/.gitignore | 2 + .../domains/satellite/metrics/internal/.gitignore | 2 + .../domains/satellite/queries/.gitignore | 6 + .../domains/satellite/queries/CostMetric.java | 544 ++++++++++++++++++++ .../domains/satellite/queries/CoverageMetric.java | 552 +++++++++++++++++++++ .../satellite/queries/SatelliteQueries.java | 33 ++ .../queries/ThreeUCubeSatWithNonUhfCrossLink.java | 103 ++-- .../domains/satellite/queries/TimeMetric.java | 544 ++++++++++++++++++++ .../domains/satellite/queries/internal/.gitignore | 18 + .../internal/AdditionalCommSubsystemCost.java | 173 +++++++ .../satellite/queries/internal/BasePrice.java | 216 ++++++++ .../satellite/queries/internal/IncomingData.java | 145 ++++++ .../internal/InterferometryPayloadCost.java | 175 +++++++ .../satellite/queries/internal/MissionCost.java | 183 +++++++ .../queries/internal/MissionCoverage.java | 183 +++++++ .../satellite/queries/internal/MissionTime.java | 183 +++++++ .../queries/internal/SatelliteQueriesAll.java | 51 ++ .../satellite/queries/internal/ScienceData.java | 179 +++++++ .../satellite/queries/internal/SmallSat.java | 23 +- .../satellite/queries/internal/SpacecraftCost.java | 215 ++++++++ .../queries/internal/SpacecraftOfKind.java | 140 ++++++ .../queries/internal/SpacecraftUplink.java | 171 +++++++ .../internal/SpacecraftWithTwoCommSubsystems.java | 146 ++++++ .../satellite/queries/internal/TransmitRate.java | 277 +++++++++++ .../satellite/queries/internal/TransmitTime.java | 200 ++++++++ .../domains/satellite/queries/SatelliteQueries.vql | 142 +++++- .../runner/.SatelliteGeneratorMain.xtendbin | Bin 2931 -> 0 bytes .../satellite/runner/SatelliteGeneratorMain.java | 15 - 45 files changed, 5119 insertions(+), 818 deletions(-) create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/SpacecraftKind.java delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/CubeSat3UImpl.java delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/CubeSat6UImpl.java delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SmallSatImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/.gitignore create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/internal/.gitignore create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CostMetric.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CoverageMetric.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/TimeMetric.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/AdditionalCommSubsystemCost.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/BasePrice.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/IncomingData.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/InterferometryPayloadCost.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCost.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCoverage.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionTime.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/ScienceData.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftOfKind.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftUplink.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftWithTwoCommSubsystems.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitRate.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitTime.java delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/runner/.SatelliteGeneratorMain.xtendbin delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/runner/SatelliteGeneratorMain.java diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/META-INF/MANIFEST.MF index 7b37655a..39b038d2 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/META-INF/MANIFEST.MF +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/META-INF/MANIFEST.MF @@ -3,10 +3,12 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.domains.satellite;singleton:=true Bundle-Version: 0.1.0.qualifier +Bundle-ClassPath: . Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: hu.bme.mit.inf.dslreasoner.domains.satellite, hu.bme.mit.inf.dslreasoner.domains.satellite.impl, + hu.bme.mit.inf.dslreasoner.domains.satellite.metrics, hu.bme.mit.inf.dslreasoner.domains.satellite.queries, hu.bme.mit.inf.dslreasoner.domains.satellite.runner, hu.bme.mit.inf.dslreasoner.domains.satellite.util @@ -17,7 +19,7 @@ Require-Bundle: org.eclipse.viatra.query.runtime, org.eclipse.emf.ecore;visibility:=reexport, org.eclipse.core.runtime, hu.bme.mit.inf.dslreasoner.application -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Bundle-ActivationPolicy: lazy Import-Package: org.apache.log4j Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.domains.satellite +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/SatelliteFactory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/SatelliteFactory.java index 3b77a668..958bbc08 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/SatelliteFactory.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/SatelliteFactory.java @@ -39,33 +39,6 @@ public interface SatelliteFactory extends EFactory { */ GroundStationNetwork createGroundStationNetwork(); - /** - * Returns a new object of class 'Cube Sat3 U'. - * - * - * @return a new object of class 'Cube Sat3 U'. - * @generated - */ - CubeSat3U createCubeSat3U(); - - /** - * Returns a new object of class 'Cube Sat6 U'. - * - * - * @return a new object of class 'Cube Sat6 U'. - * @generated - */ - CubeSat6U createCubeSat6U(); - - /** - * Returns a new object of class 'Small Sat'. - * - * - * @return a new object of class 'Small Sat'. - * @generated - */ - SmallSat createSmallSat(); - /** * Returns a new object of class 'Comm Subsystem'. * diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/SatellitePackage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/SatellitePackage.java index 7c590f4f..61da12a0 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/SatellitePackage.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/SatellitePackage.java @@ -288,187 +288,31 @@ public interface SatellitePackage extends EPackage { int SPACECRAFT__PAYLOAD = COMMUNICATING_ELEMENT_FEATURE_COUNT + 0; /** - * The number of structural features of the 'Spacecraft' class. - * - * - * @generated - * @ordered - */ - int SPACECRAFT_FEATURE_COUNT = COMMUNICATING_ELEMENT_FEATURE_COUNT + 1; - - /** - * The number of operations of the 'Spacecraft' class. - * - * - * @generated - * @ordered - */ - int SPACECRAFT_OPERATION_COUNT = COMMUNICATING_ELEMENT_OPERATION_COUNT + 0; - - /** - * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.impl.CubeSat3UImpl Cube Sat3 U}' class. - * - * - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.CubeSat3UImpl - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getCubeSat3U() - * @generated - */ - int CUBE_SAT3_U = 5; - - /** - * The feature id for the 'Comm Subsystem' containment reference list. - * - * - * @generated - * @ordered - */ - int CUBE_SAT3_U__COMM_SUBSYSTEM = SPACECRAFT__COMM_SUBSYSTEM; - - /** - * The feature id for the 'Communication Link' containment reference. - * - * - * @generated - * @ordered - */ - int CUBE_SAT3_U__COMMUNICATION_LINK = SPACECRAFT__COMMUNICATION_LINK; - - /** - * The feature id for the 'Payload' containment reference. - * - * - * @generated - * @ordered - */ - int CUBE_SAT3_U__PAYLOAD = SPACECRAFT__PAYLOAD; - - /** - * The number of structural features of the 'Cube Sat3 U' class. - * - * - * @generated - * @ordered - */ - int CUBE_SAT3_U_FEATURE_COUNT = SPACECRAFT_FEATURE_COUNT + 0; - - /** - * The number of operations of the 'Cube Sat3 U' class. - * - * - * @generated - * @ordered - */ - int CUBE_SAT3_U_OPERATION_COUNT = SPACECRAFT_OPERATION_COUNT + 0; - - /** - * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.impl.CubeSat6UImpl Cube Sat6 U}' class. - * - * - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.CubeSat6UImpl - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getCubeSat6U() - * @generated - */ - int CUBE_SAT6_U = 6; - - /** - * The feature id for the 'Comm Subsystem' containment reference list. - * - * - * @generated - * @ordered - */ - int CUBE_SAT6_U__COMM_SUBSYSTEM = SPACECRAFT__COMM_SUBSYSTEM; - - /** - * The feature id for the 'Communication Link' containment reference. - * - * - * @generated - * @ordered - */ - int CUBE_SAT6_U__COMMUNICATION_LINK = SPACECRAFT__COMMUNICATION_LINK; - - /** - * The feature id for the 'Payload' containment reference. - * - * - * @generated - * @ordered - */ - int CUBE_SAT6_U__PAYLOAD = SPACECRAFT__PAYLOAD; - - /** - * The number of structural features of the 'Cube Sat6 U' class. - * - * - * @generated - * @ordered - */ - int CUBE_SAT6_U_FEATURE_COUNT = SPACECRAFT_FEATURE_COUNT + 0; - - /** - * The number of operations of the 'Cube Sat6 U' class. - * - * - * @generated - * @ordered - */ - int CUBE_SAT6_U_OPERATION_COUNT = SPACECRAFT_OPERATION_COUNT + 0; - - /** - * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SmallSatImpl Small Sat}' class. - * - * - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SmallSatImpl - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getSmallSat() - * @generated - */ - int SMALL_SAT = 7; - - /** - * The feature id for the 'Comm Subsystem' containment reference list. - * - * - * @generated - * @ordered - */ - int SMALL_SAT__COMM_SUBSYSTEM = SPACECRAFT__COMM_SUBSYSTEM; - - /** - * The feature id for the 'Communication Link' containment reference. + * The feature id for the 'Kind' attribute. * * * @generated * @ordered */ - int SMALL_SAT__COMMUNICATION_LINK = SPACECRAFT__COMMUNICATION_LINK; + int SPACECRAFT__KIND = COMMUNICATING_ELEMENT_FEATURE_COUNT + 1; /** - * The feature id for the 'Payload' containment reference. - * - * - * @generated - * @ordered - */ - int SMALL_SAT__PAYLOAD = SPACECRAFT__PAYLOAD; - - /** - * The number of structural features of the 'Small Sat' class. + * The number of structural features of the 'Spacecraft' class. * * * @generated * @ordered */ - int SMALL_SAT_FEATURE_COUNT = SPACECRAFT_FEATURE_COUNT + 0; + int SPACECRAFT_FEATURE_COUNT = COMMUNICATING_ELEMENT_FEATURE_COUNT + 2; /** - * The number of operations of the 'Small Sat' class. + * The number of operations of the 'Spacecraft' class. * * * @generated * @ordered */ - int SMALL_SAT_OPERATION_COUNT = SPACECRAFT_OPERATION_COUNT + 0; + int SPACECRAFT_OPERATION_COUNT = COMMUNICATING_ELEMENT_OPERATION_COUNT + 0; /** * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.impl.CommSubsystemImpl Comm Subsystem}' class. @@ -478,7 +322,7 @@ public interface SatellitePackage extends EPackage { * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getCommSubsystem() * @generated */ - int COMM_SUBSYSTEM = 8; + int COMM_SUBSYSTEM = 5; /** * The feature id for the 'Band' attribute. @@ -524,7 +368,7 @@ public interface SatellitePackage extends EPackage { * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getDirectedCommunicationLink() * @generated */ - int DIRECTED_COMMUNICATION_LINK = 9; + int DIRECTED_COMMUNICATION_LINK = 6; /** * The feature id for the 'Source' reference. @@ -570,7 +414,7 @@ public interface SatellitePackage extends EPackage { * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getPayload() * @generated */ - int PAYLOAD = 10; + int PAYLOAD = 7; /** * The number of structural features of the 'Payload' class. @@ -598,7 +442,7 @@ public interface SatellitePackage extends EPackage { * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getInterferometryPayload() * @generated */ - int INTERFEROMETRY_PAYLOAD = 11; + int INTERFEROMETRY_PAYLOAD = 8; /** * The number of structural features of the 'Interferometry Payload' class. @@ -626,7 +470,7 @@ public interface SatellitePackage extends EPackage { * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getTransceiverBand() * @generated */ - int TRANSCEIVER_BAND = 12; + int TRANSCEIVER_BAND = 9; /** * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.AntennaGain Antenna Gain}' enum. @@ -636,7 +480,17 @@ public interface SatellitePackage extends EPackage { * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getAntennaGain() * @generated */ - int ANTENNA_GAIN = 13; + int ANTENNA_GAIN = 10; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind Spacecraft Kind}' enum. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind + * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getSpacecraftKind() + * @generated + */ + int SPACECRAFT_KIND = 11; /** * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.ConstellationMission Constellation Mission}'. @@ -755,34 +609,15 @@ public interface SatellitePackage extends EPackage { EReference getSpacecraft_Payload(); /** - * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat3U Cube Sat3 U}'. - * - * - * @return the meta object for class 'Cube Sat3 U'. - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat3U - * @generated - */ - EClass getCubeSat3U(); - - /** - * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat6U Cube Sat6 U}'. + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft#getKind Kind}'. * * - * @return the meta object for class 'Cube Sat6 U'. - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat6U - * @generated - */ - EClass getCubeSat6U(); - - /** - * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.SmallSat Small Sat}'. - * - * - * @return the meta object for class 'Small Sat'. - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.SmallSat + * @return the meta object for the attribute 'Kind'. + * @see hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft#getKind() + * @see #getSpacecraft() * @generated */ - EClass getSmallSat(); + EAttribute getSpacecraft_Kind(); /** * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem Comm Subsystem}'. @@ -888,6 +723,16 @@ public interface SatellitePackage extends EPackage { */ EEnum getAntennaGain(); + /** + * Returns the meta object for enum '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind Spacecraft Kind}'. + * + * + * @return the meta object for enum 'Spacecraft Kind'. + * @see hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind + * @generated + */ + EEnum getSpacecraftKind(); + /** * Returns the factory that creates the instances of the model. * @@ -1011,34 +856,12 @@ public interface SatellitePackage extends EPackage { EReference SPACECRAFT__PAYLOAD = eINSTANCE.getSpacecraft_Payload(); /** - * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.impl.CubeSat3UImpl Cube Sat3 U}' class. + * The meta object literal for the 'Kind' attribute feature. * * - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.CubeSat3UImpl - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getCubeSat3U() * @generated */ - EClass CUBE_SAT3_U = eINSTANCE.getCubeSat3U(); - - /** - * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.impl.CubeSat6UImpl Cube Sat6 U}' class. - * - * - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.CubeSat6UImpl - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getCubeSat6U() - * @generated - */ - EClass CUBE_SAT6_U = eINSTANCE.getCubeSat6U(); - - /** - * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SmallSatImpl Small Sat}' class. - * - * - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SmallSatImpl - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getSmallSat() - * @generated - */ - EClass SMALL_SAT = eINSTANCE.getSmallSat(); + EAttribute SPACECRAFT__KIND = eINSTANCE.getSpacecraft_Kind(); /** * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.impl.CommSubsystemImpl Comm Subsystem}' class. @@ -1132,6 +955,16 @@ public interface SatellitePackage extends EPackage { */ EEnum ANTENNA_GAIN = eINSTANCE.getAntennaGain(); + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind Spacecraft Kind}' enum. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind + * @see hu.bme.mit.inf.dslreasoner.domains.satellite.impl.SatellitePackageImpl#getSpacecraftKind() + * @generated + */ + EEnum SPACECRAFT_KIND = eINSTANCE.getSpacecraftKind(); + } } //SatellitePackage diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/Spacecraft.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/Spacecraft.java index 2e5e5044..cc4b85a1 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/Spacecraft.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/Spacecraft.java @@ -12,6 +12,7 @@ package hu.bme.mit.inf.dslreasoner.domains.satellite; *

* * * @see hu.bme.mit.inf.dslreasoner.domains.satellite.SatellitePackage#getSpacecraft() @@ -45,4 +46,33 @@ public interface Spacecraft extends CommunicatingElement { */ void setPayload(Payload value); + /** + * Returns the value of the 'Kind' attribute. + * The literals are from the enumeration {@link hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind}. + * + *

+ * If the meaning of the 'Kind' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Kind' attribute. + * @see hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind + * @see #setKind(SpacecraftKind) + * @see hu.bme.mit.inf.dslreasoner.domains.satellite.SatellitePackage#getSpacecraft_Kind() + * @model required="true" + * @generated + */ + SpacecraftKind getKind(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft#getKind Kind}' attribute. + * + * + * @param value the new value of the 'Kind' attribute. + * @see hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind + * @see #getKind() + * @generated + */ + void setKind(SpacecraftKind value); + } // Spacecraft diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/SpacecraftKind.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/SpacecraftKind.java new file mode 100644 index 00000000..8be6abc1 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/SpacecraftKind.java @@ -0,0 +1,241 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.eclipse.emf.common.util.Enumerator; + +/** + * + * A representation of the literals of the enumeration 'Spacecraft Kind', + * and utility methods for working with them. + * + * @see hu.bme.mit.inf.dslreasoner.domains.satellite.SatellitePackage#getSpacecraftKind() + * @model + * @generated + */ +public enum SpacecraftKind implements Enumerator { + /** + * The 'Cube Sat3 U' literal object. + * + * + * @see #CUBE_SAT3_U_VALUE + * @generated + * @ordered + */ + CUBE_SAT3_U(0, "CubeSat3U", "CubeSat3U"), + + /** + * The 'Cube Sat6 U' literal object. + * + * + * @see #CUBE_SAT6_U_VALUE + * @generated + * @ordered + */ + CUBE_SAT6_U(1, "CubeSat6U", "CubeSat6U"), + /** + * The 'Small Sat' literal object. + * + * + * @see #SMALL_SAT_VALUE + * @generated + * @ordered + */ + SMALL_SAT(2, "SmallSat", "SmallSat"); + + /** + * The 'Cube Sat3 U' literal value. + * + *

+ * If the meaning of 'Cube Sat3 U' literal object isn't clear, + * there really should be more of a description here... + *

+ * + * @see #CUBE_SAT3_U + * @model name="CubeSat3U" + * @generated + * @ordered + */ + public static final int CUBE_SAT3_U_VALUE = 0; + + /** + * The 'Cube Sat6 U' literal value. + * + *

+ * If the meaning of 'Cube Sat6 U' literal object isn't clear, + * there really should be more of a description here... + *

+ * + * @see #CUBE_SAT6_U + * @model name="CubeSat6U" + * @generated + * @ordered + */ + public static final int CUBE_SAT6_U_VALUE = 1; + + /** + * The 'Small Sat' literal value. + * + *

+ * If the meaning of 'Small Sat' literal object isn't clear, + * there really should be more of a description here... + *

+ * + * @see #SMALL_SAT + * @model name="SmallSat" + * @generated + * @ordered + */ + public static final int SMALL_SAT_VALUE = 2; + + /** + * An array of all the 'Spacecraft Kind' enumerators. + * + * + * @generated + */ + private static final SpacecraftKind[] VALUES_ARRAY = new SpacecraftKind[] { CUBE_SAT3_U, CUBE_SAT6_U, SMALL_SAT, }; + + /** + * A public read-only list of all the 'Spacecraft Kind' enumerators. + * + * + * @generated + */ + public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); + + /** + * Returns the 'Spacecraft Kind' literal with the specified literal value. + * + * + * @param literal the literal. + * @return the matching enumerator or null. + * @generated + */ + public static SpacecraftKind get(String literal) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + SpacecraftKind result = VALUES_ARRAY[i]; + if (result.toString().equals(literal)) { + return result; + } + } + return null; + } + + /** + * Returns the 'Spacecraft Kind' literal with the specified name. + * + * + * @param name the name. + * @return the matching enumerator or null. + * @generated + */ + public static SpacecraftKind getByName(String name) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + SpacecraftKind result = VALUES_ARRAY[i]; + if (result.getName().equals(name)) { + return result; + } + } + return null; + } + + /** + * Returns the 'Spacecraft Kind' literal with the specified integer value. + * + * + * @param value the integer value. + * @return the matching enumerator or null. + * @generated + */ + public static SpacecraftKind get(int value) { + switch (value) { + case CUBE_SAT3_U_VALUE: + return CUBE_SAT3_U; + case CUBE_SAT6_U_VALUE: + return CUBE_SAT6_U; + case SMALL_SAT_VALUE: + return SMALL_SAT; + } + return null; + } + + /** + * + * + * @generated + */ + private final int value; + + /** + * + * + * @generated + */ + private final String name; + + /** + * + * + * @generated + */ + private final String literal; + + /** + * Only this class can construct instances. + * + * + * @generated + */ + private SpacecraftKind(int value, String name, String literal) { + this.value = value; + this.name = name; + this.literal = literal; + } + + /** + * + * + * @generated + */ + @Override + public int getValue() { + return value; + } + + /** + * + * + * @generated + */ + @Override + public String getName() { + return name; + } + + /** + * + * + * @generated + */ + @Override + public String getLiteral() { + return literal; + } + + /** + * Returns the literal value of the enumerator, which is its string representation. + * + * + * @generated + */ + @Override + public String toString() { + return literal; + } + +} //SpacecraftKind diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/CubeSat3UImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/CubeSat3UImpl.java deleted file mode 100644 index 0057b3d4..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/CubeSat3UImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - */ -package hu.bme.mit.inf.dslreasoner.domains.satellite.impl; - -import hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat3U; -import hu.bme.mit.inf.dslreasoner.domains.satellite.SatellitePackage; - -import org.eclipse.emf.ecore.EClass; - -/** - * - * An implementation of the model object 'Cube Sat3 U'. - * - * - * @generated - */ -public class CubeSat3UImpl extends SpacecraftImpl implements CubeSat3U { - /** - * - * - * @generated - */ - protected CubeSat3UImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return SatellitePackage.Literals.CUBE_SAT3_U; - } - -} //CubeSat3UImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/CubeSat6UImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/CubeSat6UImpl.java deleted file mode 100644 index 3f34c6ea..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/CubeSat6UImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - */ -package hu.bme.mit.inf.dslreasoner.domains.satellite.impl; - -import hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat6U; -import hu.bme.mit.inf.dslreasoner.domains.satellite.SatellitePackage; - -import org.eclipse.emf.ecore.EClass; - -/** - * - * An implementation of the model object 'Cube Sat6 U'. - * - * - * @generated - */ -public class CubeSat6UImpl extends SpacecraftImpl implements CubeSat6U { - /** - * - * - * @generated - */ - protected CubeSat6UImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return SatellitePackage.Literals.CUBE_SAT6_U; - } - -} //CubeSat6UImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SatelliteFactoryImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SatelliteFactoryImpl.java index 5deb0c05..0cb07cfa 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SatelliteFactoryImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SatelliteFactoryImpl.java @@ -61,12 +61,6 @@ public class SatelliteFactoryImpl extends EFactoryImpl implements SatelliteFacto return createInterferometryMission(); case SatellitePackage.GROUND_STATION_NETWORK: return createGroundStationNetwork(); - case SatellitePackage.CUBE_SAT3_U: - return createCubeSat3U(); - case SatellitePackage.CUBE_SAT6_U: - return createCubeSat6U(); - case SatellitePackage.SMALL_SAT: - return createSmallSat(); case SatellitePackage.COMM_SUBSYSTEM: return createCommSubsystem(); case SatellitePackage.DIRECTED_COMMUNICATION_LINK: @@ -90,6 +84,8 @@ public class SatelliteFactoryImpl extends EFactoryImpl implements SatelliteFacto return createTransceiverBandFromString(eDataType, initialValue); case SatellitePackage.ANTENNA_GAIN: return createAntennaGainFromString(eDataType, initialValue); + case SatellitePackage.SPACECRAFT_KIND: + return createSpacecraftKindFromString(eDataType, initialValue); default: throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); } @@ -107,6 +103,8 @@ public class SatelliteFactoryImpl extends EFactoryImpl implements SatelliteFacto return convertTransceiverBandToString(eDataType, instanceValue); case SatellitePackage.ANTENNA_GAIN: return convertAntennaGainToString(eDataType, instanceValue); + case SatellitePackage.SPACECRAFT_KIND: + return convertSpacecraftKindToString(eDataType, instanceValue); default: throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); } @@ -134,39 +132,6 @@ public class SatelliteFactoryImpl extends EFactoryImpl implements SatelliteFacto return groundStationNetwork; } - /** - * - * - * @generated - */ - @Override - public CubeSat3U createCubeSat3U() { - CubeSat3UImpl cubeSat3U = new CubeSat3UImpl(); - return cubeSat3U; - } - - /** - * - * - * @generated - */ - @Override - public CubeSat6U createCubeSat6U() { - CubeSat6UImpl cubeSat6U = new CubeSat6UImpl(); - return cubeSat6U; - } - - /** - * - * - * @generated - */ - @Override - public SmallSat createSmallSat() { - SmallSatImpl smallSat = new SmallSatImpl(); - return smallSat; - } - /** * * @@ -244,6 +209,28 @@ public class SatelliteFactoryImpl extends EFactoryImpl implements SatelliteFacto return instanceValue == null ? null : instanceValue.toString(); } + /** + * + * + * @generated + */ + public SpacecraftKind createSpacecraftKindFromString(EDataType eDataType, String initialValue) { + SpacecraftKind result = SpacecraftKind.get(initialValue); + if (result == null) + throw new IllegalArgumentException( + "The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); + return result; + } + + /** + * + * + * @generated + */ + public String convertSpacecraftKindToString(EDataType eDataType, Object instanceValue) { + return instanceValue == null ? null : instanceValue.toString(); + } + /** * * diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SatellitePackageImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SatellitePackageImpl.java index 067eabd4..48ba32b8 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SatellitePackageImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SatellitePackageImpl.java @@ -6,8 +6,6 @@ import hu.bme.mit.inf.dslreasoner.domains.satellite.AntennaGain; import hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem; import hu.bme.mit.inf.dslreasoner.domains.satellite.CommunicatingElement; import hu.bme.mit.inf.dslreasoner.domains.satellite.ConstellationMission; -import hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat3U; -import hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat6U; import hu.bme.mit.inf.dslreasoner.domains.satellite.DirectedCommunicationLink; import hu.bme.mit.inf.dslreasoner.domains.satellite.GroundStationNetwork; import hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission; @@ -15,8 +13,8 @@ import hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryPayload; import hu.bme.mit.inf.dslreasoner.domains.satellite.Payload; import hu.bme.mit.inf.dslreasoner.domains.satellite.SatelliteFactory; import hu.bme.mit.inf.dslreasoner.domains.satellite.SatellitePackage; -import hu.bme.mit.inf.dslreasoner.domains.satellite.SmallSat; import hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft; +import hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind; import hu.bme.mit.inf.dslreasoner.domains.satellite.TransceiverBand; import org.eclipse.emf.ecore.EAttribute; @@ -69,27 +67,6 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka */ private EClass spacecraftEClass = null; - /** - * - * - * @generated - */ - private EClass cubeSat3UEClass = null; - - /** - * - * - * @generated - */ - private EClass cubeSat6UEClass = null; - - /** - * - * - * @generated - */ - private EClass smallSatEClass = null; - /** * * @@ -132,6 +109,13 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka */ private EEnum antennaGainEEnum = null; + /** + * + * + * @generated + */ + private EEnum spacecraftKindEEnum = null; + /** * Creates an instance of the model Package, registered with * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package @@ -312,28 +296,8 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka * @generated */ @Override - public EClass getCubeSat3U() { - return cubeSat3UEClass; - } - - /** - * - * - * @generated - */ - @Override - public EClass getCubeSat6U() { - return cubeSat6UEClass; - } - - /** - * - * - * @generated - */ - @Override - public EClass getSmallSat() { - return smallSatEClass; + public EAttribute getSpacecraft_Kind() { + return (EAttribute) spacecraftEClass.getEStructuralFeatures().get(1); } /** @@ -436,6 +400,16 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka return antennaGainEEnum; } + /** + * + * + * @generated + */ + @Override + public EEnum getSpacecraftKind() { + return spacecraftKindEEnum; + } + /** * * @@ -481,12 +455,7 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka spacecraftEClass = createEClass(SPACECRAFT); createEReference(spacecraftEClass, SPACECRAFT__PAYLOAD); - - cubeSat3UEClass = createEClass(CUBE_SAT3_U); - - cubeSat6UEClass = createEClass(CUBE_SAT6_U); - - smallSatEClass = createEClass(SMALL_SAT); + createEAttribute(spacecraftEClass, SPACECRAFT__KIND); commSubsystemEClass = createEClass(COMM_SUBSYSTEM); createEAttribute(commSubsystemEClass, COMM_SUBSYSTEM__BAND); @@ -503,6 +472,7 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka // Create enums transceiverBandEEnum = createEEnum(TRANSCEIVER_BAND); antennaGainEEnum = createEEnum(ANTENNA_GAIN); + spacecraftKindEEnum = createEEnum(SPACECRAFT_KIND); } /** @@ -537,9 +507,6 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka interferometryMissionEClass.getESuperTypes().add(this.getConstellationMission()); groundStationNetworkEClass.getESuperTypes().add(this.getCommunicatingElement()); spacecraftEClass.getESuperTypes().add(this.getCommunicatingElement()); - cubeSat3UEClass.getESuperTypes().add(this.getSpacecraft()); - cubeSat6UEClass.getESuperTypes().add(this.getSpacecraft()); - smallSatEClass.getESuperTypes().add(this.getSpacecraft()); interferometryPayloadEClass.getESuperTypes().add(this.getPayload()); // Initialize classes, features, and operations; add parameters @@ -575,15 +542,8 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka initEReference(getSpacecraft_Payload(), this.getPayload(), null, "payload", null, 0, 1, Spacecraft.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - initEClass(cubeSat3UEClass, CubeSat3U.class, "CubeSat3U", !IS_ABSTRACT, !IS_INTERFACE, - IS_GENERATED_INSTANCE_CLASS); - - initEClass(cubeSat6UEClass, CubeSat6U.class, "CubeSat6U", !IS_ABSTRACT, !IS_INTERFACE, - IS_GENERATED_INSTANCE_CLASS); - - initEClass(smallSatEClass, SmallSat.class, "SmallSat", !IS_ABSTRACT, !IS_INTERFACE, - IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getSpacecraft_Kind(), this.getSpacecraftKind(), "kind", null, 1, 1, Spacecraft.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(commSubsystemEClass, CommSubsystem.class, "CommSubsystem", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); @@ -617,6 +577,11 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka addEEnumLiteral(antennaGainEEnum, AntennaGain.MEDIUM); addEEnumLiteral(antennaGainEEnum, AntennaGain.HIGH); + initEEnum(spacecraftKindEEnum, SpacecraftKind.class, "SpacecraftKind"); + addEEnumLiteral(spacecraftKindEEnum, SpacecraftKind.CUBE_SAT3_U); + addEEnumLiteral(spacecraftKindEEnum, SpacecraftKind.CUBE_SAT6_U); + addEEnumLiteral(spacecraftKindEEnum, SpacecraftKind.SMALL_SAT); + // Create resource createResource(eNS_URI); } diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SmallSatImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SmallSatImpl.java deleted file mode 100644 index 522991ad..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SmallSatImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - */ -package hu.bme.mit.inf.dslreasoner.domains.satellite.impl; - -import hu.bme.mit.inf.dslreasoner.domains.satellite.SatellitePackage; -import hu.bme.mit.inf.dslreasoner.domains.satellite.SmallSat; - -import org.eclipse.emf.ecore.EClass; - -/** - * - * An implementation of the model object 'Small Sat'. - * - * - * @generated - */ -public class SmallSatImpl extends SpacecraftImpl implements SmallSat { - /** - * - * - * @generated - */ - protected SmallSatImpl() { - super(); - } - - /** - * - * - * @generated - */ - @Override - protected EClass eStaticClass() { - return SatellitePackage.Literals.SMALL_SAT; - } - -} //SmallSatImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SpacecraftImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SpacecraftImpl.java index caefd377..2135af2c 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SpacecraftImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/impl/SpacecraftImpl.java @@ -6,6 +6,7 @@ import hu.bme.mit.inf.dslreasoner.domains.satellite.Payload; import hu.bme.mit.inf.dslreasoner.domains.satellite.SatellitePackage; import hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft; +import hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; @@ -23,6 +24,7 @@ import org.eclipse.emf.ecore.impl.ENotificationImpl; *

* * * @generated @@ -38,6 +40,25 @@ public abstract class SpacecraftImpl extends CommunicatingElementImpl implements */ protected Payload payload; + /** + * The default value of the '{@link #getKind() Kind}' attribute. + * + * + * @see #getKind() + * @generated + * @ordered + */ + protected static final SpacecraftKind KIND_EDEFAULT = SpacecraftKind.CUBE_SAT3_U; + /** + * The cached value of the '{@link #getKind() Kind}' attribute. + * + * + * @see #getKind() + * @generated + * @ordered + */ + protected SpacecraftKind kind = KIND_EDEFAULT; + /** * * @@ -109,6 +130,29 @@ public abstract class SpacecraftImpl extends CommunicatingElementImpl implements newPayload)); } + /** + * + * + * @generated + */ + @Override + public SpacecraftKind getKind() { + return kind; + } + + /** + * + * + * @generated + */ + @Override + public void setKind(SpacecraftKind newKind) { + SpacecraftKind oldKind = kind; + kind = newKind == null ? KIND_EDEFAULT : newKind; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SatellitePackage.SPACECRAFT__KIND, oldKind, kind)); + } + /** * * @@ -133,6 +177,8 @@ public abstract class SpacecraftImpl extends CommunicatingElementImpl implements switch (featureID) { case SatellitePackage.SPACECRAFT__PAYLOAD: return getPayload(); + case SatellitePackage.SPACECRAFT__KIND: + return getKind(); } return super.eGet(featureID, resolve, coreType); } @@ -148,6 +194,9 @@ public abstract class SpacecraftImpl extends CommunicatingElementImpl implements case SatellitePackage.SPACECRAFT__PAYLOAD: setPayload((Payload) newValue); return; + case SatellitePackage.SPACECRAFT__KIND: + setKind((SpacecraftKind) newValue); + return; } super.eSet(featureID, newValue); } @@ -163,6 +212,9 @@ public abstract class SpacecraftImpl extends CommunicatingElementImpl implements case SatellitePackage.SPACECRAFT__PAYLOAD: setPayload((Payload) null); return; + case SatellitePackage.SPACECRAFT__KIND: + setKind(KIND_EDEFAULT); + return; } super.eUnset(featureID); } @@ -177,8 +229,27 @@ public abstract class SpacecraftImpl extends CommunicatingElementImpl implements switch (featureID) { case SatellitePackage.SPACECRAFT__PAYLOAD: return payload != null; + case SatellitePackage.SPACECRAFT__KIND: + return kind != KIND_EDEFAULT; } return super.eIsSet(featureID); } + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (kind: "); + result.append(kind); + result.append(')'); + return result.toString(); + } + } //SpacecraftImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/util/SatelliteAdapterFactory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/util/SatelliteAdapterFactory.java index c2ba615b..639a40b7 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/util/SatelliteAdapterFactory.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/util/SatelliteAdapterFactory.java @@ -91,21 +91,6 @@ public class SatelliteAdapterFactory extends AdapterFactoryImpl { return createSpacecraftAdapter(); } - @Override - public Adapter caseCubeSat3U(CubeSat3U object) { - return createCubeSat3UAdapter(); - } - - @Override - public Adapter caseCubeSat6U(CubeSat6U object) { - return createCubeSat6UAdapter(); - } - - @Override - public Adapter caseSmallSat(SmallSat object) { - return createSmallSatAdapter(); - } - @Override public Adapter caseCommSubsystem(CommSubsystem object) { return createCommSubsystemAdapter(); @@ -215,48 +200,6 @@ public class SatelliteAdapterFactory extends AdapterFactoryImpl { return null; } - /** - * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat3U Cube Sat3 U}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat3U - * @generated - */ - public Adapter createCubeSat3UAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat6U Cube Sat6 U}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat6U - * @generated - */ - public Adapter createCubeSat6UAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.SmallSat Small Sat}'. - * - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * - * @return the new adapter. - * @see hu.bme.mit.inf.dslreasoner.domains.satellite.SmallSat - * @generated - */ - public Adapter createSmallSatAdapter() { - return null; - } - /** * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.satellite.CommSubsystem Comm Subsystem}'. * diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/util/SatelliteSwitch.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/util/SatelliteSwitch.java index 65b24430..e78a1cd2 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/util/SatelliteSwitch.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/util/SatelliteSwitch.java @@ -107,39 +107,6 @@ public class SatelliteSwitch extends Switch { result = defaultCase(theEObject); return result; } - case SatellitePackage.CUBE_SAT3_U: { - CubeSat3U cubeSat3U = (CubeSat3U) theEObject; - T result = caseCubeSat3U(cubeSat3U); - if (result == null) - result = caseSpacecraft(cubeSat3U); - if (result == null) - result = caseCommunicatingElement(cubeSat3U); - if (result == null) - result = defaultCase(theEObject); - return result; - } - case SatellitePackage.CUBE_SAT6_U: { - CubeSat6U cubeSat6U = (CubeSat6U) theEObject; - T result = caseCubeSat6U(cubeSat6U); - if (result == null) - result = caseSpacecraft(cubeSat6U); - if (result == null) - result = caseCommunicatingElement(cubeSat6U); - if (result == null) - result = defaultCase(theEObject); - return result; - } - case SatellitePackage.SMALL_SAT: { - SmallSat smallSat = (SmallSat) theEObject; - T result = caseSmallSat(smallSat); - if (result == null) - result = caseSpacecraft(smallSat); - if (result == null) - result = caseCommunicatingElement(smallSat); - if (result == null) - result = defaultCase(theEObject); - return result; - } case SatellitePackage.COMM_SUBSYSTEM: { CommSubsystem commSubsystem = (CommSubsystem) theEObject; T result = caseCommSubsystem(commSubsystem); @@ -250,51 +217,6 @@ public class SatelliteSwitch extends Switch { return null; } - /** - * Returns the result of interpreting the object as an instance of 'Cube Sat3 U'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Cube Sat3 U'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseCubeSat3U(CubeSat3U object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Cube Sat6 U'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Cube Sat6 U'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseCubeSat6U(CubeSat6U object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of 'Small Sat'. - * - * This implementation returns null; - * returning a non-null result will terminate the switch. - * - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of 'Small Sat'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseSmallSat(SmallSat object) { - return null; - } - /** * Returns the result of interpreting the object as an instance of 'Comm Subsystem'. * diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.aird b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.aird index 3aa1cc06..569089d8 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.aird +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.aird @@ -1277,6 +1277,35 @@ java:/Objects/java.io.Console java:/Objects/java.io.FileOutputStream ../inputs/SatelliteInstance.xmi + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.ScriptConsole + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.ScriptConsoleDecorator + java:/Objects/hu.bme.mit.inf.dslreasoner.application.ApplicationConfigurationStandaloneSetup + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.StandardOutputBasedScriptConsole + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.util.ApplicationConfigurationParser + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.PatternLanguageWithRSSetup + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.PatternLanguageWithRSModule + java:/Objects/hu.bme.mit.inf.dslreasoner.application.ApplicationConfigurationStandaloneRuntimeModule + java:/Objects/hu.bme.mit.inf.dslreasoner.application.validation.ApplicationConfigurationValidator + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.GenerationTaskExecutor + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.MetamodelLoader + java:/Objects/hu.bme.mit.inf.dslreasoner.application.validation.MetamodelValidator + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.ModelLoader + java:/Objects/hu.bme.mit.inf.dslreasoner.application.validation.QueryAndMetamodelValidator + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.QueryLoader + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.ScopeLoader + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.SolverLoader + java:/Objects/hu.bme.mit.inf.dslreasoner.application.valueconverter.QualifiedNameValueConverter + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.NullWorkspace + java:/Objects/hu.bme.mit.inf.dslreasoner.application.execution.EclipseBasedProgressMonitor + java:/Objects/org.eclipse.viatra.query.runtime.matchers.aggregators.count + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.AggregatorType + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IAggregatorFactory + java:/Objects/java.lang.annotation.Inherited + java:/Objects/org.eclipse.viatra.query.runtime.matchers.aggregators.min + ../src/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/SatelliteMetrics.vql + java:/Objects/org.eclipse.viatra.query.runtime.matchers.aggregators.max @@ -1370,39 +1399,16 @@ + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1489,6 +1495,27 @@ + + + + + + + + + + + + + + + + + + + + + @@ -1506,54 +1533,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1782,86 +1761,25 @@ - + KEEP_LOCATION KEEP_SIZE KEEP_RATIO - + italic - - - - - KEEP_LOCATION - KEEP_SIZE - KEEP_RATIO - - - - - - - - - KEEP_LOCATION - KEEP_SIZE - KEEP_RATIO - - - - - - - - - KEEP_LOCATION - KEEP_SIZE - KEEP_RATIO - - - - - - - - - - - - italic - - - - - - - - - - - - italic - - - - - - - - - - - - italic - - - - + + + + + bold + + + @@ -1878,12 +1796,12 @@ - + - + italic - + @@ -2111,6 +2029,41 @@ + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.ecore b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.ecore index d439fe23..99766ab7 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.ecore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.ecore @@ -21,10 +21,8 @@ + - - - @@ -47,4 +45,9 @@ + + + + + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.genmodel b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.genmodel index a90d5b26..61a4104a 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.genmodel +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.genmodel @@ -22,6 +22,11 @@ + + + + + @@ -36,10 +41,8 @@ + - - - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml index 3f4b1691..0cdd345c 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml @@ -17,6 +17,9 @@ + + + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/.gitignore new file mode 100644 index 00000000..3e7cd5e2 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/.gitignore @@ -0,0 +1,2 @@ +/.CoverageMetric.java._trace +/.SatelliteMetrics.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/internal/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/internal/.gitignore new file mode 100644 index 00000000..d3195cfc --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/metrics/internal/.gitignore @@ -0,0 +1,2 @@ +/.MissionCoverage.java._trace +/.SatelliteMetricsAll.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/.gitignore index 29459700..5f0d5b4b 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/.gitignore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/.gitignore @@ -14,3 +14,9 @@ /.CubeSatWithKaAntenna.java._trace /.ThreeUCubeSatWithNonUhfCrossLink.java._trace /.CommunicationLinkDoesNotStartAtContainingElement.java._trace +/.SpacecraftWithInterferometryPayload.java._trace +/.SatelliteMetrics.java._trace +/.CoverageMetric.java._trace +/.TimeMetric.java._trace +/.CostMetric.java._trace +/.SpacecraftCost.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CostMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CostMetric.java new file mode 100644 index 00000000..474719b2 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CostMetric.java @@ -0,0 +1,544 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         // Cost
+ *         
+ *         pattern costMetric(Cost : java Double) {
+ *         	Cost == sum find missionCost(_, #_);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class CostMetric extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.costMetric pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Double fCost; + + private static List parameterNames = makeImmutableList("Cost"); + + private Match(final Double pCost) { + this.fCost = pCost; + } + + @Override + public Object get(final String parameterName) { + if ("Cost".equals(parameterName)) return this.fCost; + return null; + } + + public Double getCost() { + return this.fCost; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Cost".equals(parameterName) ) { + this.fCost = (Double) newValue; + return true; + } + return false; + } + + public void setCost(final Double pCost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fCost = pCost; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.costMetric"; + } + + @Override + public List parameterNames() { + return CostMetric.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fCost}; + } + + @Override + public CostMetric.Match toImmutable() { + return isMutable() ? newMatch(fCost) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Cost\"=" + prettyPrintValue(fCost)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fCost); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof CostMetric.Match)) { + CostMetric.Match other = (CostMetric.Match) obj; + return Objects.equals(fCost, other.fCost); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public CostMetric specification() { + return CostMetric.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static CostMetric.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static CostMetric.Match newMutableMatch(final Double pCost) { + return new Mutable(pCost); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the (partial) match object. + * + */ + public static CostMetric.Match newMatch(final Double pCost) { + return new Immutable(pCost); + } + + private static final class Mutable extends CostMetric.Match { + Mutable(final Double pCost) { + super(pCost); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends CostMetric.Match { + Immutable(final Double pCost) { + super(pCost); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.costMetric pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * // Cost
+   * 
+   * pattern costMetric(Cost : java Double) {
+   * 	Cost == sum find missionCost(_, #_);
+   * }
+   * 
+ * + * @see Match + * @see CostMetric + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static CostMetric.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static CostMetric.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_COST = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CostMetric.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Double pCost) { + return rawStreamAllMatches(new Object[]{pCost}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Double pCost) { + return rawStreamAllMatches(new Object[]{pCost}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Double pCost) { + return rawGetOneArbitraryMatch(new Object[]{pCost}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Double pCost) { + return rawHasMatch(new Object[]{pCost}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Double pCost) { + return rawCountMatches(new Object[]{pCost}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Double pCost, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pCost}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the (partial) match object. + * + */ + public CostMetric.Match newMatch(final Double pCost) { + return CostMetric.Match.newMatch(pCost); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfCost(final Object[] parameters) { + return rawStreamAllValues(POSITION_COST, parameters).map(Double.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCost() { + return rawStreamAllValuesOfCost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCost() { + return rawStreamAllValuesOfCost(emptyArray()); + } + + @Override + protected CostMetric.Match tupleToMatch(final Tuple t) { + try { + return CostMetric.Match.newMatch((Double) t.get(POSITION_COST)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected CostMetric.Match arrayToMatch(final Object[] match) { + try { + return CostMetric.Match.newMatch((Double) match[POSITION_COST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected CostMetric.Match arrayToMatchMutable(final Object[] match) { + try { + return CostMetric.Match.newMutableMatch((Double) match[POSITION_COST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return CostMetric.instance(); + } + } + + private CostMetric() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static CostMetric instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected CostMetric.Matcher instantiate(final ViatraQueryEngine engine) { + return CostMetric.Matcher.on(engine); + } + + @Override + public CostMetric.Matcher instantiate() { + return CostMetric.Matcher.create(); + } + + @Override + public CostMetric.Match newEmptyMatch() { + return CostMetric.Match.newEmptyMatch(); + } + + @Override + public CostMetric.Match newMatch(final Object... parameters) { + return CostMetric.Match.newMatch((java.lang.Double) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric (visibility: PUBLIC, simpleName: CostMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric (visibility: PUBLIC, simpleName: CostMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final CostMetric INSTANCE = new CostMetric(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final CostMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Cost); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.costMetric"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Cost"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Cost = body.getOrCreateVariableByName("Cost"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // Cost == sum find missionCost(_, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), MissionCost.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); + new Equality(body, var_Cost, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CoverageMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CoverageMetric.java new file mode 100644 index 00000000..23b02ce4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CoverageMetric.java @@ -0,0 +1,552 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCoverage; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

+ *         //
+ *         // Metrics
+ *         //
+ *         
+ *         // Coverage
+ *         
+ *         pattern coverageMetric(Coverage : java Double) {
+ *         	Coverage == sum find missionCoverage(_, #_);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class CoverageMetric extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.coverageMetric pattern, + * to be used in conjunction with {@link Matcher}. + * + *

Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Double fCoverage; + + private static List parameterNames = makeImmutableList("Coverage"); + + private Match(final Double pCoverage) { + this.fCoverage = pCoverage; + } + + @Override + public Object get(final String parameterName) { + if ("Coverage".equals(parameterName)) return this.fCoverage; + return null; + } + + public Double getCoverage() { + return this.fCoverage; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Coverage".equals(parameterName) ) { + this.fCoverage = (Double) newValue; + return true; + } + return false; + } + + public void setCoverage(final Double pCoverage) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fCoverage = pCoverage; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.coverageMetric"; + } + + @Override + public List parameterNames() { + return CoverageMetric.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fCoverage}; + } + + @Override + public CoverageMetric.Match toImmutable() { + return isMutable() ? newMatch(fCoverage) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Coverage\"=" + prettyPrintValue(fCoverage)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fCoverage); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof CoverageMetric.Match)) { + CoverageMetric.Match other = (CoverageMetric.Match) obj; + return Objects.equals(fCoverage, other.fCoverage); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public CoverageMetric specification() { + return CoverageMetric.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static CoverageMetric.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static CoverageMetric.Match newMutableMatch(final Double pCoverage) { + return new Mutable(pCoverage); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. + * @return the (partial) match object. + * + */ + public static CoverageMetric.Match newMatch(final Double pCoverage) { + return new Immutable(pCoverage); + } + + private static final class Mutable extends CoverageMetric.Match { + Mutable(final Double pCoverage) { + super(pCoverage); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends CoverageMetric.Match { + Immutable(final Double pCoverage) { + super(pCoverage); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.coverageMetric pattern, + * providing pattern-specific query methods. + * + *

Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

Matches of the pattern will be represented as {@link Match}. + * + *

Original source: + *

+   * //
+   * // Metrics
+   * //
+   * 
+   * // Coverage
+   * 
+   * pattern coverageMetric(Coverage : java Double) {
+   * 	Coverage == sum find missionCoverage(_, #_);
+   * }
+   * 
+ * + * @see Match + * @see CoverageMetric + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static CoverageMetric.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static CoverageMetric.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_COVERAGE = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CoverageMetric.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Double pCoverage) { + return rawStreamAllMatches(new Object[]{pCoverage}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

+ * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Double pCoverage) { + return rawStreamAllMatches(new Object[]{pCoverage}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Double pCoverage) { + return rawGetOneArbitraryMatch(new Object[]{pCoverage}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Double pCoverage) { + return rawHasMatch(new Object[]{pCoverage}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Double pCoverage) { + return rawCountMatches(new Object[]{pCoverage}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Double pCoverage, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pCoverage}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pCoverage the fixed value of pattern parameter Coverage, or null if not bound. + * @return the (partial) match object. + * + */ + public CoverageMetric.Match newMatch(final Double pCoverage) { + return CoverageMetric.Match.newMatch(pCoverage); + } + + /** + * Retrieve the set of values that occur in matches for Coverage. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfCoverage(final Object[] parameters) { + return rawStreamAllValues(POSITION_COVERAGE, parameters).map(Double.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Coverage. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCoverage() { + return rawStreamAllValuesOfCoverage(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Coverage. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCoverage() { + return rawStreamAllValuesOfCoverage(emptyArray()); + } + + @Override + protected CoverageMetric.Match tupleToMatch(final Tuple t) { + try { + return CoverageMetric.Match.newMatch((Double) t.get(POSITION_COVERAGE)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected CoverageMetric.Match arrayToMatch(final Object[] match) { + try { + return CoverageMetric.Match.newMatch((Double) match[POSITION_COVERAGE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected CoverageMetric.Match arrayToMatchMutable(final Object[] match) { + try { + return CoverageMetric.Match.newMutableMatch((Double) match[POSITION_COVERAGE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return CoverageMetric.instance(); + } + } + + private CoverageMetric() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static CoverageMetric instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected CoverageMetric.Matcher instantiate(final ViatraQueryEngine engine) { + return CoverageMetric.Matcher.on(engine); + } + + @Override + public CoverageMetric.Matcher instantiate() { + return CoverageMetric.Matcher.create(); + } + + @Override + public CoverageMetric.Match newEmptyMatch() { + return CoverageMetric.Match.newEmptyMatch(); + } + + @Override + public CoverageMetric.Match newMatch(final Object... parameters) { + return CoverageMetric.Match.newMatch((java.lang.Double) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CoverageMetric (visibility: PUBLIC, simpleName: CoverageMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CoverageMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CoverageMetric (visibility: PUBLIC, simpleName: CoverageMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CoverageMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final CoverageMetric INSTANCE = new CoverageMetric(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final CoverageMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Coverage = new PParameter("Coverage", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Coverage); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.coverageMetric"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Coverage"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Coverage = body.getOrCreateVariableByName("Coverage"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Coverage), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Coverage, parameter_Coverage) + )); + // Coverage == sum find missionCoverage(_, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), MissionCoverage.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); + new Equality(body, var_Coverage, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.java index d4d72391..b6601c28 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.java @@ -5,6 +5,8 @@ package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLinkDoesNotStartAtContainingElement; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLoop; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CoverageMetric; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CubeSatWithKaAntenna; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetBand; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetGain; @@ -12,6 +14,7 @@ import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.KaAntennaGainLow; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NoLinkToGroundStation; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NotEnoughInterferometryPayloads; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.ThreeUCubeSatWithNonUhfCrossLink; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.TimeMetric; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.UhfAntennaGainNotLow; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.XAntennaGainNotMedium; import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; @@ -36,6 +39,9 @@ import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; *

  • kaAntennaGainLow
  • *
  • threeUCubeSatWithNonUhfCrossLink
  • *
  • cubeSatWithKaAntenna
  • + *
  • coverageMetric
  • + *
  • timeMetric
  • + *
  • costMetric
  • * * * @see IQueryGroup @@ -71,6 +77,9 @@ public final class SatelliteQueries extends BaseGeneratedPatternGroup { querySpecifications.add(KaAntennaGainLow.instance()); querySpecifications.add(ThreeUCubeSatWithNonUhfCrossLink.instance()); querySpecifications.add(CubeSatWithKaAntenna.instance()); + querySpecifications.add(CoverageMetric.instance()); + querySpecifications.add(TimeMetric.instance()); + querySpecifications.add(CostMetric.instance()); } public CommunicationLinkDoesNotStartAtContainingElement getCommunicationLinkDoesNotStartAtContainingElement() { @@ -160,4 +169,28 @@ public final class SatelliteQueries extends BaseGeneratedPatternGroup { public CubeSatWithKaAntenna.Matcher getCubeSatWithKaAntenna(final ViatraQueryEngine engine) { return CubeSatWithKaAntenna.Matcher.on(engine); } + + public CoverageMetric getCoverageMetric() { + return CoverageMetric.instance(); + } + + public CoverageMetric.Matcher getCoverageMetric(final ViatraQueryEngine engine) { + return CoverageMetric.Matcher.on(engine); + } + + public TimeMetric getTimeMetric() { + return TimeMetric.instance(); + } + + public TimeMetric.Matcher getTimeMetric(final ViatraQueryEngine engine) { + return TimeMetric.Matcher.on(engine); + } + + public CostMetric getCostMetric() { + return CostMetric.instance(); + } + + public CostMetric.Matcher getCostMetric(final ViatraQueryEngine engine) { + return CostMetric.Matcher.on(engine); + } } diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/ThreeUCubeSatWithNonUhfCrossLink.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/ThreeUCubeSatWithNonUhfCrossLink.java index 6408033b..6500c9d3 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/ThreeUCubeSatWithNonUhfCrossLink.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/ThreeUCubeSatWithNonUhfCrossLink.java @@ -3,7 +3,7 @@ */ package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; -import hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat3U; +import hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBandUhf; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.GroundStationNetwork; import java.util.Arrays; @@ -18,6 +18,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.log4j.Logger; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; import org.eclipse.viatra.query.runtime.api.IPatternMatch; import org.eclipse.viatra.query.runtime.api.IQuerySpecification; import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; @@ -26,6 +27,7 @@ import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificat import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; @@ -35,6 +37,7 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterRe import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; @@ -53,7 +56,8 @@ import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; * * {@literal @}Constraint(severity = "error", key = {Sat}, * message = "3U CubeSats can only cross-link using UHF.") - * pattern threeUCubeSatWithNonUhfCrossLink(Sat : CubeSat3U) { + * pattern threeUCubeSatWithNonUhfCrossLink(Sat : Spacecraft) { + * Spacecraft.kind(Sat, SpacecraftKind::CubeSat3U); * CommunicatingElement.commSubsystem(Sat, SourceComm); * neg find commSubsystemBandUhf(SourceComm); * DirectedCommunicationLink.source(Link, SourceComm); @@ -82,11 +86,11 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * */ public static abstract class Match extends BasePatternMatch { - private CubeSat3U fSat; + private Spacecraft fSat; private static List parameterNames = makeImmutableList("Sat"); - private Match(final CubeSat3U pSat) { + private Match(final Spacecraft pSat) { this.fSat = pSat; } @@ -96,7 +100,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer return null; } - public CubeSat3U getSat() { + public Spacecraft getSat() { return this.fSat; } @@ -104,13 +108,13 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer public boolean set(final String parameterName, final Object newValue) { if (!isMutable()) throw new java.lang.UnsupportedOperationException(); if ("Sat".equals(parameterName) ) { - this.fSat = (CubeSat3U) newValue; + this.fSat = (Spacecraft) newValue; return true; } return false; } - public void setSat(final CubeSat3U pSat) { + public void setSat(final Spacecraft pSat) { if (!isMutable()) throw new java.lang.UnsupportedOperationException(); this.fSat = pSat; } @@ -191,7 +195,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * @return the new, mutable (partial) match object. * */ - public static ThreeUCubeSatWithNonUhfCrossLink.Match newMutableMatch(final CubeSat3U pSat) { + public static ThreeUCubeSatWithNonUhfCrossLink.Match newMutableMatch(final Spacecraft pSat) { return new Mutable(pSat); } @@ -203,12 +207,12 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * @return the (partial) match object. * */ - public static ThreeUCubeSatWithNonUhfCrossLink.Match newMatch(final CubeSat3U pSat) { + public static ThreeUCubeSatWithNonUhfCrossLink.Match newMatch(final Spacecraft pSat) { return new Immutable(pSat); } private static final class Mutable extends ThreeUCubeSatWithNonUhfCrossLink.Match { - Mutable(final CubeSat3U pSat) { + Mutable(final Spacecraft pSat) { super(pSat); } @@ -219,7 +223,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer } private static final class Immutable extends ThreeUCubeSatWithNonUhfCrossLink.Match { - Immutable(final CubeSat3U pSat) { + Immutable(final Spacecraft pSat) { super(pSat); } @@ -246,7 +250,8 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * * {@literal @}Constraint(severity = "error", key = {Sat}, * message = "3U CubeSats can only cross-link using UHF.") - * pattern threeUCubeSatWithNonUhfCrossLink(Sat : CubeSat3U) { + * pattern threeUCubeSatWithNonUhfCrossLink(Sat : Spacecraft) { + * Spacecraft.kind(Sat, SpacecraftKind::CubeSat3U); * CommunicatingElement.commSubsystem(Sat, SourceComm); * neg find commSubsystemBandUhf(SourceComm); * DirectedCommunicationLink.source(Link, SourceComm); @@ -310,7 +315,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * @return matches represented as a Match object. * */ - public Collection getAllMatches(final CubeSat3U pSat) { + public Collection getAllMatches(final Spacecraft pSat) { return rawStreamAllMatches(new Object[]{pSat}).collect(Collectors.toSet()); } @@ -324,7 +329,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * @return a stream of matches represented as a Match object. * */ - public Stream streamAllMatches(final CubeSat3U pSat) { + public Stream streamAllMatches(final Spacecraft pSat) { return rawStreamAllMatches(new Object[]{pSat}); } @@ -335,7 +340,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * @return a match represented as a Match object, or null if no match is found. * */ - public Optional getOneArbitraryMatch(final CubeSat3U pSat) { + public Optional getOneArbitraryMatch(final Spacecraft pSat) { return rawGetOneArbitraryMatch(new Object[]{pSat}); } @@ -346,7 +351,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * @return true if the input is a valid (partial) match of the pattern. * */ - public boolean hasMatch(final CubeSat3U pSat) { + public boolean hasMatch(final Spacecraft pSat) { return rawHasMatch(new Object[]{pSat}); } @@ -356,7 +361,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * @return the number of pattern matches found. * */ - public int countMatches(final CubeSat3U pSat) { + public int countMatches(final Spacecraft pSat) { return rawCountMatches(new Object[]{pSat}); } @@ -368,7 +373,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked * */ - public boolean forOneArbitraryMatch(final CubeSat3U pSat, final Consumer processor) { + public boolean forOneArbitraryMatch(final Spacecraft pSat, final Consumer processor) { return rawForOneArbitraryMatch(new Object[]{pSat}, processor); } @@ -380,7 +385,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * @return the (partial) match object. * */ - public ThreeUCubeSatWithNonUhfCrossLink.Match newMatch(final CubeSat3U pSat) { + public ThreeUCubeSatWithNonUhfCrossLink.Match newMatch(final Spacecraft pSat) { return ThreeUCubeSatWithNonUhfCrossLink.Match.newMatch(pSat); } @@ -389,8 +394,8 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * @return the Set of all values or empty set if there are no matches * */ - protected Stream rawStreamAllValuesOfSat(final Object[] parameters) { - return rawStreamAllValues(POSITION_SAT, parameters).map(CubeSat3U.class::cast); + protected Stream rawStreamAllValuesOfSat(final Object[] parameters) { + return rawStreamAllValues(POSITION_SAT, parameters).map(Spacecraft.class::cast); } /** @@ -398,7 +403,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * @return the Set of all values or empty set if there are no matches * */ - public Set getAllValuesOfSat() { + public Set getAllValuesOfSat() { return rawStreamAllValuesOfSat(emptyArray()).collect(Collectors.toSet()); } @@ -407,14 +412,14 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer * @return the Set of all values or empty set if there are no matches * */ - public Stream streamAllValuesOfSat() { + public Stream streamAllValuesOfSat() { return rawStreamAllValuesOfSat(emptyArray()); } @Override protected ThreeUCubeSatWithNonUhfCrossLink.Match tupleToMatch(final Tuple t) { try { - return ThreeUCubeSatWithNonUhfCrossLink.Match.newMatch((CubeSat3U) t.get(POSITION_SAT)); + return ThreeUCubeSatWithNonUhfCrossLink.Match.newMatch((Spacecraft) t.get(POSITION_SAT)); } catch(ClassCastException e) { LOGGER.error("Element(s) in tuple not properly typed!",e); return null; @@ -424,7 +429,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer @Override protected ThreeUCubeSatWithNonUhfCrossLink.Match arrayToMatch(final Object[] match) { try { - return ThreeUCubeSatWithNonUhfCrossLink.Match.newMatch((CubeSat3U) match[POSITION_SAT]); + return ThreeUCubeSatWithNonUhfCrossLink.Match.newMatch((Spacecraft) match[POSITION_SAT]); } catch(ClassCastException e) { LOGGER.error("Element(s) in array not properly typed!",e); return null; @@ -434,7 +439,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer @Override protected ThreeUCubeSatWithNonUhfCrossLink.Match arrayToMatchMutable(final Object[] match) { try { - return ThreeUCubeSatWithNonUhfCrossLink.Match.newMutableMatch((CubeSat3U) match[POSITION_SAT]); + return ThreeUCubeSatWithNonUhfCrossLink.Match.newMutableMatch((Spacecraft) match[POSITION_SAT]); } catch(ClassCastException e) { LOGGER.error("Element(s) in array not properly typed!",e); return null; @@ -485,7 +490,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer @Override public ThreeUCubeSatWithNonUhfCrossLink.Match newMatch(final Object... parameters) { - return ThreeUCubeSatWithNonUhfCrossLink.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat3U) parameters[0]); + return ThreeUCubeSatWithNonUhfCrossLink.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft) parameters[0]); } /** @@ -517,7 +522,7 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { private static final ThreeUCubeSatWithNonUhfCrossLink.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - private final PParameter parameter_Sat = new PParameter("Sat", "hu.bme.mit.inf.dslreasoner.domains.satellite.CubeSat3U", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CubeSat3U")), PParameterDirection.INOUT); + private final PParameter parameter_Sat = new PParameter("Sat", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); private final List parameters = Arrays.asList(parameter_Sat); @@ -551,36 +556,44 @@ public final class ThreeUCubeSatWithNonUhfCrossLink extends BaseGeneratedEMFQuer PVariable var_Link = body.getOrCreateVariableByName("Link"); PVariable var_TargetComm = body.getOrCreateVariableByName("TargetComm"); PVariable var_Target = body.getOrCreateVariableByName("Target"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CubeSat3U"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); body.setSymbolicParameters(Arrays.asList( new ExportedParameter(body, var_Sat, parameter_Sat) )); + // Spacecraft.kind(Sat, SpacecraftKind::CubeSat3U) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "CubeSat3U").getInstance()); + new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Sat, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); + new Equality(body, var__virtual_1_, var__virtual_0_); // CommunicatingElement.commSubsystem(Sat, SourceComm) new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); - PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Sat, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); - new Equality(body, var__virtual_0_, var_SourceComm); + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Sat, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); + new Equality(body, var__virtual_2_, var_SourceComm); // neg find commSubsystemBandUhf(SourceComm) new NegativePatternCall(body, Tuples.flatTupleOf(var_SourceComm), CommSubsystemBandUhf.instance().getInternalQueryRepresentation()); // DirectedCommunicationLink.source(Link, SourceComm) new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); - PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "source"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); - new Equality(body, var__virtual_1_, var_SourceComm); + PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "source"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); + new Equality(body, var__virtual_3_, var_SourceComm); // DirectedCommunicationLink.target(Link, TargetComm) new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); - PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "target"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); - new Equality(body, var__virtual_2_, var_TargetComm); + PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "target"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); + new Equality(body, var__virtual_4_, var_TargetComm); // CommunicatingElement.commSubsystem(Target, TargetComm) new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); - PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Target, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); - new Equality(body, var__virtual_3_, var_TargetComm); + PVariable var__virtual_5_ = body.getOrCreateVariableByName(".virtual{5}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Target, var__virtual_5_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_5_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); + new Equality(body, var__virtual_5_, var_TargetComm); // neg find groundStationNetwork(Target) new NegativePatternCall(body, Tuples.flatTupleOf(var_Target), GroundStationNetwork.instance().getInternalQueryRepresentation()); bodies.add(body); diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/TimeMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/TimeMetric.java new file mode 100644 index 00000000..45d4cc35 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/TimeMetric.java @@ -0,0 +1,544 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

    Original source: + *

    + *         // Time
    + *         
    + *         pattern timeMetric(Time : java Double) {
    + *         	Time == sum find missionTime(_, #_);
    + *         }
    + * 
    + * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class TimeMetric extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.timeMetric pattern, + * to be used in conjunction with {@link Matcher}. + * + *

    Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private Double fTime; + + private static List parameterNames = makeImmutableList("Time"); + + private Match(final Double pTime) { + this.fTime = pTime; + } + + @Override + public Object get(final String parameterName) { + if ("Time".equals(parameterName)) return this.fTime; + return null; + } + + public Double getTime() { + return this.fTime; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Time".equals(parameterName) ) { + this.fTime = (Double) newValue; + return true; + } + return false; + } + + public void setTime(final Double pTime) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fTime = pTime; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.timeMetric"; + } + + @Override + public List parameterNames() { + return TimeMetric.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fTime}; + } + + @Override + public TimeMetric.Match toImmutable() { + return isMutable() ? newMatch(fTime) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Time\"=" + prettyPrintValue(fTime)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fTime); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof TimeMetric.Match)) { + TimeMetric.Match other = (TimeMetric.Match) obj; + return Objects.equals(fTime, other.fTime); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public TimeMetric specification() { + return TimeMetric.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static TimeMetric.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pTime the fixed value of pattern parameter Time, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static TimeMetric.Match newMutableMatch(final Double pTime) { + return new Mutable(pTime); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

    The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pTime the fixed value of pattern parameter Time, or null if not bound. + * @return the (partial) match object. + * + */ + public static TimeMetric.Match newMatch(final Double pTime) { + return new Immutable(pTime); + } + + private static final class Mutable extends TimeMetric.Match { + Mutable(final Double pTime) { + super(pTime); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends TimeMetric.Match { + Immutable(final Double pTime) { + super(pTime); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.satellite.queries.timeMetric pattern, + * providing pattern-specific query methods. + * + *

    Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

    Matches of the pattern will be represented as {@link Match}. + * + *

    Original source: + *

    +   * // Time
    +   * 
    +   * pattern timeMetric(Time : java Double) {
    +   * 	Time == sum find missionTime(_, #_);
    +   * }
    +   * 
    + * + * @see Match + * @see TimeMetric + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static TimeMetric.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static TimeMetric.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_TIME = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TimeMetric.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pTime the fixed value of pattern parameter Time, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Double pTime) { + return rawStreamAllMatches(new Object[]{pTime}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

    + * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pTime the fixed value of pattern parameter Time, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Double pTime) { + return rawStreamAllMatches(new Object[]{pTime}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pTime the fixed value of pattern parameter Time, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Double pTime) { + return rawGetOneArbitraryMatch(new Object[]{pTime}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pTime the fixed value of pattern parameter Time, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Double pTime) { + return rawHasMatch(new Object[]{pTime}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pTime the fixed value of pattern parameter Time, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Double pTime) { + return rawCountMatches(new Object[]{pTime}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pTime the fixed value of pattern parameter Time, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final Double pTime, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pTime}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

    The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pTime the fixed value of pattern parameter Time, or null if not bound. + * @return the (partial) match object. + * + */ + public TimeMetric.Match newMatch(final Double pTime) { + return TimeMetric.Match.newMatch(pTime); + } + + /** + * Retrieve the set of values that occur in matches for Time. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfTime(final Object[] parameters) { + return rawStreamAllValues(POSITION_TIME, parameters).map(Double.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Time. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfTime() { + return rawStreamAllValuesOfTime(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Time. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfTime() { + return rawStreamAllValuesOfTime(emptyArray()); + } + + @Override + protected TimeMetric.Match tupleToMatch(final Tuple t) { + try { + return TimeMetric.Match.newMatch((Double) t.get(POSITION_TIME)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected TimeMetric.Match arrayToMatch(final Object[] match) { + try { + return TimeMetric.Match.newMatch((Double) match[POSITION_TIME]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected TimeMetric.Match arrayToMatchMutable(final Object[] match) { + try { + return TimeMetric.Match.newMutableMatch((Double) match[POSITION_TIME]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return TimeMetric.instance(); + } + } + + private TimeMetric() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TimeMetric instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected TimeMetric.Matcher instantiate(final ViatraQueryEngine engine) { + return TimeMetric.Matcher.on(engine); + } + + @Override + public TimeMetric.Matcher instantiate() { + return TimeMetric.Matcher.create(); + } + + @Override + public TimeMetric.Match newEmptyMatch() { + return TimeMetric.Match.newEmptyMatch(); + } + + @Override + public TimeMetric.Match newMatch(final Object... parameters) { + return TimeMetric.Match.newMatch((java.lang.Double) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.TimeMetric (visibility: PUBLIC, simpleName: TimeMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.TimeMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.TimeMetric (visibility: PUBLIC, simpleName: TimeMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.TimeMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TimeMetric INSTANCE = new TimeMetric(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final TimeMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Time = new PParameter("Time", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Time); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.timeMetric"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Time"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Time = body.getOrCreateVariableByName("Time"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Time), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Time, parameter_Time) + )); + // Time == sum find missionTime(_, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), MissionTime.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); + new Equality(body, var_Time, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/.gitignore index b3aca298..f72ce8f1 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/.gitignore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/.gitignore @@ -13,3 +13,21 @@ /.CommSubsystemGainLow.java._trace /.CommSubsystemGainMedium.java._trace /.CommSubsystemBandUhf.java._trace +/.MissionCoverage.java._trace +/.SatelliteMetricsAll.java._trace +/.MissionTime.java._trace +/.TimeMetric.java._trace +/.TransmitTime.java._trace +/.TransmitRate.java._trace +/.SpacecraftUplink.java._trace +/.MissionScienceData.java._trace +/.IndirectScienceData.java._trace +/.ScienceData.java._trace +/.IncomingData.java._trace +/.MissionCost.java._trace +/.BasePrice.java._trace +/.SpacecraftOfKind.java._trace +/.InterferometryPayloadCost.java._trace +/.AdditionalCommSubsystemCost.java._trace +/.SpacecraftWithTwoCommSubsystems.java._trace +/.SpacecraftCost.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/AdditionalCommSubsystemCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/AdditionalCommSubsystemCost.java new file mode 100644 index 00000000..61b1da52 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/AdditionalCommSubsystemCost.java @@ -0,0 +1,173 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithTwoCommSubsystems; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern additionalCommSubsystemCost(Spacecraft : Spacecraft, Cost : java Double) {
    + *         	find spacecraftWithTwoCommSubsystems(Spacecraft);
    + *         	Cost == 100000.0;
    + *         } or {
    + *         	neg find spacecraftWithTwoCommSubsystems(Spacecraft);
    + *         	Cost == 0.0;
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class AdditionalCommSubsystemCost extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private AdditionalCommSubsystemCost() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AdditionalCommSubsystemCost instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost (visibility: PUBLIC, simpleName: AdditionalCommSubsystemCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost (visibility: PUBLIC, simpleName: AdditionalCommSubsystemCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final AdditionalCommSubsystemCost INSTANCE = new AdditionalCommSubsystemCost(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final AdditionalCommSubsystemCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Spacecraft, parameter_Cost); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.additionalCommSubsystemCost"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Spacecraft","Cost"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_Cost = body.getOrCreateVariableByName("Cost"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // find spacecraftWithTwoCommSubsystems(Spacecraft) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft), SpacecraftWithTwoCommSubsystems.instance().getInternalQueryRepresentation()); + // Cost == 100000.0 + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, 100000.0); + new Equality(body, var_Cost, var__virtual_0_); + bodies.add(body); + } + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_Cost = body.getOrCreateVariableByName("Cost"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // neg find spacecraftWithTwoCommSubsystems(Spacecraft) + new NegativePatternCall(body, Tuples.flatTupleOf(var_Spacecraft), SpacecraftWithTwoCommSubsystems.instance().getInternalQueryRepresentation()); + // Cost == 0.0 + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, 0.0); + new Equality(body, var_Cost, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1() { + return 100000.0; + } + + private static double evaluateExpression_2_1() { + return 0.0; + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/BasePrice.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/BasePrice.java new file mode 100644 index 00000000..c70f4c8b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/BasePrice.java @@ -0,0 +1,216 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern basePrice(Spacecraft : Spacecraft, BasePrice : java Double) {
    + *         	Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat3U);
    + *         	BasePrice == 250000.0;
    + *         } or {
    + *         	Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat6U);
    + *         	BasePrice == 750000.0;
    + *         } or {
    + *         	Spacecraft.kind(Spacecraft, SpacecraftKind::SmallSat);
    + *         	BasePrice == 3000000.0;
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class BasePrice extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private BasePrice() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static BasePrice instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice (visibility: PUBLIC, simpleName: BasePrice, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice (visibility: PUBLIC, simpleName: BasePrice, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final BasePrice INSTANCE = new BasePrice(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final BasePrice.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_BasePrice = new PParameter("BasePrice", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Spacecraft, parameter_BasePrice); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.basePrice"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Spacecraft","BasePrice"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_BasePrice = body.getOrCreateVariableByName("BasePrice"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_BasePrice), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_BasePrice, parameter_BasePrice) + )); + // Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat3U) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "CubeSat3U").getInstance()); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); + new Equality(body, var__virtual_1_, var__virtual_0_); + // BasePrice == 250000.0 + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new ConstantValue(body, var__virtual_2_, 250000.0); + new Equality(body, var_BasePrice, var__virtual_2_); + bodies.add(body); + } + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_BasePrice = body.getOrCreateVariableByName("BasePrice"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_BasePrice), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_BasePrice, parameter_BasePrice) + )); + // Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat6U) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "CubeSat6U").getInstance()); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); + new Equality(body, var__virtual_1_, var__virtual_0_); + // BasePrice == 750000.0 + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new ConstantValue(body, var__virtual_2_, 750000.0); + new Equality(body, var_BasePrice, var__virtual_2_); + bodies.add(body); + } + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_BasePrice = body.getOrCreateVariableByName("BasePrice"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_BasePrice), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_BasePrice, parameter_BasePrice) + )); + // Spacecraft.kind(Spacecraft, SpacecraftKind::SmallSat) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "SmallSat").getInstance()); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); + new Equality(body, var__virtual_1_, var__virtual_0_); + // BasePrice == 3000000.0 + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new ConstantValue(body, var__virtual_2_, 3000000.0); + new Equality(body, var_BasePrice, var__virtual_2_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1() { + return 250000.0; + } + + private static double evaluateExpression_2_1() { + return 750000.0; + } + + private static double evaluateExpression_3_1() { + return 3000000.0; + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/IncomingData.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/IncomingData.java new file mode 100644 index 00000000..114bbf33 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/IncomingData.java @@ -0,0 +1,145 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IndirectCommunicationLink; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern incomingData(Spacecraft : Spacecraft, Source : Spacecraft, Data : java Double) {
    + *         	find indirectCommunicationLink(Source, Spacecraft);
    + *         	find scienceData(Source, Data);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class IncomingData extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private IncomingData() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IncomingData instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IncomingData (visibility: PUBLIC, simpleName: IncomingData, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IncomingData, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IncomingData (visibility: PUBLIC, simpleName: IncomingData, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IncomingData, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final IncomingData INSTANCE = new IncomingData(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final IncomingData.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_Source = new PParameter("Source", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_Data = new PParameter("Data", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Spacecraft, parameter_Source, parameter_Data); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.incomingData"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Spacecraft","Source","Data"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_Source = body.getOrCreateVariableByName("Source"); + PVariable var_Data = body.getOrCreateVariableByName("Data"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Source), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Data), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_Source, parameter_Source), + new ExportedParameter(body, var_Data, parameter_Data) + )); + // find indirectCommunicationLink(Source, Spacecraft) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Source, var_Spacecraft), IndirectCommunicationLink.instance().getInternalQueryRepresentation()); + // find scienceData(Source, Data) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Source, var_Data), ScienceData.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/InterferometryPayloadCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/InterferometryPayloadCost.java new file mode 100644 index 00000000..205d896a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/InterferometryPayloadCost.java @@ -0,0 +1,175 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithInterferometryPayload; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern interferometryPayloadCost(Spacecraft : Spacecraft, Cost : java Double) {
    + *         	find spacecraftWithInterferometryPayload(_, Spacecraft);
    + *         	Cost == 50000.0;
    + *         } or {
    + *         	neg find spacecraftWithInterferometryPayload(_, Spacecraft);
    + *         	Cost == 0.0;
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class InterferometryPayloadCost extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private InterferometryPayloadCost() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static InterferometryPayloadCost instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost (visibility: PUBLIC, simpleName: InterferometryPayloadCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost (visibility: PUBLIC, simpleName: InterferometryPayloadCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final InterferometryPayloadCost INSTANCE = new InterferometryPayloadCost(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final InterferometryPayloadCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Spacecraft, parameter_Cost); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.interferometryPayloadCost"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Spacecraft","Cost"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_Cost = body.getOrCreateVariableByName("Cost"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // find spacecraftWithInterferometryPayload(_, Spacecraft) + new PositivePatternCall(body, Tuples.flatTupleOf(var___0_, var_Spacecraft), SpacecraftWithInterferometryPayload.instance().getInternalQueryRepresentation()); + // Cost == 50000.0 + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, 50000.0); + new Equality(body, var_Cost, var__virtual_0_); + bodies.add(body); + } + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_Cost = body.getOrCreateVariableByName("Cost"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // neg find spacecraftWithInterferometryPayload(_, Spacecraft) + new NegativePatternCall(body, Tuples.flatTupleOf(var___0_, var_Spacecraft), SpacecraftWithInterferometryPayload.instance().getInternalQueryRepresentation()); + // Cost == 0.0 + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, 0.0); + new Equality(body, var_Cost, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1() { + return 50000.0; + } + + private static double evaluateExpression_2_1() { + return 0.0; + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCost.java new file mode 100644 index 00000000..0374195f --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCost.java @@ -0,0 +1,183 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern missionCost(Mission : InterferometryMission, Cost : java Double) {
    + *         	InterferometryMission.observationTime(Mission, ObservationTime);
    + *         	SpacecraftCost == sum find spacecraftCost(Mission, _, #_);
    + *         	Cost == eval(SpacecraftCost + 100000.0  ObservationTime);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class MissionCost extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private MissionCost() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static MissionCost instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost (visibility: PUBLIC, simpleName: MissionCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost (visibility: PUBLIC, simpleName: MissionCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final MissionCost INSTANCE = new MissionCost(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final MissionCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); + + private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Mission, parameter_Cost); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.missionCost"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Mission","Cost"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Mission = body.getOrCreateVariableByName("Mission"); + PVariable var_Cost = body.getOrCreateVariableByName("Cost"); + PVariable var_ObservationTime = body.getOrCreateVariableByName("ObservationTime"); + PVariable var_SpacecraftCost = body.getOrCreateVariableByName("SpacecraftCost"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Mission, parameter_Mission), + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // InterferometryMission.observationTime(Mission, ObservationTime) + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "InterferometryMission", "observationTime"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EFloat"))); + new Equality(body, var__virtual_0_, var_ObservationTime); + // SpacecraftCost == sum find spacecraftCost(Mission, _, #_) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var_Mission, var___0_, var___1_), SpacecraftCost.instance().getInternalQueryRepresentation(), var__virtual_1_, 2); + new Equality(body, var_SpacecraftCost, var__virtual_1_); + // Cost == eval(SpacecraftCost + 100000.0 * ObservationTime) + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern missionCost"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("ObservationTime", "SpacecraftCost");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Float ObservationTime = (Float) provider.getValue("ObservationTime"); + Double SpacecraftCost = (Double) provider.getValue("SpacecraftCost"); + return evaluateExpression_1_1(ObservationTime, SpacecraftCost); + } + }, var__virtual_2_ ); + new Equality(body, var_Cost, var__virtual_2_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1(final Float ObservationTime, final Double SpacecraftCost) { + return ((SpacecraftCost).doubleValue() + (100000.0 * (ObservationTime).floatValue())); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCoverage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCoverage.java new file mode 100644 index 00000000..583c2175 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCoverage.java @@ -0,0 +1,183 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithInterferometryPayload; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern missionCoverage(Mission : InterferometryMission, Coverage : java Double) {
    + *         	InterferometryMission.observationTime(Mission, ObservationTime);
    + *         	ObserverCount == count find spacecraftWithInterferometryPayload(Mission, _);
    + *         	Coverage == eval(Math.pow(1 - 2.0 / ObserverCount, 1 + 9  (1.0 / ObservationTime)) + 0.05  ObservationTime / 3);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class MissionCoverage extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private MissionCoverage() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static MissionCoverage instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCoverage (visibility: PUBLIC, simpleName: MissionCoverage, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCoverage, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCoverage (visibility: PUBLIC, simpleName: MissionCoverage, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCoverage, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final MissionCoverage INSTANCE = new MissionCoverage(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final MissionCoverage.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); + + private final PParameter parameter_Coverage = new PParameter("Coverage", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Mission, parameter_Coverage); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.missionCoverage"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Mission","Coverage"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Mission = body.getOrCreateVariableByName("Mission"); + PVariable var_Coverage = body.getOrCreateVariableByName("Coverage"); + PVariable var_ObservationTime = body.getOrCreateVariableByName("ObservationTime"); + PVariable var_ObserverCount = body.getOrCreateVariableByName("ObserverCount"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Coverage), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Mission, parameter_Mission), + new ExportedParameter(body, var_Coverage, parameter_Coverage) + )); + // InterferometryMission.observationTime(Mission, ObservationTime) + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "InterferometryMission", "observationTime"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EFloat"))); + new Equality(body, var__virtual_0_, var_ObservationTime); + // ObserverCount == count find spacecraftWithInterferometryPayload(Mission, _) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new PatternMatchCounter(body, Tuples.flatTupleOf(var_Mission, var___0_), SpacecraftWithInterferometryPayload.instance().getInternalQueryRepresentation(), var__virtual_1_); + new Equality(body, var_ObserverCount, var__virtual_1_); + // Coverage == eval(Math.pow(1 - 2.0 / ObserverCount, 1 + 9 * (1.0 / ObservationTime)) + 0.05 * ObservationTime / 3) + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern missionCoverage"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("ObservationTime", "ObserverCount");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Float ObservationTime = (Float) provider.getValue("ObservationTime"); + Integer ObserverCount = (Integer) provider.getValue("ObserverCount"); + return evaluateExpression_1_1(ObservationTime, ObserverCount); + } + }, var__virtual_2_ ); + new Equality(body, var_Coverage, var__virtual_2_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1(final Float ObservationTime, final Integer ObserverCount) { + double _pow = Math.pow((1 - (2.0 / (ObserverCount).intValue())), (1 + (9 * (1.0 / (ObservationTime).floatValue())))); + double _plus = (_pow + ((0.05 * (ObservationTime).floatValue()) / 3)); + return _plus; + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionTime.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionTime.java new file mode 100644 index 00000000..3ad42bf5 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionTime.java @@ -0,0 +1,183 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitTime; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern missionTime(Mission : InterferometryMission, Time : java Double) {
    + *         	InterferometryMission.observationTime(Mission, ObservationTime);
    + *         	TrasmitTime == sum find transmitTime(Mission, _, #_);
    + *         	Time == eval(TrasmitTime + 60.0  ObservationTime);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class MissionTime extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private MissionTime() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static MissionTime instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime (visibility: PUBLIC, simpleName: MissionTime, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime (visibility: PUBLIC, simpleName: MissionTime, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final MissionTime INSTANCE = new MissionTime(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final MissionTime.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); + + private final PParameter parameter_Time = new PParameter("Time", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Mission, parameter_Time); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.missionTime"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Mission","Time"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Mission = body.getOrCreateVariableByName("Mission"); + PVariable var_Time = body.getOrCreateVariableByName("Time"); + PVariable var_ObservationTime = body.getOrCreateVariableByName("ObservationTime"); + PVariable var_TrasmitTime = body.getOrCreateVariableByName("TrasmitTime"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Time), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Mission, parameter_Mission), + new ExportedParameter(body, var_Time, parameter_Time) + )); + // InterferometryMission.observationTime(Mission, ObservationTime) + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "InterferometryMission", "observationTime"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EFloat"))); + new Equality(body, var__virtual_0_, var_ObservationTime); + // TrasmitTime == sum find transmitTime(Mission, _, #_) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var_Mission, var___0_, var___1_), TransmitTime.instance().getInternalQueryRepresentation(), var__virtual_1_, 2); + new Equality(body, var_TrasmitTime, var__virtual_1_); + // Time == eval(TrasmitTime + 60.0 * ObservationTime) + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern missionTime"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("ObservationTime", "TrasmitTime");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Float ObservationTime = (Float) provider.getValue("ObservationTime"); + Double TrasmitTime = (Double) provider.getValue("TrasmitTime"); + return evaluateExpression_1_1(ObservationTime, TrasmitTime); + } + }, var__virtual_2_ ); + new Equality(body, var_Time, var__virtual_2_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1(final Float ObservationTime, final Double TrasmitTime) { + return ((TrasmitTime).doubleValue() + (60.0 * (ObservationTime).floatValue())); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SatelliteQueriesAll.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SatelliteQueriesAll.java index 7f1be700..2f310711 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SatelliteQueriesAll.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SatelliteQueriesAll.java @@ -5,6 +5,8 @@ package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLinkDoesNotStartAtContainingElement; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CommunicationLoop; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CoverageMetric; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CubeSatWithKaAntenna; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetBand; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.IncompatibleSourceAndTargetGain; @@ -12,9 +14,12 @@ import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.KaAntennaGainLow; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NoLinkToGroundStation; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NotEnoughInterferometryPayloads; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.ThreeUCubeSatWithNonUhfCrossLink; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.TimeMetric; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.UhfAntennaGainNotLow; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.XAntennaGainNotMedium; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AtLeastTwoInterferometryPayloads; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBand; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemBandUhf; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGain; @@ -22,9 +27,21 @@ import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsyst import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsystemGainMedium; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.DirectCommunicationLink; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.GroundStationNetwork; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IncomingData; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IndirectCommunicationLink; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCoverage; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SmallSat; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftUplink; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithInterferometryPayload; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithTwoCommSubsystems; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitRate; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitTime; import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; /** @@ -55,6 +72,23 @@ import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; *

  • groundStationNetwork
  • *
  • cubeSatWithKaAntenna
  • *
  • smallSat
  • + *
  • coverageMetric
  • + *
  • missionCoverage
  • + *
  • timeMetric
  • + *
  • missionTime
  • + *
  • transmitTime
  • + *
  • incomingData
  • + *
  • scienceData
  • + *
  • transmitRate
  • + *
  • spacecraftUplink
  • + *
  • costMetric
  • + *
  • missionCost
  • + *
  • spacecraftCost
  • + *
  • spacecraftOfKind
  • + *
  • basePrice
  • + *
  • interferometryPayloadCost
  • + *
  • additionalCommSubsystemCost
  • + *
  • spacecraftWithTwoCommSubsystems
  • * * * @see IQueryGroup @@ -101,5 +135,22 @@ public final class SatelliteQueriesAll extends BaseGeneratedPatternGroup { querySpecifications.add(GroundStationNetwork.instance()); querySpecifications.add(CubeSatWithKaAntenna.instance()); querySpecifications.add(SmallSat.instance()); + querySpecifications.add(CoverageMetric.instance()); + querySpecifications.add(MissionCoverage.instance()); + querySpecifications.add(TimeMetric.instance()); + querySpecifications.add(MissionTime.instance()); + querySpecifications.add(TransmitTime.instance()); + querySpecifications.add(IncomingData.instance()); + querySpecifications.add(ScienceData.instance()); + querySpecifications.add(TransmitRate.instance()); + querySpecifications.add(SpacecraftUplink.instance()); + querySpecifications.add(CostMetric.instance()); + querySpecifications.add(MissionCost.instance()); + querySpecifications.add(SpacecraftCost.instance()); + querySpecifications.add(SpacecraftOfKind.instance()); + querySpecifications.add(BasePrice.instance()); + querySpecifications.add(InterferometryPayloadCost.instance()); + querySpecifications.add(AdditionalCommSubsystemCost.instance()); + querySpecifications.add(SpacecraftWithTwoCommSubsystems.instance()); } } diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/ScienceData.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/ScienceData.java new file mode 100644 index 00000000..b558e51e --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/ScienceData.java @@ -0,0 +1,179 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern scienceData(Spacecraft : Spacecraft, Data : java Double) {
    + *         	ConstellationMission.spacecraft(Mission, Spacecraft);
    + *         	InterferometryMission.observationTime(Mission, ObservationTime);
    + *         	Data == eval(12.0  ObservationTime);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class ScienceData extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private ScienceData() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static ScienceData instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData (visibility: PUBLIC, simpleName: ScienceData, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData (visibility: PUBLIC, simpleName: ScienceData, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final ScienceData INSTANCE = new ScienceData(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final ScienceData.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_Data = new PParameter("Data", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Spacecraft, parameter_Data); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.scienceData"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Spacecraft","Data"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_Data = body.getOrCreateVariableByName("Data"); + PVariable var_Mission = body.getOrCreateVariableByName("Mission"); + PVariable var_ObservationTime = body.getOrCreateVariableByName("ObservationTime"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Data), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_Data, parameter_Data) + )); + // ConstellationMission.spacecraft(Mission, Spacecraft) + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "ConstellationMission"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "ConstellationMission", "spacecraft"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new Equality(body, var__virtual_0_, var_Spacecraft); + // InterferometryMission.observationTime(Mission, ObservationTime) + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "InterferometryMission", "observationTime"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EFloat"))); + new Equality(body, var__virtual_1_, var_ObservationTime); + // Data == eval(12.0 * ObservationTime) + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern scienceData"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("ObservationTime");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Float ObservationTime = (Float) provider.getValue("ObservationTime"); + return evaluateExpression_1_1(ObservationTime); + } + }, var__virtual_2_ ); + new Equality(body, var_Data, var__virtual_2_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1(final Float ObservationTime) { + return (12.0 * (ObservationTime).floatValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SmallSat.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SmallSat.java index 252db290..d74ed28a 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SmallSat.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SmallSat.java @@ -8,13 +8,18 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; @@ -26,8 +31,8 @@ import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; * *

    Original source: *

    - *         private pattern smallSat(Sat : SmallSat) {
    - *         	SmallSat(Sat);
    + *         private pattern smallSat(Sat : Spacecraft) {
    + *         	Spacecraft.kind(Sat, SpacecraftKind::SmallSat);
      *         }
      * 
    * @@ -83,7 +88,7 @@ public final class SmallSat extends BaseGeneratedEMFQuerySpecificationWithGeneri private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { private static final SmallSat.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - private final PParameter parameter_Sat = new PParameter("Sat", "hu.bme.mit.inf.dslreasoner.domains.satellite.SmallSat", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "SmallSat")), PParameterDirection.INOUT); + private final PParameter parameter_Sat = new PParameter("Sat", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); private final List parameters = Arrays.asList(parameter_Sat); @@ -113,12 +118,18 @@ public final class SmallSat extends BaseGeneratedEMFQuerySpecificationWithGeneri { PBody body = new PBody(this); PVariable var_Sat = body.getOrCreateVariableByName("Sat"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "SmallSat"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); body.setSymbolicParameters(Arrays.asList( new ExportedParameter(body, var_Sat, parameter_Sat) )); - // SmallSat(Sat) - new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "SmallSat"))); + // Spacecraft.kind(Sat, SpacecraftKind::SmallSat) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "SmallSat").getInstance()); + new TypeConstraint(body, Tuples.flatTupleOf(var_Sat), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Sat, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); + new Equality(body, var__virtual_1_, var__virtual_0_); bodies.add(body); } return bodies; diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java new file mode 100644 index 00000000..65fed74a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java @@ -0,0 +1,215 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.AdditionalCommSubsystemCost; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern spacecraftCost(Mission : InterferometryMission, Spacecraft : Spacecraft, Cost : java Double) {
    + *         	ConstellationMission.spacecraft(Mission, Spacecraft);
    + *         	Spacecraft.kind(Spacecraft, Kind);
    + *         	KindCount == count find spacecraftOfKind(_, Kind);
    + *         	find basePrice(Spacecraft, BasePrice);
    + *         	find interferometryPayloadCost(Spacecraft, InterferometryPayloadCost);
    + *         	find additionalCommSubsystemCost(Spacecraft, AdditionalCommSubsystemCost);
    + *         	Cost == eval(BasePrice  Math.pow(KindCount, -0.25) + InterferometryPayloadCost + AdditionalCommSubsystemCost);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class SpacecraftCost extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private SpacecraftCost() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static SpacecraftCost instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost (visibility: PUBLIC, simpleName: SpacecraftCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost (visibility: PUBLIC, simpleName: SpacecraftCost, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final SpacecraftCost INSTANCE = new SpacecraftCost(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final SpacecraftCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Mission, parameter_Spacecraft, parameter_Cost); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.spacecraftCost"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Mission","Spacecraft","Cost"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Mission = body.getOrCreateVariableByName("Mission"); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_Cost = body.getOrCreateVariableByName("Cost"); + PVariable var_Kind = body.getOrCreateVariableByName("Kind"); + PVariable var_KindCount = body.getOrCreateVariableByName("KindCount"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var_BasePrice = body.getOrCreateVariableByName("BasePrice"); + PVariable var_InterferometryPayloadCost = body.getOrCreateVariableByName("InterferometryPayloadCost"); + PVariable var_AdditionalCommSubsystemCost = body.getOrCreateVariableByName("AdditionalCommSubsystemCost"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Mission, parameter_Mission), + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // ConstellationMission.spacecraft(Mission, Spacecraft) + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "ConstellationMission"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "ConstellationMission", "spacecraft"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new Equality(body, var__virtual_0_, var_Spacecraft); + // Spacecraft.kind(Spacecraft, Kind) + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); + new Equality(body, var__virtual_1_, var_Kind); + // KindCount == count find spacecraftOfKind(_, Kind) + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new PatternMatchCounter(body, Tuples.flatTupleOf(var___0_, var_Kind), SpacecraftOfKind.instance().getInternalQueryRepresentation(), var__virtual_2_); + new Equality(body, var_KindCount, var__virtual_2_); + // find basePrice(Spacecraft, BasePrice) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_BasePrice), BasePrice.instance().getInternalQueryRepresentation()); + // find interferometryPayloadCost(Spacecraft, InterferometryPayloadCost) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_InterferometryPayloadCost), InterferometryPayloadCost.instance().getInternalQueryRepresentation()); + // find additionalCommSubsystemCost(Spacecraft, AdditionalCommSubsystemCost) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_AdditionalCommSubsystemCost), AdditionalCommSubsystemCost.instance().getInternalQueryRepresentation()); + // Cost == eval(BasePrice * Math.pow(KindCount, -0.25) + InterferometryPayloadCost + AdditionalCommSubsystemCost) + PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern spacecraftCost"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("AdditionalCommSubsystemCost", "BasePrice", "InterferometryPayloadCost", "KindCount");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Double AdditionalCommSubsystemCost = (Double) provider.getValue("AdditionalCommSubsystemCost"); + Double BasePrice = (Double) provider.getValue("BasePrice"); + Double InterferometryPayloadCost = (Double) provider.getValue("InterferometryPayloadCost"); + Integer KindCount = (Integer) provider.getValue("KindCount"); + return evaluateExpression_1_1(AdditionalCommSubsystemCost, BasePrice, InterferometryPayloadCost, KindCount); + } + }, var__virtual_3_ ); + new Equality(body, var_Cost, var__virtual_3_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1(final Double AdditionalCommSubsystemCost, final Double BasePrice, final Double InterferometryPayloadCost, final Integer KindCount) { + double _pow = Math.pow((KindCount).intValue(), (-0.25)); + double _multiply = ((BasePrice).doubleValue() * _pow); + double _plus = (_multiply + (InterferometryPayloadCost).doubleValue()); + double _plus_1 = (_plus + (AdditionalCommSubsystemCost).doubleValue()); + return _plus_1; + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftOfKind.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftOfKind.java new file mode 100644 index 00000000..5e49aa58 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftOfKind.java @@ -0,0 +1,140 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern spacecraftOfKind(Spacecraft : Spacecraft, Kind : SpacecraftKind) {
    + *         	Spacecraft.kind(Spacecraft, Kind);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class SpacecraftOfKind extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private SpacecraftOfKind() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static SpacecraftOfKind instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind (visibility: PUBLIC, simpleName: SpacecraftOfKind, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind (visibility: PUBLIC, simpleName: SpacecraftOfKind, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftOfKind, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final SpacecraftOfKind INSTANCE = new SpacecraftOfKind(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final SpacecraftOfKind.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_Kind = new PParameter("Kind", "hu.bme.mit.inf.dslreasoner.domains.satellite.SpacecraftKind", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.example.org/satellite", "SpacecraftKind")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Spacecraft, parameter_Kind); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.spacecraftOfKind"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Spacecraft","Kind"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_Kind = body.getOrCreateVariableByName("Kind"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Kind), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_Kind, parameter_Kind) + )); + // Spacecraft.kind(Spacecraft, Kind) + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind"))); + new Equality(body, var__virtual_0_, var_Kind); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftUplink.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftUplink.java new file mode 100644 index 00000000..966ff6f8 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftUplink.java @@ -0,0 +1,171 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern spacecraftUplink(Spacecraft : Spacecraft, Band : TransceiverBand, Target : CommunicatingElement) {
    + *         	CommunicatingElement.communicationLink(Spacecraft, Link);
    + *         	DirectedCommunicationLink.source.band(Link, Band);
    + *         	DirectedCommunicationLink.target(Link, TargetSubsystem);
    + *         	CommunicatingElement.commSubsystem(Target, TargetSubsystem);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class SpacecraftUplink extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private SpacecraftUplink() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static SpacecraftUplink instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftUplink (visibility: PUBLIC, simpleName: SpacecraftUplink, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftUplink, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftUplink (visibility: PUBLIC, simpleName: SpacecraftUplink, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftUplink, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final SpacecraftUplink INSTANCE = new SpacecraftUplink(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final SpacecraftUplink.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_Band = new PParameter("Band", "hu.bme.mit.inf.dslreasoner.domains.satellite.TransceiverBand", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.example.org/satellite", "TransceiverBand")), PParameterDirection.INOUT); + + private final PParameter parameter_Target = new PParameter("Target", "hu.bme.mit.inf.dslreasoner.domains.satellite.CommunicatingElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "CommunicatingElement")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Spacecraft, parameter_Band, parameter_Target); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.spacecraftUplink"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Spacecraft","Band","Target"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_Band = body.getOrCreateVariableByName("Band"); + PVariable var_Target = body.getOrCreateVariableByName("Target"); + PVariable var_Link = body.getOrCreateVariableByName("Link"); + PVariable var_TargetSubsystem = body.getOrCreateVariableByName("TargetSubsystem"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Band), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "TransceiverBand"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_Band, parameter_Band), + new ExportedParameter(body, var_Target, parameter_Target) + )); + // CommunicatingElement.communicationLink(Spacecraft, Link) + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "communicationLink"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); + new Equality(body, var__virtual_0_, var_Link); + // DirectedCommunicationLink.source.band(Link, Band) + new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "source"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommSubsystem", "band"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "TransceiverBand"))); + new Equality(body, var__virtual_2_, var_Band); + // DirectedCommunicationLink.target(Link, TargetSubsystem) + new TypeConstraint(body, Tuples.flatTupleOf(var_Link), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "DirectedCommunicationLink"))); + PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Link, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "DirectedCommunicationLink", "target"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); + new Equality(body, var__virtual_3_, var_TargetSubsystem); + // CommunicatingElement.commSubsystem(Target, TargetSubsystem) + new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommunicatingElement"))); + PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Target, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); + new Equality(body, var__virtual_4_, var_TargetSubsystem); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftWithTwoCommSubsystems.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftWithTwoCommSubsystems.java new file mode 100644 index 00000000..98f1be7b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftWithTwoCommSubsystems.java @@ -0,0 +1,146 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern spacecraftWithTwoCommSubsystems(Spacecraft : Spacecraft) {
    + *         	Spacecraft.commSubsystem(Spacecraft, Subsystem1);
    + *         	Spacecraft.commSubsystem(Spacecraft, Subsystem2);
    + *         	Subsystem1 != Subsystem2;
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class SpacecraftWithTwoCommSubsystems extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private SpacecraftWithTwoCommSubsystems() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static SpacecraftWithTwoCommSubsystems instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithTwoCommSubsystems (visibility: PUBLIC, simpleName: SpacecraftWithTwoCommSubsystems, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithTwoCommSubsystems, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithTwoCommSubsystems (visibility: PUBLIC, simpleName: SpacecraftWithTwoCommSubsystems, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftWithTwoCommSubsystems, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final SpacecraftWithTwoCommSubsystems INSTANCE = new SpacecraftWithTwoCommSubsystems(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final SpacecraftWithTwoCommSubsystems.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Spacecraft); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.spacecraftWithTwoCommSubsystems"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Spacecraft"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_Subsystem1 = body.getOrCreateVariableByName("Subsystem1"); + PVariable var_Subsystem2 = body.getOrCreateVariableByName("Subsystem2"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft) + )); + // Spacecraft.commSubsystem(Spacecraft, Subsystem1) + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); + new Equality(body, var__virtual_0_, var_Subsystem1); + // Spacecraft.commSubsystem(Spacecraft, Subsystem2) + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "CommunicatingElement", "commSubsystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CommSubsystem"))); + new Equality(body, var__virtual_1_, var_Subsystem2); + // Subsystem1 != Subsystem2 + new Inequality(body, var_Subsystem1, var_Subsystem2); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitRate.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitRate.java new file mode 100644 index 00000000..2faa7733 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitRate.java @@ -0,0 +1,277 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SpacecraftUplink; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern transmitRate(Spacecraft : Spacecraft, TransmitRate : java Double) {
    + *         	find spacecraftUplink(Spacecraft, TransceiverBand::UHF, Target);
    + *         	Spacecraft(Target);
    + *         	TransmitRate == 5.0;
    + *         } or {
    + *         	find spacecraftUplink(Spacecraft, TransceiverBand::X, Target);
    + *         	Spacecraft(Target);
    + *         	TransmitRate == 1.6;
    + *         } or {
    + *         	find spacecraftUplink(Spacecraft, TransceiverBand::X, Target);
    + *         	GroundStationNetwork(Target);
    + *         	TransmitRate == 0.7;
    + *         } or {
    + *         	find spacecraftUplink(Spacecraft, TransceiverBand::Ka, Target);
    + *         	Spacecraft(Target);
    + *         	TransmitRate == 220.0;
    + *         } or {
    + *         	find spacecraftUplink(Spacecraft, TransceiverBand::Ka, Target);
    + *         	GroundStationNetwork(Target);
    + *         	TransmitRate == 80.0;
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class TransmitRate extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private TransmitRate() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TransmitRate instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitRate (visibility: PUBLIC, simpleName: TransmitRate, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitRate, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitRate (visibility: PUBLIC, simpleName: TransmitRate, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitRate, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TransmitRate INSTANCE = new TransmitRate(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final TransmitRate.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_TransmitRate = new PParameter("TransmitRate", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Spacecraft, parameter_TransmitRate); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.transmitRate"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Spacecraft","TransmitRate"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); + PVariable var_Target = body.getOrCreateVariableByName("Target"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitRate), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_TransmitRate, parameter_TransmitRate) + )); + // find spacecraftUplink(Spacecraft, TransceiverBand::UHF, Target) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "UHF").getInstance()); + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_, var_Target), SpacecraftUplink.instance().getInternalQueryRepresentation()); + // Spacecraft(Target) + new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + // TransmitRate == 5.0 + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new ConstantValue(body, var__virtual_1_, 5.0); + new Equality(body, var_TransmitRate, var__virtual_1_); + bodies.add(body); + } + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); + PVariable var_Target = body.getOrCreateVariableByName("Target"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitRate), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_TransmitRate, parameter_TransmitRate) + )); + // find spacecraftUplink(Spacecraft, TransceiverBand::X, Target) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "X").getInstance()); + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_, var_Target), SpacecraftUplink.instance().getInternalQueryRepresentation()); + // Spacecraft(Target) + new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + // TransmitRate == 1.6 + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new ConstantValue(body, var__virtual_1_, 1.6); + new Equality(body, var_TransmitRate, var__virtual_1_); + bodies.add(body); + } + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); + PVariable var_Target = body.getOrCreateVariableByName("Target"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitRate), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_TransmitRate, parameter_TransmitRate) + )); + // find spacecraftUplink(Spacecraft, TransceiverBand::X, Target) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "X").getInstance()); + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_, var_Target), SpacecraftUplink.instance().getInternalQueryRepresentation()); + // GroundStationNetwork(Target) + new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "GroundStationNetwork"))); + // TransmitRate == 0.7 + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new ConstantValue(body, var__virtual_1_, 0.7); + new Equality(body, var_TransmitRate, var__virtual_1_); + bodies.add(body); + } + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); + PVariable var_Target = body.getOrCreateVariableByName("Target"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitRate), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_TransmitRate, parameter_TransmitRate) + )); + // find spacecraftUplink(Spacecraft, TransceiverBand::Ka, Target) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "Ka").getInstance()); + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_, var_Target), SpacecraftUplink.instance().getInternalQueryRepresentation()); + // Spacecraft(Target) + new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + // TransmitRate == 220.0 + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new ConstantValue(body, var__virtual_1_, 220.0); + new Equality(body, var_TransmitRate, var__virtual_1_); + bodies.add(body); + } + { + PBody body = new PBody(this); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); + PVariable var_Target = body.getOrCreateVariableByName("Target"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitRate), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_TransmitRate, parameter_TransmitRate) + )); + // find spacecraftUplink(Spacecraft, TransceiverBand::Ka, Target) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "TransceiverBand", "Ka").getInstance()); + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_0_, var_Target), SpacecraftUplink.instance().getInternalQueryRepresentation()); + // GroundStationNetwork(Target) + new TypeConstraint(body, Tuples.flatTupleOf(var_Target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "GroundStationNetwork"))); + // TransmitRate == 80.0 + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new ConstantValue(body, var__virtual_1_, 80.0); + new Equality(body, var_TransmitRate, var__virtual_1_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1() { + return 5.0; + } + + private static double evaluateExpression_2_1() { + return 1.6; + } + + private static double evaluateExpression_3_1() { + return 0.7; + } + + private static double evaluateExpression_4_1() { + return 220.0; + } + + private static double evaluateExpression_5_1() { + return 80.0; + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitTime.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitTime.java new file mode 100644 index 00000000..eb338bec --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitTime.java @@ -0,0 +1,200 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.IncomingData; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.ScienceData; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitRate; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; +import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.xtext.xbase.lib.DoubleExtensions; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern transmitTime(Mission : InterferometryMission, Spacecraft : Spacecraft, TransmitTime : java Double) {
    + *         	ConstellationMission.spacecraft(Mission, Spacecraft);
    + *         	find scienceData(Spacecraft, ScienceData);
    + *         	IncomingData == sum find incomingData(Spacecraft, _, #_);
    + *         	find transmitRate(Spacecraft, TransmitRate);
    + *         	TransmitTime == eval((ScienceData + IncomingData) / (7.5  TransmitRate));
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class TransmitTime extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private TransmitTime() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TransmitTime instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitTime (visibility: PUBLIC, simpleName: TransmitTime, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitTime, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitTime (visibility: PUBLIC, simpleName: TransmitTime, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.TransmitTime, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TransmitTime INSTANCE = new TransmitTime(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final TransmitTime.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Mission = new PParameter("Mission", "hu.bme.mit.inf.dslreasoner.domains.satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_TransmitTime = new PParameter("TransmitTime", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Mission, parameter_Spacecraft, parameter_TransmitTime); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.transmitTime"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Mission","Spacecraft","TransmitTime"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Mission = body.getOrCreateVariableByName("Mission"); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_TransmitTime = body.getOrCreateVariableByName("TransmitTime"); + PVariable var_ScienceData = body.getOrCreateVariableByName("ScienceData"); + PVariable var_IncomingData = body.getOrCreateVariableByName("IncomingData"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitTime), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Mission, parameter_Mission), + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_TransmitTime, parameter_TransmitTime) + )); + // ConstellationMission.spacecraft(Mission, Spacecraft) + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "ConstellationMission"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "ConstellationMission", "spacecraft"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new Equality(body, var__virtual_0_, var_Spacecraft); + // find scienceData(Spacecraft, ScienceData) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_ScienceData), ScienceData.instance().getInternalQueryRepresentation()); + // IncomingData == sum find incomingData(Spacecraft, _, #_) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var_Spacecraft, var___0_, var___1_), IncomingData.instance().getInternalQueryRepresentation(), var__virtual_1_, 2); + new Equality(body, var_IncomingData, var__virtual_1_); + // find transmitRate(Spacecraft, TransmitRate) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_TransmitRate), TransmitRate.instance().getInternalQueryRepresentation()); + // TransmitTime == eval((ScienceData + IncomingData) / (7.5 * TransmitRate)) + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern transmitTime"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("IncomingData", "ScienceData", "TransmitRate");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Double IncomingData = (Double) provider.getValue("IncomingData"); + Double ScienceData = (Double) provider.getValue("ScienceData"); + Double TransmitRate = (Double) provider.getValue("TransmitRate"); + return evaluateExpression_1_1(IncomingData, ScienceData, TransmitRate); + } + }, var__virtual_2_ ); + new Equality(body, var_TransmitTime, var__virtual_2_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1(final Double IncomingData, final Double ScienceData, final Double TransmitRate) { + double _plus = DoubleExtensions.operator_plus(ScienceData, IncomingData); + double _divide = (_plus / (7.5 * (TransmitRate).doubleValue())); + return _divide; + } +} 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 index d0542b4a..7ca948cc 100644 --- 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 @@ -133,7 +133,8 @@ pattern kaAntennaGainLow(Comm : CommSubsystem) { @Constraint(severity = "error", key = {Sat}, message = "3U CubeSats can only cross-link using UHF.") -pattern threeUCubeSatWithNonUhfCrossLink(Sat : CubeSat3U) { +pattern threeUCubeSatWithNonUhfCrossLink(Sat : Spacecraft) { + Spacecraft.kind(Sat, SpacecraftKind::CubeSat3U); CommunicatingElement.commSubsystem(Sat, SourceComm); neg find commSubsystemBandUhf(SourceComm); DirectedCommunicationLink.source(Link, SourceComm); @@ -159,6 +160,141 @@ pattern cubeSatWithKaAntenna(Spacecraft : Spacecraft) { neg find smallSat(Spacecraft); } -private pattern smallSat(Sat : SmallSat) { - SmallSat(Sat); +private pattern smallSat(Sat : Spacecraft) { + Spacecraft.kind(Sat, SpacecraftKind::SmallSat); +} + +// +// Metrics +// + +// Coverage + +pattern coverageMetric(Coverage : java Double) { + Coverage == sum find missionCoverage(_, #_); +} + +private pattern missionCoverage(Mission : InterferometryMission, Coverage : java Double) { + InterferometryMission.observationTime(Mission, ObservationTime); + ObserverCount == count find spacecraftWithInterferometryPayload(Mission, _); + Coverage == eval(Math.pow(1 - 2.0 / ObserverCount, 1 + 9 * (1.0 / ObservationTime)) + 0.05 * ObservationTime / 3); +} + +// Time + +pattern timeMetric(Time : java Double) { + Time == sum find missionTime(_, #_); +} + +private pattern missionTime(Mission : InterferometryMission, Time : java Double) { + InterferometryMission.observationTime(Mission, ObservationTime); + TrasmitTime == sum find transmitTime(Mission, _, #_); + Time == eval(TrasmitTime + 60.0 * ObservationTime); +} + +private pattern transmitTime(Mission : InterferometryMission, Spacecraft : Spacecraft, TransmitTime : java Double) { + ConstellationMission.spacecraft(Mission, Spacecraft); + find scienceData(Spacecraft, ScienceData); + IncomingData == sum find incomingData(Spacecraft, _, #_); + find transmitRate(Spacecraft, TransmitRate); + TransmitTime == eval((ScienceData + IncomingData) / (7.5 * TransmitRate)); +} + +private pattern incomingData(Spacecraft : Spacecraft, Source : Spacecraft, Data : java Double) { + find indirectCommunicationLink(Source, Spacecraft); + find scienceData(Source, Data); +} + +private pattern scienceData(Spacecraft : Spacecraft, Data : java Double) { + ConstellationMission.spacecraft(Mission, Spacecraft); + InterferometryMission.observationTime(Mission, ObservationTime); + Data == eval(12.0 * ObservationTime); +} + +private pattern transmitRate(Spacecraft : Spacecraft, TransmitRate : java Double) { + find spacecraftUplink(Spacecraft, TransceiverBand::UHF, Target); + Spacecraft(Target); + TransmitRate == 5.0; +} or { + find spacecraftUplink(Spacecraft, TransceiverBand::X, Target); + Spacecraft(Target); + TransmitRate == 1.6; +} or { + find spacecraftUplink(Spacecraft, TransceiverBand::X, Target); + GroundStationNetwork(Target); + TransmitRate == 0.7; +} or { + find spacecraftUplink(Spacecraft, TransceiverBand::Ka, Target); + Spacecraft(Target); + TransmitRate == 220.0; +} or { + find spacecraftUplink(Spacecraft, TransceiverBand::Ka, Target); + GroundStationNetwork(Target); + TransmitRate == 80.0; +} + +private pattern spacecraftUplink(Spacecraft : Spacecraft, Band : TransceiverBand, Target : CommunicatingElement) { + CommunicatingElement.communicationLink(Spacecraft, Link); + DirectedCommunicationLink.source.band(Link, Band); + DirectedCommunicationLink.target(Link, TargetSubsystem); + CommunicatingElement.commSubsystem(Target, TargetSubsystem); +} + +// Cost + +pattern costMetric(Cost : java Double) { + Cost == sum find missionCost(_, #_); +} + +private pattern missionCost(Mission : InterferometryMission, Cost : java Double) { + InterferometryMission.observationTime(Mission, ObservationTime); + SpacecraftCost == sum find spacecraftCost(Mission, _, #_); + Cost == eval(SpacecraftCost + 100000.0 * ObservationTime); +} + +private pattern spacecraftCost(Mission : InterferometryMission, Spacecraft : Spacecraft, Cost : java Double) { + ConstellationMission.spacecraft(Mission, Spacecraft); + Spacecraft.kind(Spacecraft, Kind); + KindCount == count find spacecraftOfKind(_, Kind); + find basePrice(Spacecraft, BasePrice); + find interferometryPayloadCost(Spacecraft, InterferometryPayloadCost); + find additionalCommSubsystemCost(Spacecraft, AdditionalCommSubsystemCost); + Cost == eval(BasePrice * Math.pow(KindCount, -0.25) + InterferometryPayloadCost + AdditionalCommSubsystemCost); +} + +private pattern spacecraftOfKind(Spacecraft : Spacecraft, Kind : SpacecraftKind) { + Spacecraft.kind(Spacecraft, Kind); +} + +private pattern basePrice(Spacecraft : Spacecraft, BasePrice : java Double) { + Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat3U); + BasePrice == 250000.0; +} or { + Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat6U); + BasePrice == 750000.0; +} or { + Spacecraft.kind(Spacecraft, SpacecraftKind::SmallSat); + BasePrice == 3000000.0; +} + +private pattern interferometryPayloadCost(Spacecraft : Spacecraft, Cost : java Double) { + find spacecraftWithInterferometryPayload(_, Spacecraft); + Cost == 50000.0; +} or { + neg find spacecraftWithInterferometryPayload(_, Spacecraft); + Cost == 0.0; +} + +private pattern additionalCommSubsystemCost(Spacecraft : Spacecraft, Cost : java Double) { + find spacecraftWithTwoCommSubsystems(Spacecraft); + Cost == 100000.0; +} or { + neg find spacecraftWithTwoCommSubsystems(Spacecraft); + Cost == 0.0; +} + +private pattern spacecraftWithTwoCommSubsystems(Spacecraft : Spacecraft) { + Spacecraft.commSubsystem(Spacecraft, Subsystem1); + Spacecraft.commSubsystem(Spacecraft, Subsystem2); + Subsystem1 != Subsystem2; } diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/runner/.SatelliteGeneratorMain.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/runner/.SatelliteGeneratorMain.xtendbin deleted file mode 100644 index d2d60846..00000000 Binary files a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/runner/.SatelliteGeneratorMain.xtendbin and /dev/null differ diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/runner/SatelliteGeneratorMain.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/runner/SatelliteGeneratorMain.java deleted file mode 100644 index f6890163..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/runner/SatelliteGeneratorMain.java +++ /dev/null @@ -1,15 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.satellite.runner; - -import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor; -import org.eclipse.xtext.xbase.lib.InputOutput; - -@SuppressWarnings("all") -public final class SatelliteGeneratorMain { - private SatelliteGeneratorMain() { - throw new IllegalStateException("This is a static utility class and should not be instantiated directly."); - } - - public static void main(final String[] args) { - InputOutput.println(StandaloneScriptExecutor.executeScript("configs/generation.vsconfig")); - } -} -- cgit v1.2.3-70-g09d2