From 2531cfb60d747c261a20201415728beb0e24ab9b Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Mon, 15 Apr 2019 16:23:19 +0200 Subject: Satellite constellation case study WIP --- .../model/cps.genmodel | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel') diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel new file mode 100644 index 00000000..679e2c49 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel @@ -0,0 +1,62 @@ + + + cps.ecore + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-54-g00ecf From e904f9d4b1d2d15ab4ec6d72ee881f4c7de34eef Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Wed, 15 May 2019 13:46:38 -0400 Subject: Formalize CPS case study for optimization --- .../.classpath | 2 + .../.gitignore | 1 + .../.project | 12 + .../META-INF/MANIFEST.MF | 22 +- .../build.properties | 9 + .../domains/cps/ApplicationInstance.java | 110 ++ .../dslreasoner/domains/cps/ApplicationType.java | 61 + .../inf/dslreasoner/domains/cps/CpsFactory.java | 105 ++ .../inf/dslreasoner/domains/cps/CpsPackage.java | 1253 ++++++++++++++++++++ .../domains/cps/CyberPhysicalSystem.java | 112 ++ .../inf/dslreasoner/domains/cps/HostInstance.java | 141 +++ .../mit/inf/dslreasoner/domains/cps/HostType.java | 125 ++ .../mit/inf/dslreasoner/domains/cps/Request.java | 44 + .../inf/dslreasoner/domains/cps/Requirement.java | 127 ++ .../domains/cps/ResourceRequirement.java | 104 ++ .../domains/cps/impl/ApplicationInstanceImpl.java | 405 +++++++ .../domains/cps/impl/ApplicationTypeImpl.java | 209 ++++ .../domains/cps/impl/CpsFactoryImpl.java | 188 +++ .../domains/cps/impl/CpsPackageImpl.java | 765 ++++++++++++ .../domains/cps/impl/CyberPhysicalSystemImpl.java | 289 +++++ .../domains/cps/impl/HostInstanceImpl.java | 355 ++++++ .../dslreasoner/domains/cps/impl/HostTypeImpl.java | 356 ++++++ .../dslreasoner/domains/cps/impl/RequestImpl.java | 169 +++ .../domains/cps/impl/RequirementImpl.java | 387 ++++++ .../domains/cps/impl/ResourceRequirementImpl.java | 291 +++++ .../domains/cps/util/CpsAdapterFactory.java | 252 ++++ .../dslreasoner/domains/cps/util/CpsSwitch.java | 266 +++++ .../model/cps.aird | 1167 +++++++++++++++--- .../model/cps.ecore | 53 +- .../model/cps.genmodel | 5 +- .../plugin.properties | 4 + .../plugin.xml | 44 + .../inf/dslreasoner/domains/cps/queries/.gitignore | 16 + .../AllocationWithoutResourceRequirement.java | 717 +++++++++++ .../domains/cps/queries/AvailableHdd.java | 743 ++++++++++++ .../domains/cps/queries/AvailableMemory.java | 743 ++++++++++++ .../domains/cps/queries/AverageFreeHddMetric.java | 540 +++++++++ .../cps/queries/AverageFreeMemoryMetric.java | 540 +++++++++ .../domains/cps/queries/CostMetric.java | 540 +++++++++ .../domains/cps/queries/CpsApplications.java | 705 +++++++++++ .../dslreasoner/domains/cps/queries/CpsCost.java | 738 ++++++++++++ .../dslreasoner/domains/cps/queries/CpsHosts.java | 705 +++++++++++ .../domains/cps/queries/CpsQueries.java | 207 ++++ .../queries/InstanceDoesNotSatisfyRequirement.java | 716 +++++++++++ .../domains/cps/queries/NotEnoughAvailableHdd.java | 579 +++++++++ .../cps/queries/NotEnoughAvailableMemory.java | 579 +++++++++ .../cps/queries/RequirementNotSatisfied.java | 597 ++++++++++ .../dslreasoner/domains/cps/queries/TotalHdd.java | 706 +++++++++++ .../domains/cps/queries/TotalMemory.java | 706 +++++++++++ .../domains/cps/queries/internal/.gitignore | 11 + .../cps/queries/internal/CpsQueriesAll.java | 105 ++ .../cps/queries/internal/FreeHddPercentage.java | 172 +++ .../cps/queries/internal/FreeMemoryPercentage.java | 172 +++ .../cps/queries/internal/HddRequirement.java | 151 +++ .../cps/queries/internal/HostInstanceCost.java | 153 +++ .../cps/queries/internal/MemoryRequirement.java | 151 +++ .../cps/queries/internal/ResourceRequirement.java | 168 +++ .../cps/queries/internal/SatisfyingInstance.java | 153 +++ .../dslreasoner/domains/cps/queries/CpsQueries.vql | 132 +++ .../plugin.xml | 9 +- .../domains/satellite/queries/CostMetric.java | 544 +++++++++ .../domains/satellite/queries/CoverageMetric.java | 552 +++++++++ .../satellite/queries/SatelliteQueries.java | 33 + .../domains/satellite/queries/TimeMetric.java | 544 +++++++++ .../internal/AdditionalCommSubsystemCost.java | 173 +++ .../satellite/queries/internal/BasePrice.java | 195 +++ .../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 | 48 + .../satellite/queries/internal/ScienceData.java | 179 +++ .../satellite/queries/internal/SpacecraftCost.java | 209 ++++ .../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 | 9 +- .../runner/.SatelliteGeneratorMain.xtendbin | Bin 2931 -> 0 bytes .../satellite/runner/SatelliteGeneratorMain.java | 15 - 81 files changed, 22860 insertions(+), 191 deletions(-) create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.gitignore create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/build.properties create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationInstance.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationType.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsFactory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostType.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Request.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Requirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ResourceRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationInstanceImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationTypeImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsFactoryImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostTypeImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequestImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequirementImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ResourceRequirementImpl.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsAdapterFactory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsSwitch.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.properties create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/InstanceDoesNotSatisfyRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RequirementNotSatisfied.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/SatisfyingInstance.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql 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/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 (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel') diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.classpath b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.classpath index 22f30643..00cbac94 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.classpath +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.classpath @@ -1,7 +1,9 @@ + + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.gitignore new file mode 100644 index 00000000..ae3c1726 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project index 994e7632..69c44278 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project @@ -5,6 +5,16 @@ + + org.eclipse.viatra.query.tooling.ui.projectbuilder + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + org.eclipse.jdt.core.javabuilder @@ -25,5 +35,7 @@ org.eclipse.sirius.nature.modelingproject org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature + org.eclipse.viatra.query.projectnature + org.eclipse.xtext.ui.shared.xtextNature diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF index 4d2fd769..7fd7252c 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF @@ -1,7 +1,23 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: hu.bme.mit.inf.dslreasoner.domains.cps -Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.domains.cps; singleton:=true +Bundle-Name: %pluginName +Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.domains.cps;singleton:=true Bundle-Version: 0.1.0.qualifier -Require-Bundle: org.eclipse.emf.ecore;visibility:=reexport, +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Export-Package: hu.bme.mit.inf.dslreasoner.domains.cps, + hu.bme.mit.inf.dslreasoner.domains.cps.impl, + hu.bme.mit.inf.dslreasoner.domains.cps.queries, + hu.bme.mit.inf.dslreasoner.domains.cps.util +Require-Bundle: org.eclipse.viatra.addon.querybasedfeatures.runtime, + org.eclipse.viatra.query.runtime, + org.eclipse.viatra.query.runtime.rete, + org.eclipse.viatra.query.runtime.localsearch, + org.eclipse.xtext.xbase.lib, + org.eclipse.emf.ecore;visibility:=reexport, org.eclipse.core.runtime +Import-Package: org.apache.log4j +Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.domains.cps +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/build.properties b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/build.properties new file mode 100644 index 00000000..37a7e53b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/build.properties @@ -0,0 +1,9 @@ +bin.includes = .,\ + model/,\ + META-INF/,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = ecore-gen/,\ + src-gen/ +output.. = bin/ diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationInstance.java new file mode 100644 index 00000000..dc9426f2 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationInstance.java @@ -0,0 +1,110 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Application Instance'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement Requirement}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType Type}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo Allocated To}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationInstance() + * @model + * @generated + */ +public interface ApplicationInstance extends EObject { + /** + * Returns the value of the 'Requirement' reference. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances Instances}'. + * + *

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

+ * + * @return the value of the 'Requirement' reference. + * @see #setRequirement(Requirement) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationInstance_Requirement() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances + * @model opposite="instances" + * @generated + */ + Requirement getRequirement(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement Requirement}' reference. + * + * + * @param value the new value of the 'Requirement' reference. + * @see #getRequirement() + * @generated + */ + void setRequirement(Requirement value); + + /** + * Returns the value of the 'Type' container reference. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances Instances}'. + * + *

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

+ * + * @return the value of the 'Type' container reference. + * @see #setType(ApplicationType) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationInstance_Type() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances + * @model opposite="instances" required="true" transient="false" + * @generated + */ + ApplicationType getType(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType Type}' container reference. + * + * + * @param value the new value of the 'Type' container reference. + * @see #getType() + * @generated + */ + void setType(ApplicationType value); + + /** + * Returns the value of the 'Allocated To' reference. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications Applications}'. + * + *

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

+ * + * @return the value of the 'Allocated To' reference. + * @see #setAllocatedTo(HostInstance) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationInstance_AllocatedTo() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications + * @model opposite="applications" required="true" + * @generated + */ + HostInstance getAllocatedTo(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo Allocated To}' reference. + * + * + * @param value the new value of the 'Allocated To' reference. + * @see #getAllocatedTo() + * @generated + */ + void setAllocatedTo(HostInstance value); + +} // ApplicationInstance diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationType.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationType.java new file mode 100644 index 00000000..f44287ae --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ApplicationType.java @@ -0,0 +1,61 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Application Type'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances Instances}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getRequirements Requirements}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationType() + * @model + * @generated + */ +public interface ApplicationType extends EObject { + /** + * Returns the value of the 'Instances' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType Type}'. + * + *

+ * If the meaning of the 'Instances' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Instances' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationType_Instances() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType + * @model opposite="type" containment="true" + * @generated + */ + EList getInstances(); + + /** + * Returns the value of the 'Requirements' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement}. + * + *

+ * If the meaning of the 'Requirements' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Requirements' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getApplicationType_Requirements() + * @model containment="true" + * @generated + */ + EList getRequirements(); + +} // ApplicationType diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsFactory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsFactory.java new file mode 100644 index 00000000..93a5fc95 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsFactory.java @@ -0,0 +1,105 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage + * @generated + */ +public interface CpsFactory extends EFactory { + /** + * The singleton instance of the factory. + * + * + * @generated + */ + CpsFactory eINSTANCE = hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsFactoryImpl.init(); + + /** + * Returns a new object of class 'Cyber Physical System'. + * + * + * @return a new object of class 'Cyber Physical System'. + * @generated + */ + CyberPhysicalSystem createCyberPhysicalSystem(); + + /** + * Returns a new object of class 'Application Type'. + * + * + * @return a new object of class 'Application Type'. + * @generated + */ + ApplicationType createApplicationType(); + + /** + * Returns a new object of class 'Host Type'. + * + * + * @return a new object of class 'Host Type'. + * @generated + */ + HostType createHostType(); + + /** + * Returns a new object of class 'Request'. + * + * + * @return a new object of class 'Request'. + * @generated + */ + Request createRequest(); + + /** + * Returns a new object of class 'Requirement'. + * + * + * @return a new object of class 'Requirement'. + * @generated + */ + Requirement createRequirement(); + + /** + * Returns a new object of class 'Application Instance'. + * + * + * @return a new object of class 'Application Instance'. + * @generated + */ + ApplicationInstance createApplicationInstance(); + + /** + * Returns a new object of class 'Resource Requirement'. + * + * + * @return a new object of class 'Resource Requirement'. + * @generated + */ + ResourceRequirement createResourceRequirement(); + + /** + * Returns a new object of class 'Host Instance'. + * + * + * @return a new object of class 'Host Instance'. + * @generated + */ + HostInstance createHostInstance(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + CpsPackage getCpsPackage(); + +} //CpsFactory diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java new file mode 100644 index 00000000..2d7e0660 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java @@ -0,0 +1,1253 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory + * @model kind="package" + * annotation="http://www.eclipse.org/emf/2002/Ecore settingDelegates='org.eclipse.viatra.query.querybasedfeature'" + * @generated + */ +public interface CpsPackage extends EPackage { + /** + * The package name. + * + * + * @generated + */ + String eNAME = "cps"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://www.example.org/cps"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "cps"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + CpsPackage eINSTANCE = hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl.init(); + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl Cyber Physical System}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getCyberPhysicalSystem() + * @generated + */ + int CYBER_PHYSICAL_SYSTEM = 0; + + /** + * The feature id for the 'Requests' containment reference list. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM__REQUESTS = 0; + + /** + * The feature id for the 'Application Types' containment reference list. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES = 1; + + /** + * The feature id for the 'Host Types' containment reference list. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM__HOST_TYPES = 2; + + /** + * The feature id for the 'Hosts' reference list. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM__HOSTS = 3; + + /** + * The feature id for the 'Applications' reference list. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM__APPLICATIONS = 4; + + /** + * The number of structural features of the 'Cyber Physical System' class. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM_FEATURE_COUNT = 5; + + /** + * The number of operations of the 'Cyber Physical System' class. + * + * + * @generated + * @ordered + */ + int CYBER_PHYSICAL_SYSTEM_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl Application Type}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getApplicationType() + * @generated + */ + int APPLICATION_TYPE = 1; + + /** + * The feature id for the 'Instances' containment reference list. + * + * + * @generated + * @ordered + */ + int APPLICATION_TYPE__INSTANCES = 0; + + /** + * The feature id for the 'Requirements' containment reference list. + * + * + * @generated + * @ordered + */ + int APPLICATION_TYPE__REQUIREMENTS = 1; + + /** + * The number of structural features of the 'Application Type' class. + * + * + * @generated + * @ordered + */ + int APPLICATION_TYPE_FEATURE_COUNT = 2; + + /** + * The number of operations of the 'Application Type' class. + * + * + * @generated + * @ordered + */ + int APPLICATION_TYPE_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl Host Type}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getHostType() + * @generated + */ + int HOST_TYPE = 2; + + /** + * The feature id for the 'Default Memory' attribute. + * + * + * @generated + * @ordered + */ + int HOST_TYPE__DEFAULT_MEMORY = 0; + + /** + * The feature id for the 'Default Hdd' attribute. + * + * + * @generated + * @ordered + */ + int HOST_TYPE__DEFAULT_HDD = 1; + + /** + * The feature id for the 'Instances' containment reference list. + * + * + * @generated + * @ordered + */ + int HOST_TYPE__INSTANCES = 2; + + /** + * The feature id for the 'Cost' attribute. + * + * + * @generated + * @ordered + */ + int HOST_TYPE__COST = 3; + + /** + * The number of structural features of the 'Host Type' class. + * + * + * @generated + * @ordered + */ + int HOST_TYPE_FEATURE_COUNT = 4; + + /** + * The number of operations of the 'Host Type' class. + * + * + * @generated + * @ordered + */ + int HOST_TYPE_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl Request}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getRequest() + * @generated + */ + int REQUEST = 3; + + /** + * The feature id for the 'Requirements' containment reference list. + * + * + * @generated + * @ordered + */ + int REQUEST__REQUIREMENTS = 0; + + /** + * The number of structural features of the 'Request' class. + * + * + * @generated + * @ordered + */ + int REQUEST_FEATURE_COUNT = 1; + + /** + * The number of operations of the 'Request' class. + * + * + * @generated + * @ordered + */ + int REQUEST_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl Requirement}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getRequirement() + * @generated + */ + int REQUIREMENT = 4; + + /** + * The feature id for the 'Request' container reference. + * + * + * @generated + * @ordered + */ + int REQUIREMENT__REQUEST = 0; + + /** + * The feature id for the 'Count' attribute. + * + * + * @generated + * @ordered + */ + int REQUIREMENT__COUNT = 1; + + /** + * The feature id for the 'Type' reference. + * + * + * @generated + * @ordered + */ + int REQUIREMENT__TYPE = 2; + + /** + * The feature id for the 'Instances' reference list. + * + * + * @generated + * @ordered + */ + int REQUIREMENT__INSTANCES = 3; + + /** + * The number of structural features of the 'Requirement' class. + * + * + * @generated + * @ordered + */ + int REQUIREMENT_FEATURE_COUNT = 4; + + /** + * The number of operations of the 'Requirement' class. + * + * + * @generated + * @ordered + */ + int REQUIREMENT_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl Application Instance}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getApplicationInstance() + * @generated + */ + int APPLICATION_INSTANCE = 5; + + /** + * The feature id for the 'Requirement' reference. + * + * + * @generated + * @ordered + */ + int APPLICATION_INSTANCE__REQUIREMENT = 0; + + /** + * The feature id for the 'Type' container reference. + * + * + * @generated + * @ordered + */ + int APPLICATION_INSTANCE__TYPE = 1; + + /** + * The feature id for the 'Allocated To' reference. + * + * + * @generated + * @ordered + */ + int APPLICATION_INSTANCE__ALLOCATED_TO = 2; + + /** + * The number of structural features of the 'Application Instance' class. + * + * + * @generated + * @ordered + */ + int APPLICATION_INSTANCE_FEATURE_COUNT = 3; + + /** + * The number of operations of the 'Application Instance' class. + * + * + * @generated + * @ordered + */ + int APPLICATION_INSTANCE_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl Resource Requirement}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getResourceRequirement() + * @generated + */ + int RESOURCE_REQUIREMENT = 6; + + /** + * The feature id for the 'Required Memory' attribute. + * + * + * @generated + * @ordered + */ + int RESOURCE_REQUIREMENT__REQUIRED_MEMORY = 0; + + /** + * The feature id for the 'Required Hdd' attribute. + * + * + * @generated + * @ordered + */ + int RESOURCE_REQUIREMENT__REQUIRED_HDD = 1; + + /** + * The feature id for the 'Host Type' reference. + * + * + * @generated + * @ordered + */ + int RESOURCE_REQUIREMENT__HOST_TYPE = 2; + + /** + * The number of structural features of the 'Resource Requirement' class. + * + * + * @generated + * @ordered + */ + int RESOURCE_REQUIREMENT_FEATURE_COUNT = 3; + + /** + * The number of operations of the 'Resource Requirement' class. + * + * + * @generated + * @ordered + */ + int RESOURCE_REQUIREMENT_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl Host Instance}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getHostInstance() + * @generated + */ + int HOST_INSTANCE = 7; + + /** + * The feature id for the 'Type' container reference. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE__TYPE = 0; + + /** + * The feature id for the 'Available Memory' attribute. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE__AVAILABLE_MEMORY = 1; + + /** + * The feature id for the 'Available Hdd' attribute. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE__AVAILABLE_HDD = 2; + + /** + * The feature id for the 'Total Memory' attribute. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE__TOTAL_MEMORY = 3; + + /** + * The feature id for the 'Total Hdd' attribute. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE__TOTAL_HDD = 4; + + /** + * The feature id for the 'Applications' reference list. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE__APPLICATIONS = 5; + + /** + * The number of structural features of the 'Host Instance' class. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE_FEATURE_COUNT = 6; + + /** + * The number of operations of the 'Host Instance' class. + * + * + * @generated + * @ordered + */ + int HOST_INSTANCE_OPERATION_COUNT = 0; + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem Cyber Physical System}'. + * + * + * @return the meta object for class 'Cyber Physical System'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem + * @generated + */ + EClass getCyberPhysicalSystem(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getRequests Requests}'. + * + * + * @return the meta object for the containment reference list 'Requests'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getRequests() + * @see #getCyberPhysicalSystem() + * @generated + */ + EReference getCyberPhysicalSystem_Requests(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplicationTypes Application Types}'. + * + * + * @return the meta object for the containment reference list 'Application Types'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplicationTypes() + * @see #getCyberPhysicalSystem() + * @generated + */ + EReference getCyberPhysicalSystem_ApplicationTypes(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHostTypes Host Types}'. + * + * + * @return the meta object for the containment reference list 'Host Types'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHostTypes() + * @see #getCyberPhysicalSystem() + * @generated + */ + EReference getCyberPhysicalSystem_HostTypes(); + + /** + * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHosts Hosts}'. + * + * + * @return the meta object for the reference list 'Hosts'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHosts() + * @see #getCyberPhysicalSystem() + * @generated + */ + EReference getCyberPhysicalSystem_Hosts(); + + /** + * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplications Applications}'. + * + * + * @return the meta object for the reference list 'Applications'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplications() + * @see #getCyberPhysicalSystem() + * @generated + */ + EReference getCyberPhysicalSystem_Applications(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType Application Type}'. + * + * + * @return the meta object for class 'Application Type'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType + * @generated + */ + EClass getApplicationType(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances Instances}'. + * + * + * @return the meta object for the containment reference list 'Instances'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getInstances() + * @see #getApplicationType() + * @generated + */ + EReference getApplicationType_Instances(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getRequirements Requirements}'. + * + * + * @return the meta object for the containment reference list 'Requirements'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType#getRequirements() + * @see #getApplicationType() + * @generated + */ + EReference getApplicationType_Requirements(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType Host Type}'. + * + * + * @return the meta object for class 'Host Type'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType + * @generated + */ + EClass getHostType(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultMemory Default Memory}'. + * + * + * @return the meta object for the attribute 'Default Memory'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultMemory() + * @see #getHostType() + * @generated + */ + EAttribute getHostType_DefaultMemory(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultHdd Default Hdd}'. + * + * + * @return the meta object for the attribute 'Default Hdd'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultHdd() + * @see #getHostType() + * @generated + */ + EAttribute getHostType_DefaultHdd(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances Instances}'. + * + * + * @return the meta object for the containment reference list 'Instances'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances() + * @see #getHostType() + * @generated + */ + EReference getHostType_Instances(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getCost Cost}'. + * + * + * @return the meta object for the attribute 'Cost'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getCost() + * @see #getHostType() + * @generated + */ + EAttribute getHostType_Cost(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request Request}'. + * + * + * @return the meta object for class 'Request'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Request + * @generated + */ + EClass getRequest(); + + /** + * Returns the meta object for the containment reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements Requirements}'. + * + * + * @return the meta object for the containment reference list 'Requirements'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements() + * @see #getRequest() + * @generated + */ + EReference getRequest_Requirements(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement Requirement}'. + * + * + * @return the meta object for class 'Requirement'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement + * @generated + */ + EClass getRequirement(); + + /** + * Returns the meta object for the container reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest Request}'. + * + * + * @return the meta object for the container reference 'Request'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest() + * @see #getRequirement() + * @generated + */ + EReference getRequirement_Request(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getCount Count}'. + * + * + * @return the meta object for the attribute 'Count'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getCount() + * @see #getRequirement() + * @generated + */ + EAttribute getRequirement_Count(); + + /** + * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getType Type}'. + * + * + * @return the meta object for the reference 'Type'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getType() + * @see #getRequirement() + * @generated + */ + EReference getRequirement_Type(); + + /** + * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances Instances}'. + * + * + * @return the meta object for the reference list 'Instances'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances() + * @see #getRequirement() + * @generated + */ + EReference getRequirement_Instances(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance Application Instance}'. + * + * + * @return the meta object for class 'Application Instance'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance + * @generated + */ + EClass getApplicationInstance(); + + /** + * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement Requirement}'. + * + * + * @return the meta object for the reference 'Requirement'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement() + * @see #getApplicationInstance() + * @generated + */ + EReference getApplicationInstance_Requirement(); + + /** + * Returns the meta object for the container reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType Type}'. + * + * + * @return the meta object for the container reference 'Type'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getType() + * @see #getApplicationInstance() + * @generated + */ + EReference getApplicationInstance_Type(); + + /** + * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo Allocated To}'. + * + * + * @return the meta object for the reference 'Allocated To'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo() + * @see #getApplicationInstance() + * @generated + */ + EReference getApplicationInstance_AllocatedTo(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement Resource Requirement}'. + * + * + * @return the meta object for class 'Resource Requirement'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement + * @generated + */ + EClass getResourceRequirement(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredMemory Required Memory}'. + * + * + * @return the meta object for the attribute 'Required Memory'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredMemory() + * @see #getResourceRequirement() + * @generated + */ + EAttribute getResourceRequirement_RequiredMemory(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredHdd Required Hdd}'. + * + * + * @return the meta object for the attribute 'Required Hdd'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredHdd() + * @see #getResourceRequirement() + * @generated + */ + EAttribute getResourceRequirement_RequiredHdd(); + + /** + * Returns the meta object for the reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getHostType Host Type}'. + * + * + * @return the meta object for the reference 'Host Type'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getHostType() + * @see #getResourceRequirement() + * @generated + */ + EReference getResourceRequirement_HostType(); + + /** + * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance Host Instance}'. + * + * + * @return the meta object for class 'Host Instance'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance + * @generated + */ + EClass getHostInstance(); + + /** + * Returns the meta object for the container reference '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType Type}'. + * + * + * @return the meta object for the container reference 'Type'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType() + * @see #getHostInstance() + * @generated + */ + EReference getHostInstance_Type(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableMemory Available Memory}'. + * + * + * @return the meta object for the attribute 'Available Memory'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableMemory() + * @see #getHostInstance() + * @generated + */ + EAttribute getHostInstance_AvailableMemory(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableHdd Available Hdd}'. + * + * + * @return the meta object for the attribute 'Available Hdd'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableHdd() + * @see #getHostInstance() + * @generated + */ + EAttribute getHostInstance_AvailableHdd(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalMemory Total Memory}'. + * + * + * @return the meta object for the attribute 'Total Memory'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalMemory() + * @see #getHostInstance() + * @generated + */ + EAttribute getHostInstance_TotalMemory(); + + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalHdd Total Hdd}'. + * + * + * @return the meta object for the attribute 'Total Hdd'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalHdd() + * @see #getHostInstance() + * @generated + */ + EAttribute getHostInstance_TotalHdd(); + + /** + * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications Applications}'. + * + * + * @return the meta object for the reference list 'Applications'. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications() + * @see #getHostInstance() + * @generated + */ + EReference getHostInstance_Applications(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + CpsFactory getCpsFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl Cyber Physical System}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getCyberPhysicalSystem() + * @generated + */ + EClass CYBER_PHYSICAL_SYSTEM = eINSTANCE.getCyberPhysicalSystem(); + + /** + * The meta object literal for the 'Requests' containment reference list feature. + * + * + * @generated + */ + EReference CYBER_PHYSICAL_SYSTEM__REQUESTS = eINSTANCE.getCyberPhysicalSystem_Requests(); + + /** + * The meta object literal for the 'Application Types' containment reference list feature. + * + * + * @generated + */ + EReference CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES = eINSTANCE.getCyberPhysicalSystem_ApplicationTypes(); + + /** + * The meta object literal for the 'Host Types' containment reference list feature. + * + * + * @generated + */ + EReference CYBER_PHYSICAL_SYSTEM__HOST_TYPES = eINSTANCE.getCyberPhysicalSystem_HostTypes(); + + /** + * The meta object literal for the 'Hosts' reference list feature. + * + * + * @generated + */ + EReference CYBER_PHYSICAL_SYSTEM__HOSTS = eINSTANCE.getCyberPhysicalSystem_Hosts(); + + /** + * The meta object literal for the 'Applications' reference list feature. + * + * + * @generated + */ + EReference CYBER_PHYSICAL_SYSTEM__APPLICATIONS = eINSTANCE.getCyberPhysicalSystem_Applications(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl Application Type}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getApplicationType() + * @generated + */ + EClass APPLICATION_TYPE = eINSTANCE.getApplicationType(); + + /** + * The meta object literal for the 'Instances' containment reference list feature. + * + * + * @generated + */ + EReference APPLICATION_TYPE__INSTANCES = eINSTANCE.getApplicationType_Instances(); + + /** + * The meta object literal for the 'Requirements' containment reference list feature. + * + * + * @generated + */ + EReference APPLICATION_TYPE__REQUIREMENTS = eINSTANCE.getApplicationType_Requirements(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl Host Type}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getHostType() + * @generated + */ + EClass HOST_TYPE = eINSTANCE.getHostType(); + + /** + * The meta object literal for the 'Default Memory' attribute feature. + * + * + * @generated + */ + EAttribute HOST_TYPE__DEFAULT_MEMORY = eINSTANCE.getHostType_DefaultMemory(); + + /** + * The meta object literal for the 'Default Hdd' attribute feature. + * + * + * @generated + */ + EAttribute HOST_TYPE__DEFAULT_HDD = eINSTANCE.getHostType_DefaultHdd(); + + /** + * The meta object literal for the 'Instances' containment reference list feature. + * + * + * @generated + */ + EReference HOST_TYPE__INSTANCES = eINSTANCE.getHostType_Instances(); + + /** + * The meta object literal for the 'Cost' attribute feature. + * + * + * @generated + */ + EAttribute HOST_TYPE__COST = eINSTANCE.getHostType_Cost(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl Request}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getRequest() + * @generated + */ + EClass REQUEST = eINSTANCE.getRequest(); + + /** + * The meta object literal for the 'Requirements' containment reference list feature. + * + * + * @generated + */ + EReference REQUEST__REQUIREMENTS = eINSTANCE.getRequest_Requirements(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl Requirement}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getRequirement() + * @generated + */ + EClass REQUIREMENT = eINSTANCE.getRequirement(); + + /** + * The meta object literal for the 'Request' container reference feature. + * + * + * @generated + */ + EReference REQUIREMENT__REQUEST = eINSTANCE.getRequirement_Request(); + + /** + * The meta object literal for the 'Count' attribute feature. + * + * + * @generated + */ + EAttribute REQUIREMENT__COUNT = eINSTANCE.getRequirement_Count(); + + /** + * The meta object literal for the 'Type' reference feature. + * + * + * @generated + */ + EReference REQUIREMENT__TYPE = eINSTANCE.getRequirement_Type(); + + /** + * The meta object literal for the 'Instances' reference list feature. + * + * + * @generated + */ + EReference REQUIREMENT__INSTANCES = eINSTANCE.getRequirement_Instances(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl Application Instance}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getApplicationInstance() + * @generated + */ + EClass APPLICATION_INSTANCE = eINSTANCE.getApplicationInstance(); + + /** + * The meta object literal for the 'Requirement' reference feature. + * + * + * @generated + */ + EReference APPLICATION_INSTANCE__REQUIREMENT = eINSTANCE.getApplicationInstance_Requirement(); + + /** + * The meta object literal for the 'Type' container reference feature. + * + * + * @generated + */ + EReference APPLICATION_INSTANCE__TYPE = eINSTANCE.getApplicationInstance_Type(); + + /** + * The meta object literal for the 'Allocated To' reference feature. + * + * + * @generated + */ + EReference APPLICATION_INSTANCE__ALLOCATED_TO = eINSTANCE.getApplicationInstance_AllocatedTo(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl Resource Requirement}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getResourceRequirement() + * @generated + */ + EClass RESOURCE_REQUIREMENT = eINSTANCE.getResourceRequirement(); + + /** + * The meta object literal for the 'Required Memory' attribute feature. + * + * + * @generated + */ + EAttribute RESOURCE_REQUIREMENT__REQUIRED_MEMORY = eINSTANCE.getResourceRequirement_RequiredMemory(); + + /** + * The meta object literal for the 'Required Hdd' attribute feature. + * + * + * @generated + */ + EAttribute RESOURCE_REQUIREMENT__REQUIRED_HDD = eINSTANCE.getResourceRequirement_RequiredHdd(); + + /** + * The meta object literal for the 'Host Type' reference feature. + * + * + * @generated + */ + EReference RESOURCE_REQUIREMENT__HOST_TYPE = eINSTANCE.getResourceRequirement_HostType(); + + /** + * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl Host Instance}' class. + * + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl + * @see hu.bme.mit.inf.dslreasoner.domains.cps.impl.CpsPackageImpl#getHostInstance() + * @generated + */ + EClass HOST_INSTANCE = eINSTANCE.getHostInstance(); + + /** + * The meta object literal for the 'Type' container reference feature. + * + * + * @generated + */ + EReference HOST_INSTANCE__TYPE = eINSTANCE.getHostInstance_Type(); + + /** + * The meta object literal for the 'Available Memory' attribute feature. + * + * + * @generated + */ + EAttribute HOST_INSTANCE__AVAILABLE_MEMORY = eINSTANCE.getHostInstance_AvailableMemory(); + + /** + * The meta object literal for the 'Available Hdd' attribute feature. + * + * + * @generated + */ + EAttribute HOST_INSTANCE__AVAILABLE_HDD = eINSTANCE.getHostInstance_AvailableHdd(); + + /** + * The meta object literal for the 'Total Memory' attribute feature. + * + * + * @generated + */ + EAttribute HOST_INSTANCE__TOTAL_MEMORY = eINSTANCE.getHostInstance_TotalMemory(); + + /** + * The meta object literal for the 'Total Hdd' attribute feature. + * + * + * @generated + */ + EAttribute HOST_INSTANCE__TOTAL_HDD = eINSTANCE.getHostInstance_TotalHdd(); + + /** + * The meta object literal for the 'Applications' reference list feature. + * + * + * @generated + */ + EReference HOST_INSTANCE__APPLICATIONS = eINSTANCE.getHostInstance_Applications(); + + } + +} //CpsPackage diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java new file mode 100644 index 00000000..541916ba --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java @@ -0,0 +1,112 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Cyber Physical System'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getRequests Requests}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplicationTypes Application Types}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHostTypes Host Types}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHosts Hosts}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplications Applications}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem() + * @model + * @generated + */ +public interface CyberPhysicalSystem extends EObject { + /** + * Returns the value of the 'Requests' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.Request}. + * + *

+ * If the meaning of the 'Requests' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Requests' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_Requests() + * @model containment="true" + * @generated + */ + EList getRequests(); + + /** + * Returns the value of the 'Application Types' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType}. + * + *

+ * If the meaning of the 'Application Types' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Application Types' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_ApplicationTypes() + * @model containment="true" + * @generated + */ + EList getApplicationTypes(); + + /** + * Returns the value of the 'Host Types' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType}. + * + *

+ * If the meaning of the 'Host Types' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Host Types' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_HostTypes() + * @model containment="true" + * @generated + */ + EList getHostTypes(); + + /** + * Returns the value of the 'Hosts' reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance}. + * + *

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

+ * + * @return the value of the 'Hosts' reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_Hosts() + * @model transient="true" changeable="false" volatile="true" derived="true" + * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts'" + * @generated + */ + EList getHosts(); + + /** + * Returns the value of the 'Applications' reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. + * + *

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

+ * + * @return the value of the 'Applications' reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_Applications() + * @model transient="true" changeable="false" volatile="true" derived="true" + * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications'" + * @generated + */ + EList getApplications(); + +} // CyberPhysicalSystem diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java new file mode 100644 index 00000000..43379e0f --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java @@ -0,0 +1,141 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Host Instance'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType Type}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableMemory Available Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableHdd Available Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalMemory Total Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalHdd Total Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications Applications}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance() + * @model + * @generated + */ +public interface HostInstance extends EObject { + /** + * Returns the value of the 'Type' container reference. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances Instances}'. + * + *

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

+ * + * @return the value of the 'Type' container reference. + * @see #setType(HostType) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_Type() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances + * @model opposite="instances" required="true" transient="false" + * @generated + */ + HostType getType(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType Type}' container reference. + * + * + * @param value the new value of the 'Type' container reference. + * @see #getType() + * @generated + */ + void setType(HostType value); + + /** + * Returns the value of the 'Available Memory' attribute. + * + *

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

+ * + * @return the value of the 'Available Memory' attribute. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_AvailableMemory() + * @model transient="true" changeable="false" volatile="true" derived="true" + * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory'" + * @generated + */ + int getAvailableMemory(); + + /** + * Returns the value of the 'Available Hdd' attribute. + * + *

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

+ * + * @return the value of the 'Available Hdd' attribute. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_AvailableHdd() + * @model transient="true" changeable="false" volatile="true" derived="true" + * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd'" + * @generated + */ + int getAvailableHdd(); + + /** + * Returns the value of the 'Total Memory' attribute. + * + *

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

+ * + * @return the value of the 'Total Memory' attribute. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_TotalMemory() + * @model transient="true" changeable="false" volatile="true" derived="true" + * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory'" + * @generated + */ + int getTotalMemory(); + + /** + * Returns the value of the 'Total Hdd' attribute. + * + *

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

+ * + * @return the value of the 'Total Hdd' attribute. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_TotalHdd() + * @model transient="true" changeable="false" volatile="true" derived="true" + * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd'" + * @generated + */ + int getTotalHdd(); + + /** + * Returns the value of the 'Applications' reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo Allocated To}'. + * + *

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

+ * + * @return the value of the 'Applications' reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_Applications() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getAllocatedTo + * @model opposite="allocatedTo" + * @generated + */ + EList getApplications(); + +} // HostInstance diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostType.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostType.java new file mode 100644 index 00000000..45201930 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostType.java @@ -0,0 +1,125 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Host Type'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultMemory Default Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultHdd Default Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getInstances Instances}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getCost Cost}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType() + * @model + * @generated + */ +public interface HostType extends EObject { + /** + * Returns the value of the 'Default Memory' attribute. + * + *

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

+ * + * @return the value of the 'Default Memory' attribute. + * @see #setDefaultMemory(int) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType_DefaultMemory() + * @model required="true" + * @generated + */ + int getDefaultMemory(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultMemory Default Memory}' attribute. + * + * + * @param value the new value of the 'Default Memory' attribute. + * @see #getDefaultMemory() + * @generated + */ + void setDefaultMemory(int value); + + /** + * Returns the value of the 'Default Hdd' attribute. + * + *

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

+ * + * @return the value of the 'Default Hdd' attribute. + * @see #setDefaultHdd(int) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType_DefaultHdd() + * @model required="true" + * @generated + */ + int getDefaultHdd(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getDefaultHdd Default Hdd}' attribute. + * + * + * @param value the new value of the 'Default Hdd' attribute. + * @see #getDefaultHdd() + * @generated + */ + void setDefaultHdd(int value); + + /** + * Returns the value of the 'Instances' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance}. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType Type}'. + * + *

+ * If the meaning of the 'Instances' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Instances' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType_Instances() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType + * @model opposite="type" containment="true" + * @generated + */ + EList getInstances(); + + /** + * Returns the value of the 'Cost' attribute. + * + *

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

+ * + * @return the value of the 'Cost' attribute. + * @see #setCost(int) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostType_Cost() + * @model required="true" + * @generated + */ + int getCost(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType#getCost Cost}' attribute. + * + * + * @param value the new value of the 'Cost' attribute. + * @see #getCost() + * @generated + */ + void setCost(int value); + +} // HostType diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Request.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Request.java new file mode 100644 index 00000000..261562a0 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Request.java @@ -0,0 +1,44 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Request'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements Requirements}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequest() + * @model + * @generated + */ +public interface Request extends EObject { + /** + * Returns the value of the 'Requirements' containment reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement}. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest Request}'. + * + *

+ * If the meaning of the 'Requirements' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Requirements' containment reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequest_Requirements() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest + * @model opposite="request" containment="true" + * @generated + */ + EList getRequirements(); + +} // Request diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Requirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Requirement.java new file mode 100644 index 00000000..a1d494e4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/Requirement.java @@ -0,0 +1,127 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Requirement'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest Request}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getCount Count}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getType Type}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getInstances Instances}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement() + * @model + * @generated + */ +public interface Requirement extends EObject { + /** + * Returns the value of the 'Request' container reference. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements Requirements}'. + * + *

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

+ * + * @return the value of the 'Request' container reference. + * @see #setRequest(Request) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement_Request() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.Request#getRequirements + * @model opposite="requirements" required="true" transient="false" + * @generated + */ + Request getRequest(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getRequest Request}' container reference. + * + * + * @param value the new value of the 'Request' container reference. + * @see #getRequest() + * @generated + */ + void setRequest(Request value); + + /** + * Returns the value of the 'Count' attribute. + * + *

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

+ * + * @return the value of the 'Count' attribute. + * @see #setCount(int) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement_Count() + * @model required="true" + * @generated + */ + int getCount(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getCount Count}' attribute. + * + * + * @param value the new value of the 'Count' attribute. + * @see #getCount() + * @generated + */ + void setCount(int value); + + /** + * Returns the value of the 'Type' reference. + * + *

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

+ * + * @return the value of the 'Type' reference. + * @see #setType(ApplicationType) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement_Type() + * @model + * @generated + */ + ApplicationType getType(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement#getType Type}' reference. + * + * + * @param value the new value of the 'Type' reference. + * @see #getType() + * @generated + */ + void setType(ApplicationType value); + + /** + * Returns the value of the 'Instances' reference list. + * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. + * It is bidirectional and its opposite is '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement Requirement}'. + * + *

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

+ * + * @return the value of the 'Instances' reference list. + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getRequirement_Instances() + * @see hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance#getRequirement + * @model opposite="requirement" + * @generated + */ + EList getInstances(); + +} // Requirement diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ResourceRequirement.java new file mode 100644 index 00000000..a99cc12e --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/ResourceRequirement.java @@ -0,0 +1,104 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Resource Requirement'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredMemory Required Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredHdd Required Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getHostType Host Type}
  • + *
+ * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getResourceRequirement() + * @model + * @generated + */ +public interface ResourceRequirement extends EObject { + /** + * Returns the value of the 'Required Memory' attribute. + * + *

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

+ * + * @return the value of the 'Required Memory' attribute. + * @see #setRequiredMemory(int) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getResourceRequirement_RequiredMemory() + * @model required="true" + * @generated + */ + int getRequiredMemory(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredMemory Required Memory}' attribute. + * + * + * @param value the new value of the 'Required Memory' attribute. + * @see #getRequiredMemory() + * @generated + */ + void setRequiredMemory(int value); + + /** + * Returns the value of the 'Required Hdd' attribute. + * + *

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

+ * + * @return the value of the 'Required Hdd' attribute. + * @see #setRequiredHdd(int) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getResourceRequirement_RequiredHdd() + * @model required="true" + * @generated + */ + int getRequiredHdd(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getRequiredHdd Required Hdd}' attribute. + * + * + * @param value the new value of the 'Required Hdd' attribute. + * @see #getRequiredHdd() + * @generated + */ + void setRequiredHdd(int value); + + /** + * Returns the value of the 'Host Type' reference. + * + *

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

+ * + * @return the value of the 'Host Type' reference. + * @see #setHostType(HostType) + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getResourceRequirement_HostType() + * @model required="true" + * @generated + */ + HostType getHostType(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement#getHostType Host Type}' reference. + * + * + * @param value the new value of the 'Host Type' reference. + * @see #getHostType() + * @generated + */ + void setHostType(HostType value); + +} // ResourceRequirement diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationInstanceImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationInstanceImpl.java new file mode 100644 index 00000000..cea2d6f4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationInstanceImpl.java @@ -0,0 +1,405 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EcoreUtil; + +/** + * + * An implementation of the model object 'Application Instance'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl#getRequirement Requirement}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl#getType Type}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationInstanceImpl#getAllocatedTo Allocated To}
  • + *
+ * + * @generated + */ +public class ApplicationInstanceImpl extends MinimalEObjectImpl.Container implements ApplicationInstance { + /** + * The cached value of the '{@link #getRequirement() Requirement}' reference. + * + * + * @see #getRequirement() + * @generated + * @ordered + */ + protected Requirement requirement; + + /** + * The cached value of the '{@link #getAllocatedTo() Allocated To}' reference. + * + * + * @see #getAllocatedTo() + * @generated + * @ordered + */ + protected HostInstance allocatedTo; + + /** + * + * + * @generated + */ + protected ApplicationInstanceImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.APPLICATION_INSTANCE; + } + + /** + * + * + * @generated + */ + @Override + public Requirement getRequirement() { + if (requirement != null && requirement.eIsProxy()) { + InternalEObject oldRequirement = (InternalEObject) requirement; + requirement = (Requirement) eResolveProxy(oldRequirement); + if (requirement != oldRequirement) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, + CpsPackage.APPLICATION_INSTANCE__REQUIREMENT, oldRequirement, requirement)); + } + } + return requirement; + } + + /** + * + * + * @generated + */ + public Requirement basicGetRequirement() { + return requirement; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetRequirement(Requirement newRequirement, NotificationChain msgs) { + Requirement oldRequirement = requirement; + requirement = newRequirement; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, + CpsPackage.APPLICATION_INSTANCE__REQUIREMENT, oldRequirement, newRequirement); + if (msgs == null) + msgs = notification; + else + msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setRequirement(Requirement newRequirement) { + if (newRequirement != requirement) { + NotificationChain msgs = null; + if (requirement != null) + msgs = ((InternalEObject) requirement).eInverseRemove(this, CpsPackage.REQUIREMENT__INSTANCES, + Requirement.class, msgs); + if (newRequirement != null) + msgs = ((InternalEObject) newRequirement).eInverseAdd(this, CpsPackage.REQUIREMENT__INSTANCES, + Requirement.class, msgs); + msgs = basicSetRequirement(newRequirement, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.APPLICATION_INSTANCE__REQUIREMENT, + newRequirement, newRequirement)); + } + + /** + * + * + * @generated + */ + @Override + public ApplicationType getType() { + if (eContainerFeatureID() != CpsPackage.APPLICATION_INSTANCE__TYPE) + return null; + return (ApplicationType) eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetType(ApplicationType newType, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject) newType, CpsPackage.APPLICATION_INSTANCE__TYPE, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setType(ApplicationType newType) { + if (newType != eInternalContainer() + || (eContainerFeatureID() != CpsPackage.APPLICATION_INSTANCE__TYPE && newType != null)) { + if (EcoreUtil.isAncestor(this, newType)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newType != null) + msgs = ((InternalEObject) newType).eInverseAdd(this, CpsPackage.APPLICATION_TYPE__INSTANCES, + ApplicationType.class, msgs); + msgs = basicSetType(newType, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.APPLICATION_INSTANCE__TYPE, newType, + newType)); + } + + /** + * + * + * @generated + */ + @Override + public HostInstance getAllocatedTo() { + if (allocatedTo != null && allocatedTo.eIsProxy()) { + InternalEObject oldAllocatedTo = (InternalEObject) allocatedTo; + allocatedTo = (HostInstance) eResolveProxy(oldAllocatedTo); + if (allocatedTo != oldAllocatedTo) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, + CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO, oldAllocatedTo, allocatedTo)); + } + } + return allocatedTo; + } + + /** + * + * + * @generated + */ + public HostInstance basicGetAllocatedTo() { + return allocatedTo; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetAllocatedTo(HostInstance newAllocatedTo, NotificationChain msgs) { + HostInstance oldAllocatedTo = allocatedTo; + allocatedTo = newAllocatedTo; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, + CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO, oldAllocatedTo, newAllocatedTo); + if (msgs == null) + msgs = notification; + else + msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setAllocatedTo(HostInstance newAllocatedTo) { + if (newAllocatedTo != allocatedTo) { + NotificationChain msgs = null; + if (allocatedTo != null) + msgs = ((InternalEObject) allocatedTo).eInverseRemove(this, CpsPackage.HOST_INSTANCE__APPLICATIONS, + HostInstance.class, msgs); + if (newAllocatedTo != null) + msgs = ((InternalEObject) newAllocatedTo).eInverseAdd(this, CpsPackage.HOST_INSTANCE__APPLICATIONS, + HostInstance.class, msgs); + msgs = basicSetAllocatedTo(newAllocatedTo, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO, + newAllocatedTo, newAllocatedTo)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: + if (requirement != null) + msgs = ((InternalEObject) requirement).eInverseRemove(this, CpsPackage.REQUIREMENT__INSTANCES, + Requirement.class, msgs); + return basicSetRequirement((Requirement) otherEnd, msgs); + case CpsPackage.APPLICATION_INSTANCE__TYPE: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetType((ApplicationType) otherEnd, msgs); + case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: + if (allocatedTo != null) + msgs = ((InternalEObject) allocatedTo).eInverseRemove(this, CpsPackage.HOST_INSTANCE__APPLICATIONS, + HostInstance.class, msgs); + return basicSetAllocatedTo((HostInstance) otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: + return basicSetRequirement(null, msgs); + case CpsPackage.APPLICATION_INSTANCE__TYPE: + return basicSetType(null, msgs); + case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: + return basicSetAllocatedTo(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case CpsPackage.APPLICATION_INSTANCE__TYPE: + return eInternalContainer().eInverseRemove(this, CpsPackage.APPLICATION_TYPE__INSTANCES, + ApplicationType.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: + if (resolve) + return getRequirement(); + return basicGetRequirement(); + case CpsPackage.APPLICATION_INSTANCE__TYPE: + return getType(); + case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: + if (resolve) + return getAllocatedTo(); + return basicGetAllocatedTo(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: + setRequirement((Requirement) newValue); + return; + case CpsPackage.APPLICATION_INSTANCE__TYPE: + setType((ApplicationType) newValue); + return; + case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: + setAllocatedTo((HostInstance) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: + setRequirement((Requirement) null); + return; + case CpsPackage.APPLICATION_INSTANCE__TYPE: + setType((ApplicationType) null); + return; + case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: + setAllocatedTo((HostInstance) null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.APPLICATION_INSTANCE__REQUIREMENT: + return requirement != null; + case CpsPackage.APPLICATION_INSTANCE__TYPE: + return getType() != null; + case CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO: + return allocatedTo != null; + } + return super.eIsSet(featureID); + } + +} //ApplicationInstanceImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationTypeImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationTypeImpl.java new file mode 100644 index 00000000..f8793e30 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ApplicationTypeImpl.java @@ -0,0 +1,209 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Application Type'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl#getInstances Instances}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl#getRequirements Requirements}
  • + *
+ * + * @generated + */ +public class ApplicationTypeImpl extends MinimalEObjectImpl.Container implements ApplicationType { + /** + * The cached value of the '{@link #getInstances() Instances}' containment reference list. + * + * + * @see #getInstances() + * @generated + * @ordered + */ + protected EList instances; + + /** + * The cached value of the '{@link #getRequirements() Requirements}' containment reference list. + * + * + * @see #getRequirements() + * @generated + * @ordered + */ + protected EList requirements; + + /** + * + * + * @generated + */ + protected ApplicationTypeImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.APPLICATION_TYPE; + } + + /** + * + * + * @generated + */ + @Override + public EList getInstances() { + if (instances == null) { + instances = new EObjectContainmentWithInverseEList(ApplicationInstance.class, this, + CpsPackage.APPLICATION_TYPE__INSTANCES, CpsPackage.APPLICATION_INSTANCE__TYPE); + } + return instances; + } + + /** + * + * + * @generated + */ + @Override + public EList getRequirements() { + if (requirements == null) { + requirements = new EObjectContainmentEList(ResourceRequirement.class, this, + CpsPackage.APPLICATION_TYPE__REQUIREMENTS); + } + return requirements; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.APPLICATION_TYPE__INSTANCES: + return ((InternalEList) (InternalEList) getInstances()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.APPLICATION_TYPE__INSTANCES: + return ((InternalEList) getInstances()).basicRemove(otherEnd, msgs); + case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: + return ((InternalEList) getRequirements()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.APPLICATION_TYPE__INSTANCES: + return getInstances(); + case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: + return getRequirements(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.APPLICATION_TYPE__INSTANCES: + getInstances().clear(); + getInstances().addAll((Collection) newValue); + return; + case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: + getRequirements().clear(); + getRequirements().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.APPLICATION_TYPE__INSTANCES: + getInstances().clear(); + return; + case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: + getRequirements().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.APPLICATION_TYPE__INSTANCES: + return instances != null && !instances.isEmpty(); + case CpsPackage.APPLICATION_TYPE__REQUIREMENTS: + return requirements != null && !requirements.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //ApplicationTypeImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsFactoryImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsFactoryImpl.java new file mode 100644 index 00000000..110f5abb --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsFactoryImpl.java @@ -0,0 +1,188 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.*; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class CpsFactoryImpl extends EFactoryImpl implements CpsFactory { + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static CpsFactory init() { + try { + CpsFactory theCpsFactory = (CpsFactory) EPackage.Registry.INSTANCE.getEFactory(CpsPackage.eNS_URI); + if (theCpsFactory != null) { + return theCpsFactory; + } + } catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new CpsFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public CpsFactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM: + return createCyberPhysicalSystem(); + case CpsPackage.APPLICATION_TYPE: + return createApplicationType(); + case CpsPackage.HOST_TYPE: + return createHostType(); + case CpsPackage.REQUEST: + return createRequest(); + case CpsPackage.REQUIREMENT: + return createRequirement(); + case CpsPackage.APPLICATION_INSTANCE: + return createApplicationInstance(); + case CpsPackage.RESOURCE_REQUIREMENT: + return createResourceRequirement(); + case CpsPackage.HOST_INSTANCE: + return createHostInstance(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + @Override + public CyberPhysicalSystem createCyberPhysicalSystem() { + CyberPhysicalSystemImpl cyberPhysicalSystem = new CyberPhysicalSystemImpl(); + return cyberPhysicalSystem; + } + + /** + * + * + * @generated + */ + @Override + public ApplicationType createApplicationType() { + ApplicationTypeImpl applicationType = new ApplicationTypeImpl(); + return applicationType; + } + + /** + * + * + * @generated + */ + @Override + public HostType createHostType() { + HostTypeImpl hostType = new HostTypeImpl(); + return hostType; + } + + /** + * + * + * @generated + */ + @Override + public Request createRequest() { + RequestImpl request = new RequestImpl(); + return request; + } + + /** + * + * + * @generated + */ + @Override + public Requirement createRequirement() { + RequirementImpl requirement = new RequirementImpl(); + return requirement; + } + + /** + * + * + * @generated + */ + @Override + public ApplicationInstance createApplicationInstance() { + ApplicationInstanceImpl applicationInstance = new ApplicationInstanceImpl(); + return applicationInstance; + } + + /** + * + * + * @generated + */ + @Override + public ResourceRequirement createResourceRequirement() { + ResourceRequirementImpl resourceRequirement = new ResourceRequirementImpl(); + return resourceRequirement; + } + + /** + * + * + * @generated + */ + @Override + public HostInstance createHostInstance() { + HostInstanceImpl hostInstance = new HostInstanceImpl(); + return hostInstance; + } + + /** + * + * + * @generated + */ + @Override + public CpsPackage getCpsPackage() { + return (CpsPackage) getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static CpsPackage getPackage() { + return CpsPackage.eINSTANCE; + } + +} //CpsFactoryImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java new file mode 100644 index 00000000..1f143a64 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java @@ -0,0 +1,765 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; +import hu.bme.mit.inf.dslreasoner.domains.cps.Request; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class CpsPackageImpl extends EPackageImpl implements CpsPackage { + /** + * + * + * @generated + */ + private EClass cyberPhysicalSystemEClass = null; + + /** + * + * + * @generated + */ + private EClass applicationTypeEClass = null; + + /** + * + * + * @generated + */ + private EClass hostTypeEClass = null; + + /** + * + * + * @generated + */ + private EClass requestEClass = null; + + /** + * + * + * @generated + */ + private EClass requirementEClass = null; + + /** + * + * + * @generated + */ + private EClass applicationInstanceEClass = null; + + /** + * + * + * @generated + */ + private EClass resourceRequirementEClass = null; + + /** + * + * + * @generated + */ + private EClass hostInstanceEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#eNS_URI + * @see #init() + * @generated + */ + private CpsPackageImpl() { + super(eNS_URI, CpsFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link CpsPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static CpsPackage init() { + if (isInited) + return (CpsPackage) EPackage.Registry.INSTANCE.getEPackage(CpsPackage.eNS_URI); + + // Obtain or create and register package + Object registeredCpsPackage = EPackage.Registry.INSTANCE.get(eNS_URI); + CpsPackageImpl theCpsPackage = registeredCpsPackage instanceof CpsPackageImpl + ? (CpsPackageImpl) registeredCpsPackage + : new CpsPackageImpl(); + + isInited = true; + + // Create package meta-data objects + theCpsPackage.createPackageContents(); + + // Initialize created meta-data + theCpsPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theCpsPackage.freeze(); + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, theCpsPackage); + return theCpsPackage; + } + + /** + * + * + * @generated + */ + @Override + public EClass getCyberPhysicalSystem() { + return cyberPhysicalSystemEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getCyberPhysicalSystem_Requests() { + return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EReference getCyberPhysicalSystem_ApplicationTypes() { + return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EReference getCyberPhysicalSystem_HostTypes() { + return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EReference getCyberPhysicalSystem_Hosts() { + return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + @Override + public EReference getCyberPhysicalSystem_Applications() { + return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + @Override + public EClass getApplicationType() { + return applicationTypeEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getApplicationType_Instances() { + return (EReference) applicationTypeEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EReference getApplicationType_Requirements() { + return (EReference) applicationTypeEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EClass getHostType() { + return hostTypeEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostType_DefaultMemory() { + return (EAttribute) hostTypeEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostType_DefaultHdd() { + return (EAttribute) hostTypeEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EReference getHostType_Instances() { + return (EReference) hostTypeEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostType_Cost() { + return (EAttribute) hostTypeEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + @Override + public EClass getRequest() { + return requestEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getRequest_Requirements() { + return (EReference) requestEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EClass getRequirement() { + return requirementEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getRequirement_Request() { + return (EReference) requirementEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getRequirement_Count() { + return (EAttribute) requirementEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EReference getRequirement_Type() { + return (EReference) requirementEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EReference getRequirement_Instances() { + return (EReference) requirementEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + @Override + public EClass getApplicationInstance() { + return applicationInstanceEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getApplicationInstance_Requirement() { + return (EReference) applicationInstanceEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EReference getApplicationInstance_Type() { + return (EReference) applicationInstanceEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EReference getApplicationInstance_AllocatedTo() { + return (EReference) applicationInstanceEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EClass getResourceRequirement() { + return resourceRequirementEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getResourceRequirement_RequiredMemory() { + return (EAttribute) resourceRequirementEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getResourceRequirement_RequiredHdd() { + return (EAttribute) resourceRequirementEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EReference getResourceRequirement_HostType() { + return (EReference) resourceRequirementEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EClass getHostInstance() { + return hostInstanceEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getHostInstance_Type() { + return (EReference) hostInstanceEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostInstance_AvailableMemory() { + return (EAttribute) hostInstanceEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostInstance_AvailableHdd() { + return (EAttribute) hostInstanceEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostInstance_TotalMemory() { + return (EAttribute) hostInstanceEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getHostInstance_TotalHdd() { + return (EAttribute) hostInstanceEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + @Override + public EReference getHostInstance_Applications() { + return (EReference) hostInstanceEClass.getEStructuralFeatures().get(5); + } + + /** + * + * + * @generated + */ + @Override + public CpsFactory getCpsFactory() { + return (CpsFactory) getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if (isCreated) + return; + isCreated = true; + + // Create classes and their features + cyberPhysicalSystemEClass = createEClass(CYBER_PHYSICAL_SYSTEM); + createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__REQUESTS); + createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES); + createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__HOST_TYPES); + createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__HOSTS); + createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__APPLICATIONS); + + applicationTypeEClass = createEClass(APPLICATION_TYPE); + createEReference(applicationTypeEClass, APPLICATION_TYPE__INSTANCES); + createEReference(applicationTypeEClass, APPLICATION_TYPE__REQUIREMENTS); + + hostTypeEClass = createEClass(HOST_TYPE); + createEAttribute(hostTypeEClass, HOST_TYPE__DEFAULT_MEMORY); + createEAttribute(hostTypeEClass, HOST_TYPE__DEFAULT_HDD); + createEReference(hostTypeEClass, HOST_TYPE__INSTANCES); + createEAttribute(hostTypeEClass, HOST_TYPE__COST); + + requestEClass = createEClass(REQUEST); + createEReference(requestEClass, REQUEST__REQUIREMENTS); + + requirementEClass = createEClass(REQUIREMENT); + createEReference(requirementEClass, REQUIREMENT__REQUEST); + createEAttribute(requirementEClass, REQUIREMENT__COUNT); + createEReference(requirementEClass, REQUIREMENT__TYPE); + createEReference(requirementEClass, REQUIREMENT__INSTANCES); + + applicationInstanceEClass = createEClass(APPLICATION_INSTANCE); + createEReference(applicationInstanceEClass, APPLICATION_INSTANCE__REQUIREMENT); + createEReference(applicationInstanceEClass, APPLICATION_INSTANCE__TYPE); + createEReference(applicationInstanceEClass, APPLICATION_INSTANCE__ALLOCATED_TO); + + resourceRequirementEClass = createEClass(RESOURCE_REQUIREMENT); + createEAttribute(resourceRequirementEClass, RESOURCE_REQUIREMENT__REQUIRED_MEMORY); + createEAttribute(resourceRequirementEClass, RESOURCE_REQUIREMENT__REQUIRED_HDD); + createEReference(resourceRequirementEClass, RESOURCE_REQUIREMENT__HOST_TYPE); + + hostInstanceEClass = createEClass(HOST_INSTANCE); + createEReference(hostInstanceEClass, HOST_INSTANCE__TYPE); + createEAttribute(hostInstanceEClass, HOST_INSTANCE__AVAILABLE_MEMORY); + createEAttribute(hostInstanceEClass, HOST_INSTANCE__AVAILABLE_HDD); + createEAttribute(hostInstanceEClass, HOST_INSTANCE__TOTAL_MEMORY); + createEAttribute(hostInstanceEClass, HOST_INSTANCE__TOTAL_HDD); + createEReference(hostInstanceEClass, HOST_INSTANCE__APPLICATIONS); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() { + if (isInitialized) + return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes, features, and operations; add parameters + initEClass(cyberPhysicalSystemEClass, CyberPhysicalSystem.class, "CyberPhysicalSystem", !IS_ABSTRACT, + !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getCyberPhysicalSystem_Requests(), this.getRequest(), null, "requests", null, 0, -1, + CyberPhysicalSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getCyberPhysicalSystem_ApplicationTypes(), this.getApplicationType(), null, "applicationTypes", + null, 0, -1, CyberPhysicalSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getCyberPhysicalSystem_HostTypes(), this.getHostType(), null, "hostTypes", null, 0, -1, + CyberPhysicalSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getCyberPhysicalSystem_Hosts(), this.getHostInstance(), null, "hosts", null, 0, -1, + CyberPhysicalSystem.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, + !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEReference(getCyberPhysicalSystem_Applications(), this.getApplicationInstance(), null, "applications", null, + 0, -1, CyberPhysicalSystem.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, + IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + + initEClass(applicationTypeEClass, ApplicationType.class, "ApplicationType", !IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + initEReference(getApplicationType_Instances(), this.getApplicationInstance(), + this.getApplicationInstance_Type(), "instances", null, 0, -1, ApplicationType.class, !IS_TRANSIENT, + !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, + IS_ORDERED); + initEReference(getApplicationType_Requirements(), this.getResourceRequirement(), null, "requirements", null, 0, + -1, ApplicationType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(hostTypeEClass, HostType.class, "HostType", !IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getHostType_DefaultMemory(), ecorePackage.getEInt(), "defaultMemory", null, 1, 1, HostType.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getHostType_DefaultHdd(), ecorePackage.getEInt(), "defaultHdd", null, 1, 1, HostType.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getHostType_Instances(), this.getHostInstance(), this.getHostInstance_Type(), "instances", null, + 0, -1, HostType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, + !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getHostType_Cost(), ecorePackage.getEInt(), "cost", null, 1, 1, HostType.class, !IS_TRANSIENT, + !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(requestEClass, Request.class, "Request", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getRequest_Requirements(), this.getRequirement(), this.getRequirement_Request(), "requirements", + null, 0, -1, Request.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, + !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(requirementEClass, Requirement.class, "Requirement", !IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + initEReference(getRequirement_Request(), this.getRequest(), this.getRequest_Requirements(), "request", null, 1, + 1, Requirement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, + !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getRequirement_Count(), ecorePackage.getEInt(), "count", null, 1, 1, Requirement.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getRequirement_Type(), this.getApplicationType(), null, "type", null, 0, 1, Requirement.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getRequirement_Instances(), this.getApplicationInstance(), + this.getApplicationInstance_Requirement(), "instances", null, 0, -1, Requirement.class, !IS_TRANSIENT, + !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, + IS_ORDERED); + + initEClass(applicationInstanceEClass, ApplicationInstance.class, "ApplicationInstance", !IS_ABSTRACT, + !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getApplicationInstance_Requirement(), this.getRequirement(), this.getRequirement_Instances(), + "requirement", null, 0, 1, ApplicationInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, + !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getApplicationInstance_Type(), this.getApplicationType(), this.getApplicationType_Instances(), + "type", null, 1, 1, ApplicationInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, + !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getApplicationInstance_AllocatedTo(), this.getHostInstance(), + this.getHostInstance_Applications(), "allocatedTo", null, 1, 1, ApplicationInstance.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(resourceRequirementEClass, ResourceRequirement.class, "ResourceRequirement", !IS_ABSTRACT, + !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getResourceRequirement_RequiredMemory(), ecorePackage.getEInt(), "requiredMemory", null, 1, 1, + ResourceRequirement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getResourceRequirement_RequiredHdd(), ecorePackage.getEInt(), "requiredHdd", null, 1, 1, + ResourceRequirement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getResourceRequirement_HostType(), this.getHostType(), null, "hostType", null, 1, 1, + ResourceRequirement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, + IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(hostInstanceEClass, HostInstance.class, "HostInstance", !IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + initEReference(getHostInstance_Type(), this.getHostType(), this.getHostType_Instances(), "type", null, 1, 1, + HostInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, + !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getHostInstance_AvailableMemory(), ecorePackage.getEInt(), "availableMemory", null, 0, 1, + HostInstance.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, + IS_DERIVED, IS_ORDERED); + initEAttribute(getHostInstance_AvailableHdd(), ecorePackage.getEInt(), "availableHdd", null, 0, 1, + HostInstance.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, + IS_DERIVED, IS_ORDERED); + initEAttribute(getHostInstance_TotalMemory(), ecorePackage.getEInt(), "totalMemory", null, 0, 1, + HostInstance.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, + IS_DERIVED, IS_ORDERED); + initEAttribute(getHostInstance_TotalHdd(), ecorePackage.getEInt(), "totalHdd", null, 0, 1, HostInstance.class, + IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEReference(getHostInstance_Applications(), this.getApplicationInstance(), + this.getApplicationInstance_AllocatedTo(), "applications", null, 0, -1, HostInstance.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + + // Create annotations + // http://www.eclipse.org/emf/2002/Ecore + createEcoreAnnotations(); + // org.eclipse.viatra.query.querybasedfeature + createOrgAnnotations(); + } + + /** + * Initializes the annotations for http://www.eclipse.org/emf/2002/Ecore. + * + * + * @generated + */ + protected void createEcoreAnnotations() { + String source = "http://www.eclipse.org/emf/2002/Ecore"; + addAnnotation(this, source, new String[] { "settingDelegates", "org.eclipse.viatra.query.querybasedfeature" }); + } + + /** + * Initializes the annotations for org.eclipse.viatra.query.querybasedfeature. + * + * + * @generated + */ + protected void createOrgAnnotations() { + String source = "org.eclipse.viatra.query.querybasedfeature"; + addAnnotation(getCyberPhysicalSystem_Hosts(), source, + new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts" }); + addAnnotation(getCyberPhysicalSystem_Applications(), source, + new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications" }); + addAnnotation(getHostInstance_AvailableMemory(), source, + new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory" }); + addAnnotation(getHostInstance_AvailableHdd(), source, + new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd" }); + addAnnotation(getHostInstance_TotalMemory(), source, + new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory" }); + addAnnotation(getHostInstance_TotalHdd(), source, + new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd" }); + } + +} //CpsPackageImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java new file mode 100644 index 00000000..4d254f25 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java @@ -0,0 +1,289 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; +import hu.bme.mit.inf.dslreasoner.domains.cps.Request; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Cyber Physical System'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getRequests Requests}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getApplicationTypes Application Types}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getHostTypes Host Types}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getHosts Hosts}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getApplications Applications}
  • + *
+ * + * @generated + */ +public class CyberPhysicalSystemImpl extends MinimalEObjectImpl.Container implements CyberPhysicalSystem { + /** + * The cached value of the '{@link #getRequests() Requests}' containment reference list. + * + * + * @see #getRequests() + * @generated + * @ordered + */ + protected EList requests; + + /** + * The cached value of the '{@link #getApplicationTypes() Application Types}' containment reference list. + * + * + * @see #getApplicationTypes() + * @generated + * @ordered + */ + protected EList applicationTypes; + + /** + * The cached value of the '{@link #getHostTypes() Host Types}' containment reference list. + * + * + * @see #getHostTypes() + * @generated + * @ordered + */ + protected EList hostTypes; + + /** + * The cached setting delegate for the '{@link #getHosts() Hosts}' reference list. + * + * + * @see #getHosts() + * @generated + * @ordered + */ + protected EStructuralFeature.Internal.SettingDelegate HOSTS__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.CYBER_PHYSICAL_SYSTEM__HOSTS) + .getSettingDelegate(); + + /** + * The cached setting delegate for the '{@link #getApplications() Applications}' reference list. + * + * + * @see #getApplications() + * @generated + * @ordered + */ + protected EStructuralFeature.Internal.SettingDelegate APPLICATIONS__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.CYBER_PHYSICAL_SYSTEM__APPLICATIONS) + .getSettingDelegate(); + + /** + * + * + * @generated + */ + protected CyberPhysicalSystemImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.CYBER_PHYSICAL_SYSTEM; + } + + /** + * + * + * @generated + */ + @Override + public EList getRequests() { + if (requests == null) { + requests = new EObjectContainmentEList(Request.class, this, + CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS); + } + return requests; + } + + /** + * + * + * @generated + */ + @Override + public EList getApplicationTypes() { + if (applicationTypes == null) { + applicationTypes = new EObjectContainmentEList(ApplicationType.class, this, + CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES); + } + return applicationTypes; + } + + /** + * + * + * @generated + */ + @Override + public EList getHostTypes() { + if (hostTypes == null) { + hostTypes = new EObjectContainmentEList(HostType.class, this, + CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES); + } + return hostTypes; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public EList getHosts() { + return (EList) HOSTS__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public EList getApplications() { + return (EList) APPLICATIONS__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: + return ((InternalEList) getRequests()).basicRemove(otherEnd, msgs); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: + return ((InternalEList) getApplicationTypes()).basicRemove(otherEnd, msgs); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: + return ((InternalEList) getHostTypes()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: + return getRequests(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: + return getApplicationTypes(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: + return getHostTypes(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOSTS: + return getHosts(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATIONS: + return getApplications(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: + getRequests().clear(); + getRequests().addAll((Collection) newValue); + return; + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: + getApplicationTypes().clear(); + getApplicationTypes().addAll((Collection) newValue); + return; + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: + getHostTypes().clear(); + getHostTypes().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: + getRequests().clear(); + return; + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: + getApplicationTypes().clear(); + return; + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: + getHostTypes().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM__REQUESTS: + return requests != null && !requests.isEmpty(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES: + return applicationTypes != null && !applicationTypes.isEmpty(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: + return hostTypes != null && !hostTypes.isEmpty(); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOSTS: + return HOSTS__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); + case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATIONS: + return APPLICATIONS__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); + } + return super.eIsSet(featureID); + } + +} //CyberPhysicalSystemImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java new file mode 100644 index 00000000..bbaca59c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java @@ -0,0 +1,355 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Host Instance'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getType Type}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getAvailableMemory Available Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getAvailableHdd Available Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getTotalMemory Total Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getTotalHdd Total Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getApplications Applications}
  • + *
+ * + * @generated + */ +public class HostInstanceImpl extends MinimalEObjectImpl.Container implements HostInstance { + /** + * The cached setting delegate for the '{@link #getAvailableMemory() Available Memory}' attribute. + * + * + * @see #getAvailableMemory() + * @generated + * @ordered + */ + protected EStructuralFeature.Internal.SettingDelegate AVAILABLE_MEMORY__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.HOST_INSTANCE__AVAILABLE_MEMORY) + .getSettingDelegate(); + + /** + * The cached setting delegate for the '{@link #getAvailableHdd() Available Hdd}' attribute. + * + * + * @see #getAvailableHdd() + * @generated + * @ordered + */ + protected EStructuralFeature.Internal.SettingDelegate AVAILABLE_HDD__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.HOST_INSTANCE__AVAILABLE_HDD) + .getSettingDelegate(); + + /** + * The cached setting delegate for the '{@link #getTotalMemory() Total Memory}' attribute. + * + * + * @see #getTotalMemory() + * @generated + * @ordered + */ + protected EStructuralFeature.Internal.SettingDelegate TOTAL_MEMORY__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.HOST_INSTANCE__TOTAL_MEMORY) + .getSettingDelegate(); + + /** + * The cached setting delegate for the '{@link #getTotalHdd() Total Hdd}' attribute. + * + * + * @see #getTotalHdd() + * @generated + * @ordered + */ + protected EStructuralFeature.Internal.SettingDelegate TOTAL_HDD__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.HOST_INSTANCE__TOTAL_HDD) + .getSettingDelegate(); + + /** + * The cached value of the '{@link #getApplications() Applications}' reference list. + * + * + * @see #getApplications() + * @generated + * @ordered + */ + protected EList applications; + + /** + * + * + * @generated + */ + protected HostInstanceImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.HOST_INSTANCE; + } + + /** + * + * + * @generated + */ + @Override + public HostType getType() { + if (eContainerFeatureID() != CpsPackage.HOST_INSTANCE__TYPE) + return null; + return (HostType) eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetType(HostType newType, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject) newType, CpsPackage.HOST_INSTANCE__TYPE, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setType(HostType newType) { + if (newType != eInternalContainer() + || (eContainerFeatureID() != CpsPackage.HOST_INSTANCE__TYPE && newType != null)) { + if (EcoreUtil.isAncestor(this, newType)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newType != null) + msgs = ((InternalEObject) newType).eInverseAdd(this, CpsPackage.HOST_TYPE__INSTANCES, HostType.class, + msgs); + msgs = basicSetType(newType, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_INSTANCE__TYPE, newType, newType)); + } + + /** + * + * + * @generated + */ + @Override + public int getAvailableMemory() { + return (Integer) AVAILABLE_MEMORY__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); + } + + /** + * + * + * @generated + */ + @Override + public int getAvailableHdd() { + return (Integer) AVAILABLE_HDD__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); + } + + /** + * + * + * @generated + */ + @Override + public int getTotalMemory() { + return (Integer) TOTAL_MEMORY__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); + } + + /** + * + * + * @generated + */ + @Override + public int getTotalHdd() { + return (Integer) TOTAL_HDD__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); + } + + /** + * + * + * @generated + */ + @Override + public EList getApplications() { + if (applications == null) { + applications = new EObjectWithInverseResolvingEList(ApplicationInstance.class, this, + CpsPackage.HOST_INSTANCE__APPLICATIONS, CpsPackage.APPLICATION_INSTANCE__ALLOCATED_TO); + } + return applications; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.HOST_INSTANCE__TYPE: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetType((HostType) otherEnd, msgs); + case CpsPackage.HOST_INSTANCE__APPLICATIONS: + return ((InternalEList) (InternalEList) getApplications()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.HOST_INSTANCE__TYPE: + return basicSetType(null, msgs); + case CpsPackage.HOST_INSTANCE__APPLICATIONS: + return ((InternalEList) getApplications()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case CpsPackage.HOST_INSTANCE__TYPE: + return eInternalContainer().eInverseRemove(this, CpsPackage.HOST_TYPE__INSTANCES, HostType.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.HOST_INSTANCE__TYPE: + return getType(); + case CpsPackage.HOST_INSTANCE__AVAILABLE_MEMORY: + return getAvailableMemory(); + case CpsPackage.HOST_INSTANCE__AVAILABLE_HDD: + return getAvailableHdd(); + case CpsPackage.HOST_INSTANCE__TOTAL_MEMORY: + return getTotalMemory(); + case CpsPackage.HOST_INSTANCE__TOTAL_HDD: + return getTotalHdd(); + case CpsPackage.HOST_INSTANCE__APPLICATIONS: + return getApplications(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.HOST_INSTANCE__TYPE: + setType((HostType) newValue); + return; + case CpsPackage.HOST_INSTANCE__APPLICATIONS: + getApplications().clear(); + getApplications().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.HOST_INSTANCE__TYPE: + setType((HostType) null); + return; + case CpsPackage.HOST_INSTANCE__APPLICATIONS: + getApplications().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.HOST_INSTANCE__TYPE: + return getType() != null; + case CpsPackage.HOST_INSTANCE__AVAILABLE_MEMORY: + return AVAILABLE_MEMORY__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); + case CpsPackage.HOST_INSTANCE__AVAILABLE_HDD: + return AVAILABLE_HDD__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); + case CpsPackage.HOST_INSTANCE__TOTAL_MEMORY: + return TOTAL_MEMORY__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); + case CpsPackage.HOST_INSTANCE__TOTAL_HDD: + return TOTAL_HDD__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); + case CpsPackage.HOST_INSTANCE__APPLICATIONS: + return applications != null && !applications.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //HostInstanceImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostTypeImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostTypeImpl.java new file mode 100644 index 00000000..c3d5b3dc --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostTypeImpl.java @@ -0,0 +1,356 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Host Type'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl#getDefaultMemory Default Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl#getDefaultHdd Default Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl#getInstances Instances}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostTypeImpl#getCost Cost}
  • + *
+ * + * @generated + */ +public class HostTypeImpl extends MinimalEObjectImpl.Container implements HostType { + /** + * The default value of the '{@link #getDefaultMemory() Default Memory}' attribute. + * + * + * @see #getDefaultMemory() + * @generated + * @ordered + */ + protected static final int DEFAULT_MEMORY_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getDefaultMemory() Default Memory}' attribute. + * + * + * @see #getDefaultMemory() + * @generated + * @ordered + */ + protected int defaultMemory = DEFAULT_MEMORY_EDEFAULT; + + /** + * The default value of the '{@link #getDefaultHdd() Default Hdd}' attribute. + * + * + * @see #getDefaultHdd() + * @generated + * @ordered + */ + protected static final int DEFAULT_HDD_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getDefaultHdd() Default Hdd}' attribute. + * + * + * @see #getDefaultHdd() + * @generated + * @ordered + */ + protected int defaultHdd = DEFAULT_HDD_EDEFAULT; + + /** + * The cached value of the '{@link #getInstances() Instances}' containment reference list. + * + * + * @see #getInstances() + * @generated + * @ordered + */ + protected EList instances; + + /** + * The default value of the '{@link #getCost() Cost}' attribute. + * + * + * @see #getCost() + * @generated + * @ordered + */ + protected static final int COST_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getCost() Cost}' attribute. + * + * + * @see #getCost() + * @generated + * @ordered + */ + protected int cost = COST_EDEFAULT; + + /** + * + * + * @generated + */ + protected HostTypeImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.HOST_TYPE; + } + + /** + * + * + * @generated + */ + @Override + public int getDefaultMemory() { + return defaultMemory; + } + + /** + * + * + * @generated + */ + @Override + public void setDefaultMemory(int newDefaultMemory) { + int oldDefaultMemory = defaultMemory; + defaultMemory = newDefaultMemory; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_TYPE__DEFAULT_MEMORY, + oldDefaultMemory, defaultMemory)); + } + + /** + * + * + * @generated + */ + @Override + public int getDefaultHdd() { + return defaultHdd; + } + + /** + * + * + * @generated + */ + @Override + public void setDefaultHdd(int newDefaultHdd) { + int oldDefaultHdd = defaultHdd; + defaultHdd = newDefaultHdd; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_TYPE__DEFAULT_HDD, oldDefaultHdd, + defaultHdd)); + } + + /** + * + * + * @generated + */ + @Override + public EList getInstances() { + if (instances == null) { + instances = new EObjectContainmentWithInverseEList(HostInstance.class, this, + CpsPackage.HOST_TYPE__INSTANCES, CpsPackage.HOST_INSTANCE__TYPE); + } + return instances; + } + + /** + * + * + * @generated + */ + @Override + public int getCost() { + return cost; + } + + /** + * + * + * @generated + */ + @Override + public void setCost(int newCost) { + int oldCost = cost; + cost = newCost; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_TYPE__COST, oldCost, cost)); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.HOST_TYPE__INSTANCES: + return ((InternalEList) (InternalEList) getInstances()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.HOST_TYPE__INSTANCES: + return ((InternalEList) getInstances()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.HOST_TYPE__DEFAULT_MEMORY: + return getDefaultMemory(); + case CpsPackage.HOST_TYPE__DEFAULT_HDD: + return getDefaultHdd(); + case CpsPackage.HOST_TYPE__INSTANCES: + return getInstances(); + case CpsPackage.HOST_TYPE__COST: + return getCost(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.HOST_TYPE__DEFAULT_MEMORY: + setDefaultMemory((Integer) newValue); + return; + case CpsPackage.HOST_TYPE__DEFAULT_HDD: + setDefaultHdd((Integer) newValue); + return; + case CpsPackage.HOST_TYPE__INSTANCES: + getInstances().clear(); + getInstances().addAll((Collection) newValue); + return; + case CpsPackage.HOST_TYPE__COST: + setCost((Integer) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.HOST_TYPE__DEFAULT_MEMORY: + setDefaultMemory(DEFAULT_MEMORY_EDEFAULT); + return; + case CpsPackage.HOST_TYPE__DEFAULT_HDD: + setDefaultHdd(DEFAULT_HDD_EDEFAULT); + return; + case CpsPackage.HOST_TYPE__INSTANCES: + getInstances().clear(); + return; + case CpsPackage.HOST_TYPE__COST: + setCost(COST_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.HOST_TYPE__DEFAULT_MEMORY: + return defaultMemory != DEFAULT_MEMORY_EDEFAULT; + case CpsPackage.HOST_TYPE__DEFAULT_HDD: + return defaultHdd != DEFAULT_HDD_EDEFAULT; + case CpsPackage.HOST_TYPE__INSTANCES: + return instances != null && !instances.isEmpty(); + case CpsPackage.HOST_TYPE__COST: + return cost != COST_EDEFAULT; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (defaultMemory: "); + result.append(defaultMemory); + result.append(", defaultHdd: "); + result.append(defaultHdd); + result.append(", cost: "); + result.append(cost); + result.append(')'); + return result.toString(); + } + +} //HostTypeImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequestImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequestImpl.java new file mode 100644 index 00000000..72b4c732 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequestImpl.java @@ -0,0 +1,169 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.Request; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Request'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequestImpl#getRequirements Requirements}
  • + *
+ * + * @generated + */ +public class RequestImpl extends MinimalEObjectImpl.Container implements Request { + /** + * The cached value of the '{@link #getRequirements() Requirements}' containment reference list. + * + * + * @see #getRequirements() + * @generated + * @ordered + */ + protected EList requirements; + + /** + * + * + * @generated + */ + protected RequestImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.REQUEST; + } + + /** + * + * + * @generated + */ + @Override + public EList getRequirements() { + if (requirements == null) { + requirements = new EObjectContainmentWithInverseEList(Requirement.class, this, + CpsPackage.REQUEST__REQUIREMENTS, CpsPackage.REQUIREMENT__REQUEST); + } + return requirements; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.REQUEST__REQUIREMENTS: + return ((InternalEList) (InternalEList) getRequirements()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.REQUEST__REQUIREMENTS: + return ((InternalEList) getRequirements()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.REQUEST__REQUIREMENTS: + return getRequirements(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.REQUEST__REQUIREMENTS: + getRequirements().clear(); + getRequirements().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.REQUEST__REQUIREMENTS: + getRequirements().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.REQUEST__REQUIREMENTS: + return requirements != null && !requirements.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //RequestImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequirementImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequirementImpl.java new file mode 100644 index 00000000..79dc4f62 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/RequirementImpl.java @@ -0,0 +1,387 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.Request; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Requirement'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl#getRequest Request}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl#getCount Count}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl#getType Type}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.RequirementImpl#getInstances Instances}
  • + *
+ * + * @generated + */ +public class RequirementImpl extends MinimalEObjectImpl.Container implements Requirement { + /** + * The default value of the '{@link #getCount() Count}' attribute. + * + * + * @see #getCount() + * @generated + * @ordered + */ + protected static final int COUNT_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getCount() Count}' attribute. + * + * + * @see #getCount() + * @generated + * @ordered + */ + protected int count = COUNT_EDEFAULT; + + /** + * The cached value of the '{@link #getType() Type}' reference. + * + * + * @see #getType() + * @generated + * @ordered + */ + protected ApplicationType type; + + /** + * The cached value of the '{@link #getInstances() Instances}' reference list. + * + * + * @see #getInstances() + * @generated + * @ordered + */ + protected EList instances; + + /** + * + * + * @generated + */ + protected RequirementImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.REQUIREMENT; + } + + /** + * + * + * @generated + */ + @Override + public Request getRequest() { + if (eContainerFeatureID() != CpsPackage.REQUIREMENT__REQUEST) + return null; + return (Request) eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetRequest(Request newRequest, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject) newRequest, CpsPackage.REQUIREMENT__REQUEST, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + @Override + public void setRequest(Request newRequest) { + if (newRequest != eInternalContainer() + || (eContainerFeatureID() != CpsPackage.REQUIREMENT__REQUEST && newRequest != null)) { + if (EcoreUtil.isAncestor(this, newRequest)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newRequest != null) + msgs = ((InternalEObject) newRequest).eInverseAdd(this, CpsPackage.REQUEST__REQUIREMENTS, Request.class, + msgs); + msgs = basicSetRequest(newRequest, msgs); + if (msgs != null) + msgs.dispatch(); + } else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.REQUIREMENT__REQUEST, newRequest, + newRequest)); + } + + /** + * + * + * @generated + */ + @Override + public int getCount() { + return count; + } + + /** + * + * + * @generated + */ + @Override + public void setCount(int newCount) { + int oldCount = count; + count = newCount; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.REQUIREMENT__COUNT, oldCount, count)); + } + + /** + * + * + * @generated + */ + @Override + public ApplicationType getType() { + if (type != null && type.eIsProxy()) { + InternalEObject oldType = (InternalEObject) type; + type = (ApplicationType) eResolveProxy(oldType); + if (type != oldType) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, CpsPackage.REQUIREMENT__TYPE, oldType, + type)); + } + } + return type; + } + + /** + * + * + * @generated + */ + public ApplicationType basicGetType() { + return type; + } + + /** + * + * + * @generated + */ + @Override + public void setType(ApplicationType newType) { + ApplicationType oldType = type; + type = newType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.REQUIREMENT__TYPE, oldType, type)); + } + + /** + * + * + * @generated + */ + @Override + public EList getInstances() { + if (instances == null) { + instances = new EObjectWithInverseResolvingEList(ApplicationInstance.class, this, + CpsPackage.REQUIREMENT__INSTANCES, CpsPackage.APPLICATION_INSTANCE__REQUIREMENT); + } + return instances; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.REQUIREMENT__REQUEST: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetRequest((Request) otherEnd, msgs); + case CpsPackage.REQUIREMENT__INSTANCES: + return ((InternalEList) (InternalEList) getInstances()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case CpsPackage.REQUIREMENT__REQUEST: + return basicSetRequest(null, msgs); + case CpsPackage.REQUIREMENT__INSTANCES: + return ((InternalEList) getInstances()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case CpsPackage.REQUIREMENT__REQUEST: + return eInternalContainer().eInverseRemove(this, CpsPackage.REQUEST__REQUIREMENTS, Request.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.REQUIREMENT__REQUEST: + return getRequest(); + case CpsPackage.REQUIREMENT__COUNT: + return getCount(); + case CpsPackage.REQUIREMENT__TYPE: + if (resolve) + return getType(); + return basicGetType(); + case CpsPackage.REQUIREMENT__INSTANCES: + return getInstances(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.REQUIREMENT__REQUEST: + setRequest((Request) newValue); + return; + case CpsPackage.REQUIREMENT__COUNT: + setCount((Integer) newValue); + return; + case CpsPackage.REQUIREMENT__TYPE: + setType((ApplicationType) newValue); + return; + case CpsPackage.REQUIREMENT__INSTANCES: + getInstances().clear(); + getInstances().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.REQUIREMENT__REQUEST: + setRequest((Request) null); + return; + case CpsPackage.REQUIREMENT__COUNT: + setCount(COUNT_EDEFAULT); + return; + case CpsPackage.REQUIREMENT__TYPE: + setType((ApplicationType) null); + return; + case CpsPackage.REQUIREMENT__INSTANCES: + getInstances().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.REQUIREMENT__REQUEST: + return getRequest() != null; + case CpsPackage.REQUIREMENT__COUNT: + return count != COUNT_EDEFAULT; + case CpsPackage.REQUIREMENT__TYPE: + return type != null; + case CpsPackage.REQUIREMENT__INSTANCES: + return instances != null && !instances.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (count: "); + result.append(count); + result.append(')'); + return result.toString(); + } + +} //RequirementImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ResourceRequirementImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ResourceRequirementImpl.java new file mode 100644 index 00000000..f4deb575 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/ResourceRequirementImpl.java @@ -0,0 +1,291 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.impl; + +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; +import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * + * An implementation of the model object 'Resource Requirement'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl#getRequiredMemory Required Memory}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl#getRequiredHdd Required Hdd}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ResourceRequirementImpl#getHostType Host Type}
  • + *
+ * + * @generated + */ +public class ResourceRequirementImpl extends MinimalEObjectImpl.Container implements ResourceRequirement { + /** + * The default value of the '{@link #getRequiredMemory() Required Memory}' attribute. + * + * + * @see #getRequiredMemory() + * @generated + * @ordered + */ + protected static final int REQUIRED_MEMORY_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getRequiredMemory() Required Memory}' attribute. + * + * + * @see #getRequiredMemory() + * @generated + * @ordered + */ + protected int requiredMemory = REQUIRED_MEMORY_EDEFAULT; + + /** + * The default value of the '{@link #getRequiredHdd() Required Hdd}' attribute. + * + * + * @see #getRequiredHdd() + * @generated + * @ordered + */ + protected static final int REQUIRED_HDD_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getRequiredHdd() Required Hdd}' attribute. + * + * + * @see #getRequiredHdd() + * @generated + * @ordered + */ + protected int requiredHdd = REQUIRED_HDD_EDEFAULT; + + /** + * The cached value of the '{@link #getHostType() Host Type}' reference. + * + * + * @see #getHostType() + * @generated + * @ordered + */ + protected HostType hostType; + + /** + * + * + * @generated + */ + protected ResourceRequirementImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return CpsPackage.Literals.RESOURCE_REQUIREMENT; + } + + /** + * + * + * @generated + */ + @Override + public int getRequiredMemory() { + return requiredMemory; + } + + /** + * + * + * @generated + */ + @Override + public void setRequiredMemory(int newRequiredMemory) { + int oldRequiredMemory = requiredMemory; + requiredMemory = newRequiredMemory; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY, + oldRequiredMemory, requiredMemory)); + } + + /** + * + * + * @generated + */ + @Override + public int getRequiredHdd() { + return requiredHdd; + } + + /** + * + * + * @generated + */ + @Override + public void setRequiredHdd(int newRequiredHdd) { + int oldRequiredHdd = requiredHdd; + requiredHdd = newRequiredHdd; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD, + oldRequiredHdd, requiredHdd)); + } + + /** + * + * + * @generated + */ + @Override + public HostType getHostType() { + if (hostType != null && hostType.eIsProxy()) { + InternalEObject oldHostType = (InternalEObject) hostType; + hostType = (HostType) eResolveProxy(oldHostType); + if (hostType != oldHostType) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, + CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE, oldHostType, hostType)); + } + } + return hostType; + } + + /** + * + * + * @generated + */ + public HostType basicGetHostType() { + return hostType; + } + + /** + * + * + * @generated + */ + @Override + public void setHostType(HostType newHostType) { + HostType oldHostType = hostType; + hostType = newHostType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE, + oldHostType, hostType)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY: + return getRequiredMemory(); + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD: + return getRequiredHdd(); + case CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE: + if (resolve) + return getHostType(); + return basicGetHostType(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY: + setRequiredMemory((Integer) newValue); + return; + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD: + setRequiredHdd((Integer) newValue); + return; + case CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE: + setHostType((HostType) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY: + setRequiredMemory(REQUIRED_MEMORY_EDEFAULT); + return; + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD: + setRequiredHdd(REQUIRED_HDD_EDEFAULT); + return; + case CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE: + setHostType((HostType) null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_MEMORY: + return requiredMemory != REQUIRED_MEMORY_EDEFAULT; + case CpsPackage.RESOURCE_REQUIREMENT__REQUIRED_HDD: + return requiredHdd != REQUIRED_HDD_EDEFAULT; + case CpsPackage.RESOURCE_REQUIREMENT__HOST_TYPE: + return hostType != null; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (requiredMemory: "); + result.append(requiredMemory); + result.append(", requiredHdd: "); + result.append(requiredHdd); + result.append(')'); + return result.toString(); + } + +} //ResourceRequirementImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsAdapterFactory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsAdapterFactory.java new file mode 100644 index 00000000..83e984a6 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsAdapterFactory.java @@ -0,0 +1,252 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.util; + +import hu.bme.mit.inf.dslreasoner.domains.cps.*; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage + * @generated + */ +public class CpsAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * + * + * @generated + */ + protected static CpsPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public CpsAdapterFactory() { + if (modelPackage == null) { + modelPackage = CpsPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject) object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected CpsSwitch modelSwitch = new CpsSwitch() { + @Override + public Adapter caseCyberPhysicalSystem(CyberPhysicalSystem object) { + return createCyberPhysicalSystemAdapter(); + } + + @Override + public Adapter caseApplicationType(ApplicationType object) { + return createApplicationTypeAdapter(); + } + + @Override + public Adapter caseHostType(HostType object) { + return createHostTypeAdapter(); + } + + @Override + public Adapter caseRequest(Request object) { + return createRequestAdapter(); + } + + @Override + public Adapter caseRequirement(Requirement object) { + return createRequirementAdapter(); + } + + @Override + public Adapter caseApplicationInstance(ApplicationInstance object) { + return createApplicationInstanceAdapter(); + } + + @Override + public Adapter caseResourceRequirement(ResourceRequirement object) { + return createResourceRequirementAdapter(); + } + + @Override + public Adapter caseHostInstance(HostInstance object) { + return createHostInstanceAdapter(); + } + + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject) target); + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem Cyber Physical System}'. + * + * 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.cps.CyberPhysicalSystem + * @generated + */ + public Adapter createCyberPhysicalSystemAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType Application Type}'. + * + * 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.cps.ApplicationType + * @generated + */ + public Adapter createApplicationTypeAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostType Host Type}'. + * + * 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.cps.HostType + * @generated + */ + public Adapter createHostTypeAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Request Request}'. + * + * 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.cps.Request + * @generated + */ + public Adapter createRequestAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.Requirement Requirement}'. + * + * 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.cps.Requirement + * @generated + */ + public Adapter createRequirementAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance Application Instance}'. + * + * 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.cps.ApplicationInstance + * @generated + */ + public Adapter createApplicationInstanceAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement Resource Requirement}'. + * + * 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.cps.ResourceRequirement + * @generated + */ + public Adapter createResourceRequirementAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance Host Instance}'. + * + * 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.cps.HostInstance + * @generated + */ + public Adapter createHostInstanceAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //CpsAdapterFactory diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsSwitch.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsSwitch.java new file mode 100644 index 00000000..28b630a9 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/util/CpsSwitch.java @@ -0,0 +1,266 @@ +/** + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.util; + +import hu.bme.mit.inf.dslreasoner.domains.cps.*; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage + * @generated + */ +public class CpsSwitch extends Switch { + /** + * The cached model package + * + * + * @generated + */ + protected static CpsPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public CpsSwitch() { + if (modelPackage == null) { + modelPackage = CpsPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case CpsPackage.CYBER_PHYSICAL_SYSTEM: { + CyberPhysicalSystem cyberPhysicalSystem = (CyberPhysicalSystem) theEObject; + T result = caseCyberPhysicalSystem(cyberPhysicalSystem); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.APPLICATION_TYPE: { + ApplicationType applicationType = (ApplicationType) theEObject; + T result = caseApplicationType(applicationType); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.HOST_TYPE: { + HostType hostType = (HostType) theEObject; + T result = caseHostType(hostType); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.REQUEST: { + Request request = (Request) theEObject; + T result = caseRequest(request); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.REQUIREMENT: { + Requirement requirement = (Requirement) theEObject; + T result = caseRequirement(requirement); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.APPLICATION_INSTANCE: { + ApplicationInstance applicationInstance = (ApplicationInstance) theEObject; + T result = caseApplicationInstance(applicationInstance); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.RESOURCE_REQUIREMENT: { + ResourceRequirement resourceRequirement = (ResourceRequirement) theEObject; + T result = caseResourceRequirement(resourceRequirement); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case CpsPackage.HOST_INSTANCE: { + HostInstance hostInstance = (HostInstance) theEObject; + T result = caseHostInstance(hostInstance); + if (result == null) + result = defaultCase(theEObject); + return result; + } + default: + return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Cyber Physical System'. + * + * 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 'Cyber Physical System'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseCyberPhysicalSystem(CyberPhysicalSystem object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Application Type'. + * + * 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 'Application Type'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseApplicationType(ApplicationType object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Host Type'. + * + * 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 'Host Type'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseHostType(HostType object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Request'. + * + * 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 'Request'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseRequest(Request object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Requirement'. + * + * 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 'Requirement'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseRequirement(Requirement object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Application Instance'. + * + * 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 'Application Instance'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseApplicationInstance(ApplicationInstance object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Resource Requirement'. + * + * 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 'Resource Requirement'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseResourceRequirement(ResourceRequirement object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Host Instance'. + * + * 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 'Host Instance'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseHostInstance(HostInstance object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //CpsSwitch diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.aird b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.aird index d94d68b4..3f1b0301 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.aird +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.aird @@ -3,6 +3,991 @@ cps.ecore cps.genmodel + ../src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + http://www.eclipse.org/emf/2002/Ecore + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch + java:/Objects/java.lang.Object + java:/Objects/org.eclipse.viatra.query.runtime.api.IPatternMatch + java:/Primitives + java:/Objects/java.lang.SafeVarargs + java:/Objects/java.util.List + java:/Objects/java.lang.String + java:/Objects/java.lang.CloneNotSupportedException + java:/Objects/java.lang.Throwable + java:/Objects/java.lang.Class + java:/Objects/java.lang.InterruptedException + java:/Objects/java.lang.Exception + java:/Objects/java.io.Serializable + java:/Objects/java.io.PrintWriter + java:/Objects/java.io.PrintStream + java:/Objects/java.lang.StackTraceElement + java:/Objects/java.util.Set + java:/Objects/java.io.ObjectInputStream + java:/Objects/java.io.IOException + java:/Objects/java.lang.ClassNotFoundException + java:/Objects/java.io.ObjectOutputStream + java:/Objects/java.io.Writer + java:/Objects/java.io.OutputStream + java:/Objects/java.io.FileNotFoundException + java:/Objects/java.io.File + java:/Objects/java.nio.charset.Charset + java:/Objects/java.io.UnsupportedEncodingException + java:/Objects/java.lang.CharSequence + java:/Objects/java.util.Locale + java:/Objects/java.util.Formatter + java:/Objects/java.lang.Appendable + java:/Objects/java.io.Closeable + java:/Objects/java.io.Flushable + java:/Objects/java.lang.AutoCloseable + java:/Objects/java.lang.Comparable + java:/Objects/java.security.SecureRandom + java:/Objects/java.lang.Enum + java:/Objects/java.net.URI + java:/Objects/java.io.FilenameFilter + java:/Objects/java.io.FileFilter + java:/Objects/java.nio.file.Path + java:/Objects/java.lang.Deprecated + java:/Objects/java.net.MalformedURLException + java:/Objects/java.net.URL + java:/Objects/sun.misc.Unsafe + java:/Objects/java.io.FileSystem + java:/Objects/java.util.Random + java:/Objects/java.util.regex.Pattern + java:/Objects/java.security.SecureRandomSpi + java:/Objects/java.security.Provider + java:/Objects/java.security.NoSuchAlgorithmException + java:/Objects/java.security.NoSuchProviderException + java:/Objects/java.security.MessageDigest + java:/Objects/sun.security.util.Debug + java:/Objects/java.util.Spliterator + java:/Objects/java.util.function.DoubleConsumer + java:/Objects/java.util.function.LongConsumer + java:/Objects/java.util.function.IntConsumer + java:/Objects/java.util.stream.DoubleStream + java:/Objects/java.util.stream.IntStream + java:/Objects/java.util.stream.LongStream + java:/Objects/java.util.concurrent.atomic.AtomicLong + java:/Objects/java.io.ObjectStreamField + java:/Objects/java.lang.Double + java:/Objects/java.util.function.Consumer + java:/Objects/java.lang.Long + java:/Objects/java.lang.Integer + java:/Objects/java.util.Comparator + java:/Objects/java.lang.Number + java:/Objects/java.lang.NumberFormatException + java:/Objects/java.lang.IllegalArgumentException + java:/Objects/java.lang.RuntimeException + java:/Objects/java.lang.FunctionalInterface + java:/Objects/java.lang.annotation.Target + java:/Objects/java.lang.annotation.ElementType + java:/Objects/java.lang.annotation.Retention + java:/Objects/java.lang.annotation.RetentionPolicy + java:/Objects/java.lang.annotation.Documented + java:/Objects/java.lang.annotation.Annotation + java:/Objects/java.math.BigInteger + java:/Objects/java.lang.StringBuilder + java:/Objects/java.lang.AbstractStringBuilder + java:/Objects/java.lang.StringBuffer + java:/Objects/java.util.function.Function + java:/Objects/java.util.function.ToDoubleFunction + java:/Objects/java.util.function.ToIntFunction + java:/Objects/java.util.function.ToLongFunction + java:/Objects/java.util.stream.BaseStream + java:/Objects/java.util.function.DoublePredicate + java:/Objects/java.util.OptionalDouble + java:/Objects/java.util.stream.Stream + java:/Objects/java.util.function.Supplier + java:/Objects/java.util.function.ObjDoubleConsumer + java:/Objects/java.util.function.BiConsumer + java:/Objects/java.util.function.DoubleFunction + java:/Objects/java.util.function.DoubleSupplier + java:/Objects/java.util.function.DoubleUnaryOperator + java:/Objects/java.util.PrimitiveIterator + java:/Objects/java.util.function.DoubleToIntFunction + java:/Objects/java.util.function.DoubleToLongFunction + java:/Objects/java.util.function.DoubleBinaryOperator + java:/Objects/java.util.DoubleSummaryStatistics + java:/Objects/java.util.Iterator + java:/Objects/java.lang.Runnable + java:/Objects/java.util.function.Predicate + java:/Objects/java.util.stream.Collector + java:/Objects/java.util.Optional + java:/Objects/java.util.function.UnaryOperator + java:/Objects/java.util.function.BinaryOperator + java:/Objects/java.util.function.BiFunction + java:/Objects/java.util.function.IntFunction + java:/Objects/java.util.function.IntPredicate + java:/Objects/java.util.function.ObjIntConsumer + java:/Objects/java.util.OptionalInt + java:/Objects/java.util.function.IntSupplier + java:/Objects/java.util.function.IntUnaryOperator + java:/Objects/java.util.function.IntToDoubleFunction + java:/Objects/java.util.function.IntToLongFunction + java:/Objects/java.util.function.IntBinaryOperator + java:/Objects/java.util.IntSummaryStatistics + java:/Objects/java.util.function.LongPredicate + java:/Objects/java.util.function.ObjLongConsumer + java:/Objects/java.util.OptionalLong + java:/Objects/java.util.function.LongFunction + java:/Objects/java.util.function.LongSupplier + java:/Objects/java.util.function.LongUnaryOperator + java:/Objects/java.util.function.LongToDoubleFunction + java:/Objects/java.util.function.LongToIntFunction + java:/Objects/java.util.function.LongBinaryOperator + java:/Objects/java.util.LongSummaryStatistics + java:/Objects/java.lang.reflect.Field + java:/Objects/sun.reflect.CallerSensitive + java:/Objects/java.lang.reflect.AccessibleObject + java:/Objects/java.lang.reflect.Member + java:/Objects/sun.reflect.FieldAccessor + java:/Objects/java.util.Map + java:/Objects/java.lang.IllegalAccessException + java:/Objects/java.lang.reflect.AnnotatedType + java:/Objects/sun.reflect.generics.factory.GenericsFactory + java:/Objects/sun.reflect.generics.repository.FieldRepository + java:/Objects/java.lang.reflect.Type + java:/Objects/java.lang.reflect.AnnotatedElement + java:/Objects/java.lang.SecurityException + java:/Objects/java.security.Permission + java:/Objects/sun.reflect.ReflectionFactory + java:/Objects/java.security.Guard + java:/Objects/java.security.PermissionCollection + java:/Objects/java.util.Enumeration + java:/Objects/java.security.PrivilegedAction + java:/Objects/java.lang.reflect.Constructor + java:/Objects/java.lang.reflect.Method + java:/Objects/java.lang.invoke.MethodHandle + java:/Objects/sun.reflect.ConstructorAccessor + java:/Objects/java.lang.reflect.Executable + java:/Objects/sun.reflect.MethodAccessor + java:/Objects/sun.reflect.LangReflectAccess + java:/Objects/java.io.OptionalDataException + java:/Objects/sun.reflect.generics.repository.ConstructorRepository + java:/Objects/java.lang.reflect.TypeVariable + java:/Objects/java.lang.InstantiationException + java:/Objects/java.lang.reflect.InvocationTargetException + java:/Objects/sun.reflect.generics.repository.GenericDeclRepository + java:/Objects/sun.reflect.generics.tree.MethodTypeSignature + java:/Objects/sun.reflect.generics.repository.AbstractRepository + java:/Objects/sun.reflect.generics.tree.Signature + java:/Objects/sun.reflect.generics.visitor.Reifier + java:/Objects/sun.reflect.generics.tree.Tree + java:/Objects/sun.reflect.generics.visitor.TypeTreeVisitor + java:/Objects/sun.reflect.generics.tree.TypeArgument + java:/Objects/sun.reflect.generics.tree.ArrayTypeSignature + java:/Objects/sun.reflect.generics.tree.BooleanSignature + java:/Objects/sun.reflect.generics.tree.BottomSignature + java:/Objects/sun.reflect.generics.tree.ByteSignature + java:/Objects/sun.reflect.generics.tree.CharSignature + java:/Objects/sun.reflect.generics.tree.ClassTypeSignature + java:/Objects/sun.reflect.generics.tree.DoubleSignature + java:/Objects/sun.reflect.generics.tree.FloatSignature + java:/Objects/sun.reflect.generics.tree.FormalTypeParameter + java:/Objects/sun.reflect.generics.tree.IntSignature + java:/Objects/sun.reflect.generics.tree.LongSignature + java:/Objects/sun.reflect.generics.tree.ShortSignature + java:/Objects/sun.reflect.generics.tree.SimpleClassTypeSignature + java:/Objects/sun.reflect.generics.tree.TypeVariableSignature + java:/Objects/sun.reflect.generics.tree.VoidDescriptor + java:/Objects/sun.reflect.generics.tree.Wildcard + java:/Objects/sun.reflect.generics.tree.TypeTree + java:/Objects/sun.reflect.generics.tree.FieldTypeSignature + java:/Objects/sun.reflect.generics.tree.TypeSignature + java:/Objects/sun.reflect.generics.tree.BaseType + java:/Objects/sun.reflect.generics.tree.ReturnType + java:/Objects/sun.reflect.generics.visitor.Visitor + java:/Objects/sun.reflect.generics.tree.ClassSignature + java:/Objects/java.lang.reflect.GenericDeclaration + java:/Objects/java.lang.ReflectiveOperationException + java:/Objects/sun.reflect.generics.repository.MethodRepository + java:/Objects/java.lang.invoke.MethodType + java:/Objects/java.lang.invoke.LambdaForm + java:/Objects/java.lang.invoke.BoundMethodHandle + java:/Objects/java.lang.invoke.MemberName + java:/Objects/java.lang.invoke.MethodHandleImpl + java:/Objects/java.lang.ref.WeakReference + java:/Objects/java.lang.ref.ReferenceQueue + java:/Objects/java.util.concurrent.ConcurrentMap + java:/Objects/java.lang.invoke.MethodTypeForm + java:/Objects/java.lang.ClassLoader + java:/Objects/java.lang.TypeNotPresentException + java:/Objects/java.lang.invoke.Invokers + java:/Objects/java.lang.IndexOutOfBoundsException + java:/Objects/java.lang.invoke.Stable + java:/Objects/java.lang.ref.Reference + java:/Objects/java.lang.Thread + java:/Objects/java.lang.ThreadGroup + java:/Objects/java.lang.Boolean + java:/Objects/java.security.AccessControlContext + java:/Objects/sun.nio.ch.Interruptible + java:/Objects/java.lang.RuntimePermission + java:/Objects/java.lang.ThreadLocal + java:/Objects/sun.misc.Contended + java:/Objects/java.security.ProtectionDomain + java:/Objects/java.security.DomainCombiner + java:/Objects/java.security.AccessControlException + java:/Objects/sun.misc.JavaSecurityAccess + java:/Objects/java.security.CodeSource + java:/Objects/java.security.Principal + java:/Objects/java.security.cert.Certificate + java:/Objects/java.security.CodeSigner + java:/Objects/java.security.cert.CertificateFactory + java:/Objects/java.net.SocketPermission + java:/Objects/java.io.ObjectStreamException + java:/Objects/java.security.cert.CertificateEncodingException + java:/Objects/java.security.PublicKey + java:/Objects/java.security.cert.CertificateException + java:/Objects/java.security.InvalidKeyException + java:/Objects/java.security.SignatureException + java:/Objects/java.security.Key + java:/Objects/java.security.GeneralSecurityException + java:/Objects/java.security.KeyException + java:/Objects/java.security.cert.CertPath + java:/Objects/java.security.Timestamp + java:/Objects/java.util.Date + java:/Objects/java.lang.Cloneable + java:/Objects/java.time.Instant + java:/Objects/sun.util.calendar.BaseCalendar + java:/Objects/java.time.temporal.Temporal + java:/Objects/java.time.temporal.TemporalAdjuster + java:/Objects/java.time.ZoneOffset + java:/Objects/java.time.OffsetDateTime + java:/Objects/java.time.ZoneId + java:/Objects/java.time.ZonedDateTime + java:/Objects/java.time.temporal.TemporalAccessor + java:/Objects/java.time.temporal.TemporalField + java:/Objects/java.time.temporal.TemporalUnit + java:/Objects/java.time.temporal.TemporalAmount + java:/Objects/java.time.Clock + java:/Objects/java.time.temporal.TemporalQuery + java:/Objects/java.time.temporal.ValueRange + java:/Objects/java.io.DataInput + java:/Objects/java.io.InvalidObjectException + java:/Objects/java.io.DataOutput + java:/Objects/java.time.zone.ZoneRules + java:/Objects/java.time.zone.ZoneOffsetTransition + java:/Objects/java.time.zone.ZoneOffsetTransitionRule + java:/Objects/java.time.LocalDateTime + java:/Objects/java.time.Duration + java:/Objects/java.time.Month + java:/Objects/java.time.DayOfWeek + java:/Objects/java.time.LocalTime + java:/Objects/java.time.format.TextStyle + java:/Objects/java.time.LocalDate + java:/Objects/java.time.OffsetTime + java:/Objects/java.time.format.DateTimeFormatter + java:/Objects/java.time.chrono.ChronoLocalDate + java:/Objects/java.time.chrono.IsoChronology + java:/Objects/java.time.chrono.Era + java:/Objects/java.time.Period + java:/Objects/java.time.chrono.ChronoLocalDateTime + java:/Objects/java.time.chrono.Chronology + java:/Objects/java.time.chrono.ChronoPeriod + java:/Objects/java.time.chrono.ChronoZonedDateTime + java:/Objects/java.time.temporal.ChronoField + java:/Objects/java.time.format.ResolverStyle + java:/Objects/java.time.chrono.AbstractChronology + java:/Objects/java.time.chrono.IsoEra + java:/Objects/java.util.concurrent.ConcurrentHashMap + java:/Objects/java.util.AbstractMap + java:/Objects/java.util.function.ToIntBiFunction + java:/Objects/java.util.function.ToLongBiFunction + java:/Objects/java.util.function.ToDoubleBiFunction + java:/Objects/java.util.concurrent.atomic.AtomicReference + java:/Objects/java.lang.Void + java:/Objects/java.util.concurrent.CountedCompleter + java:/Objects/java.util.Collection + java:/Objects/java.util.concurrent.locks.ReentrantLock + java:/Objects/java.util.concurrent.ForkJoinTask + java:/Objects/java.util.concurrent.Future + java:/Objects/java.util.concurrent.RunnableFuture + java:/Objects/java.util.concurrent.Callable + java:/Objects/java.util.concurrent.ExecutionException + java:/Objects/java.util.concurrent.TimeUnit + java:/Objects/java.util.concurrent.TimeoutException + java:/Objects/java.util.concurrent.ForkJoinPool + java:/Objects/java.util.concurrent.AbstractExecutorService + java:/Objects/java.util.concurrent.ForkJoinWorkerThread + java:/Objects/java.util.concurrent.ExecutorService + java:/Objects/java.util.concurrent.Executor + java:/Objects/java.lang.Iterable + java:/Objects/java.util.concurrent.locks.Lock + java:/Objects/java.util.concurrent.locks.AbstractQueuedSynchronizer + java:/Objects/java.util.concurrent.locks.Condition + java:/Objects/java.util.concurrent.locks.AbstractOwnableSynchronizer + java:/Objects/java.lang.NullPointerException + java:/Objects/java.io.ObjectInput + java:/Objects/java.io.ObjectOutput + java:/Objects/java.text.Format + java:/Objects/java.text.FieldPosition + java:/Objects/java.text.ParseException + java:/Objects/java.text.ParsePosition + java:/Objects/java.time.format.DateTimeFormatterBuilder + java:/Objects/java.time.format.DecimalStyle + java:/Objects/java.time.format.DateTimeParseException + java:/Objects/java.time.format.FormatStyle + java:/Objects/java.time.format.DateTimeParseContext + java:/Objects/java.text.AttributedCharacterIterator + java:/Objects/java.text.CharacterIterator + java:/Objects/java.time.format.DateTimePrintContext + java:/Objects/java.lang.ref.SoftReference + java:/Objects/java.time.format.DateTimeTextProvider + java:/Objects/java.math.BigDecimal + java:/Objects/java.time.format.SignStyle + java:/Objects/java.lang.Character + java:/Objects/java.math.MathContext + java:/Objects/java.math.RoundingMode + java:/Objects/java.math.MutableBigInteger + java:/Objects/java.util.HashMap + java:/Objects/java.util.LinkedHashMap + java:/Objects/java.util.AbstractSet + java:/Objects/java.util.AbstractCollection + java:/Objects/java.time.DateTimeException + java:/Objects/java.time.format.Parsed + java:/Objects/java.util.ArrayList + java:/Objects/java.util.AbstractList + java:/Objects/java.util.RandomAccess + java:/Objects/java.util.ListIterator + java:/Objects/sun.util.calendar.AbstractCalendar + java:/Objects/sun.util.calendar.CalendarDate + java:/Objects/java.util.TimeZone + java:/Objects/sun.util.calendar.CalendarSystem + java:/Objects/sun.util.calendar.Era + java:/Objects/java.util.Properties + java:/Objects/sun.util.calendar.Gregorian + java:/Objects/java.util.Hashtable + java:/Objects/java.io.InputStream + java:/Objects/java.util.InvalidPropertiesFormatException + java:/Objects/sun.util.spi.XmlPropertiesProvider + java:/Objects/java.io.Reader + java:/Objects/java.io.BufferedWriter + java:/Objects/java.util.Dictionary + java:/Objects/java.io.StreamCorruptedException + java:/Objects/java.io.NotSerializableException + java:/Objects/java.lang.Readable + java:/Objects/java.nio.CharBuffer + java:/Objects/java.nio.Buffer + java:/Objects/java.nio.ByteOrder + java:/Objects/java.security.cert.CertificateFactorySpi + java:/Objects/java.security.cert.CRLException + java:/Objects/java.security.cert.CRL + java:/Objects/java.net.UnknownHostException + java:/Objects/java.net.InetAddress + java:/Objects/sun.net.spi.nameservice.NameService + java:/Objects/java.net.NetworkInterface + java:/Objects/java.net.InetAddressImpl + java:/Objects/java.net.SocketException + java:/Objects/java.net.InterfaceAddress + java:/Objects/java.net.Inet4Address + java:/Objects/javax.security.auth.Subject + java:/Objects/javax.security.auth.AuthPermission + java:/Objects/java.util.LinkedList + java:/Objects/java.security.PrivilegedExceptionAction + java:/Objects/java.security.PrivilegedActionException + java:/Objects/java.security.BasicPermission + java:/Objects/java.util.AbstractSequentialList + java:/Objects/java.util.Deque + java:/Objects/java.util.Queue + java:/Objects/java.util.concurrent.atomic.AtomicInteger + java:/Objects/java.lang.ClassFormatError + java:/Objects/java.nio.ByteBuffer + java:/Objects/java.lang.Package + java:/Objects/sun.misc.URLClassPath + java:/Objects/java.lang.AssertionStatusDirectives + java:/Objects/java.util.Vector + java:/Objects/java.util.Stack + java:/Objects/java.lang.LinkageError + java:/Objects/java.lang.Error + java:/Objects/java.nio.DoubleBuffer + java:/Objects/java.nio.FloatBuffer + java:/Objects/java.nio.IntBuffer + java:/Objects/java.nio.LongBuffer + java:/Objects/java.nio.ShortBuffer + java:/Objects/java.util.jar.Manifest + java:/Objects/java.io.FilterInputStream + java:/Objects/java.util.jar.JarVerifier + java:/Objects/java.util.jar.Attributes + java:/Objects/java.util.jar.JarEntry + java:/Objects/sun.security.util.ManifestEntryVerifier + java:/Objects/java.util.jar.JarFile + java:/Objects/java.util.zip.ZipEntry + java:/Objects/java.io.ByteArrayOutputStream + java:/Objects/sun.security.util.ManifestDigester + java:/Objects/sun.security.util.SignatureFileVerifier + java:/Objects/java.util.jar.JarException + java:/Objects/java.util.zip.ZipException + java:/Objects/java.util.zip.ZipFile + java:/Objects/java.util.zip.ZipConstants + java:/Objects/java.util.zip.InflaterInputStream + java:/Objects/java.util.zip.Inflater + java:/Objects/java.util.zip.ZipCoder + java:/Objects/java.util.zip.DataFormatException + java:/Objects/java.util.zip.ZStreamRef + java:/Objects/java.nio.charset.CharsetDecoder + java:/Objects/java.nio.charset.CharsetEncoder + java:/Objects/java.nio.charset.CharacterCodingException + java:/Objects/java.nio.charset.CoderResult + java:/Objects/java.nio.charset.CodingErrorAction + java:/Objects/java.nio.file.attribute.FileTime + java:/Objects/sun.security.pkcs.SignerInfo + java:/Objects/sun.security.pkcs.PKCS7 + java:/Objects/sun.security.util.DisabledAlgorithmConstraints + java:/Objects/sun.security.util.DerEncoder + java:/Objects/sun.security.util.DerInputStream + java:/Objects/sun.security.pkcs.ParsingException + java:/Objects/sun.security.x509.X500Name + java:/Objects/sun.security.x509.AlgorithmId + java:/Objects/sun.security.pkcs.PKCS9Attributes + java:/Objects/sun.security.util.DerOutputStream + java:/Objects/java.security.cert.X509Certificate + java:/Objects/sun.security.timestamp.TimestampToken + java:/Objects/java.security.CryptoPrimitive + java:/Objects/sun.security.util.DerInputBuffer + java:/Objects/sun.security.util.DerValue + java:/Objects/sun.security.util.ObjectIdentifier + java:/Objects/sun.security.util.BitArray + java:/Objects/java.io.ByteArrayInputStream + java:/Objects/java.lang.ArrayIndexOutOfBoundsException + java:/Objects/sun.security.x509.GeneralNameInterface + java:/Objects/sun.security.x509.RDN + java:/Objects/sun.security.x509.AVA + java:/Objects/javax.security.auth.x500.X500Principal + java:/Objects/java.lang.UnsupportedOperationException + java:/Objects/java.lang.Byte + java:/Objects/java.io.NotActiveException + java:/Objects/java.security.AlgorithmParameters + java:/Objects/java.security.AlgorithmParametersSpi + java:/Objects/java.security.spec.AlgorithmParameterSpec + java:/Objects/java.security.spec.InvalidParameterSpecException + java:/Objects/sun.security.pkcs.PKCS9Attribute + java:/Objects/sun.security.util.ByteArrayLexOrder + java:/Objects/sun.security.util.ByteArrayTagOrder + java:/Objects/java.security.cert.X509Extension + java:/Objects/java.security.cert.CertificateExpiredException + java:/Objects/java.security.cert.CertificateNotYetValidException + java:/Objects/java.security.cert.CertificateParsingException + java:/Objects/sun.security.pkcs.ContentInfo + java:/Objects/java.security.cert.X509CRL + java:/Objects/sun.security.timestamp.Timestamper + java:/Objects/java.security.cert.X509CRLEntry + java:/Objects/java.security.cert.CRLReason + java:/Objects/sun.security.timestamp.TSRequest + java:/Objects/sun.security.timestamp.TSResponse + java:/Objects/sun.security.util.AbstractAlgorithmConstraints + java:/Objects/sun.security.util.ConstraintsParameters + java:/Objects/java.security.cert.CertPathValidatorException + java:/Objects/java.text.SimpleDateFormat + java:/Objects/sun.security.util.AlgorithmDecomposer + java:/Objects/java.security.AlgorithmConstraints + java:/Objects/java.text.DateFormat + java:/Objects/java.text.DateFormatSymbols + java:/Objects/java.text.CalendarBuilder + java:/Objects/java.text.NumberFormat + java:/Objects/sun.util.locale.provider.LocaleProviderAdapter + java:/Objects/java.util.Calendar + java:/Objects/java.util.spi.LocaleServiceProvider + java:/Objects/java.text.spi.BreakIteratorProvider + java:/Objects/java.util.spi.CalendarDataProvider + java:/Objects/java.util.spi.CalendarNameProvider + java:/Objects/sun.util.spi.CalendarProvider + java:/Objects/java.text.spi.CollatorProvider + java:/Objects/java.util.spi.CurrencyNameProvider + java:/Objects/java.text.spi.DateFormatProvider + java:/Objects/java.text.spi.DateFormatSymbolsProvider + java:/Objects/java.text.spi.DecimalFormatSymbolsProvider + java:/Objects/java.util.spi.LocaleNameProvider + java:/Objects/sun.util.locale.provider.LocaleResources + java:/Objects/java.text.spi.NumberFormatProvider + java:/Objects/java.util.spi.TimeZoneNameProvider + java:/Objects/java.text.BreakIterator + java:/Objects/java.text.Collator + java:/Objects/java.text.CollationKey + java:/Objects/java.text.DecimalFormatSymbols + java:/Objects/java.util.Currency + java:/Objects/sun.util.locale.provider.LocaleServiceProviderPool + java:/Objects/java.io.DataInputStream + java:/Objects/java.util.HashSet + java:/Objects/sun.util.locale.provider.ResourceBundleBasedAdapter + java:/Objects/java.util.ResourceBundle + java:/Objects/sun.util.resources.LocaleData + java:/Objects/sun.util.locale.LocaleObjectCache + java:/Objects/sun.util.locale.BaseLocale + java:/Objects/java.util.spi.ResourceBundleControlProvider + java:/Objects/sun.util.resources.OpenListResourceBundle + java:/Objects/sun.util.resources.TimeZoneNamesBundle + java:/Objects/sun.util.resources.ParallelListResourceBundle + java:/Objects/java.util.concurrent.atomic.AtomicMarkableReference + java:/Objects/java.io.DataOutputStream + java:/Objects/java.io.FilterOutputStream + java:/Objects/sun.misc.Resource + java:/Objects/java.net.URLStreamHandler + java:/Objects/sun.misc.JarIndex + java:/Objects/sun.misc.MetaIndex + java:/Objects/sun.misc.JavaUtilZipFileAccess + java:/Objects/java.net.URLStreamHandlerFactory + java:/Objects/java.net.URLConnection + java:/Objects/java.net.Proxy + java:/Objects/java.net.UnknownServiceException + java:/Objects/java.net.ContentHandler + java:/Objects/java.net.FileNameMap + java:/Objects/java.net.ContentHandlerFactory + java:/Objects/sun.net.www.MessageHeader + java:/Objects/java.net.SocketAddress + java:/Objects/java.lang.invoke.ForceInline + java:/Objects/java.lang.invoke.DontInline + java:/Objects/java.lang.invoke.WrongMethodTypeException + java:/Objects/sun.invoke.util.Wrapper + java:/Objects/java.lang.invoke.LambdaFormEditor + java:/Objects/java.lang.ClassCastException + java:/Objects/java.lang.invoke.LambdaFormBuffer + java:/Objects/jdk.internal.org.objectweb.asm.MethodVisitor + java:/Objects/java.lang.invoke.MethodHandles + java:/Objects/jdk.internal.org.objectweb.asm.AnnotationVisitor + java:/Objects/jdk.internal.org.objectweb.asm.Attribute + java:/Objects/jdk.internal.org.objectweb.asm.TypePath + java:/Objects/jdk.internal.org.objectweb.asm.Handle + java:/Objects/jdk.internal.org.objectweb.asm.Label + java:/Objects/jdk.internal.org.objectweb.asm.ClassWriter + java:/Objects/jdk.internal.org.objectweb.asm.ByteVector + java:/Objects/jdk.internal.org.objectweb.asm.ClassReader + java:/Objects/jdk.internal.org.objectweb.asm.ClassVisitor + java:/Objects/jdk.internal.org.objectweb.asm.Item + java:/Objects/jdk.internal.org.objectweb.asm.FieldVisitor + java:/Objects/jdk.internal.org.objectweb.asm.AnnotationWriter + java:/Objects/jdk.internal.org.objectweb.asm.FieldWriter + java:/Objects/jdk.internal.org.objectweb.asm.MethodWriter + java:/Objects/jdk.internal.org.objectweb.asm.Frame + java:/Objects/jdk.internal.org.objectweb.asm.Handler + java:/Objects/jdk.internal.org.objectweb.asm.Type + java:/Objects/jdk.internal.org.objectweb.asm.Context + java:/Objects/jdk.internal.org.objectweb.asm.Edge + java:/Objects/java.lang.NoSuchMethodException + java:/Objects/java.lang.NoSuchFieldException + java:/Objects/java.lang.invoke.DirectMethodHandle + java:/Objects/java.lang.invoke.MethodHandleInfo + java:/Objects/java.lang.ClassValue + java:/Objects/java.util.WeakHashMap + java:/Objects/java.lang.invoke.DelegatingMethodHandle + java:/Objects/sun.invoke.empty.Empty + java:/Objects/java.lang.reflect.Parameter + java:/Objects/java.lang.reflect.ParameterizedType + java:/Objects/java.lang.reflect.WildcardType + java:/Objects/java.util.regex.Matcher + java:/Objects/java.util.regex.UnicodeProp + java:/Objects/java.util.regex.PatternSyntaxException + java:/Objects/java.util.regex.MatchResult + java:/Objects/java.security.MessageDigestSpi + java:/Objects/java.security.DigestException + java:/Objects/java.net.URISyntaxException + java:/Objects/java.nio.file.Watchable + java:/Objects/java.nio.file.FileSystem + java:/Objects/java.nio.file.WatchService + java:/Objects/java.nio.file.WatchEvent + java:/Objects/java.nio.file.WatchKey + java:/Objects/java.nio.file.LinkOption + java:/Objects/java.nio.file.FileStore + java:/Objects/java.nio.file.PathMatcher + java:/Objects/java.nio.file.attribute.UserPrincipalLookupService + java:/Objects/java.nio.file.spi.FileSystemProvider + java:/Objects/java.nio.file.attribute.FileStoreAttributeView + java:/Objects/java.nio.file.attribute.FileAttributeView + java:/Objects/java.nio.file.attribute.AttributeView + java:/Objects/java.nio.file.attribute.GroupPrincipal + java:/Objects/java.nio.file.attribute.UserPrincipal + java:/Objects/java.nio.file.AccessMode + java:/Objects/java.nio.file.CopyOption + java:/Objects/java.nio.file.attribute.FileAttribute + java:/Objects/java.nio.file.OpenOption + java:/Objects/java.nio.channels.AsynchronousFileChannel + java:/Objects/java.nio.channels.SeekableByteChannel + java:/Objects/java.nio.file.DirectoryStream + java:/Objects/java.nio.channels.FileChannel + java:/Objects/java.nio.file.attribute.BasicFileAttributes + java:/Objects/java.nio.channels.AsynchronousChannel + java:/Objects/java.nio.channels.FileLock + java:/Objects/java.nio.channels.CompletionHandler + java:/Objects/java.nio.channels.Channel + java:/Objects/java.nio.channels.ByteChannel + java:/Objects/java.nio.channels.ReadableByteChannel + java:/Objects/java.nio.channels.WritableByteChannel + java:/Objects/java.nio.channels.spi.AbstractInterruptibleChannel + java:/Objects/java.nio.channels.GatheringByteChannel + java:/Objects/java.nio.channels.ScatteringByteChannel + java:/Objects/java.nio.MappedByteBuffer + java:/Objects/java.nio.channels.InterruptibleChannel + java:/Objects/java.nio.channels.AsynchronousCloseException + java:/Objects/java.nio.channels.ClosedChannelException + java:/Objects/java.io.FileDescriptor + java:/Objects/java.io.SyncFailedException + java:/Objects/java.lang.SecurityManager + java:/Objects/java.net.UrlDeserializedState + java:/Objects/java.nio.charset.spi.CharsetProvider + java:/Objects/java.util.SortedMap + java:/Objects/sun.util.locale.InternalLocaleBuilder + java:/Objects/sun.util.locale.LocaleExtensions + java:/Objects/java.text.MessageFormat + java:/Objects/java.util.MissingResourceException + java:/Objects/sun.util.locale.LocaleSyntaxException + java:/Objects/sun.util.locale.LanguageTag + java:/Objects/sun.util.locale.ParseStatus + java:/Objects/sun.util.locale.StringTokenIterator + java:/Objects/sun.util.locale.Extension + java:/Objects/java.io.OutputStreamWriter + java:/Objects/sun.nio.cs.StreamEncoder + java:/Objects/java.io.ObjectStreamConstants + java:/Objects/sun.misc.ObjectInputFilter + java:/Objects/java.io.ObjectInputValidation + java:/Objects/java.io.ObjectStreamClass + java:/Objects/sun.util.logging.PlatformLogger + java:/Objects/java.io.InvalidClassException + java:/Objects/java.io.Externalizable + java:/Objects/sun.misc.ObjectStreamClassValidator + java:/Objects/java.io.SerialCallbackContext + java:/Objects/java.io.SerializablePermission + java:/Objects/sun.reflect.annotation.AnnotationType + java:/Objects/sun.reflect.ConstantPool + java:/Objects/sun.reflect.generics.repository.ClassRepository + java:/Objects/org.eclipse.viatra.query.runtime.api.IQuerySpecification + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQueryHeader + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryEngine + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.QueryScope + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IInputKey + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PTraceable + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PDisjunction + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PProblem + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.TypeJudgement + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PBody + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PVariable + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryMetaContext + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.InputKeyImplication + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IPosetComparator + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.Tuple + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.AbstractTuple + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.ITuple + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.VariableDeferredPConstraint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.DeferredPConstraint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.planning.SubPlan + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.BasePConstraint + java:/Objects/org.eclipse.viatra.query.runtime.matchers.planning.operations.POperation + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.QueryHintOption + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IMatcherCapability + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryBackendContext + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackend + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendHintProvider + java:/Objects/org.apache.log4j.Logger + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.analysis.QueryAnalyzer + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryCacheContext + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryResultProviderAccess + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContext + java:/Objects/org.apache.log4j.Category + java:/Objects/org.apache.log4j.spi.LoggerFactory + java:/Objects/org.apache.log4j.spi.AppenderAttachable + java:/Objects/org.apache.log4j.Appender + java:/Objects/org.apache.log4j.spi.LoggingEvent + java:/Objects/org.apache.log4j.Priority + java:/Objects/org.apache.log4j.spi.LoggerRepository + java:/Objects/org.apache.log4j.Level + java:/Objects/org.apache.log4j.helpers.AppenderAttachableImpl + java:/Objects/org.apache.log4j.spi.Filter + java:/Objects/org.apache.log4j.spi.ErrorHandler + java:/Objects/org.apache.log4j.Layout + java:/Objects/org.apache.log4j.spi.OptionHandler + java:/Objects/org.apache.log4j.spi.ThrowableInformation + java:/Objects/org.apache.log4j.spi.LocationInfo + java:/Objects/java.io.StringWriter + java:/Objects/org.apache.log4j.spi.HierarchyEventListener + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryResultProvider + java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IUpdateable + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask + java:/Objects/org.eclipse.viatra.query.runtime.matchers.util.Accuracy + java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.IModifiableTuple + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContextListener + java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IndexingService + java:/Objects/org.eclipse.viatra.query.runtime.matchers.planning.QueryProcessingException + java:/Objects/org.eclipse.viatra.query.runtime.matchers.ViatraQueryRuntimeException + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IBaseIndex + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.ViatraBaseIndexChangeListener + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IIndexingErrorListener + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IInstanceObserver + java:/Objects/org.eclipse.viatra.query.runtime.internal.apiimpl.EngineContextFactory + java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IEngineContext + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseMatcher + java:/Objects/org.eclipse.viatra.query.runtime.internal.apiimpl.QueryResultWrapper + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseQuerySpecification + java:/Objects/java.lang.ExceptionInInitializerError + java:/Objects/org.eclipse.viatra.query.runtime.exception.ViatraQueryException + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.QueryInitializationException + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseQueryGroup + java:/Objects/org.eclipse.viatra.query.runtime.api.IQueryGroup + java:/Objects/org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryEngineLifecycleListener + java:/Objects/org.eclipse.viatra.query.runtime.api.IMatchUpdateListener + java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryModelUpdateListener + java:/Objects/java.lang.Override + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.BasePQuery + java:/Objects/org.eclipse.emf.ecore.EClassifier + java:/Objects/org.eclipse.emf.ecore.EEnumLiteral + java:/Objects/org.eclipse.emf.ecore.EStructuralFeature + java:/Objects/org.eclipse.emf.ecore.ENamedElement + java:/Objects/org.eclipse.emf.ecore.EPackage + java:/Objects/org.eclipse.emf.common.util.EList + java:/Objects/org.eclipse.emf.ecore.ETypeParameter + java:/Objects/org.eclipse.emf.ecore.EModelElement + java:/Objects/org.eclipse.emf.ecore.EObject + java:/Objects/org.eclipse.emf.ecore.EAnnotation + java:/Objects/org.eclipse.emf.common.notify.Notifier + java:/Objects/org.eclipse.emf.common.util.TreeIterator + java:/Objects/org.eclipse.emf.ecore.EClass + java:/Objects/org.eclipse.emf.ecore.EReference + java:/Objects/org.eclipse.emf.ecore.EOperation + java:/Objects/org.eclipse.emf.ecore.resource.Resource + java:/Objects/org.eclipse.emf.common.notify.Adapter + java:/Objects/org.eclipse.emf.common.notify.Notification + java:/Objects/org.eclipse.emf.ecore.EAttribute + java:/Objects/org.eclipse.emf.ecore.EGenericType + java:/Objects/org.eclipse.emf.ecore.EDataType + java:/Objects/org.eclipse.emf.ecore.InternalEObject + java:/Objects/org.eclipse.emf.common.CommonPlugin + java:/Objects/org.eclipse.emf.common.notify.NotificationChain + java:/Objects/org.eclipse.emf.common.util.URI + java:/Objects/org.eclipse.emf.common.util.Pool + java:/Objects/org.eclipse.emf.common.util.SegmentSequence + java:/Objects/org.eclipse.emf.common.util.CommonUtil + java:/Objects/org.eclipse.emf.common.util.WeakInterningHashSet + java:/Objects/java.util.concurrent.locks.ReentrantReadWriteLock + java:/Objects/org.eclipse.emf.common.util.InterningSet + java:/Objects/java.util.concurrent.locks.ReadWriteLock + java:/Objects/java.lang.IllegalMonitorStateException + java:/Objects/org.eclipse.emf.common.EMFPlugin + java:/Objects/org.osgi.framework.BundleActivator + java:/Objects/org.eclipse.emf.common.util.ResourceLocator + java:/Objects/org.eclipse.emf.common.util.DelegatingResourceLocator + java:/Objects/org.eclipse.emf.common.util.Logger + java:/Objects/org.eclipse.core.runtime.Plugin + java:/Objects/org.eclipse.core.runtime.IPluginDescriptor + java:/Objects/org.osgi.framework.Bundle + java:/Objects/org.eclipse.core.runtime.ILog + java:/Objects/org.osgi.framework.BundleContext + java:/Objects/org.eclipse.core.runtime.IPath + java:/Objects/org.eclipse.osgi.service.debug.DebugOptions + java:/Objects/org.eclipse.core.runtime.Preferences + java:/Objects/java.lang.IllegalStateException + java:/Objects/org.eclipse.core.runtime.CoreException + java:/Objects/org.osgi.util.tracker.ServiceTracker + java:/Objects/org.eclipse.osgi.service.debug.DebugTrace + java:/Objects/java.util.EventListener + java:/Objects/java.util.EventObject + java:/Objects/org.eclipse.core.runtime.IStatus + java:/Objects/org.eclipse.core.runtime.ListenerList + java:/Objects/org.osgi.util.tracker.ServiceTrackerCustomizer + java:/Objects/org.osgi.framework.AllServiceListener + java:/Objects/org.osgi.util.tracker.AbstractTracked + java:/Objects/org.osgi.framework.ServiceReference + java:/Objects/org.osgi.framework.ServiceEvent + java:/Objects/org.osgi.framework.ServiceListener + java:/Objects/org.osgi.framework.Filter + java:/Objects/org.osgi.framework.InvalidSyntaxException + java:/Objects/org.eclipse.core.runtime.IExtension + java:/Objects/org.eclipse.core.runtime.IExtensionPoint + java:/Objects/org.eclipse.core.runtime.IPluginPrerequisite + java:/Objects/org.eclipse.core.runtime.ILibrary + java:/Objects/org.eclipse.core.runtime.PluginVersionIdentifier + java:/Objects/org.eclipse.core.runtime.InvalidRegistryObjectException + java:/Objects/org.eclipse.core.runtime.IConfigurationElement + java:/Objects/org.eclipse.core.runtime.IContributor + java:/Objects/org.osgi.framework.Version + java:/Objects/org.osgi.framework.BundleException + java:/Objects/org.eclipse.core.runtime.ILogListener + java:/Objects/org.osgi.framework.BundleReference + java:/Objects/org.osgi.framework.BundleListener + java:/Objects/org.osgi.framework.FrameworkListener + java:/Objects/org.osgi.framework.ServiceObjects + java:/Objects/org.osgi.framework.ServiceRegistration + java:/Objects/org.osgi.framework.ServiceFactory + java:/Objects/org.osgi.framework.BundleEvent + java:/Objects/org.osgi.framework.FrameworkEvent + java:/Objects/org.eclipse.emf.ecore.ETypedElement + java:/Objects/org.eclipse.emf.ecore.EParameter + java:/Objects/org.eclipse.emf.ecore.resource.ResourceSet + java:/Objects/org.eclipse.emf.common.notify.AdapterFactory + java:/Objects/org.eclipse.emf.ecore.resource.URIConverter + java:/Objects/java.io.InputStreamReader + java:/Objects/org.eclipse.emf.ecore.resource.ContentHandler + java:/Objects/org.eclipse.emf.ecore.resource.URIHandler + java:/Objects/sun.nio.cs.StreamDecoder + java:/Objects/java.io.FileInputStream + java:/Objects/org.eclipse.emf.common.util.EMap + java:/Objects/org.eclipse.emf.ecore.EFactory + java:/Objects/org.eclipse.emf.common.util.Enumerator + java:/Objects/org.eclipse.emf.ecore.EEnum + java:/Objects/org.eclipse.emf.ecore.util.FeatureMap + java:/Objects/org.eclipse.emf.ecore.util.InternalEList + java:/Objects/org.eclipse.emf.ecore.util.EContentsEList + java:/Objects/org.eclipse.emf.ecore.util.AbstractSequentialInternalEList + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.HostType + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.Request + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement + java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.Requirement + java:/Objects/java.lang.SuppressWarnings + java:/Objects/javax.annotation.Generated + java:/Objects/org.eclipse.viatra.query.runtime.api.GenericPatternMatcher + java:/Objects/org.eclipse.viatra.query.runtime.api.GenericPatternMatch + java:/Objects/org.eclipse.viatra.query.runtime.api.GenericQuerySpecification + java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher + java:/Objects/org.eclipse.viatra.query.runtime.matchers.aggregators.sum + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.AggregatorType + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IAggregatorFactory + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.BoundAggregator + java:/Objects/java.lang.annotation.Inherited + java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator + java:/Objects/org.eclipse.xtext.xbase.lib.ArrayLiterals + java:/Objects/com.google.common.annotations.GwtCompatible + java:/Objects/org.eclipse.xtext.xbase.lib.Pure + java:/Objects/org.eclipse.xtext.xbase.lib.Inline + java:/Objects/com.google.common.annotations.Beta + java:/Objects/org.eclipse.xtext.xbase.lib.CollectionLiterals + java:/Objects/org.eclipse.xtext.xbase.lib.Pair + java:/Objects/java.util.LinkedHashSet + java:/Objects/java.util.TreeMap + java:/Objects/java.util.TreeSet + java:/Objects/java.util.NavigableMap + java:/Objects/java.util.NavigableSet + java:/Objects/java.util.SortedSet + java:/Objects/org.eclipse.xtext.xbase.lib.InputOutput + java:/Objects/org.eclipse.xtext.xbase.lib.ArrayExtensions + java:/Objects/com.google.common.annotations.GwtIncompatible + java:/Objects/org.eclipse.xtext.xbase.lib.BigDecimalExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.BigIntegerExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.BooleanExtensions + java:/Objects/com.google.common.primitives.Booleans + java:/Objects/org.eclipse.xtext.xbase.lib.ByteExtensions + java:/Objects/java.lang.Math + java:/Objects/org.eclipse.xtext.xbase.lib.CharacterExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.CollectionExtensions + java:/Objects/com.google.common.collect.Iterables + java:/Objects/com.google.common.collect.ImmutableList + java:/Objects/com.google.common.collect.ImmutableSet + java:/Objects/com.google.common.collect.ImmutableSortedSet + java:/Objects/com.google.common.collect.ImmutableMap + java:/Objects/com.google.common.collect.ImmutableSortedMap + java:/Objects/java.util.Collections + java:/Objects/com.google.common.collect.FluentIterable + java:/Objects/com.google.common.base.Predicate + java:/Objects/com.google.common.base.Function + java:/Objects/com.google.common.base.Optional + java:/Objects/com.google.common.collect.ImmutableCollection + java:/Objects/com.google.common.collect.ImmutableListMultimap + java:/Objects/com.google.common.base.Joiner + java:/Objects/com.google.common.collect.ImmutableMultiset + java:/Objects/com.google.common.collect.ImmutableMultimap + java:/Objects/com.google.common.collect.ListMultimap + java:/Objects/com.google.common.collect.Multimap + java:/Objects/com.google.common.collect.AbstractMultimap + java:/Objects/com.google.common.collect.UnmodifiableIterator + java:/Objects/com.google.common.collect.Serialization + java:/Objects/com.google.common.collect.ImmutableSetMultimap + java:/Objects/com.google.common.collect.Multiset + java:/Objects/com.google.common.collect.Multimaps + java:/Objects/com.google.common.collect.Maps + java:/Objects/com.google.common.collect.AbstractListMultimap + java:/Objects/com.google.common.base.Supplier + java:/Objects/com.google.common.collect.AbstractMapBasedMultimap + java:/Objects/com.google.common.collect.AbstractSetMultimap + java:/Objects/com.google.common.collect.AbstractSortedSetMultimap + java:/Objects/com.google.common.collect.AbstractMultiset + java:/Objects/com.google.common.collect.Multisets + java:/Objects/com.google.common.collect.SetMultimap + java:/Objects/com.google.common.collect.ForwardingMultimap + java:/Objects/com.google.common.collect.SortedSetMultimap + java:/Objects/com.google.common.collect.FilteredMultimap + java:/Objects/com.google.common.collect.FilteredSetMultimap + java:/Objects/java.util.EnumMap + java:/Objects/com.google.common.base.Converter + java:/Objects/com.google.common.collect.BiMap + java:/Objects/com.google.common.collect.ForwardingMap + java:/Objects/com.google.common.collect.Ordering + java:/Objects/com.google.common.collect.Sets + java:/Objects/com.google.common.collect.ForwardingSet + java:/Objects/com.google.common.collect.AbstractNavigableMap + java:/Objects/com.google.common.collect.MapDifference + java:/Objects/com.google.common.collect.SortedMapDifference + java:/Objects/com.google.common.collect.ForwardingCollection + java:/Objects/com.google.common.collect.ForwardingSortedMap + java:/Objects/com.google.common.base.Equivalence + java:/Objects/java.util.IdentityHashMap + java:/Objects/com.google.common.collect.Range + java:/Objects/com.google.common.collect.ForwardingObject + java:/Objects/com.google.common.annotations.VisibleForTesting + java:/Objects/java.util.EnumSet + java:/Objects/com.google.common.collect.CartesianList + java:/Objects/com.google.common.collect.ForwardingNavigableSet + java:/Objects/com.google.common.collect.Collections2 + java:/Objects/com.google.common.collect.ForwardingSortedSet + java:/Objects/java.util.concurrent.CopyOnWriteArraySet + java:/Objects/com.google.common.collect.AbstractIterator + java:/Objects/java.util.concurrent.CopyOnWriteArrayList + java:/Objects/java.util.function.BiPredicate + java:/Objects/com.google.common.collect.Cut + java:/Objects/com.google.common.collect.DiscreteDomain + java:/Objects/com.google.common.collect.BoundType + java:/Objects/com.google.common.collect.ForwardingMultiset + java:/Objects/com.google.common.collect.SortedMultiset + java:/Objects/com.google.common.collect.SortedMultisetBridge + java:/Objects/com.google.common.collect.SortedIterable + java:/Objects/com.google.common.collect.UnmodifiableListIterator + java:/Objects/com.google.common.collect.ImmutableSortedSetFauxverideShim + java:/Objects/com.google.common.collect.RegularImmutableSortedSet + java:/Objects/com.google.common.collect.ImmutableMapEntry + java:/Objects/com.google.common.collect.ImmutableEntry + java:/Objects/com.google.common.collect.AbstractMapEntry + java:/Objects/com.google.common.collect.ImmutableSortedMapFauxverideShim + java:/Objects/java.util.AbstractQueue + java:/Objects/org.eclipse.xtext.xbase.lib.ComparableExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.DoubleExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.FloatExtensions + java:/Objects/java.lang.Float + java:/Objects/org.eclipse.xtext.xbase.lib.FunctionExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.Functions + java:/Objects/org.eclipse.xtext.xbase.lib.Procedures + java:/Objects/org.eclipse.xtext.xbase.lib.IntegerExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.ExclusiveRange + java:/Objects/org.eclipse.xtext.xbase.lib.IntegerRange + java:/Objects/org.eclipse.xtext.xbase.lib.IterableExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.IteratorExtensions + java:/Objects/com.google.common.collect.Iterators + java:/Objects/com.google.common.collect.MultitransformedIterator + java:/Objects/com.google.common.collect.PeekingIterator + java:/Objects/org.eclipse.xtext.xbase.lib.ListExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.LongExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.MapExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.internal.UnmodifiableMergingMapView + java:/Objects/org.eclipse.xtext.xbase.lib.ObjectExtensions + java:/Objects/com.google.common.base.Objects + java:/Objects/com.google.common.base.ExtraObjectsMethodsForWeb + java:/Objects/org.eclipse.xtext.xbase.lib.ProcedureExtensions + java:/Objects/org.eclipse.xtext.xbase.lib.ShortExtensions + java:/Objects/java.lang.Short + java:/Objects/org.eclipse.xtext.xbase.lib.StringExtensions + java:/Objects/org.eclipse.viatra.query.runtime.matchers.aggregators.count + java:/Objects/org.eclipse.viatra.query.runtime.matchers.aggregators.avg @@ -62,6 +1047,17 @@ + + + + bold + + + + bold + + + @@ -95,6 +1091,10 @@ + + + + @@ -383,70 +1383,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -460,7 +1396,7 @@ - + KEEP_LOCATION @@ -471,13 +1407,13 @@ - + KEEP_LOCATION KEEP_SIZE KEEP_RATIO - + @@ -497,6 +1433,14 @@ + + + + + bold + + + @@ -528,7 +1472,7 @@ - + KEEP_LOCATION @@ -603,7 +1547,7 @@ - + @@ -648,7 +1592,7 @@ - + KEEP_LOCATION @@ -693,14 +1637,17 @@ - + - - - - + + + bold + + + bold + @@ -748,76 +1695,6 @@ - - - - - strokeColor - - - labelFormat - labelSize - labelColor - - - labelFormat - labelSize - labelColor - - - - - - - - - strokeColor - - - labelSize - labelColor - - - labelSize - labelColor - - - - - - - - - strokeColor - - - labelSize - labelColor - - - labelSize - labelColor - - - - - - - - - strokeColor - - - labelSize - labelColor - - - labelSize - labelColor - - - - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore index bcf0ed99..36db23be 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore @@ -1,6 +1,9 @@ + +
+ @@ -10,18 +13,24 @@ eType="#//HostType" containment="true"/> + derived="true"> + +
+ + + derived="true"> + +
+ + - - + - + - - + changeable="false" volatile="true" transient="true" derived="true"> + +
+ + + changeable="false" volatile="true" transient="true" derived="true"> + +
+ + + changeable="false" volatile="true" transient="true" derived="true"> + +
+ + + changeable="false" volatile="true" transient="true" derived="true"> + +
+ + - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel index 679e2c49..a0ccec7f 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel @@ -21,13 +21,12 @@ - - + @@ -42,7 +41,6 @@ - @@ -56,7 +54,6 @@ - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.properties b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.properties new file mode 100644 index 00000000..aa7cf04c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName = hu.bme.mit.inf.dslreasoner.domains.cps +providerName = www.example.org diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml new file mode 100644 index 00000000..256b967d --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore new file mode 100644 index 00000000..bd8f7d9f --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore @@ -0,0 +1,16 @@ +/.CpsApplications.java._trace +/.CpsQueries.java._trace +/.CpsHosts.java._trace +/.TotalMemory.java._trace +/.TotalHdd.java._trace +/.AvailableMemory.java._trace +/.AvailableHdd.java._trace +/.AllocationWithoutResourceRequirement.java._trace +/.NotEnoughAvailableMemory.java._trace +/.NotEnoughAvailableHdd.java._trace +/.InstanceDoesNotSatisfyRequirement.java._trace +/.RequirementNotSatisfied.java._trace +/.AverageFreeMemoryMetric.java._trace +/.AverageFreeHddMetric.java._trace +/.CostMetric.java._trace +/.CpsCost.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java new file mode 100644 index 00000000..be7488b6 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java @@ -0,0 +1,717 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; +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.emf.ecore.EClass; +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.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.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +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.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.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: + *

+ *         {@literal @}Constraint(severity = "error", key = {Host, App},
+ *         	message = "Application instance must be allocated to a supported host type.")
+ *         pattern allocationWithoutResourceRequirement(Host : HostInstance, App : ApplicationInstance) {
+ *         	ApplicationInstance.allocatedTo(App, Host);
+ *         	neg find resourceRequirement(Host, App, _);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class AllocationWithoutResourceRequirement extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement 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 HostInstance fHost; + + private ApplicationInstance fApp; + + private static List parameterNames = makeImmutableList("Host", "App"); + + private Match(final HostInstance pHost, final ApplicationInstance pApp) { + this.fHost = pHost; + this.fApp = pApp; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + if ("App".equals(parameterName)) return this.fApp; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + public ApplicationInstance getApp() { + return this.fApp; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + if ("App".equals(parameterName) ) { + this.fApp = (ApplicationInstance) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + public void setApp(final ApplicationInstance pApp) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fApp = pApp; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement"; + } + + @Override + public List parameterNames() { + return AllocationWithoutResourceRequirement.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost, fApp}; + } + + @Override + public AllocationWithoutResourceRequirement.Match toImmutable() { + return isMutable() ? newMatch(fHost, fApp) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); + result.append("\"App\"=" + prettyPrintValue(fApp)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost, fApp); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof AllocationWithoutResourceRequirement.Match)) { + AllocationWithoutResourceRequirement.Match other = (AllocationWithoutResourceRequirement.Match) obj; + return Objects.equals(fHost, other.fHost) && Objects.equals(fApp, other.fApp); + } 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 AllocationWithoutResourceRequirement specification() { + return AllocationWithoutResourceRequirement.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 AllocationWithoutResourceRequirement.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static AllocationWithoutResourceRequirement.Match newMutableMatch(final HostInstance pHost, final ApplicationInstance pApp) { + return new Mutable(pHost, pApp); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the (partial) match object. + * + */ + public static AllocationWithoutResourceRequirement.Match newMatch(final HostInstance pHost, final ApplicationInstance pApp) { + return new Immutable(pHost, pApp); + } + + private static final class Mutable extends AllocationWithoutResourceRequirement.Match { + Mutable(final HostInstance pHost, final ApplicationInstance pApp) { + super(pHost, pApp); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends AllocationWithoutResourceRequirement.Match { + Immutable(final HostInstance pHost, final ApplicationInstance pApp) { + super(pHost, pApp); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement 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: + *

+   * {@literal @}Constraint(severity = "error", key = {Host, App},
+   * 	message = "Application instance must be allocated to a supported host type.")
+   * pattern allocationWithoutResourceRequirement(Host : HostInstance, App : ApplicationInstance) {
+   * 	ApplicationInstance.allocatedTo(App, Host);
+   * 	neg find resourceRequirement(Host, App, _);
+   * }
+   * 
+ * + * @see Match + * @see AllocationWithoutResourceRequirement + * + */ + 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 AllocationWithoutResourceRequirement.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 AllocationWithoutResourceRequirement.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final int POSITION_APP = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AllocationWithoutResourceRequirement.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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost, final ApplicationInstance pApp) { + return rawStreamAllMatches(new Object[]{pHost, pApp}).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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost, final ApplicationInstance pApp) { + return rawStreamAllMatches(new Object[]{pHost, pApp}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost, final ApplicationInstance pApp) { + return rawGetOneArbitraryMatch(new Object[]{pHost, pApp}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost, final ApplicationInstance pApp) { + return rawHasMatch(new Object[]{pHost, pApp}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost, final ApplicationInstance pApp) { + return rawCountMatches(new Object[]{pHost, pApp}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, 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 HostInstance pHost, final ApplicationInstance pApp, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost, pApp}, 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the (partial) match object. + * + */ + public AllocationWithoutResourceRequirement.Match newMatch(final HostInstance pHost, final ApplicationInstance pApp) { + return AllocationWithoutResourceRequirement.Match.newMatch(pHost, pApp); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final AllocationWithoutResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final ApplicationInstance pApp) { + return rawStreamAllValuesOfHost(new Object[]{null, pApp}); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final AllocationWithoutResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final ApplicationInstance pApp) { + return rawStreamAllValuesOfHost(new Object[]{null, pApp}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfApp(final Object[] parameters) { + return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for App. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp(final AllocationWithoutResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfApp(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for App. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp(final HostInstance pHost) { + return rawStreamAllValuesOfApp(new Object[]{pHost, null}); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp(final AllocationWithoutResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfApp(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp(final HostInstance pHost) { + return rawStreamAllValuesOfApp(new Object[]{pHost, null}).collect(Collectors.toSet()); + } + + @Override + protected AllocationWithoutResourceRequirement.Match tupleToMatch(final Tuple t) { + try { + return AllocationWithoutResourceRequirement.Match.newMatch((HostInstance) t.get(POSITION_HOST), (ApplicationInstance) t.get(POSITION_APP)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected AllocationWithoutResourceRequirement.Match arrayToMatch(final Object[] match) { + try { + return AllocationWithoutResourceRequirement.Match.newMatch((HostInstance) match[POSITION_HOST], (ApplicationInstance) match[POSITION_APP]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected AllocationWithoutResourceRequirement.Match arrayToMatchMutable(final Object[] match) { + try { + return AllocationWithoutResourceRequirement.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (ApplicationInstance) match[POSITION_APP]); + } 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 AllocationWithoutResourceRequirement.instance(); + } + } + + private AllocationWithoutResourceRequirement() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AllocationWithoutResourceRequirement instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected AllocationWithoutResourceRequirement.Matcher instantiate(final ViatraQueryEngine engine) { + return AllocationWithoutResourceRequirement.Matcher.on(engine); + } + + @Override + public AllocationWithoutResourceRequirement.Matcher instantiate() { + return AllocationWithoutResourceRequirement.Matcher.create(); + } + + @Override + public AllocationWithoutResourceRequirement.Match newEmptyMatch() { + return AllocationWithoutResourceRequirement.Match.newEmptyMatch(); + } + + @Override + public AllocationWithoutResourceRequirement.Match newMatch(final Object... parameters) { + return AllocationWithoutResourceRequirement.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement (visibility: PUBLIC, simpleName: AllocationWithoutResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.AllocationWithoutResourceRequirement (visibility: PUBLIC, simpleName: AllocationWithoutResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final AllocationWithoutResourceRequirement INSTANCE = new AllocationWithoutResourceRequirement(); + + /** + * 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 AllocationWithoutResourceRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_App); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocationWithoutResourceRequirement"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","App"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_App = body.getOrCreateVariableByName("App"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_App, parameter_App) + )); + // ApplicationInstance.allocatedTo(App, Host) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new Equality(body, var__virtual_0_, var_Host); + // neg find resourceRequirement(Host, App, _) + new NegativePatternCall(body, Tuples.flatTupleOf(var_Host, var_App, var___0_), ResourceRequirement.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("Host"), + new ParameterReference("App") + })); + annotation.addAttribute("message", "Application instance must be allocated to a supported host type."); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java new file mode 100644 index 00000000..22821c4a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java @@ -0,0 +1,743 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement; +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.emf.ecore.EClass; +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.emf.types.EClassTransitiveInstancesKey; +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.annotations.PAnnotation; +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.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: + *

+ *         {@literal @}QueryBasedFeature(feature = "availableHdd")
+ *         pattern availableHdd(Host : HostInstance, Hdd : java Integer) {
+ *         	find totalHdd(Host, TotalHdd);
+ *         	RequiredHdd == sum find hddRequirement(Host, _, #_);
+ *         	Hdd == eval(TotalHdd - RequiredHdd);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class AvailableHdd extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd 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 HostInstance fHost; + + private Integer fHdd; + + private static List parameterNames = makeImmutableList("Host", "Hdd"); + + private Match(final HostInstance pHost, final Integer pHdd) { + this.fHost = pHost; + this.fHdd = pHdd; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + if ("Hdd".equals(parameterName)) return this.fHdd; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + public Integer getHdd() { + return this.fHdd; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + if ("Hdd".equals(parameterName) ) { + this.fHdd = (Integer) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + public void setHdd(final Integer pHdd) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHdd = pHdd; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd"; + } + + @Override + public List parameterNames() { + return AvailableHdd.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost, fHdd}; + } + + @Override + public AvailableHdd.Match toImmutable() { + return isMutable() ? newMatch(fHost, fHdd) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); + result.append("\"Hdd\"=" + prettyPrintValue(fHdd)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost, fHdd); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof AvailableHdd.Match)) { + AvailableHdd.Match other = (AvailableHdd.Match) obj; + return Objects.equals(fHost, other.fHost) && Objects.equals(fHdd, other.fHdd); + } 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 AvailableHdd specification() { + return AvailableHdd.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 AvailableHdd.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static AvailableHdd.Match newMutableMatch(final HostInstance pHost, final Integer pHdd) { + return new Mutable(pHost, pHdd); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the (partial) match object. + * + */ + public static AvailableHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) { + return new Immutable(pHost, pHdd); + } + + private static final class Mutable extends AvailableHdd.Match { + Mutable(final HostInstance pHost, final Integer pHdd) { + super(pHost, pHdd); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends AvailableHdd.Match { + Immutable(final HostInstance pHost, final Integer pHdd) { + super(pHost, pHdd); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd 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: + *

+   * {@literal @}QueryBasedFeature(feature = "availableHdd")
+   * pattern availableHdd(Host : HostInstance, Hdd : java Integer) {
+   * 	find totalHdd(Host, TotalHdd);
+   * 	RequiredHdd == sum find hddRequirement(Host, _, #_);
+   * 	Hdd == eval(TotalHdd - RequiredHdd);
+   * }
+   * 
+ * + * @see Match + * @see AvailableHdd + * + */ + 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 AvailableHdd.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 AvailableHdd.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final int POSITION_HDD = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AvailableHdd.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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost, final Integer pHdd) { + return rawStreamAllMatches(new Object[]{pHost, pHdd}).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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost, final Integer pHdd) { + return rawStreamAllMatches(new Object[]{pHost, pHdd}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost, final Integer pHdd) { + return rawGetOneArbitraryMatch(new Object[]{pHost, pHdd}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost, final Integer pHdd) { + return rawHasMatch(new Object[]{pHost, pHdd}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost, final Integer pHdd) { + return rawCountMatches(new Object[]{pHost, pHdd}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, 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 HostInstance pHost, final Integer pHdd, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost, pHdd}, 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the (partial) match object. + * + */ + public AvailableHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) { + return AvailableHdd.Match.newMatch(pHost, pHdd); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final AvailableHdd.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final Integer pHdd) { + return rawStreamAllValuesOfHost(new Object[]{null, pHdd}); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final AvailableHdd.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final Integer pHdd) { + return rawStreamAllValuesOfHost(new Object[]{null, pHdd}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHdd(final Object[] parameters) { + return rawStreamAllValues(POSITION_HDD, parameters).map(Integer.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHdd() { + return rawStreamAllValuesOfHdd(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHdd() { + return rawStreamAllValuesOfHdd(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHdd(final AvailableHdd.Match partialMatch) { + return rawStreamAllValuesOfHdd(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHdd(final HostInstance pHost) { + return rawStreamAllValuesOfHdd(new Object[]{pHost, null}); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHdd(final AvailableHdd.Match partialMatch) { + return rawStreamAllValuesOfHdd(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHdd(final HostInstance pHost) { + return rawStreamAllValuesOfHdd(new Object[]{pHost, null}).collect(Collectors.toSet()); + } + + @Override + protected AvailableHdd.Match tupleToMatch(final Tuple t) { + try { + return AvailableHdd.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_HDD)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected AvailableHdd.Match arrayToMatch(final Object[] match) { + try { + return AvailableHdd.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected AvailableHdd.Match arrayToMatchMutable(final Object[] match) { + try { + return AvailableHdd.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]); + } 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 AvailableHdd.instance(); + } + } + + private AvailableHdd() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AvailableHdd instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected AvailableHdd.Matcher instantiate(final ViatraQueryEngine engine) { + return AvailableHdd.Matcher.on(engine); + } + + @Override + public AvailableHdd.Matcher instantiate() { + return AvailableHdd.Matcher.create(); + } + + @Override + public AvailableHdd.Match newEmptyMatch() { + return AvailableHdd.Match.newEmptyMatch(); + } + + @Override + public AvailableHdd.Match newMatch(final Object... parameters) { + return AvailableHdd.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd (visibility: PUBLIC, simpleName: AvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.AvailableHdd (visibility: PUBLIC, simpleName: AvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final AvailableHdd INSTANCE = new AvailableHdd(); + + /** + * 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 AvailableHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Hdd); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Hdd"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); + PVariable var_TotalHdd = body.getOrCreateVariableByName("TotalHdd"); + PVariable var_RequiredHdd = body.getOrCreateVariableByName("RequiredHdd"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Hdd), new JavaTransitiveInstancesKey(java.lang.Integer.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Hdd, parameter_Hdd) + )); + // find totalHdd(Host, TotalHdd) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_TotalHdd), TotalHdd.instance().getInternalQueryRepresentation()); + // RequiredHdd == sum find hddRequirement(Host, _, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Host, var___0_, var___1_), HddRequirement.instance().getInternalQueryRepresentation(), var__virtual_0_, 2); + new Equality(body, var_RequiredHdd, var__virtual_0_); + // Hdd == eval(TotalHdd - RequiredHdd) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern availableHdd"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("RequiredHdd", "TotalHdd");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer RequiredHdd = (Integer) provider.getValue("RequiredHdd"); + Integer TotalHdd = (Integer) provider.getValue("TotalHdd"); + return evaluateExpression_1_1(RequiredHdd, TotalHdd); + } + }, var__virtual_1_ ); + new Equality(body, var_Hdd, var__virtual_1_); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("QueryBasedFeature"); + annotation.addAttribute("feature", "availableHdd"); + addAnnotation(annotation); + } + return bodies; + } + } + + private static int evaluateExpression_1_1(final Integer RequiredHdd, final Integer TotalHdd) { + return ((TotalHdd).intValue() - (RequiredHdd).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java new file mode 100644 index 00000000..930a24ba --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java @@ -0,0 +1,743 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement; +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.emf.ecore.EClass; +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.emf.types.EClassTransitiveInstancesKey; +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.annotations.PAnnotation; +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.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: + *

+ *         {@literal @}QueryBasedFeature(feature = "availableMemory")
+ *         pattern availableMemory(Host : HostInstance, Memory : java Integer) {
+ *         	find totalMemory(Host, TotalMemory);
+ *         	RequiredMemory == sum find memoryRequirement(Host, _, #_);
+ *         	Memory == eval(TotalMemory - RequiredMemory);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class AvailableMemory extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory 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 HostInstance fHost; + + private Integer fMemory; + + private static List parameterNames = makeImmutableList("Host", "Memory"); + + private Match(final HostInstance pHost, final Integer pMemory) { + this.fHost = pHost; + this.fMemory = pMemory; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + if ("Memory".equals(parameterName)) return this.fMemory; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + public Integer getMemory() { + return this.fMemory; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + if ("Memory".equals(parameterName) ) { + this.fMemory = (Integer) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + public void setMemory(final Integer pMemory) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fMemory = pMemory; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory"; + } + + @Override + public List parameterNames() { + return AvailableMemory.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost, fMemory}; + } + + @Override + public AvailableMemory.Match toImmutable() { + return isMutable() ? newMatch(fHost, fMemory) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); + result.append("\"Memory\"=" + prettyPrintValue(fMemory)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost, fMemory); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof AvailableMemory.Match)) { + AvailableMemory.Match other = (AvailableMemory.Match) obj; + return Objects.equals(fHost, other.fHost) && Objects.equals(fMemory, other.fMemory); + } 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 AvailableMemory specification() { + return AvailableMemory.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 AvailableMemory.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static AvailableMemory.Match newMutableMatch(final HostInstance pHost, final Integer pMemory) { + return new Mutable(pHost, pMemory); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the (partial) match object. + * + */ + public static AvailableMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) { + return new Immutable(pHost, pMemory); + } + + private static final class Mutable extends AvailableMemory.Match { + Mutable(final HostInstance pHost, final Integer pMemory) { + super(pHost, pMemory); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends AvailableMemory.Match { + Immutable(final HostInstance pHost, final Integer pMemory) { + super(pHost, pMemory); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory 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: + *

+   * {@literal @}QueryBasedFeature(feature = "availableMemory")
+   * pattern availableMemory(Host : HostInstance, Memory : java Integer) {
+   * 	find totalMemory(Host, TotalMemory);
+   * 	RequiredMemory == sum find memoryRequirement(Host, _, #_);
+   * 	Memory == eval(TotalMemory - RequiredMemory);
+   * }
+   * 
+ * + * @see Match + * @see AvailableMemory + * + */ + 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 AvailableMemory.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 AvailableMemory.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final int POSITION_MEMORY = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AvailableMemory.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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost, final Integer pMemory) { + return rawStreamAllMatches(new Object[]{pHost, pMemory}).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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost, final Integer pMemory) { + return rawStreamAllMatches(new Object[]{pHost, pMemory}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost, final Integer pMemory) { + return rawGetOneArbitraryMatch(new Object[]{pHost, pMemory}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost, final Integer pMemory) { + return rawHasMatch(new Object[]{pHost, pMemory}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost, final Integer pMemory) { + return rawCountMatches(new Object[]{pHost, pMemory}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, 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 HostInstance pHost, final Integer pMemory, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost, pMemory}, 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the (partial) match object. + * + */ + public AvailableMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) { + return AvailableMemory.Match.newMatch(pHost, pMemory); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final AvailableMemory.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final Integer pMemory) { + return rawStreamAllValuesOfHost(new Object[]{null, pMemory}); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final AvailableMemory.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final Integer pMemory) { + return rawStreamAllValuesOfHost(new Object[]{null, pMemory}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfMemory(final Object[] parameters) { + return rawStreamAllValues(POSITION_MEMORY, parameters).map(Integer.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfMemory() { + return rawStreamAllValuesOfMemory(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfMemory() { + return rawStreamAllValuesOfMemory(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfMemory(final AvailableMemory.Match partialMatch) { + return rawStreamAllValuesOfMemory(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfMemory(final HostInstance pHost) { + return rawStreamAllValuesOfMemory(new Object[]{pHost, null}); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfMemory(final AvailableMemory.Match partialMatch) { + return rawStreamAllValuesOfMemory(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfMemory(final HostInstance pHost) { + return rawStreamAllValuesOfMemory(new Object[]{pHost, null}).collect(Collectors.toSet()); + } + + @Override + protected AvailableMemory.Match tupleToMatch(final Tuple t) { + try { + return AvailableMemory.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_MEMORY)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected AvailableMemory.Match arrayToMatch(final Object[] match) { + try { + return AvailableMemory.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected AvailableMemory.Match arrayToMatchMutable(final Object[] match) { + try { + return AvailableMemory.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]); + } 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 AvailableMemory.instance(); + } + } + + private AvailableMemory() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AvailableMemory instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected AvailableMemory.Matcher instantiate(final ViatraQueryEngine engine) { + return AvailableMemory.Matcher.on(engine); + } + + @Override + public AvailableMemory.Matcher instantiate() { + return AvailableMemory.Matcher.create(); + } + + @Override + public AvailableMemory.Match newEmptyMatch() { + return AvailableMemory.Match.newEmptyMatch(); + } + + @Override + public AvailableMemory.Match newMatch(final Object... parameters) { + return AvailableMemory.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory (visibility: PUBLIC, simpleName: AvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.AvailableMemory (visibility: PUBLIC, simpleName: AvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final AvailableMemory INSTANCE = new AvailableMemory(); + + /** + * 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 AvailableMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Memory); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Memory"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Memory = body.getOrCreateVariableByName("Memory"); + PVariable var_TotalMemory = body.getOrCreateVariableByName("TotalMemory"); + PVariable var_RequiredMemory = body.getOrCreateVariableByName("RequiredMemory"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Memory), new JavaTransitiveInstancesKey(java.lang.Integer.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Memory, parameter_Memory) + )); + // find totalMemory(Host, TotalMemory) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_TotalMemory), TotalMemory.instance().getInternalQueryRepresentation()); + // RequiredMemory == sum find memoryRequirement(Host, _, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Host, var___0_, var___1_), MemoryRequirement.instance().getInternalQueryRepresentation(), var__virtual_0_, 2); + new Equality(body, var_RequiredMemory, var__virtual_0_); + // Memory == eval(TotalMemory - RequiredMemory) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern availableMemory"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("RequiredMemory", "TotalMemory");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer RequiredMemory = (Integer) provider.getValue("RequiredMemory"); + Integer TotalMemory = (Integer) provider.getValue("TotalMemory"); + return evaluateExpression_1_1(RequiredMemory, TotalMemory); + } + }, var__virtual_1_ ); + new Equality(body, var_Memory, var__virtual_1_); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("QueryBasedFeature"); + annotation.addAttribute("feature", "availableMemory"); + addAnnotation(annotation); + } + return bodies; + } + } + + private static int evaluateExpression_1_1(final Integer RequiredMemory, final Integer TotalMemory) { + return ((TotalMemory).intValue() - (RequiredMemory).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java new file mode 100644 index 00000000..59d4ad27 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java @@ -0,0 +1,540 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage; +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.avg; +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: + *

+ *         pattern averageFreeHddMetric(Average : java Double) {
+ *         	Average == avg find freeHddPercentage(_, #_);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class AverageFreeHddMetric extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric 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 fAverage; + + private static List parameterNames = makeImmutableList("Average"); + + private Match(final Double pAverage) { + this.fAverage = pAverage; + } + + @Override + public Object get(final String parameterName) { + if ("Average".equals(parameterName)) return this.fAverage; + return null; + } + + public Double getAverage() { + return this.fAverage; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Average".equals(parameterName) ) { + this.fAverage = (Double) newValue; + return true; + } + return false; + } + + public void setAverage(final Double pAverage) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fAverage = pAverage; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric"; + } + + @Override + public List parameterNames() { + return AverageFreeHddMetric.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fAverage}; + } + + @Override + public AverageFreeHddMetric.Match toImmutable() { + return isMutable() ? newMatch(fAverage) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Average\"=" + prettyPrintValue(fAverage)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fAverage); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof AverageFreeHddMetric.Match)) { + AverageFreeHddMetric.Match other = (AverageFreeHddMetric.Match) obj; + return Objects.equals(fAverage, other.fAverage); + } 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 AverageFreeHddMetric specification() { + return AverageFreeHddMetric.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 AverageFreeHddMetric.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 pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static AverageFreeHddMetric.Match newMutableMatch(final Double pAverage) { + return new Mutable(pAverage); + } + + /** + * 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 pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the (partial) match object. + * + */ + public static AverageFreeHddMetric.Match newMatch(final Double pAverage) { + return new Immutable(pAverage); + } + + private static final class Mutable extends AverageFreeHddMetric.Match { + Mutable(final Double pAverage) { + super(pAverage); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends AverageFreeHddMetric.Match { + Immutable(final Double pAverage) { + super(pAverage); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric 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: + *

+   * pattern averageFreeHddMetric(Average : java Double) {
+   * 	Average == avg find freeHddPercentage(_, #_);
+   * }
+   * 
+ * + * @see Match + * @see AverageFreeHddMetric + * + */ + 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 AverageFreeHddMetric.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 AverageFreeHddMetric.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_AVERAGE = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AverageFreeHddMetric.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 pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Double pAverage) { + return rawStreamAllMatches(new Object[]{pAverage}).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 pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Double pAverage) { + return rawStreamAllMatches(new Object[]{pAverage}); + } + + /** + * 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 pAverage the fixed value of pattern parameter Average, 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 pAverage) { + return rawGetOneArbitraryMatch(new Object[]{pAverage}); + } + + /** + * 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 pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Double pAverage) { + return rawHasMatch(new Object[]{pAverage}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Double pAverage) { + return rawCountMatches(new Object[]{pAverage}); + } + + /** + * 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 pAverage the fixed value of pattern parameter Average, 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 pAverage, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pAverage}, 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 pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the (partial) match object. + * + */ + public AverageFreeHddMetric.Match newMatch(final Double pAverage) { + return AverageFreeHddMetric.Match.newMatch(pAverage); + } + + /** + * Retrieve the set of values that occur in matches for Average. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfAverage(final Object[] parameters) { + return rawStreamAllValues(POSITION_AVERAGE, parameters).map(Double.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Average. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfAverage() { + return rawStreamAllValuesOfAverage(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Average. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfAverage() { + return rawStreamAllValuesOfAverage(emptyArray()); + } + + @Override + protected AverageFreeHddMetric.Match tupleToMatch(final Tuple t) { + try { + return AverageFreeHddMetric.Match.newMatch((Double) t.get(POSITION_AVERAGE)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected AverageFreeHddMetric.Match arrayToMatch(final Object[] match) { + try { + return AverageFreeHddMetric.Match.newMatch((Double) match[POSITION_AVERAGE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected AverageFreeHddMetric.Match arrayToMatchMutable(final Object[] match) { + try { + return AverageFreeHddMetric.Match.newMutableMatch((Double) match[POSITION_AVERAGE]); + } 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 AverageFreeHddMetric.instance(); + } + } + + private AverageFreeHddMetric() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AverageFreeHddMetric instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected AverageFreeHddMetric.Matcher instantiate(final ViatraQueryEngine engine) { + return AverageFreeHddMetric.Matcher.on(engine); + } + + @Override + public AverageFreeHddMetric.Matcher instantiate() { + return AverageFreeHddMetric.Matcher.create(); + } + + @Override + public AverageFreeHddMetric.Match newEmptyMatch() { + return AverageFreeHddMetric.Match.newEmptyMatch(); + } + + @Override + public AverageFreeHddMetric.Match newMatch(final Object... parameters) { + return AverageFreeHddMetric.Match.newMatch((java.lang.Double) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric (visibility: PUBLIC, simpleName: AverageFreeHddMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.AverageFreeHddMetric (visibility: PUBLIC, simpleName: AverageFreeHddMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final AverageFreeHddMetric INSTANCE = new AverageFreeHddMetric(); + + /** + * 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 AverageFreeHddMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Average = new PParameter("Average", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Average); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Average"); + } + + @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_Average = body.getOrCreateVariableByName("Average"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Average), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Average, parameter_Average) + )); + // Average == avg find freeHddPercentage(_, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new avg().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), FreeHddPercentage.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); + new Equality(body, var_Average, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java new file mode 100644 index 00000000..a0d087f4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java @@ -0,0 +1,540 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage; +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.avg; +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: + *

+ *         pattern averageFreeMemoryMetric(Average : java Double) {
+ *         	Average == avg find freeMemoryPercentage(_, #_);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class AverageFreeMemoryMetric extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric 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 fAverage; + + private static List parameterNames = makeImmutableList("Average"); + + private Match(final Double pAverage) { + this.fAverage = pAverage; + } + + @Override + public Object get(final String parameterName) { + if ("Average".equals(parameterName)) return this.fAverage; + return null; + } + + public Double getAverage() { + return this.fAverage; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Average".equals(parameterName) ) { + this.fAverage = (Double) newValue; + return true; + } + return false; + } + + public void setAverage(final Double pAverage) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fAverage = pAverage; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric"; + } + + @Override + public List parameterNames() { + return AverageFreeMemoryMetric.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fAverage}; + } + + @Override + public AverageFreeMemoryMetric.Match toImmutable() { + return isMutable() ? newMatch(fAverage) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Average\"=" + prettyPrintValue(fAverage)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fAverage); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof AverageFreeMemoryMetric.Match)) { + AverageFreeMemoryMetric.Match other = (AverageFreeMemoryMetric.Match) obj; + return Objects.equals(fAverage, other.fAverage); + } 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 AverageFreeMemoryMetric specification() { + return AverageFreeMemoryMetric.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 AverageFreeMemoryMetric.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 pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static AverageFreeMemoryMetric.Match newMutableMatch(final Double pAverage) { + return new Mutable(pAverage); + } + + /** + * 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 pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the (partial) match object. + * + */ + public static AverageFreeMemoryMetric.Match newMatch(final Double pAverage) { + return new Immutable(pAverage); + } + + private static final class Mutable extends AverageFreeMemoryMetric.Match { + Mutable(final Double pAverage) { + super(pAverage); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends AverageFreeMemoryMetric.Match { + Immutable(final Double pAverage) { + super(pAverage); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric 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: + *

+   * pattern averageFreeMemoryMetric(Average : java Double) {
+   * 	Average == avg find freeMemoryPercentage(_, #_);
+   * }
+   * 
+ * + * @see Match + * @see AverageFreeMemoryMetric + * + */ + 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 AverageFreeMemoryMetric.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 AverageFreeMemoryMetric.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_AVERAGE = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AverageFreeMemoryMetric.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 pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Double pAverage) { + return rawStreamAllMatches(new Object[]{pAverage}).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 pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Double pAverage) { + return rawStreamAllMatches(new Object[]{pAverage}); + } + + /** + * 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 pAverage the fixed value of pattern parameter Average, 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 pAverage) { + return rawGetOneArbitraryMatch(new Object[]{pAverage}); + } + + /** + * 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 pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Double pAverage) { + return rawHasMatch(new Object[]{pAverage}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Double pAverage) { + return rawCountMatches(new Object[]{pAverage}); + } + + /** + * 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 pAverage the fixed value of pattern parameter Average, 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 pAverage, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pAverage}, 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 pAverage the fixed value of pattern parameter Average, or null if not bound. + * @return the (partial) match object. + * + */ + public AverageFreeMemoryMetric.Match newMatch(final Double pAverage) { + return AverageFreeMemoryMetric.Match.newMatch(pAverage); + } + + /** + * Retrieve the set of values that occur in matches for Average. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfAverage(final Object[] parameters) { + return rawStreamAllValues(POSITION_AVERAGE, parameters).map(Double.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Average. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfAverage() { + return rawStreamAllValuesOfAverage(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Average. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfAverage() { + return rawStreamAllValuesOfAverage(emptyArray()); + } + + @Override + protected AverageFreeMemoryMetric.Match tupleToMatch(final Tuple t) { + try { + return AverageFreeMemoryMetric.Match.newMatch((Double) t.get(POSITION_AVERAGE)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected AverageFreeMemoryMetric.Match arrayToMatch(final Object[] match) { + try { + return AverageFreeMemoryMetric.Match.newMatch((Double) match[POSITION_AVERAGE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected AverageFreeMemoryMetric.Match arrayToMatchMutable(final Object[] match) { + try { + return AverageFreeMemoryMetric.Match.newMutableMatch((Double) match[POSITION_AVERAGE]); + } 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 AverageFreeMemoryMetric.instance(); + } + } + + private AverageFreeMemoryMetric() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AverageFreeMemoryMetric instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected AverageFreeMemoryMetric.Matcher instantiate(final ViatraQueryEngine engine) { + return AverageFreeMemoryMetric.Matcher.on(engine); + } + + @Override + public AverageFreeMemoryMetric.Matcher instantiate() { + return AverageFreeMemoryMetric.Matcher.create(); + } + + @Override + public AverageFreeMemoryMetric.Match newEmptyMatch() { + return AverageFreeMemoryMetric.Match.newEmptyMatch(); + } + + @Override + public AverageFreeMemoryMetric.Match newMatch(final Object... parameters) { + return AverageFreeMemoryMetric.Match.newMatch((java.lang.Double) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric (visibility: PUBLIC, simpleName: AverageFreeMemoryMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.AverageFreeMemoryMetric (visibility: PUBLIC, simpleName: AverageFreeMemoryMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final AverageFreeMemoryMetric INSTANCE = new AverageFreeMemoryMetric(); + + /** + * 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 AverageFreeMemoryMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Average = new PParameter("Average", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Average); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeMemoryMetric"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Average"); + } + + @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_Average = body.getOrCreateVariableByName("Average"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Average), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Average, parameter_Average) + )); + // Average == avg find freeMemoryPercentage(_, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new avg().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), FreeMemoryPercentage.instance().getInternalQueryRepresentation(), var__virtual_0_, 1); + new Equality(body, var_Average, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java new file mode 100644 index 00000000..4d8ca4cc --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java @@ -0,0 +1,540 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; +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: + *

+ *         pattern costMetric(Cost : java Integer) {
+ *         	Cost == sum find cpsCost(_, #_);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class CostMetric extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.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 Integer fCost; + + private static List parameterNames = makeImmutableList("Cost"); + + private Match(final Integer pCost) { + this.fCost = pCost; + } + + @Override + public Object get(final String parameterName) { + if ("Cost".equals(parameterName)) return this.fCost; + return null; + } + + public Integer 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 = (Integer) newValue; + return true; + } + return false; + } + + public void setCost(final Integer pCost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fCost = pCost; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.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 Integer 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 Integer pCost) { + return new Immutable(pCost); + } + + private static final class Mutable extends CostMetric.Match { + Mutable(final Integer pCost) { + super(pCost); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends CostMetric.Match { + Immutable(final Integer pCost) { + super(pCost); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.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: + *

+   * pattern costMetric(Cost : java Integer) {
+   * 	Cost == sum find cpsCost(_, #_);
+   * }
+   * 
+ * + * @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 Integer 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 Integer 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 Integer 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 Integer 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 Integer 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 Integer 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 Integer 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(Integer.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((Integer) 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((Integer) 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((Integer) 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.Integer) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric (visibility: PUBLIC, simpleName: CostMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.CostMetric (visibility: PUBLIC, simpleName: CostMetric, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.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.cps.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.Integer.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // Cost == sum find cpsCost(_, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var___0_, var___1_), CpsCost.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.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java new file mode 100644 index 00000000..2c20b38e --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java @@ -0,0 +1,705 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +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.emf.ecore.EClass; +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.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.annotations.PAnnotation; +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.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: + *

+ *         {@literal @}QueryBasedFeature(feature = "applications")
+ *         pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) {
+ *         	CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class CpsApplications extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications 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 CyberPhysicalSystem fCps; + + private ApplicationInstance fAppInstance; + + private static List parameterNames = makeImmutableList("Cps", "AppInstance"); + + private Match(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + this.fCps = pCps; + this.fAppInstance = pAppInstance; + } + + @Override + public Object get(final String parameterName) { + if ("Cps".equals(parameterName)) return this.fCps; + if ("AppInstance".equals(parameterName)) return this.fAppInstance; + return null; + } + + public CyberPhysicalSystem getCps() { + return this.fCps; + } + + public ApplicationInstance getAppInstance() { + return this.fAppInstance; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Cps".equals(parameterName) ) { + this.fCps = (CyberPhysicalSystem) newValue; + return true; + } + if ("AppInstance".equals(parameterName) ) { + this.fAppInstance = (ApplicationInstance) newValue; + return true; + } + return false; + } + + public void setCps(final CyberPhysicalSystem pCps) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fCps = pCps; + } + + public void setAppInstance(final ApplicationInstance pAppInstance) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fAppInstance = pAppInstance; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications"; + } + + @Override + public List parameterNames() { + return CpsApplications.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fCps, fAppInstance}; + } + + @Override + public CpsApplications.Match toImmutable() { + return isMutable() ? newMatch(fCps, fAppInstance) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Cps\"=" + prettyPrintValue(fCps) + ", "); + result.append("\"AppInstance\"=" + prettyPrintValue(fAppInstance)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fCps, fAppInstance); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof CpsApplications.Match)) { + CpsApplications.Match other = (CpsApplications.Match) obj; + return Objects.equals(fCps, other.fCps) && Objects.equals(fAppInstance, other.fAppInstance); + } 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 CpsApplications specification() { + return CpsApplications.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 CpsApplications.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static CpsApplications.Match newMutableMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return new Mutable(pCps, pAppInstance); + } + + /** + * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return the (partial) match object. + * + */ + public static CpsApplications.Match newMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return new Immutable(pCps, pAppInstance); + } + + private static final class Mutable extends CpsApplications.Match { + Mutable(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + super(pCps, pAppInstance); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends CpsApplications.Match { + Immutable(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + super(pCps, pAppInstance); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications 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: + *

+   * {@literal @}QueryBasedFeature(feature = "applications")
+   * pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) {
+   * 	CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance);
+   * }
+   * 
+ * + * @see Match + * @see CpsApplications + * + */ + 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 CpsApplications.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 CpsApplications.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_CPS = 0; + + private static final int POSITION_APPINSTANCE = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CpsApplications.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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return rawStreamAllMatches(new Object[]{pCps, pAppInstance}).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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return rawStreamAllMatches(new Object[]{pCps, pAppInstance}); + } + + /** + * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return rawGetOneArbitraryMatch(new Object[]{pCps, pAppInstance}); + } + + /** + * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return rawHasMatch(new Object[]{pCps, pAppInstance}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return rawCountMatches(new Object[]{pCps, pAppInstance}); + } + + /** + * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, 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 CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pCps, pAppInstance}, 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. + * @return the (partial) match object. + * + */ + public CpsApplications.Match newMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { + return CpsApplications.Match.newMatch(pCps, pAppInstance); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfCps(final Object[] parameters) { + return rawStreamAllValues(POSITION_CPS, parameters).map(CyberPhysicalSystem.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps() { + return rawStreamAllValuesOfCps(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps() { + return rawStreamAllValuesOfCps(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps(final CpsApplications.Match partialMatch) { + return rawStreamAllValuesOfCps(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps(final ApplicationInstance pAppInstance) { + return rawStreamAllValuesOfCps(new Object[]{null, pAppInstance}); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps(final CpsApplications.Match partialMatch) { + return rawStreamAllValuesOfCps(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps(final ApplicationInstance pAppInstance) { + return rawStreamAllValuesOfCps(new Object[]{null, pAppInstance}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfAppInstance(final Object[] parameters) { + return rawStreamAllValues(POSITION_APPINSTANCE, parameters).map(ApplicationInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfAppInstance() { + return rawStreamAllValuesOfAppInstance(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfAppInstance() { + return rawStreamAllValuesOfAppInstance(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfAppInstance(final CpsApplications.Match partialMatch) { + return rawStreamAllValuesOfAppInstance(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfAppInstance(final CyberPhysicalSystem pCps) { + return rawStreamAllValuesOfAppInstance(new Object[]{pCps, null}); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfAppInstance(final CpsApplications.Match partialMatch) { + return rawStreamAllValuesOfAppInstance(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for AppInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfAppInstance(final CyberPhysicalSystem pCps) { + return rawStreamAllValuesOfAppInstance(new Object[]{pCps, null}).collect(Collectors.toSet()); + } + + @Override + protected CpsApplications.Match tupleToMatch(final Tuple t) { + try { + return CpsApplications.Match.newMatch((CyberPhysicalSystem) t.get(POSITION_CPS), (ApplicationInstance) t.get(POSITION_APPINSTANCE)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected CpsApplications.Match arrayToMatch(final Object[] match) { + try { + return CpsApplications.Match.newMatch((CyberPhysicalSystem) match[POSITION_CPS], (ApplicationInstance) match[POSITION_APPINSTANCE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected CpsApplications.Match arrayToMatchMutable(final Object[] match) { + try { + return CpsApplications.Match.newMutableMatch((CyberPhysicalSystem) match[POSITION_CPS], (ApplicationInstance) match[POSITION_APPINSTANCE]); + } 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 CpsApplications.instance(); + } + } + + private CpsApplications() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static CpsApplications instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected CpsApplications.Matcher instantiate(final ViatraQueryEngine engine) { + return CpsApplications.Matcher.on(engine); + } + + @Override + public CpsApplications.Matcher instantiate() { + return CpsApplications.Matcher.create(); + } + + @Override + public CpsApplications.Match newEmptyMatch() { + return CpsApplications.Match.newEmptyMatch(); + } + + @Override + public CpsApplications.Match newMatch(final Object... parameters) { + return CpsApplications.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final CpsApplications INSTANCE = new CpsApplications(); + + /** + * 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 CpsApplications.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); + + private final PParameter parameter_AppInstance = new PParameter("AppInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Cps, parameter_AppInstance); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Cps","AppInstance"); + } + + @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_Cps = body.getOrCreateVariableByName("Cps"); + PVariable var_AppInstance = body.getOrCreateVariableByName("AppInstance"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_AppInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cps, parameter_Cps), + new ExportedParameter(body, var_AppInstance, parameter_AppInstance) + )); + // CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance) + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "applicationTypes"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "instances"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new Equality(body, var__virtual_1_, var_AppInstance); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("QueryBasedFeature"); + annotation.addAttribute("feature", "applications"); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java new file mode 100644 index 00000000..169a30e5 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java @@ -0,0 +1,738 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost; +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.emf.ecore.EClass; +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.emf.types.EClassTransitiveInstancesKey; +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.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.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: + *

+ *         pattern cpsCost(Cps : CyberPhysicalSystem, Cost : java Integer) {
+ *         	AppCount == count find cpsApplications(Cps, _);
+ *         	HostCost == sum find hostInstanceCost(Cps, _, #_);
+ *         	Cost == eval(5  AppCount + HostCost);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class CpsCost extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost 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 CyberPhysicalSystem fCps; + + private Integer fCost; + + private static List parameterNames = makeImmutableList("Cps", "Cost"); + + private Match(final CyberPhysicalSystem pCps, final Integer pCost) { + this.fCps = pCps; + this.fCost = pCost; + } + + @Override + public Object get(final String parameterName) { + if ("Cps".equals(parameterName)) return this.fCps; + if ("Cost".equals(parameterName)) return this.fCost; + return null; + } + + public CyberPhysicalSystem getCps() { + return this.fCps; + } + + public Integer getCost() { + return this.fCost; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Cps".equals(parameterName) ) { + this.fCps = (CyberPhysicalSystem) newValue; + return true; + } + if ("Cost".equals(parameterName) ) { + this.fCost = (Integer) newValue; + return true; + } + return false; + } + + public void setCps(final CyberPhysicalSystem pCps) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fCps = pCps; + } + + public void setCost(final Integer pCost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fCost = pCost; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost"; + } + + @Override + public List parameterNames() { + return CpsCost.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fCps, fCost}; + } + + @Override + public CpsCost.Match toImmutable() { + return isMutable() ? newMatch(fCps, fCost) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Cps\"=" + prettyPrintValue(fCps) + ", "); + result.append("\"Cost\"=" + prettyPrintValue(fCost)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fCps, fCost); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof CpsCost.Match)) { + CpsCost.Match other = (CpsCost.Match) obj; + return Objects.equals(fCps, other.fCps) && 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 CpsCost specification() { + return CpsCost.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 CpsCost.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static CpsCost.Match newMutableMatch(final CyberPhysicalSystem pCps, final Integer pCost) { + return new Mutable(pCps, 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the (partial) match object. + * + */ + public static CpsCost.Match newMatch(final CyberPhysicalSystem pCps, final Integer pCost) { + return new Immutable(pCps, pCost); + } + + private static final class Mutable extends CpsCost.Match { + Mutable(final CyberPhysicalSystem pCps, final Integer pCost) { + super(pCps, pCost); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends CpsCost.Match { + Immutable(final CyberPhysicalSystem pCps, final Integer pCost) { + super(pCps, pCost); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost 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: + *

+   * pattern cpsCost(Cps : CyberPhysicalSystem, Cost : java Integer) {
+   * 	AppCount == count find cpsApplications(Cps, _);
+   * 	HostCost == sum find hostInstanceCost(Cps, _, #_);
+   * 	Cost == eval(5  AppCount + HostCost);
+   * }
+   * 
+ * + * @see Match + * @see CpsCost + * + */ + 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 CpsCost.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 CpsCost.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_CPS = 0; + + private static final int POSITION_COST = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CpsCost.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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @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 CyberPhysicalSystem pCps, final Integer pCost) { + return rawStreamAllMatches(new Object[]{pCps, 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @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 CyberPhysicalSystem pCps, final Integer pCost) { + return rawStreamAllMatches(new Object[]{pCps, 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @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 CyberPhysicalSystem pCps, final Integer pCost) { + return rawGetOneArbitraryMatch(new Object[]{pCps, 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @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 CyberPhysicalSystem pCps, final Integer pCost) { + return rawHasMatch(new Object[]{pCps, pCost}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @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 CyberPhysicalSystem pCps, final Integer pCost) { + return rawCountMatches(new Object[]{pCps, 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @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 CyberPhysicalSystem pCps, final Integer pCost, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pCps, 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pCost the fixed value of pattern parameter Cost, or null if not bound. + * @return the (partial) match object. + * + */ + public CpsCost.Match newMatch(final CyberPhysicalSystem pCps, final Integer pCost) { + return CpsCost.Match.newMatch(pCps, pCost); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfCps(final Object[] parameters) { + return rawStreamAllValues(POSITION_CPS, parameters).map(CyberPhysicalSystem.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps() { + return rawStreamAllValuesOfCps(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps() { + return rawStreamAllValuesOfCps(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps(final CpsCost.Match partialMatch) { + return rawStreamAllValuesOfCps(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps(final Integer pCost) { + return rawStreamAllValuesOfCps(new Object[]{null, pCost}); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps(final CpsCost.Match partialMatch) { + return rawStreamAllValuesOfCps(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps(final Integer pCost) { + return rawStreamAllValuesOfCps(new Object[]{null, pCost}).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 + * + */ + protected Stream rawStreamAllValuesOfCost(final Object[] parameters) { + return rawStreamAllValues(POSITION_COST, parameters).map(Integer.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()); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCost(final CpsCost.Match partialMatch) { + return rawStreamAllValuesOfCost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cost. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCost(final CyberPhysicalSystem pCps) { + return rawStreamAllValuesOfCost(new Object[]{pCps, null}); + } + + /** + * 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(final CpsCost.Match partialMatch) { + return rawStreamAllValuesOfCost(partialMatch.toArray()).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 Set getAllValuesOfCost(final CyberPhysicalSystem pCps) { + return rawStreamAllValuesOfCost(new Object[]{pCps, null}).collect(Collectors.toSet()); + } + + @Override + protected CpsCost.Match tupleToMatch(final Tuple t) { + try { + return CpsCost.Match.newMatch((CyberPhysicalSystem) t.get(POSITION_CPS), (Integer) t.get(POSITION_COST)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected CpsCost.Match arrayToMatch(final Object[] match) { + try { + return CpsCost.Match.newMatch((CyberPhysicalSystem) match[POSITION_CPS], (Integer) match[POSITION_COST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected CpsCost.Match arrayToMatchMutable(final Object[] match) { + try { + return CpsCost.Match.newMutableMatch((CyberPhysicalSystem) match[POSITION_CPS], (Integer) 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 CpsCost.instance(); + } + } + + private CpsCost() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static CpsCost instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected CpsCost.Matcher instantiate(final ViatraQueryEngine engine) { + return CpsCost.Matcher.on(engine); + } + + @Override + public CpsCost.Matcher instantiate() { + return CpsCost.Matcher.create(); + } + + @Override + public CpsCost.Match newEmptyMatch() { + return CpsCost.Match.newEmptyMatch(); + } + + @Override + public CpsCost.Match newMatch(final Object... parameters) { + return CpsCost.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem) parameters[0], (java.lang.Integer) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost (visibility: PUBLIC, simpleName: CpsCost, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.CpsCost (visibility: PUBLIC, simpleName: CpsCost, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final CpsCost INSTANCE = new CpsCost(); + + /** + * 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 CpsCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); + + private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Cps, parameter_Cost); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsCost"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Cps","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_Cps = body.getOrCreateVariableByName("Cps"); + PVariable var_Cost = body.getOrCreateVariableByName("Cost"); + PVariable var_AppCount = body.getOrCreateVariableByName("AppCount"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var_HostCost = body.getOrCreateVariableByName("HostCost"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + PVariable var___2_ = body.getOrCreateVariableByName("_<2>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Cost), new JavaTransitiveInstancesKey(java.lang.Integer.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cps, parameter_Cps), + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // AppCount == count find cpsApplications(Cps, _) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new PatternMatchCounter(body, Tuples.flatTupleOf(var_Cps, var___0_), CpsApplications.instance().getInternalQueryRepresentation(), var__virtual_0_); + new Equality(body, var_AppCount, var__virtual_0_); + // HostCost == sum find hostInstanceCost(Cps, _, #_) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Cps, var___1_, var___2_), HostInstanceCost.instance().getInternalQueryRepresentation(), var__virtual_1_, 2); + new Equality(body, var_HostCost, var__virtual_1_); + // Cost == eval(5 * AppCount + HostCost) + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern cpsCost"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("AppCount", "HostCost");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer AppCount = (Integer) provider.getValue("AppCount"); + Integer HostCost = (Integer) provider.getValue("HostCost"); + return evaluateExpression_1_1(AppCount, HostCost); + } + }, var__virtual_2_ ); + new Equality(body, var_Cost, var__virtual_2_); + bodies.add(body); + } + return bodies; + } + } + + private static int evaluateExpression_1_1(final Integer AppCount, final Integer HostCost) { + return ((5 * (AppCount).intValue()) + (HostCost).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java new file mode 100644 index 00000000..e1abf758 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java @@ -0,0 +1,705 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +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.emf.ecore.EClass; +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.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.annotations.PAnnotation; +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.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: + *

+ *         {@literal @}QueryBasedFeature(feature = "hosts")
+ *         pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) {
+ *         	CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class CpsHosts extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts 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 CyberPhysicalSystem fCps; + + private HostInstance fHostInstance; + + private static List parameterNames = makeImmutableList("Cps", "HostInstance"); + + private Match(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + this.fCps = pCps; + this.fHostInstance = pHostInstance; + } + + @Override + public Object get(final String parameterName) { + if ("Cps".equals(parameterName)) return this.fCps; + if ("HostInstance".equals(parameterName)) return this.fHostInstance; + return null; + } + + public CyberPhysicalSystem getCps() { + return this.fCps; + } + + public HostInstance getHostInstance() { + return this.fHostInstance; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Cps".equals(parameterName) ) { + this.fCps = (CyberPhysicalSystem) newValue; + return true; + } + if ("HostInstance".equals(parameterName) ) { + this.fHostInstance = (HostInstance) newValue; + return true; + } + return false; + } + + public void setCps(final CyberPhysicalSystem pCps) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fCps = pCps; + } + + public void setHostInstance(final HostInstance pHostInstance) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHostInstance = pHostInstance; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts"; + } + + @Override + public List parameterNames() { + return CpsHosts.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fCps, fHostInstance}; + } + + @Override + public CpsHosts.Match toImmutable() { + return isMutable() ? newMatch(fCps, fHostInstance) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Cps\"=" + prettyPrintValue(fCps) + ", "); + result.append("\"HostInstance\"=" + prettyPrintValue(fHostInstance)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fCps, fHostInstance); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof CpsHosts.Match)) { + CpsHosts.Match other = (CpsHosts.Match) obj; + return Objects.equals(fCps, other.fCps) && Objects.equals(fHostInstance, other.fHostInstance); + } 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 CpsHosts specification() { + return CpsHosts.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 CpsHosts.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static CpsHosts.Match newMutableMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return new Mutable(pCps, pHostInstance); + } + + /** + * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return the (partial) match object. + * + */ + public static CpsHosts.Match newMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return new Immutable(pCps, pHostInstance); + } + + private static final class Mutable extends CpsHosts.Match { + Mutable(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + super(pCps, pHostInstance); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends CpsHosts.Match { + Immutable(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + super(pCps, pHostInstance); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts 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: + *

+   * {@literal @}QueryBasedFeature(feature = "hosts")
+   * pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) {
+   * 	CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance);
+   * }
+   * 
+ * + * @see Match + * @see CpsHosts + * + */ + 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 CpsHosts.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 CpsHosts.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_CPS = 0; + + private static final int POSITION_HOSTINSTANCE = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CpsHosts.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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return rawStreamAllMatches(new Object[]{pCps, pHostInstance}).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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return rawStreamAllMatches(new Object[]{pCps, pHostInstance}); + } + + /** + * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return rawGetOneArbitraryMatch(new Object[]{pCps, pHostInstance}); + } + + /** + * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return rawHasMatch(new Object[]{pCps, pHostInstance}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return rawCountMatches(new Object[]{pCps, pHostInstance}); + } + + /** + * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, 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 CyberPhysicalSystem pCps, final HostInstance pHostInstance, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pCps, pHostInstance}, 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 pCps the fixed value of pattern parameter Cps, or null if not bound. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return the (partial) match object. + * + */ + public CpsHosts.Match newMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { + return CpsHosts.Match.newMatch(pCps, pHostInstance); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfCps(final Object[] parameters) { + return rawStreamAllValues(POSITION_CPS, parameters).map(CyberPhysicalSystem.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps() { + return rawStreamAllValuesOfCps(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps() { + return rawStreamAllValuesOfCps(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps(final CpsHosts.Match partialMatch) { + return rawStreamAllValuesOfCps(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfCps(final HostInstance pHostInstance) { + return rawStreamAllValuesOfCps(new Object[]{null, pHostInstance}); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps(final CpsHosts.Match partialMatch) { + return rawStreamAllValuesOfCps(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Cps. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfCps(final HostInstance pHostInstance) { + return rawStreamAllValuesOfCps(new Object[]{null, pHostInstance}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHostInstance(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOSTINSTANCE, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHostInstance() { + return rawStreamAllValuesOfHostInstance(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHostInstance() { + return rawStreamAllValuesOfHostInstance(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHostInstance(final CpsHosts.Match partialMatch) { + return rawStreamAllValuesOfHostInstance(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHostInstance(final CyberPhysicalSystem pCps) { + return rawStreamAllValuesOfHostInstance(new Object[]{pCps, null}); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHostInstance(final CpsHosts.Match partialMatch) { + return rawStreamAllValuesOfHostInstance(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHostInstance(final CyberPhysicalSystem pCps) { + return rawStreamAllValuesOfHostInstance(new Object[]{pCps, null}).collect(Collectors.toSet()); + } + + @Override + protected CpsHosts.Match tupleToMatch(final Tuple t) { + try { + return CpsHosts.Match.newMatch((CyberPhysicalSystem) t.get(POSITION_CPS), (HostInstance) t.get(POSITION_HOSTINSTANCE)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected CpsHosts.Match arrayToMatch(final Object[] match) { + try { + return CpsHosts.Match.newMatch((CyberPhysicalSystem) match[POSITION_CPS], (HostInstance) match[POSITION_HOSTINSTANCE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected CpsHosts.Match arrayToMatchMutable(final Object[] match) { + try { + return CpsHosts.Match.newMutableMatch((CyberPhysicalSystem) match[POSITION_CPS], (HostInstance) match[POSITION_HOSTINSTANCE]); + } 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 CpsHosts.instance(); + } + } + + private CpsHosts() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static CpsHosts instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected CpsHosts.Matcher instantiate(final ViatraQueryEngine engine) { + return CpsHosts.Matcher.on(engine); + } + + @Override + public CpsHosts.Matcher instantiate() { + return CpsHosts.Matcher.create(); + } + + @Override + public CpsHosts.Match newEmptyMatch() { + return CpsHosts.Match.newEmptyMatch(); + } + + @Override + public CpsHosts.Match newMatch(final Object... parameters) { + return CpsHosts.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts (visibility: PUBLIC, simpleName: CpsHosts, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.CpsHosts (visibility: PUBLIC, simpleName: CpsHosts, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final CpsHosts INSTANCE = new CpsHosts(); + + /** + * 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 CpsHosts.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); + + private final PParameter parameter_HostInstance = new PParameter("HostInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Cps, parameter_HostInstance); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Cps","HostInstance"); + } + + @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_Cps = body.getOrCreateVariableByName("Cps"); + PVariable var_HostInstance = body.getOrCreateVariableByName("HostInstance"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_HostInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cps, parameter_Cps), + new ExportedParameter(body, var_HostInstance, parameter_HostInstance) + )); + // CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance) + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "hostTypes"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "instances"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new Equality(body, var__virtual_1_, var_HostInstance); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("QueryBasedFeature"); + annotation.addAttribute("feature", "hosts"); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java new file mode 100644 index 00000000..4442718b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java @@ -0,0 +1,207 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; + +/** + * A pattern group formed of all public patterns defined in CpsQueries.vql. + * + *

Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare + * a VIATRA Query engine for matching all patterns originally defined in file CpsQueries.vql, + * in order to achieve better performance than one-by-one on-demand matcher initialization. + * + *

From package hu.bme.mit.inf.dslreasoner.domains.cps.queries, the group contains the definition of the following patterns:

    + *
  • cpsApplications
  • + *
  • cpsHosts
  • + *
  • totalMemory
  • + *
  • totalHdd
  • + *
  • availableMemory
  • + *
  • availableHdd
  • + *
  • allocationWithoutResourceRequirement
  • + *
  • notEnoughAvailableMemory
  • + *
  • notEnoughAvailableHdd
  • + *
  • instanceDoesNotSatisfyRequirement
  • + *
  • requirementNotSatisfied
  • + *
  • averageFreeMemoryMetric
  • + *
  • averageFreeHddMetric
  • + *
  • costMetric
  • + *
  • cpsCost
  • + *
+ * + * @see IQueryGroup + * + */ +@SuppressWarnings("all") +public final class CpsQueries extends BaseGeneratedPatternGroup { + /** + * Access the pattern group. + * + * @return the singleton instance of the group + * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications + * + */ + public static CpsQueries instance() { + if (INSTANCE == null) { + INSTANCE = new CpsQueries(); + } + return INSTANCE; + } + + private static CpsQueries INSTANCE; + + private CpsQueries() { + querySpecifications.add(CpsApplications.instance()); + querySpecifications.add(CpsHosts.instance()); + querySpecifications.add(TotalMemory.instance()); + querySpecifications.add(TotalHdd.instance()); + querySpecifications.add(AvailableMemory.instance()); + querySpecifications.add(AvailableHdd.instance()); + querySpecifications.add(AllocationWithoutResourceRequirement.instance()); + querySpecifications.add(NotEnoughAvailableMemory.instance()); + querySpecifications.add(NotEnoughAvailableHdd.instance()); + querySpecifications.add(InstanceDoesNotSatisfyRequirement.instance()); + querySpecifications.add(RequirementNotSatisfied.instance()); + querySpecifications.add(AverageFreeMemoryMetric.instance()); + querySpecifications.add(AverageFreeHddMetric.instance()); + querySpecifications.add(CostMetric.instance()); + querySpecifications.add(CpsCost.instance()); + } + + public CpsApplications getCpsApplications() { + return CpsApplications.instance(); + } + + public CpsApplications.Matcher getCpsApplications(final ViatraQueryEngine engine) { + return CpsApplications.Matcher.on(engine); + } + + public CpsHosts getCpsHosts() { + return CpsHosts.instance(); + } + + public CpsHosts.Matcher getCpsHosts(final ViatraQueryEngine engine) { + return CpsHosts.Matcher.on(engine); + } + + public TotalMemory getTotalMemory() { + return TotalMemory.instance(); + } + + public TotalMemory.Matcher getTotalMemory(final ViatraQueryEngine engine) { + return TotalMemory.Matcher.on(engine); + } + + public TotalHdd getTotalHdd() { + return TotalHdd.instance(); + } + + public TotalHdd.Matcher getTotalHdd(final ViatraQueryEngine engine) { + return TotalHdd.Matcher.on(engine); + } + + public AvailableMemory getAvailableMemory() { + return AvailableMemory.instance(); + } + + public AvailableMemory.Matcher getAvailableMemory(final ViatraQueryEngine engine) { + return AvailableMemory.Matcher.on(engine); + } + + public AvailableHdd getAvailableHdd() { + return AvailableHdd.instance(); + } + + public AvailableHdd.Matcher getAvailableHdd(final ViatraQueryEngine engine) { + return AvailableHdd.Matcher.on(engine); + } + + public AllocationWithoutResourceRequirement getAllocationWithoutResourceRequirement() { + return AllocationWithoutResourceRequirement.instance(); + } + + public AllocationWithoutResourceRequirement.Matcher getAllocationWithoutResourceRequirement(final ViatraQueryEngine engine) { + return AllocationWithoutResourceRequirement.Matcher.on(engine); + } + + public NotEnoughAvailableMemory getNotEnoughAvailableMemory() { + return NotEnoughAvailableMemory.instance(); + } + + public NotEnoughAvailableMemory.Matcher getNotEnoughAvailableMemory(final ViatraQueryEngine engine) { + return NotEnoughAvailableMemory.Matcher.on(engine); + } + + public NotEnoughAvailableHdd getNotEnoughAvailableHdd() { + return NotEnoughAvailableHdd.instance(); + } + + public NotEnoughAvailableHdd.Matcher getNotEnoughAvailableHdd(final ViatraQueryEngine engine) { + return NotEnoughAvailableHdd.Matcher.on(engine); + } + + public InstanceDoesNotSatisfyRequirement getInstanceDoesNotSatisfyRequirement() { + return InstanceDoesNotSatisfyRequirement.instance(); + } + + public InstanceDoesNotSatisfyRequirement.Matcher getInstanceDoesNotSatisfyRequirement(final ViatraQueryEngine engine) { + return InstanceDoesNotSatisfyRequirement.Matcher.on(engine); + } + + public RequirementNotSatisfied getRequirementNotSatisfied() { + return RequirementNotSatisfied.instance(); + } + + public RequirementNotSatisfied.Matcher getRequirementNotSatisfied(final ViatraQueryEngine engine) { + return RequirementNotSatisfied.Matcher.on(engine); + } + + public AverageFreeMemoryMetric getAverageFreeMemoryMetric() { + return AverageFreeMemoryMetric.instance(); + } + + public AverageFreeMemoryMetric.Matcher getAverageFreeMemoryMetric(final ViatraQueryEngine engine) { + return AverageFreeMemoryMetric.Matcher.on(engine); + } + + public AverageFreeHddMetric getAverageFreeHddMetric() { + return AverageFreeHddMetric.instance(); + } + + public AverageFreeHddMetric.Matcher getAverageFreeHddMetric(final ViatraQueryEngine engine) { + return AverageFreeHddMetric.Matcher.on(engine); + } + + public CostMetric getCostMetric() { + return CostMetric.instance(); + } + + public CostMetric.Matcher getCostMetric(final ViatraQueryEngine engine) { + return CostMetric.Matcher.on(engine); + } + + public CpsCost getCpsCost() { + return CpsCost.instance(); + } + + public CpsCost.Matcher getCpsCost(final ViatraQueryEngine engine) { + return CpsCost.Matcher.on(engine); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/InstanceDoesNotSatisfyRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/InstanceDoesNotSatisfyRequirement.java new file mode 100644 index 00000000..14deb337 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/InstanceDoesNotSatisfyRequirement.java @@ -0,0 +1,716 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; +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.emf.ecore.EClass; +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.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.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +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.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.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: + *

+ *         {@literal @}Constraint(severity = "error", key = {Req, App},
+ *         	message = "Requirement must be satisfied by the required application type.")
+ *         pattern instanceDoesNotSatisfyRequirement(Req : Requirement, App : ApplicationInstance) {
+ *         	Requirement.instances(Req, App);
+ *         	neg find satisfyingInstance(Req, App);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class InstanceDoesNotSatisfyRequirement extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement 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 Requirement fReq; + + private ApplicationInstance fApp; + + private static List parameterNames = makeImmutableList("Req", "App"); + + private Match(final Requirement pReq, final ApplicationInstance pApp) { + this.fReq = pReq; + this.fApp = pApp; + } + + @Override + public Object get(final String parameterName) { + if ("Req".equals(parameterName)) return this.fReq; + if ("App".equals(parameterName)) return this.fApp; + return null; + } + + public Requirement getReq() { + return this.fReq; + } + + public ApplicationInstance getApp() { + return this.fApp; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Req".equals(parameterName) ) { + this.fReq = (Requirement) newValue; + return true; + } + if ("App".equals(parameterName) ) { + this.fApp = (ApplicationInstance) newValue; + return true; + } + return false; + } + + public void setReq(final Requirement pReq) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fReq = pReq; + } + + public void setApp(final ApplicationInstance pApp) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fApp = pApp; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement"; + } + + @Override + public List parameterNames() { + return InstanceDoesNotSatisfyRequirement.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fReq, fApp}; + } + + @Override + public InstanceDoesNotSatisfyRequirement.Match toImmutable() { + return isMutable() ? newMatch(fReq, fApp) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Req\"=" + prettyPrintValue(fReq) + ", "); + result.append("\"App\"=" + prettyPrintValue(fApp)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fReq, fApp); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof InstanceDoesNotSatisfyRequirement.Match)) { + InstanceDoesNotSatisfyRequirement.Match other = (InstanceDoesNotSatisfyRequirement.Match) obj; + return Objects.equals(fReq, other.fReq) && Objects.equals(fApp, other.fApp); + } 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 InstanceDoesNotSatisfyRequirement specification() { + return InstanceDoesNotSatisfyRequirement.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 InstanceDoesNotSatisfyRequirement.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static InstanceDoesNotSatisfyRequirement.Match newMutableMatch(final Requirement pReq, final ApplicationInstance pApp) { + return new Mutable(pReq, pApp); + } + + /** + * 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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the (partial) match object. + * + */ + public static InstanceDoesNotSatisfyRequirement.Match newMatch(final Requirement pReq, final ApplicationInstance pApp) { + return new Immutable(pReq, pApp); + } + + private static final class Mutable extends InstanceDoesNotSatisfyRequirement.Match { + Mutable(final Requirement pReq, final ApplicationInstance pApp) { + super(pReq, pApp); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends InstanceDoesNotSatisfyRequirement.Match { + Immutable(final Requirement pReq, final ApplicationInstance pApp) { + super(pReq, pApp); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement 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: + *

+   * {@literal @}Constraint(severity = "error", key = {Req, App},
+   * 	message = "Requirement must be satisfied by the required application type.")
+   * pattern instanceDoesNotSatisfyRequirement(Req : Requirement, App : ApplicationInstance) {
+   * 	Requirement.instances(Req, App);
+   * 	neg find satisfyingInstance(Req, App);
+   * }
+   * 
+ * + * @see Match + * @see InstanceDoesNotSatisfyRequirement + * + */ + 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 InstanceDoesNotSatisfyRequirement.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 InstanceDoesNotSatisfyRequirement.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_REQ = 0; + + private static final int POSITION_APP = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(InstanceDoesNotSatisfyRequirement.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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Requirement pReq, final ApplicationInstance pApp) { + return rawStreamAllMatches(new Object[]{pReq, pApp}).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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Requirement pReq, final ApplicationInstance pApp) { + return rawStreamAllMatches(new Object[]{pReq, pApp}); + } + + /** + * 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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Requirement pReq, final ApplicationInstance pApp) { + return rawGetOneArbitraryMatch(new Object[]{pReq, pApp}); + } + + /** + * 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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Requirement pReq, final ApplicationInstance pApp) { + return rawHasMatch(new Object[]{pReq, pApp}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Requirement pReq, final ApplicationInstance pApp) { + return rawCountMatches(new Object[]{pReq, pApp}); + } + + /** + * 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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, 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 Requirement pReq, final ApplicationInstance pApp, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pReq, pApp}, 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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the (partial) match object. + * + */ + public InstanceDoesNotSatisfyRequirement.Match newMatch(final Requirement pReq, final ApplicationInstance pApp) { + return InstanceDoesNotSatisfyRequirement.Match.newMatch(pReq, pApp); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfReq(final Object[] parameters) { + return rawStreamAllValues(POSITION_REQ, parameters).map(Requirement.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfReq() { + return rawStreamAllValuesOfReq(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfReq() { + return rawStreamAllValuesOfReq(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfReq(final InstanceDoesNotSatisfyRequirement.Match partialMatch) { + return rawStreamAllValuesOfReq(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfReq(final ApplicationInstance pApp) { + return rawStreamAllValuesOfReq(new Object[]{null, pApp}); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfReq(final InstanceDoesNotSatisfyRequirement.Match partialMatch) { + return rawStreamAllValuesOfReq(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfReq(final ApplicationInstance pApp) { + return rawStreamAllValuesOfReq(new Object[]{null, pApp}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfApp(final Object[] parameters) { + return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for App. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp(final InstanceDoesNotSatisfyRequirement.Match partialMatch) { + return rawStreamAllValuesOfApp(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for App. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp(final Requirement pReq) { + return rawStreamAllValuesOfApp(new Object[]{pReq, null}); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp(final InstanceDoesNotSatisfyRequirement.Match partialMatch) { + return rawStreamAllValuesOfApp(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp(final Requirement pReq) { + return rawStreamAllValuesOfApp(new Object[]{pReq, null}).collect(Collectors.toSet()); + } + + @Override + protected InstanceDoesNotSatisfyRequirement.Match tupleToMatch(final Tuple t) { + try { + return InstanceDoesNotSatisfyRequirement.Match.newMatch((Requirement) t.get(POSITION_REQ), (ApplicationInstance) t.get(POSITION_APP)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected InstanceDoesNotSatisfyRequirement.Match arrayToMatch(final Object[] match) { + try { + return InstanceDoesNotSatisfyRequirement.Match.newMatch((Requirement) match[POSITION_REQ], (ApplicationInstance) match[POSITION_APP]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected InstanceDoesNotSatisfyRequirement.Match arrayToMatchMutable(final Object[] match) { + try { + return InstanceDoesNotSatisfyRequirement.Match.newMutableMatch((Requirement) match[POSITION_REQ], (ApplicationInstance) match[POSITION_APP]); + } 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 InstanceDoesNotSatisfyRequirement.instance(); + } + } + + private InstanceDoesNotSatisfyRequirement() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static InstanceDoesNotSatisfyRequirement instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected InstanceDoesNotSatisfyRequirement.Matcher instantiate(final ViatraQueryEngine engine) { + return InstanceDoesNotSatisfyRequirement.Matcher.on(engine); + } + + @Override + public InstanceDoesNotSatisfyRequirement.Matcher instantiate() { + return InstanceDoesNotSatisfyRequirement.Matcher.create(); + } + + @Override + public InstanceDoesNotSatisfyRequirement.Match newEmptyMatch() { + return InstanceDoesNotSatisfyRequirement.Match.newEmptyMatch(); + } + + @Override + public InstanceDoesNotSatisfyRequirement.Match newMatch(final Object... parameters) { + return InstanceDoesNotSatisfyRequirement.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.Requirement) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement (visibility: PUBLIC, simpleName: InstanceDoesNotSatisfyRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.InstanceDoesNotSatisfyRequirement (visibility: PUBLIC, simpleName: InstanceDoesNotSatisfyRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final InstanceDoesNotSatisfyRequirement INSTANCE = new InstanceDoesNotSatisfyRequirement(); + + /** + * 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 InstanceDoesNotSatisfyRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.Requirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "Requirement")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Req, parameter_App); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.instanceDoesNotSatisfyRequirement"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Req","App"); + } + + @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_Req = body.getOrCreateVariableByName("Req"); + PVariable var_App = body.getOrCreateVariableByName("App"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Req, parameter_Req), + new ExportedParameter(body, var_App, parameter_App) + )); + // Requirement.instances(Req, App) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "instances"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new Equality(body, var__virtual_0_, var_App); + // neg find satisfyingInstance(Req, App) + new NegativePatternCall(body, Tuples.flatTupleOf(var_Req, var_App), SatisfyingInstance.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("Req"), + new ParameterReference("App") + })); + annotation.addAttribute("message", "Requirement must be satisfied by the required application type."); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java new file mode 100644 index 00000000..41615598 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java @@ -0,0 +1,579 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; +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.emf.ecore.EClass; +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.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +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.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +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.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.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: + *

+ *         {@literal @}Constraint(severity = "error", key = {Host},
+ *         	message = "Insufficient HDD available on host.")
+ *         pattern notEnoughAvailableHdd(Host : HostInstance) {
+ *         	find availableHdd(Host, Hdd);
+ *         	check(Hdd {@literal <} 0);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class NotEnoughAvailableHdd extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd 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 HostInstance fHost; + + private static List parameterNames = makeImmutableList("Host"); + + private Match(final HostInstance pHost) { + this.fHost = pHost; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd"; + } + + @Override + public List parameterNames() { + return NotEnoughAvailableHdd.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost}; + } + + @Override + public NotEnoughAvailableHdd.Match toImmutable() { + return isMutable() ? newMatch(fHost) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof NotEnoughAvailableHdd.Match)) { + NotEnoughAvailableHdd.Match other = (NotEnoughAvailableHdd.Match) obj; + return Objects.equals(fHost, other.fHost); + } 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 NotEnoughAvailableHdd specification() { + return NotEnoughAvailableHdd.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 NotEnoughAvailableHdd.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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static NotEnoughAvailableHdd.Match newMutableMatch(final HostInstance pHost) { + return new Mutable(pHost); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the (partial) match object. + * + */ + public static NotEnoughAvailableHdd.Match newMatch(final HostInstance pHost) { + return new Immutable(pHost); + } + + private static final class Mutable extends NotEnoughAvailableHdd.Match { + Mutable(final HostInstance pHost) { + super(pHost); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends NotEnoughAvailableHdd.Match { + Immutable(final HostInstance pHost) { + super(pHost); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd 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: + *

+   * {@literal @}Constraint(severity = "error", key = {Host},
+   * 	message = "Insufficient HDD available on host.")
+   * pattern notEnoughAvailableHdd(Host : HostInstance) {
+   * 	find availableHdd(Host, Hdd);
+   * 	check(Hdd {@literal <} 0);
+   * }
+   * 
+ * + * @see Match + * @see NotEnoughAvailableHdd + * + */ + 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 NotEnoughAvailableHdd.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 NotEnoughAvailableHdd.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NotEnoughAvailableHdd.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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost) { + return rawStreamAllMatches(new Object[]{pHost}).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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost) { + return rawStreamAllMatches(new Object[]{pHost}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost) { + return rawGetOneArbitraryMatch(new Object[]{pHost}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost) { + return rawHasMatch(new Object[]{pHost}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost) { + return rawCountMatches(new Object[]{pHost}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, 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 HostInstance pHost, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost}, 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the (partial) match object. + * + */ + public NotEnoughAvailableHdd.Match newMatch(final HostInstance pHost) { + return NotEnoughAvailableHdd.Match.newMatch(pHost); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + @Override + protected NotEnoughAvailableHdd.Match tupleToMatch(final Tuple t) { + try { + return NotEnoughAvailableHdd.Match.newMatch((HostInstance) t.get(POSITION_HOST)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected NotEnoughAvailableHdd.Match arrayToMatch(final Object[] match) { + try { + return NotEnoughAvailableHdd.Match.newMatch((HostInstance) match[POSITION_HOST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected NotEnoughAvailableHdd.Match arrayToMatchMutable(final Object[] match) { + try { + return NotEnoughAvailableHdd.Match.newMutableMatch((HostInstance) match[POSITION_HOST]); + } 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 NotEnoughAvailableHdd.instance(); + } + } + + private NotEnoughAvailableHdd() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static NotEnoughAvailableHdd instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected NotEnoughAvailableHdd.Matcher instantiate(final ViatraQueryEngine engine) { + return NotEnoughAvailableHdd.Matcher.on(engine); + } + + @Override + public NotEnoughAvailableHdd.Matcher instantiate() { + return NotEnoughAvailableHdd.Matcher.create(); + } + + @Override + public NotEnoughAvailableHdd.Match newEmptyMatch() { + return NotEnoughAvailableHdd.Match.newEmptyMatch(); + } + + @Override + public NotEnoughAvailableHdd.Match newMatch(final Object... parameters) { + return NotEnoughAvailableHdd.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd (visibility: PUBLIC, simpleName: NotEnoughAvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.NotEnoughAvailableHdd (visibility: PUBLIC, simpleName: NotEnoughAvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final NotEnoughAvailableHdd INSTANCE = new NotEnoughAvailableHdd(); + + /** + * 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 NotEnoughAvailableHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableHdd"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host) + )); + // find availableHdd(Host, Hdd) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Hdd), AvailableHdd.instance().getInternalQueryRepresentation()); + // check(Hdd < 0) + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern notEnoughAvailableHdd"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("Hdd");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer Hdd = (Integer) provider.getValue("Hdd"); + return evaluateExpression_1_1(Hdd); + } + }, null); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("Host") + })); + annotation.addAttribute("message", "Insufficient HDD available on host."); + addAnnotation(annotation); + } + return bodies; + } + } + + private static boolean evaluateExpression_1_1(final Integer Hdd) { + return ((Hdd).intValue() < 0); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java new file mode 100644 index 00000000..4803ec3a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java @@ -0,0 +1,579 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; +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.emf.ecore.EClass; +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.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +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.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +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.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.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: + *

+ *         {@literal @}Constraint(severity = "error", key = {Host},
+ *         	message = "Insufficient memory available on host.")
+ *         pattern notEnoughAvailableMemory(Host : HostInstance) {
+ *         	find availableMemory(Host, Memory);
+ *         	check(Memory {@literal <} 0);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class NotEnoughAvailableMemory extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory 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 HostInstance fHost; + + private static List parameterNames = makeImmutableList("Host"); + + private Match(final HostInstance pHost) { + this.fHost = pHost; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory"; + } + + @Override + public List parameterNames() { + return NotEnoughAvailableMemory.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost}; + } + + @Override + public NotEnoughAvailableMemory.Match toImmutable() { + return isMutable() ? newMatch(fHost) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof NotEnoughAvailableMemory.Match)) { + NotEnoughAvailableMemory.Match other = (NotEnoughAvailableMemory.Match) obj; + return Objects.equals(fHost, other.fHost); + } 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 NotEnoughAvailableMemory specification() { + return NotEnoughAvailableMemory.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 NotEnoughAvailableMemory.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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static NotEnoughAvailableMemory.Match newMutableMatch(final HostInstance pHost) { + return new Mutable(pHost); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the (partial) match object. + * + */ + public static NotEnoughAvailableMemory.Match newMatch(final HostInstance pHost) { + return new Immutable(pHost); + } + + private static final class Mutable extends NotEnoughAvailableMemory.Match { + Mutable(final HostInstance pHost) { + super(pHost); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends NotEnoughAvailableMemory.Match { + Immutable(final HostInstance pHost) { + super(pHost); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory 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: + *

+   * {@literal @}Constraint(severity = "error", key = {Host},
+   * 	message = "Insufficient memory available on host.")
+   * pattern notEnoughAvailableMemory(Host : HostInstance) {
+   * 	find availableMemory(Host, Memory);
+   * 	check(Memory {@literal <} 0);
+   * }
+   * 
+ * + * @see Match + * @see NotEnoughAvailableMemory + * + */ + 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 NotEnoughAvailableMemory.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 NotEnoughAvailableMemory.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NotEnoughAvailableMemory.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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost) { + return rawStreamAllMatches(new Object[]{pHost}).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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost) { + return rawStreamAllMatches(new Object[]{pHost}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost) { + return rawGetOneArbitraryMatch(new Object[]{pHost}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost) { + return rawHasMatch(new Object[]{pHost}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost) { + return rawCountMatches(new Object[]{pHost}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, 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 HostInstance pHost, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost}, 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the (partial) match object. + * + */ + public NotEnoughAvailableMemory.Match newMatch(final HostInstance pHost) { + return NotEnoughAvailableMemory.Match.newMatch(pHost); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + @Override + protected NotEnoughAvailableMemory.Match tupleToMatch(final Tuple t) { + try { + return NotEnoughAvailableMemory.Match.newMatch((HostInstance) t.get(POSITION_HOST)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected NotEnoughAvailableMemory.Match arrayToMatch(final Object[] match) { + try { + return NotEnoughAvailableMemory.Match.newMatch((HostInstance) match[POSITION_HOST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected NotEnoughAvailableMemory.Match arrayToMatchMutable(final Object[] match) { + try { + return NotEnoughAvailableMemory.Match.newMutableMatch((HostInstance) match[POSITION_HOST]); + } 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 NotEnoughAvailableMemory.instance(); + } + } + + private NotEnoughAvailableMemory() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static NotEnoughAvailableMemory instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected NotEnoughAvailableMemory.Matcher instantiate(final ViatraQueryEngine engine) { + return NotEnoughAvailableMemory.Matcher.on(engine); + } + + @Override + public NotEnoughAvailableMemory.Matcher instantiate() { + return NotEnoughAvailableMemory.Matcher.create(); + } + + @Override + public NotEnoughAvailableMemory.Match newEmptyMatch() { + return NotEnoughAvailableMemory.Match.newEmptyMatch(); + } + + @Override + public NotEnoughAvailableMemory.Match newMatch(final Object... parameters) { + return NotEnoughAvailableMemory.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory (visibility: PUBLIC, simpleName: NotEnoughAvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.NotEnoughAvailableMemory (visibility: PUBLIC, simpleName: NotEnoughAvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final NotEnoughAvailableMemory INSTANCE = new NotEnoughAvailableMemory(); + + /** + * 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 NotEnoughAvailableMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Memory = body.getOrCreateVariableByName("Memory"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host) + )); + // find availableMemory(Host, Memory) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Memory), AvailableMemory.instance().getInternalQueryRepresentation()); + // check(Memory < 0) + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern notEnoughAvailableMemory"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("Memory");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer Memory = (Integer) provider.getValue("Memory"); + return evaluateExpression_1_1(Memory); + } + }, null); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("Host") + })); + annotation.addAttribute("message", "Insufficient memory available on host."); + addAnnotation(annotation); + } + return bodies; + } + } + + private static boolean evaluateExpression_1_1(final Integer Memory) { + return ((Memory).intValue() < 0); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RequirementNotSatisfied.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RequirementNotSatisfied.java new file mode 100644 index 00000000..04066c50 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RequirementNotSatisfied.java @@ -0,0 +1,597 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; +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.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; +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.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.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.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +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.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.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: + *

+ *         {@literal @}Constraint(severity = "error", key = {Req},
+ *         	message = "Requirement is not satisfied by enough application instances.")
+ *         pattern requirementNotSatisfied(Req : Requirement) {
+ *         	Instances == count find satisfyingInstance(Req, _);
+ *         	Requirement.count(Req, RequiredCount);
+ *         	check(Instances {@literal <} RequiredCount);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class RequirementNotSatisfied extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied 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 Requirement fReq; + + private static List parameterNames = makeImmutableList("Req"); + + private Match(final Requirement pReq) { + this.fReq = pReq; + } + + @Override + public Object get(final String parameterName) { + if ("Req".equals(parameterName)) return this.fReq; + return null; + } + + public Requirement getReq() { + return this.fReq; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Req".equals(parameterName) ) { + this.fReq = (Requirement) newValue; + return true; + } + return false; + } + + public void setReq(final Requirement pReq) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fReq = pReq; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied"; + } + + @Override + public List parameterNames() { + return RequirementNotSatisfied.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fReq}; + } + + @Override + public RequirementNotSatisfied.Match toImmutable() { + return isMutable() ? newMatch(fReq) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Req\"=" + prettyPrintValue(fReq)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fReq); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof RequirementNotSatisfied.Match)) { + RequirementNotSatisfied.Match other = (RequirementNotSatisfied.Match) obj; + return Objects.equals(fReq, other.fReq); + } 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 RequirementNotSatisfied specification() { + return RequirementNotSatisfied.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 RequirementNotSatisfied.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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static RequirementNotSatisfied.Match newMutableMatch(final Requirement pReq) { + return new Mutable(pReq); + } + + /** + * 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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @return the (partial) match object. + * + */ + public static RequirementNotSatisfied.Match newMatch(final Requirement pReq) { + return new Immutable(pReq); + } + + private static final class Mutable extends RequirementNotSatisfied.Match { + Mutable(final Requirement pReq) { + super(pReq); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends RequirementNotSatisfied.Match { + Immutable(final Requirement pReq) { + super(pReq); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied 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: + *

+   * {@literal @}Constraint(severity = "error", key = {Req},
+   * 	message = "Requirement is not satisfied by enough application instances.")
+   * pattern requirementNotSatisfied(Req : Requirement) {
+   * 	Instances == count find satisfyingInstance(Req, _);
+   * 	Requirement.count(Req, RequiredCount);
+   * 	check(Instances {@literal <} RequiredCount);
+   * }
+   * 
+ * + * @see Match + * @see RequirementNotSatisfied + * + */ + 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 RequirementNotSatisfied.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 RequirementNotSatisfied.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_REQ = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(RequirementNotSatisfied.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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Requirement pReq) { + return rawStreamAllMatches(new Object[]{pReq}).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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Requirement pReq) { + return rawStreamAllMatches(new Object[]{pReq}); + } + + /** + * 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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Requirement pReq) { + return rawGetOneArbitraryMatch(new Object[]{pReq}); + } + + /** + * 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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Requirement pReq) { + return rawHasMatch(new Object[]{pReq}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Requirement pReq) { + return rawCountMatches(new Object[]{pReq}); + } + + /** + * 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 pReq the fixed value of pattern parameter Req, 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 Requirement pReq, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pReq}, 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 pReq the fixed value of pattern parameter Req, or null if not bound. + * @return the (partial) match object. + * + */ + public RequirementNotSatisfied.Match newMatch(final Requirement pReq) { + return RequirementNotSatisfied.Match.newMatch(pReq); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfReq(final Object[] parameters) { + return rawStreamAllValues(POSITION_REQ, parameters).map(Requirement.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfReq() { + return rawStreamAllValuesOfReq(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfReq() { + return rawStreamAllValuesOfReq(emptyArray()); + } + + @Override + protected RequirementNotSatisfied.Match tupleToMatch(final Tuple t) { + try { + return RequirementNotSatisfied.Match.newMatch((Requirement) t.get(POSITION_REQ)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected RequirementNotSatisfied.Match arrayToMatch(final Object[] match) { + try { + return RequirementNotSatisfied.Match.newMatch((Requirement) match[POSITION_REQ]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected RequirementNotSatisfied.Match arrayToMatchMutable(final Object[] match) { + try { + return RequirementNotSatisfied.Match.newMutableMatch((Requirement) match[POSITION_REQ]); + } 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 RequirementNotSatisfied.instance(); + } + } + + private RequirementNotSatisfied() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static RequirementNotSatisfied instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected RequirementNotSatisfied.Matcher instantiate(final ViatraQueryEngine engine) { + return RequirementNotSatisfied.Matcher.on(engine); + } + + @Override + public RequirementNotSatisfied.Matcher instantiate() { + return RequirementNotSatisfied.Matcher.create(); + } + + @Override + public RequirementNotSatisfied.Match newEmptyMatch() { + return RequirementNotSatisfied.Match.newEmptyMatch(); + } + + @Override + public RequirementNotSatisfied.Match newMatch(final Object... parameters) { + return RequirementNotSatisfied.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.Requirement) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied (visibility: PUBLIC, simpleName: RequirementNotSatisfied, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.RequirementNotSatisfied (visibility: PUBLIC, simpleName: RequirementNotSatisfied, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final RequirementNotSatisfied INSTANCE = new RequirementNotSatisfied(); + + /** + * 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 RequirementNotSatisfied.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.Requirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "Requirement")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Req); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.requirementNotSatisfied"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Req"); + } + + @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_Req = body.getOrCreateVariableByName("Req"); + PVariable var_Instances = body.getOrCreateVariableByName("Instances"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var_RequiredCount = body.getOrCreateVariableByName("RequiredCount"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Req, parameter_Req) + )); + // Instances == count find satisfyingInstance(Req, _) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new PatternMatchCounter(body, Tuples.flatTupleOf(var_Req, var___0_), SatisfyingInstance.instance().getInternalQueryRepresentation(), var__virtual_0_); + new Equality(body, var_Instances, var__virtual_0_); + // Requirement.count(Req, RequiredCount) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "count"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_1_, var_RequiredCount); + // check(Instances < RequiredCount) + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern requirementNotSatisfied"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("Instances", "RequiredCount");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer Instances = (Integer) provider.getValue("Instances"); + Integer RequiredCount = (Integer) provider.getValue("RequiredCount"); + return evaluateExpression_1_1(Instances, RequiredCount); + } + }, null); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("Req") + })); + annotation.addAttribute("message", "Requirement is not satisfied by enough application instances."); + addAnnotation(annotation); + } + return bodies; + } + } + + private static boolean evaluateExpression_1_1(final Integer Instances, final Integer RequiredCount) { + boolean _lessThan = (Instances.compareTo(RequiredCount) < 0); + return _lessThan; + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java new file mode 100644 index 00000000..f91853de --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java @@ -0,0 +1,706 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +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.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; +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.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.annotations.PAnnotation; +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.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: + *

+ *         {@literal @}QueryBasedFeature(feature = "totalHdd")
+ *         pattern totalHdd(Host : HostInstance, Hdd : EInt) {
+ *         	HostInstance.type.defaultHdd(Host, Hdd);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class TotalHdd extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd 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 HostInstance fHost; + + private Integer fHdd; + + private static List parameterNames = makeImmutableList("Host", "Hdd"); + + private Match(final HostInstance pHost, final Integer pHdd) { + this.fHost = pHost; + this.fHdd = pHdd; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + if ("Hdd".equals(parameterName)) return this.fHdd; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + public Integer getHdd() { + return this.fHdd; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + if ("Hdd".equals(parameterName) ) { + this.fHdd = (Integer) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + public void setHdd(final Integer pHdd) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHdd = pHdd; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd"; + } + + @Override + public List parameterNames() { + return TotalHdd.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost, fHdd}; + } + + @Override + public TotalHdd.Match toImmutable() { + return isMutable() ? newMatch(fHost, fHdd) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); + result.append("\"Hdd\"=" + prettyPrintValue(fHdd)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost, fHdd); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof TotalHdd.Match)) { + TotalHdd.Match other = (TotalHdd.Match) obj; + return Objects.equals(fHost, other.fHost) && Objects.equals(fHdd, other.fHdd); + } 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 TotalHdd specification() { + return TotalHdd.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 TotalHdd.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static TotalHdd.Match newMutableMatch(final HostInstance pHost, final Integer pHdd) { + return new Mutable(pHost, pHdd); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the (partial) match object. + * + */ + public static TotalHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) { + return new Immutable(pHost, pHdd); + } + + private static final class Mutable extends TotalHdd.Match { + Mutable(final HostInstance pHost, final Integer pHdd) { + super(pHost, pHdd); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends TotalHdd.Match { + Immutable(final HostInstance pHost, final Integer pHdd) { + super(pHost, pHdd); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd 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: + *

+   * {@literal @}QueryBasedFeature(feature = "totalHdd")
+   * pattern totalHdd(Host : HostInstance, Hdd : EInt) {
+   * 	HostInstance.type.defaultHdd(Host, Hdd);
+   * }
+   * 
+ * + * @see Match + * @see TotalHdd + * + */ + 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 TotalHdd.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 TotalHdd.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final int POSITION_HDD = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TotalHdd.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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost, final Integer pHdd) { + return rawStreamAllMatches(new Object[]{pHost, pHdd}).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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost, final Integer pHdd) { + return rawStreamAllMatches(new Object[]{pHost, pHdd}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost, final Integer pHdd) { + return rawGetOneArbitraryMatch(new Object[]{pHost, pHdd}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost, final Integer pHdd) { + return rawHasMatch(new Object[]{pHost, pHdd}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost, final Integer pHdd) { + return rawCountMatches(new Object[]{pHost, pHdd}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, 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 HostInstance pHost, final Integer pHdd, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost, pHdd}, 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. + * @return the (partial) match object. + * + */ + public TotalHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) { + return TotalHdd.Match.newMatch(pHost, pHdd); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final TotalHdd.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final Integer pHdd) { + return rawStreamAllValuesOfHost(new Object[]{null, pHdd}); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final TotalHdd.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final Integer pHdd) { + return rawStreamAllValuesOfHost(new Object[]{null, pHdd}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHdd(final Object[] parameters) { + return rawStreamAllValues(POSITION_HDD, parameters).map(Integer.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHdd() { + return rawStreamAllValuesOfHdd(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHdd() { + return rawStreamAllValuesOfHdd(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHdd(final TotalHdd.Match partialMatch) { + return rawStreamAllValuesOfHdd(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHdd(final HostInstance pHost) { + return rawStreamAllValuesOfHdd(new Object[]{pHost, null}); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHdd(final TotalHdd.Match partialMatch) { + return rawStreamAllValuesOfHdd(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Hdd. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHdd(final HostInstance pHost) { + return rawStreamAllValuesOfHdd(new Object[]{pHost, null}).collect(Collectors.toSet()); + } + + @Override + protected TotalHdd.Match tupleToMatch(final Tuple t) { + try { + return TotalHdd.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_HDD)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected TotalHdd.Match arrayToMatch(final Object[] match) { + try { + return TotalHdd.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected TotalHdd.Match arrayToMatchMutable(final Object[] match) { + try { + return TotalHdd.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]); + } 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 TotalHdd.instance(); + } + } + + private TotalHdd() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TotalHdd instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected TotalHdd.Matcher instantiate(final ViatraQueryEngine engine) { + return TotalHdd.Matcher.on(engine); + } + + @Override + public TotalHdd.Matcher instantiate() { + return TotalHdd.Matcher.create(); + } + + @Override + public TotalHdd.Match newEmptyMatch() { + return TotalHdd.Match.newEmptyMatch(); + } + + @Override + public TotalHdd.Match newMatch(final Object... parameters) { + return TotalHdd.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd (visibility: PUBLIC, simpleName: TotalHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.TotalHdd (visibility: PUBLIC, simpleName: TotalHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TotalHdd INSTANCE = new TotalHdd(); + + /** + * 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 TotalHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Hdd); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Hdd"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Hdd), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Hdd, parameter_Hdd) + )); + // HostInstance.type.defaultHdd(Host, Hdd) + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "defaultHdd"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_1_, var_Hdd); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("QueryBasedFeature"); + annotation.addAttribute("feature", "totalHdd"); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java new file mode 100644 index 00000000..e8a11e36 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java @@ -0,0 +1,706 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +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.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; +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.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.annotations.PAnnotation; +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.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: + *

+ *         {@literal @}QueryBasedFeature(feature = "totalMemory")
+ *         pattern totalMemory(Host : HostInstance, Memory : EInt) {
+ *         	HostInstance.type.defaultMemory(Host, Memory);
+ *         }
+ * 
+ * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class TotalMemory extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory 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 HostInstance fHost; + + private Integer fMemory; + + private static List parameterNames = makeImmutableList("Host", "Memory"); + + private Match(final HostInstance pHost, final Integer pMemory) { + this.fHost = pHost; + this.fMemory = pMemory; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + if ("Memory".equals(parameterName)) return this.fMemory; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + public Integer getMemory() { + return this.fMemory; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + if ("Memory".equals(parameterName) ) { + this.fMemory = (Integer) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + public void setMemory(final Integer pMemory) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fMemory = pMemory; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory"; + } + + @Override + public List parameterNames() { + return TotalMemory.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost, fMemory}; + } + + @Override + public TotalMemory.Match toImmutable() { + return isMutable() ? newMatch(fHost, fMemory) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); + result.append("\"Memory\"=" + prettyPrintValue(fMemory)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost, fMemory); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof TotalMemory.Match)) { + TotalMemory.Match other = (TotalMemory.Match) obj; + return Objects.equals(fHost, other.fHost) && Objects.equals(fMemory, other.fMemory); + } 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 TotalMemory specification() { + return TotalMemory.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 TotalMemory.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static TotalMemory.Match newMutableMatch(final HostInstance pHost, final Integer pMemory) { + return new Mutable(pHost, pMemory); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the (partial) match object. + * + */ + public static TotalMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) { + return new Immutable(pHost, pMemory); + } + + private static final class Mutable extends TotalMemory.Match { + Mutable(final HostInstance pHost, final Integer pMemory) { + super(pHost, pMemory); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends TotalMemory.Match { + Immutable(final HostInstance pHost, final Integer pMemory) { + super(pHost, pMemory); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory 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: + *

+   * {@literal @}QueryBasedFeature(feature = "totalMemory")
+   * pattern totalMemory(Host : HostInstance, Memory : EInt) {
+   * 	HostInstance.type.defaultMemory(Host, Memory);
+   * }
+   * 
+ * + * @see Match + * @see TotalMemory + * + */ + 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 TotalMemory.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 TotalMemory.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final int POSITION_MEMORY = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TotalMemory.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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost, final Integer pMemory) { + return rawStreamAllMatches(new Object[]{pHost, pMemory}).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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost, final Integer pMemory) { + return rawStreamAllMatches(new Object[]{pHost, pMemory}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost, final Integer pMemory) { + return rawGetOneArbitraryMatch(new Object[]{pHost, pMemory}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost, final Integer pMemory) { + return rawHasMatch(new Object[]{pHost, pMemory}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost, final Integer pMemory) { + return rawCountMatches(new Object[]{pHost, pMemory}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, 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 HostInstance pHost, final Integer pMemory, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost, pMemory}, 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. + * @return the (partial) match object. + * + */ + public TotalMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) { + return TotalMemory.Match.newMatch(pHost, pMemory); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final TotalMemory.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final Integer pMemory) { + return rawStreamAllValuesOfHost(new Object[]{null, pMemory}); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final TotalMemory.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final Integer pMemory) { + return rawStreamAllValuesOfHost(new Object[]{null, pMemory}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfMemory(final Object[] parameters) { + return rawStreamAllValues(POSITION_MEMORY, parameters).map(Integer.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfMemory() { + return rawStreamAllValuesOfMemory(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfMemory() { + return rawStreamAllValuesOfMemory(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfMemory(final TotalMemory.Match partialMatch) { + return rawStreamAllValuesOfMemory(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + *

+ * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfMemory(final HostInstance pHost) { + return rawStreamAllValuesOfMemory(new Object[]{pHost, null}); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfMemory(final TotalMemory.Match partialMatch) { + return rawStreamAllValuesOfMemory(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Memory. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfMemory(final HostInstance pHost) { + return rawStreamAllValuesOfMemory(new Object[]{pHost, null}).collect(Collectors.toSet()); + } + + @Override + protected TotalMemory.Match tupleToMatch(final Tuple t) { + try { + return TotalMemory.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_MEMORY)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected TotalMemory.Match arrayToMatch(final Object[] match) { + try { + return TotalMemory.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected TotalMemory.Match arrayToMatchMutable(final Object[] match) { + try { + return TotalMemory.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]); + } 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 TotalMemory.instance(); + } + } + + private TotalMemory() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TotalMemory instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected TotalMemory.Matcher instantiate(final ViatraQueryEngine engine) { + return TotalMemory.Matcher.on(engine); + } + + @Override + public TotalMemory.Matcher instantiate() { + return TotalMemory.Matcher.create(); + } + + @Override + public TotalMemory.Match newEmptyMatch() { + return TotalMemory.Match.newEmptyMatch(); + } + + @Override + public TotalMemory.Match newMatch(final Object... parameters) { + return TotalMemory.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory (visibility: PUBLIC, simpleName: TotalMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.TotalMemory (visibility: PUBLIC, simpleName: TotalMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final TotalMemory INSTANCE = new TotalMemory(); + + /** + * 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 TotalMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Memory); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Memory"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Memory = body.getOrCreateVariableByName("Memory"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Memory), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Memory, parameter_Memory) + )); + // HostInstance.type.defaultMemory(Host, Memory) + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "defaultMemory"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_1_, var_Memory); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("QueryBasedFeature"); + annotation.addAttribute("feature", "totalMemory"); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore new file mode 100644 index 00000000..2f593811 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore @@ -0,0 +1,11 @@ +/.CpsQueriesAll.java._trace +/.ResourceRequirement.java._trace +/.MemoryRequirement.java._trace +/.HddRequirement.java._trace +/.AllocationWithoutResourceRequirement.java._trace +/.RequiredType.java._trace +/.SatisfyingInstance.java._trace +/.FreeMemoryPercentage.java._trace +/.FreeHddPercentage.java._trace +/.ApplicationInstance.java._trace +/.HostInstanceCost.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java new file mode 100644 index 00000000..5f6d161d --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java @@ -0,0 +1,105 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; + +/** + * A pattern group formed of all patterns defined in CpsQueries.vql. + * + *

A private group that includes private patterns as well. Only intended use case is for pattern testing. + * + *

From package hu.bme.mit.inf.dslreasoner.domains.cps.queries, the group contains the definition of the following patterns:

    + *
  • cpsApplications
  • + *
  • cpsHosts
  • + *
  • totalMemory
  • + *
  • totalHdd
  • + *
  • availableMemory
  • + *
  • memoryRequirement
  • + *
  • availableHdd
  • + *
  • hddRequirement
  • + *
  • resourceRequirement
  • + *
  • allocationWithoutResourceRequirement
  • + *
  • notEnoughAvailableMemory
  • + *
  • notEnoughAvailableHdd
  • + *
  • instanceDoesNotSatisfyRequirement
  • + *
  • satisfyingInstance
  • + *
  • requirementNotSatisfied
  • + *
  • averageFreeMemoryMetric
  • + *
  • freeMemoryPercentage
  • + *
  • averageFreeHddMetric
  • + *
  • freeHddPercentage
  • + *
  • costMetric
  • + *
  • cpsCost
  • + *
  • hostInstanceCost
  • + *
+ * + * @see IQueryGroup + * + */ +@SuppressWarnings("all") +public final class CpsQueriesAll extends BaseGeneratedPatternGroup { + /** + * Access the pattern group. + * + * @return the singleton instance of the group + * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications + * + */ + public static CpsQueriesAll instance() { + if (INSTANCE == null) { + INSTANCE = new CpsQueriesAll(); + } + return INSTANCE; + } + + private static CpsQueriesAll INSTANCE; + + private CpsQueriesAll() { + querySpecifications.add(CpsApplications.instance()); + querySpecifications.add(CpsHosts.instance()); + querySpecifications.add(TotalMemory.instance()); + querySpecifications.add(TotalHdd.instance()); + querySpecifications.add(AvailableMemory.instance()); + querySpecifications.add(MemoryRequirement.instance()); + querySpecifications.add(AvailableHdd.instance()); + querySpecifications.add(HddRequirement.instance()); + querySpecifications.add(ResourceRequirement.instance()); + querySpecifications.add(AllocationWithoutResourceRequirement.instance()); + querySpecifications.add(NotEnoughAvailableMemory.instance()); + querySpecifications.add(NotEnoughAvailableHdd.instance()); + querySpecifications.add(InstanceDoesNotSatisfyRequirement.instance()); + querySpecifications.add(SatisfyingInstance.instance()); + querySpecifications.add(RequirementNotSatisfied.instance()); + querySpecifications.add(AverageFreeMemoryMetric.instance()); + querySpecifications.add(FreeMemoryPercentage.instance()); + querySpecifications.add(AverageFreeHddMetric.instance()); + querySpecifications.add(FreeHddPercentage.instance()); + querySpecifications.add(CostMetric.instance()); + querySpecifications.add(CpsCost.instance()); + querySpecifications.add(HostInstanceCost.instance()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java new file mode 100644 index 00000000..366677b5 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java @@ -0,0 +1,172 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; +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.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.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 freeHddPercentage(Host : HostInstance, Free : java Double) {
+ *         	find totalHdd(Host, Total);
+ *         	find availableHdd(Host, Available);
+ *         	Free == eval((Available as double) / Total);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class FreeHddPercentage extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private FreeHddPercentage() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static FreeHddPercentage 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.cps.queries.internal.FreeHddPercentage (visibility: PUBLIC, simpleName: FreeHddPercentage, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.FreeHddPercentage (visibility: PUBLIC, simpleName: FreeHddPercentage, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 FreeHddPercentage INSTANCE = new FreeHddPercentage(); + + /** + * 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 FreeHddPercentage.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Free = new PParameter("Free", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Free); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.freeHddPercentage"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Free"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Free = body.getOrCreateVariableByName("Free"); + PVariable var_Total = body.getOrCreateVariableByName("Total"); + PVariable var_Available = body.getOrCreateVariableByName("Available"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Free), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Free, parameter_Free) + )); + // find totalHdd(Host, Total) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Total), TotalHdd.instance().getInternalQueryRepresentation()); + // find availableHdd(Host, Available) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Available), AvailableHdd.instance().getInternalQueryRepresentation()); + // Free == eval((Available as double) / Total) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern freeHddPercentage"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("Available", "Total");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer Available = (Integer) provider.getValue("Available"); + Integer Total = (Integer) provider.getValue("Total"); + return evaluateExpression_1_1(Available, Total); + } + }, var__virtual_0_ ); + new Equality(body, var_Free, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1(final Integer Available, final Integer Total) { + return (((double) (Available).intValue()) / (Total).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java new file mode 100644 index 00000000..bd151ea6 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java @@ -0,0 +1,172 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; +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.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.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 freeMemoryPercentage(Host : HostInstance, Free : java Double) {
+ *         	find totalMemory(Host, Total);
+ *         	find availableMemory(Host, Available);
+ *         	Free == eval((Available as double) / Total);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class FreeMemoryPercentage extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private FreeMemoryPercentage() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static FreeMemoryPercentage 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.cps.queries.internal.FreeMemoryPercentage (visibility: PUBLIC, simpleName: FreeMemoryPercentage, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.FreeMemoryPercentage (visibility: PUBLIC, simpleName: FreeMemoryPercentage, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 FreeMemoryPercentage INSTANCE = new FreeMemoryPercentage(); + + /** + * 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 FreeMemoryPercentage.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Free = new PParameter("Free", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Free); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.freeMemoryPercentage"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Free"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Free = body.getOrCreateVariableByName("Free"); + PVariable var_Total = body.getOrCreateVariableByName("Total"); + PVariable var_Available = body.getOrCreateVariableByName("Available"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Free), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Free, parameter_Free) + )); + // find totalMemory(Host, Total) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Total), TotalMemory.instance().getInternalQueryRepresentation()); + // find availableMemory(Host, Available) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Available), AvailableMemory.instance().getInternalQueryRepresentation()); + // Free == eval((Available as double) / Total) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern freeMemoryPercentage"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("Available", "Total");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer Available = (Integer) provider.getValue("Available"); + Integer Total = (Integer) provider.getValue("Total"); + return evaluateExpression_1_1(Available, Total); + } + }, var__virtual_0_ ); + new Equality(body, var_Free, var__virtual_0_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1(final Integer Available, final Integer Total) { + return (((double) (Available).intValue()) / (Total).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java new file mode 100644 index 00000000..fbe7a46b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java @@ -0,0 +1,151 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; +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.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 hddRequirement(Host : HostInstance, App : ApplicationInstance, Hdd : EInt) {
+ *         	find resourceRequirement(Host, App, Req);
+ *         	ResourceRequirement.requiredHdd(Req, Hdd);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class HddRequirement extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private HddRequirement() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static HddRequirement 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.cps.queries.internal.HddRequirement (visibility: PUBLIC, simpleName: HddRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.HddRequirement (visibility: PUBLIC, simpleName: HddRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 HddRequirement INSTANCE = new HddRequirement(); + + /** + * 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 HddRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Hdd); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.hddRequirement"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","App","Hdd"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_App = body.getOrCreateVariableByName("App"); + PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); + PVariable var_Req = body.getOrCreateVariableByName("Req"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Hdd), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_App, parameter_App), + new ExportedParameter(body, var_Hdd, parameter_Hdd) + )); + // find resourceRequirement(Host, App, Req) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_App, var_Req), ResourceRequirement.instance().getInternalQueryRepresentation()); + // ResourceRequirement.requiredHdd(Req, Hdd) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredHdd"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_0_, var_Hdd); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java new file mode 100644 index 00000000..767ca342 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java @@ -0,0 +1,153 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts; +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.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 hostInstanceCost(Cps : CyberPhysicalSystem, Host : HostInstance, Cost : EInt) {
+ *         	find cpsHosts(Cps, Host);
+ *         	HostInstance.type.cost(Host, Cost);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class HostInstanceCost extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private HostInstanceCost() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static HostInstanceCost 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.cps.queries.internal.HostInstanceCost (visibility: PUBLIC, simpleName: HostInstanceCost, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.HostInstanceCost (visibility: PUBLIC, simpleName: HostInstanceCost, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 HostInstanceCost INSTANCE = new HostInstanceCost(); + + /** + * 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 HostInstanceCost.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Cost = new PParameter("Cost", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Cps, parameter_Host, parameter_Cost); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.hostInstanceCost"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Cps","Host","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_Cps = body.getOrCreateVariableByName("Cps"); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Cost = body.getOrCreateVariableByName("Cost"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cost), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cps, parameter_Cps), + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Cost, parameter_Cost) + )); + // find cpsHosts(Cps, Host) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Cps, var_Host), CpsHosts.instance().getInternalQueryRepresentation()); + // HostInstance.type.cost(Host, Cost) + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "cost"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_1_, var_Cost); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java new file mode 100644 index 00000000..0a24d105 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java @@ -0,0 +1,151 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; +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.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 memoryRequirement(Host : HostInstance, App : ApplicationInstance, Memory : EInt) {
+ *         	find resourceRequirement(Host, App, Req);
+ *         	ResourceRequirement.requiredMemory(Req, Memory);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class MemoryRequirement extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private MemoryRequirement() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static MemoryRequirement 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.cps.queries.internal.MemoryRequirement (visibility: PUBLIC, simpleName: MemoryRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.MemoryRequirement (visibility: PUBLIC, simpleName: MemoryRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 MemoryRequirement INSTANCE = new MemoryRequirement(); + + /** + * 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 MemoryRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Memory); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.memoryRequirement"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","App","Memory"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_App = body.getOrCreateVariableByName("App"); + PVariable var_Memory = body.getOrCreateVariableByName("Memory"); + PVariable var_Req = body.getOrCreateVariableByName("Req"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Memory), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_App, parameter_App), + new ExportedParameter(body, var_Memory, parameter_Memory) + )); + // find resourceRequirement(Host, App, Req) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_App, var_Req), ResourceRequirement.instance().getInternalQueryRepresentation()); + // ResourceRequirement.requiredMemory(Req, Memory) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredMemory"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_0_, var_Memory); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java new file mode 100644 index 00000000..8c5bdefe --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java @@ -0,0 +1,168 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.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.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 resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) {
+ *         	ApplicationInstance.allocatedTo(App, Host);
+ *         	ApplicationInstance.type.requirements(App, Req);
+ *         	HostInstance.type(Host, HostType);
+ *         	ResourceRequirement.hostType(Req, HostType);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class ResourceRequirement extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private ResourceRequirement() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static ResourceRequirement 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.cps.queries.internal.ResourceRequirement (visibility: PUBLIC, simpleName: ResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.ResourceRequirement (visibility: PUBLIC, simpleName: ResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 ResourceRequirement INSTANCE = new ResourceRequirement(); + + /** + * 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 ResourceRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ResourceRequirement")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Req); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","App","Req"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_App = body.getOrCreateVariableByName("App"); + PVariable var_Req = body.getOrCreateVariableByName("Req"); + PVariable var_HostType = body.getOrCreateVariableByName("HostType"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_App, parameter_App), + new ExportedParameter(body, var_Req, parameter_Req) + )); + // ApplicationInstance.allocatedTo(App, Host) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new Equality(body, var__virtual_0_, var_Host); + // ApplicationInstance.type.requirements(App, Req) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); + 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/cps", "ApplicationType", "requirements"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + new Equality(body, var__virtual_2_, var_Req); + // HostInstance.type(Host, HostType) + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + new Equality(body, var__virtual_3_, var_HostType); + // ResourceRequirement.hostType(Req, HostType) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + new Equality(body, var__virtual_4_, var_HostType); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/SatisfyingInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/SatisfyingInstance.java new file mode 100644 index 00000000..4285101c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/SatisfyingInstance.java @@ -0,0 +1,153 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.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.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 satisfyingInstance(Req : Requirement, App : ApplicationInstance) {
+ *         	Requirement.instances(Req, App);
+ *         	Requirement.type(Req, Type);
+ *         	ApplicationInstance.type(App, Type);
+ *         }
+ * 
+ * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class SatisfyingInstance extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private SatisfyingInstance() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static SatisfyingInstance 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.cps.queries.internal.SatisfyingInstance (visibility: PUBLIC, simpleName: SatisfyingInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.SatisfyingInstance (visibility: PUBLIC, simpleName: SatisfyingInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 SatisfyingInstance INSTANCE = new SatisfyingInstance(); + + /** + * 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 SatisfyingInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.Requirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "Requirement")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Req, parameter_App); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.satisfyingInstance"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Req","App"); + } + + @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_Req = body.getOrCreateVariableByName("Req"); + PVariable var_App = body.getOrCreateVariableByName("App"); + PVariable var_Type = body.getOrCreateVariableByName("Type"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Req, parameter_Req), + new ExportedParameter(body, var_App, parameter_App) + )); + // Requirement.instances(Req, App) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "instances"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new Equality(body, var__virtual_0_, var_App); + // Requirement.type(Req, Type) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); + new Equality(body, var__virtual_1_, var_Type); + // ApplicationInstance.type(App, Type) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); + new Equality(body, var__virtual_2_, var_Type); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql new file mode 100644 index 00000000..7f7cc5a4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql @@ -0,0 +1,132 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries + +import "http://www.eclipse.org/emf/2002/Ecore" +import "http://www.example.org/cps" + +@QueryBasedFeature(feature = "applications") +pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) { + CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance); +} + +@QueryBasedFeature(feature = "hosts") +pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) { + CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance); +} + +@QueryBasedFeature(feature = "totalMemory") +pattern totalMemory(Host : HostInstance, Memory : EInt) { + HostInstance.type.defaultMemory(Host, Memory); +} + +@QueryBasedFeature(feature = "totalHdd") +pattern totalHdd(Host : HostInstance, Hdd : EInt) { + HostInstance.type.defaultHdd(Host, Hdd); +} + +@QueryBasedFeature(feature = "availableMemory") +pattern availableMemory(Host : HostInstance, Memory : java Integer) { + find totalMemory(Host, TotalMemory); + RequiredMemory == sum find memoryRequirement(Host, _, #_); + Memory == eval(TotalMemory - RequiredMemory); +} + +private pattern memoryRequirement(Host : HostInstance, App : ApplicationInstance, Memory : EInt) { + find resourceRequirement(Host, App, Req); + ResourceRequirement.requiredMemory(Req, Memory); +} + +@QueryBasedFeature(feature = "availableHdd") +pattern availableHdd(Host : HostInstance, Hdd : java Integer) { + find totalHdd(Host, TotalHdd); + RequiredHdd == sum find hddRequirement(Host, _, #_); + Hdd == eval(TotalHdd - RequiredHdd); +} + +private pattern hddRequirement(Host : HostInstance, App : ApplicationInstance, Hdd : EInt) { + find resourceRequirement(Host, App, Req); + ResourceRequirement.requiredHdd(Req, Hdd); +} + +private pattern resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) { + ApplicationInstance.allocatedTo(App, Host); + ApplicationInstance.type.requirements(App, Req); + HostInstance.type(Host, HostType); + ResourceRequirement.hostType(Req, HostType); +} + +@Constraint(severity = "error", key = {Host, App}, + message = "Application instance must be allocated to a supported host type.") +pattern allocationWithoutResourceRequirement(Host : HostInstance, App : ApplicationInstance) { + ApplicationInstance.allocatedTo(App, Host); + neg find resourceRequirement(Host, App, _); +} + +@Constraint(severity = "error", key = {Host}, + message = "Insufficient memory available on host.") +pattern notEnoughAvailableMemory(Host : HostInstance) { + find availableMemory(Host, Memory); + check(Memory < 0); +} + +@Constraint(severity = "error", key = {Host}, + message = "Insufficient HDD available on host.") +pattern notEnoughAvailableHdd(Host : HostInstance) { + find availableHdd(Host, Hdd); + check(Hdd < 0); +} + +@Constraint(severity = "error", key = {Req, App}, + message = "Requirement must be satisfied by the required application type.") +pattern instanceDoesNotSatisfyRequirement(Req : Requirement, App : ApplicationInstance) { + Requirement.instances(Req, App); + neg find satisfyingInstance(Req, App); +} + +private pattern satisfyingInstance(Req : Requirement, App : ApplicationInstance) { + Requirement.instances(Req, App); + Requirement.type(Req, Type); + ApplicationInstance.type(App, Type); +} + +@Constraint(severity = "error", key = {Req}, + message = "Requirement is not satisfied by enough application instances.") +pattern requirementNotSatisfied(Req : Requirement) { + Instances == count find satisfyingInstance(Req, _); + Requirement.count(Req, RequiredCount); + check(Instances < RequiredCount); +} + +pattern averageFreeMemoryMetric(Average : java Double) { + Average == avg find freeMemoryPercentage(_, #_); +} + +private pattern freeMemoryPercentage(Host : HostInstance, Free : java Double) { + find totalMemory(Host, Total); + find availableMemory(Host, Available); + Free == eval((Available as double) / Total); +} + +pattern averageFreeHddMetric(Average : java Double) { + Average == avg find freeHddPercentage(_, #_); +} + +private pattern freeHddPercentage(Host : HostInstance, Free : java Double) { + find totalHdd(Host, Total); + find availableHdd(Host, Available); + Free == eval((Available as double) / Total); +} + +pattern costMetric(Cost : java Integer) { + Cost == sum find cpsCost(_, #_); +} + +pattern cpsCost(Cps : CyberPhysicalSystem, Cost : java Integer) { + AppCount == count find cpsApplications(Cps, _); + HostCost == sum find hostInstanceCost(Cps, _, #_); + Cost == eval(5 * AppCount + HostCost); +} + +private pattern hostInstanceCost(Cps : CyberPhysicalSystem, Host : HostInstance, Cost : EInt) { + find cpsHosts(Cps, Host); + HostInstance.type.cost(Host, Cost); +} 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 5d75b948..f08e6b96 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml @@ -1,12 +1,12 @@ - - - + + + @@ -23,6 +23,9 @@ + + + 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 c86761ce..31c5a70a 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; @@ -15,6 +17,7 @@ import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NotEnoughInterferome import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.SmallSat; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.SpacecraftOfKind; 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; @@ -42,6 +45,9 @@ import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; *

  • cubeSatWithKaAntenna
  • *
  • smallSat
  • *
  • spacecraftOfKind
  • + *
  • coverageMetric
  • + *
  • timeMetric
  • + *
  • costMetric
  • * * * @see IQueryGroup @@ -80,6 +86,9 @@ public final class SatelliteQueries extends BaseGeneratedPatternGroup { querySpecifications.add(CubeSatWithKaAntenna.instance()); querySpecifications.add(SmallSat.instance()); querySpecifications.add(SpacecraftOfKind.instance()); + querySpecifications.add(CoverageMetric.instance()); + querySpecifications.add(TimeMetric.instance()); + querySpecifications.add(CostMetric.instance()); } public CommunicationLinkDoesNotStartAtContainingElement getCommunicationLinkDoesNotStartAtContainingElement() { @@ -193,4 +202,28 @@ public final class SatelliteQueries extends BaseGeneratedPatternGroup { public SpacecraftOfKind.Matcher getSpacecraftOfKind(final ViatraQueryEngine engine) { return SpacecraftOfKind.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/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/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..293fdbe0 --- /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", "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..833148f9 --- /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,195 @@ +/** + * 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.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) {
    + *         	CubeSat3U(Spacecraft);
    + *         	BasePrice == 250000.0;
    + *         } or {
    + *         	CubeSat6U(Spacecraft);
    + *         	BasePrice == 750000.0;
    + *         } or {
    + *         	SmallSat(Spacecraft);
    + *         	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", "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) + )); + // CubeSat3U(Spacecraft) + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CubeSat3U"))); + // BasePrice == 250000.0 + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, 250000.0); + new Equality(body, var_BasePrice, var__virtual_0_); + 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) + )); + // CubeSat6U(Spacecraft) + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "CubeSat6U"))); + // BasePrice == 750000.0 + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, 750000.0); + new Equality(body, var_BasePrice, var__virtual_0_); + 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) + )); + // SmallSat(Spacecraft) + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "SmallSat"))); + // BasePrice == 3000000.0 + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new ConstantValue(body, var__virtual_0_, 3000000.0); + new Equality(body, var_BasePrice, var__virtual_0_); + 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..4d18f028 --- /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", "satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_Source = new PParameter("Source", "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..535f32d9 --- /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", "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..c3389e11 --- /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", "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..639d82ef --- /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", "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..5e610441 --- /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", "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 36fa4557..e474ddf1 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; @@ -15,9 +17,12 @@ import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.NotEnoughInterferome import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.SmallSat; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.SpacecraftOfKind; 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; @@ -26,11 +31,22 @@ import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CommSubsyst import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.CubeSat3U; 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.IndirectLinkAllowed; +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.InterferometryPayloadCost; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.LinkAllowed; import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MatchingAntenna; +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.SpacecraftCost; +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; /** @@ -67,6 +83,22 @@ import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; *

  • cubeSatWithKaAntenna
  • *
  • smallSat
  • *
  • spacecraftOfKind
  • + *
  • coverageMetric
  • + *
  • missionCoverage
  • + *
  • timeMetric
  • + *
  • missionTime
  • + *
  • transmitTime
  • + *
  • incomingData
  • + *
  • scienceData
  • + *
  • transmitRate
  • + *
  • spacecraftUplink
  • + *
  • costMetric
  • + *
  • missionCost
  • + *
  • spacecraftCost
  • + *
  • basePrice
  • + *
  • interferometryPayloadCost
  • + *
  • additionalCommSubsystemCost
  • + *
  • spacecraftWithTwoCommSubsystems
  • * * * @see IQueryGroup @@ -119,5 +151,21 @@ public final class SatelliteQueriesAll extends BaseGeneratedPatternGroup { querySpecifications.add(CubeSatWithKaAntenna.instance()); querySpecifications.add(SmallSat.instance()); querySpecifications.add(SpacecraftOfKind.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(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..bb262a0b --- /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", "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/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..ca71cdd8 --- /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,209 @@ +/** + * 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.SpacecraftOfKind; +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 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.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);
    + *         	find spacecraftOfKind(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", "satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "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); + // find spacecraftOfKind(Spacecraft, Kind) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_Kind), SpacecraftOfKind.instance().getInternalQueryRepresentation()); + // KindCount == count find spacecraftOfKind(_, Kind) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new PatternMatchCounter(body, Tuples.flatTupleOf(var___0_, var_Kind), SpacecraftOfKind.instance().getInternalQueryRepresentation(), var__virtual_1_); + new Equality(body, var_KindCount, var__virtual_1_); + // 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_2_ = body.getOrCreateVariableByName(".virtual{2}"); + 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_2_ ); + new Equality(body, var_Cost, var__virtual_2_); + 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/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..8ecc1717 --- /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", "satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_Band = new PParameter("Band", "satellite.TransceiverBand", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.example.org/satellite", "TransceiverBand")), PParameterDirection.INOUT); + + private final PParameter parameter_Target = new PParameter("Target", "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..a91f7b92 --- /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", "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..174e076a --- /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", "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..a64c750a --- /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", "satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "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 0207cfe3..9b77ef72 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 @@ -210,7 +210,7 @@ pattern spacecraftOfKind(Spacecraft : Spacecraft, Kind : SpacecraftKind) { Kind == SpacecraftKind::SmallSat; } -/* + // // Metrics // @@ -310,13 +310,13 @@ private pattern spacecraftCost(Mission : InterferometryMission, Spacecraft : Spa } private pattern basePrice(Spacecraft : Spacecraft, BasePrice : java Double) { - CubeSat3U(Spacecraft): + CubeSat3U(Spacecraft); BasePrice == 250000.0; } or { - CubeSat6U(Spacecraft): + CubeSat6U(Spacecraft); BasePrice == 750000.0; } or { - SmallSat(Spacecraft): + SmallSat(Spacecraft); BasePrice == 3000000.0; } @@ -341,4 +341,3 @@ private pattern spacecraftWithTwoCommSubsystems(Spacecraft : Spacecraft) { Spacecraft.commSubsystem(Spacecraft, Subsystem2); Subsystem1 != Subsystem2; } -*/ \ No newline at end of file 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 2f1887a8..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-54-g00ecf From fd3684b5440dacca0c4bf4be15930555a79e2100 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Tue, 21 May 2019 17:00:01 -0400 Subject: VIATRA DSE and COIN-OR CBC implementations of CPS case study --- .../.project | 1 - .../META-INF/MANIFEST.MF | 7 +- .../inf/dslreasoner/domains/cps/CpsPackage.java | 175 +- .../domains/cps/CyberPhysicalSystem.java | 36 - .../inf/dslreasoner/domains/cps/HostInstance.java | 68 - .../domains/cps/impl/CpsPackageImpl.java | 124 +- .../domains/cps/impl/CyberPhysicalSystemImpl.java | 57 - .../domains/cps/impl/HostInstanceImpl.java | 105 -- .../model/cps.aird | 1705 -------------------- .../model/cps.ecore | 41 - .../model/cps.genmodel | 6 - .../plugin.xml | 30 +- .../representations.aird | 600 +++++++ .../inf/dslreasoner/domains/cps/queries/.gitignore | 10 + .../dslreasoner/domains/cps/queries/Allocate.java | 862 ++++++++++ .../AllocationWithoutResourceRequirement.java | 2 +- .../domains/cps/queries/AvailableHdd.java | 743 --------- .../domains/cps/queries/AvailableMemory.java | 743 --------- .../domains/cps/queries/AverageFreeHddMetric.java | 4 + .../cps/queries/AverageFreeMemoryMetric.java | 12 + .../domains/cps/queries/CostMetric.java | 4 + .../domains/cps/queries/CpsApplications.java | 705 -------- .../dslreasoner/domains/cps/queries/CpsCost.java | 2 +- .../dslreasoner/domains/cps/queries/CpsHosts.java | 705 -------- .../domains/cps/queries/CpsQueries.java | 124 +- .../domains/cps/queries/CreateHostInstance.java | 553 +++++++ .../domains/cps/queries/GuidanceObjective.java | 591 +++++++ .../domains/cps/queries/NotEnoughAvailableHdd.java | 2 +- .../cps/queries/NotEnoughAvailableMemory.java | 2 +- .../domains/cps/queries/RemoveHostInstance.java | 579 +++++++ .../domains/cps/queries/ResourceRequirement.java | 829 ++++++++++ .../dslreasoner/domains/cps/queries/TotalHdd.java | 706 -------- .../domains/cps/queries/TotalMemory.java | 706 -------- .../domains/cps/queries/UnallocateAppInstance.java | 541 +++++++ .../domains/cps/queries/internal/.gitignore | 9 + .../domains/cps/queries/internal/AvailableHdd.java | 178 ++ .../cps/queries/internal/AvailableMemory.java | 178 ++ .../cps/queries/internal/CpsApplications.java | 141 ++ .../domains/cps/queries/internal/CpsHosts.java | 141 ++ .../cps/queries/internal/CpsQueriesAll.java | 38 +- .../cps/queries/internal/FreeHddPercentage.java | 4 +- .../cps/queries/internal/FreeMemoryPercentage.java | 4 +- .../cps/queries/internal/HddRequirement.java | 2 +- .../cps/queries/internal/HostInstanceCost.java | 2 +- .../cps/queries/internal/MemoryRequirement.java | 2 +- .../cps/queries/internal/NoHostToAllocateTo.java | 135 ++ .../cps/queries/internal/RequiredAppInstances.java | 181 +++ .../cps/queries/internal/ResourceRequirement.java | 168 -- .../domains/cps/queries/internal/TotalHdd.java | 143 ++ .../domains/cps/queries/internal/TotalMemory.java | 143 ++ .../queries/internal/UnallocatedAppInstance.java | 172 ++ .../dslreasoner/domains/cps/cplex/CbcCpsMain.xtend | 53 + .../domains/cps/cplex/CpsToLpTranslator.xtend | 171 ++ .../domains/cps/dse/CpsStateCoder.xtend | 134 ++ .../domains/cps/dse/RuleBasedCpsMain.xtend | 39 + .../domains/cps/dse/RuleBasedCpsSolver.xtend | 74 + .../domains/cps/generator/CpsGenerator.xtend | 7 + .../dslreasoner/domains/cps/queries/CpsQueries.vql | 82 +- .../domains/cps/cplex/.CbcCpsMain.xtendbin | Bin 0 -> 5693 bytes .../domains/cps/cplex/.CpsToLpTranslator.xtendbin | Bin 0 -> 11104 bytes .../inf/dslreasoner/domains/cps/cplex/.gitignore | 2 + .../dslreasoner/domains/cps/cplex/CbcCpsMain.java | 77 + .../domains/cps/cplex/CpsToLpTranslator.java | 505 ++++++ .../domains/cps/dse/.CpsStateCoder.xtendbin | Bin 0 -> 7626 bytes .../domains/cps/dse/.RuleBasedCpsMain.xtendbin | Bin 0 -> 5189 bytes .../domains/cps/dse/.RuleBasedCpsSolver.xtendbin | Bin 0 -> 7336 bytes .../mit/inf/dslreasoner/domains/cps/dse/.gitignore | 3 + .../dslreasoner/domains/cps/dse/CpsStateCoder.java | 316 ++++ .../domains/cps/dse/RuleBasedCpsMain.java | 46 + .../domains/cps/dse/RuleBasedCpsSolver.java | 93 ++ .../domains/cps/generator/.CpsGenerator.xtendbin | Bin 0 -> 8807 bytes .../domains/cps/generator/CpsGenerator.java | 154 ++ 72 files changed, 7869 insertions(+), 6908 deletions(-) delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.aird create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/representations.aird create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/Allocate.java delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CreateHostInstance.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/GuidanceObjective.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RemoveHostInstance.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/ResourceRequirement.java delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/UnallocateAppInstance.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableHdd.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableMemory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsApplications.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsHosts.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/NoHostToAllocateTo.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/RequiredAppInstances.java delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalHdd.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalMemory.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/UnallocatedAppInstance.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.xtend create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.xtend create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.xtend create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.xtend create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CbcCpsMain.xtendbin create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CpsToLpTranslator.xtendbin create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.gitignore create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.CpsStateCoder.xtendbin create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsMain.xtendbin create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsSolver.xtendbin create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.gitignore create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/.CpsGenerator.xtendbin create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.java (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel') diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project index 69c44278..41867b27 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/.project @@ -32,7 +32,6 @@ - org.eclipse.sirius.nature.modelingproject org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature org.eclipse.viatra.query.projectnature diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF index 76e1eefb..c06b7112 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/META-INF/MANIFEST.MF @@ -18,7 +18,12 @@ Require-Bundle: org.eclipse.viatra.addon.querybasedfeatures.runtime, org.eclipse.emf.ecore;visibility:=reexport, org.eclipse.core.runtime, org.eclipse.xtend.lib;bundle-version="2.16.0", - org.eclipse.xtend.lib.macro;bundle-version="2.16.0" + org.eclipse.xtend.lib.macro;bundle-version="2.16.0", + hu.bme.mit.inf.dslreasoner.application;bundle-version="1.0.0", + org.eclipse.viatra.dse;bundle-version="0.22.0", + org.eclipse.viatra.dse.genetic;bundle-version="0.22.0", + hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner;bundle-version="1.0.0", + org.eclipse.emf.ecore.xmi;bundle-version="2.15.0" Import-Package: org.apache.log4j Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.domains.cps Bundle-ActivationPolicy: lazy diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java index 2d7e0660..b0c69786 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CpsPackage.java @@ -21,7 +21,6 @@ import org.eclipse.emf.ecore.EReference; * * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory * @model kind="package" - * annotation="http://www.eclipse.org/emf/2002/Ecore settingDelegates='org.eclipse.viatra.query.querybasedfeature'" * @generated */ public interface CpsPackage extends EPackage { @@ -94,24 +93,6 @@ public interface CpsPackage extends EPackage { */ int CYBER_PHYSICAL_SYSTEM__HOST_TYPES = 2; - /** - * The feature id for the 'Hosts' reference list. - * - * - * @generated - * @ordered - */ - int CYBER_PHYSICAL_SYSTEM__HOSTS = 3; - - /** - * The feature id for the 'Applications' reference list. - * - * - * @generated - * @ordered - */ - int CYBER_PHYSICAL_SYSTEM__APPLICATIONS = 4; - /** * The number of structural features of the 'Cyber Physical System' class. * @@ -119,7 +100,7 @@ public interface CpsPackage extends EPackage { * @generated * @ordered */ - int CYBER_PHYSICAL_SYSTEM_FEATURE_COUNT = 5; + int CYBER_PHYSICAL_SYSTEM_FEATURE_COUNT = 3; /** * The number of operations of the 'Cyber Physical System' class. @@ -470,42 +451,6 @@ public interface CpsPackage extends EPackage { */ int HOST_INSTANCE__TYPE = 0; - /** - * The feature id for the 'Available Memory' attribute. - * - * - * @generated - * @ordered - */ - int HOST_INSTANCE__AVAILABLE_MEMORY = 1; - - /** - * The feature id for the 'Available Hdd' attribute. - * - * - * @generated - * @ordered - */ - int HOST_INSTANCE__AVAILABLE_HDD = 2; - - /** - * The feature id for the 'Total Memory' attribute. - * - * - * @generated - * @ordered - */ - int HOST_INSTANCE__TOTAL_MEMORY = 3; - - /** - * The feature id for the 'Total Hdd' attribute. - * - * - * @generated - * @ordered - */ - int HOST_INSTANCE__TOTAL_HDD = 4; - /** * The feature id for the 'Applications' reference list. * @@ -513,7 +458,7 @@ public interface CpsPackage extends EPackage { * @generated * @ordered */ - int HOST_INSTANCE__APPLICATIONS = 5; + int HOST_INSTANCE__APPLICATIONS = 1; /** * The number of structural features of the 'Host Instance' class. @@ -522,7 +467,7 @@ public interface CpsPackage extends EPackage { * @generated * @ordered */ - int HOST_INSTANCE_FEATURE_COUNT = 6; + int HOST_INSTANCE_FEATURE_COUNT = 2; /** * The number of operations of the 'Host Instance' class. @@ -576,28 +521,6 @@ public interface CpsPackage extends EPackage { */ EReference getCyberPhysicalSystem_HostTypes(); - /** - * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHosts Hosts}'. - * - * - * @return the meta object for the reference list 'Hosts'. - * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHosts() - * @see #getCyberPhysicalSystem() - * @generated - */ - EReference getCyberPhysicalSystem_Hosts(); - - /** - * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplications Applications}'. - * - * - * @return the meta object for the reference list 'Applications'. - * @see hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplications() - * @see #getCyberPhysicalSystem() - * @generated - */ - EReference getCyberPhysicalSystem_Applications(); - /** * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType Application Type}'. * @@ -866,50 +789,6 @@ public interface CpsPackage extends EPackage { */ EReference getHostInstance_Type(); - /** - * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableMemory Available Memory}'. - * - * - * @return the meta object for the attribute 'Available Memory'. - * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableMemory() - * @see #getHostInstance() - * @generated - */ - EAttribute getHostInstance_AvailableMemory(); - - /** - * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableHdd Available Hdd}'. - * - * - * @return the meta object for the attribute 'Available Hdd'. - * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableHdd() - * @see #getHostInstance() - * @generated - */ - EAttribute getHostInstance_AvailableHdd(); - - /** - * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalMemory Total Memory}'. - * - * - * @return the meta object for the attribute 'Total Memory'. - * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalMemory() - * @see #getHostInstance() - * @generated - */ - EAttribute getHostInstance_TotalMemory(); - - /** - * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalHdd Total Hdd}'. - * - * - * @return the meta object for the attribute 'Total Hdd'. - * @see hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalHdd() - * @see #getHostInstance() - * @generated - */ - EAttribute getHostInstance_TotalHdd(); - /** * Returns the meta object for the reference list '{@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications Applications}'. * @@ -978,22 +857,6 @@ public interface CpsPackage extends EPackage { */ EReference CYBER_PHYSICAL_SYSTEM__HOST_TYPES = eINSTANCE.getCyberPhysicalSystem_HostTypes(); - /** - * The meta object literal for the 'Hosts' reference list feature. - * - * - * @generated - */ - EReference CYBER_PHYSICAL_SYSTEM__HOSTS = eINSTANCE.getCyberPhysicalSystem_Hosts(); - - /** - * The meta object literal for the 'Applications' reference list feature. - * - * - * @generated - */ - EReference CYBER_PHYSICAL_SYSTEM__APPLICATIONS = eINSTANCE.getCyberPhysicalSystem_Applications(); - /** * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.ApplicationTypeImpl Application Type}' class. * @@ -1208,38 +1071,6 @@ public interface CpsPackage extends EPackage { */ EReference HOST_INSTANCE__TYPE = eINSTANCE.getHostInstance_Type(); - /** - * The meta object literal for the 'Available Memory' attribute feature. - * - * - * @generated - */ - EAttribute HOST_INSTANCE__AVAILABLE_MEMORY = eINSTANCE.getHostInstance_AvailableMemory(); - - /** - * The meta object literal for the 'Available Hdd' attribute feature. - * - * - * @generated - */ - EAttribute HOST_INSTANCE__AVAILABLE_HDD = eINSTANCE.getHostInstance_AvailableHdd(); - - /** - * The meta object literal for the 'Total Memory' attribute feature. - * - * - * @generated - */ - EAttribute HOST_INSTANCE__TOTAL_MEMORY = eINSTANCE.getHostInstance_TotalMemory(); - - /** - * The meta object literal for the 'Total Hdd' attribute feature. - * - * - * @generated - */ - EAttribute HOST_INSTANCE__TOTAL_HDD = eINSTANCE.getHostInstance_TotalHdd(); - /** * The meta object literal for the 'Applications' reference list feature. * diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java index 541916ba..fbf4ce0d 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/CyberPhysicalSystem.java @@ -18,8 +18,6 @@ import org.eclipse.emf.ecore.EObject; *

  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getRequests Requests}
  • *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplicationTypes Application Types}
  • *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHostTypes Host Types}
  • - *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getHosts Hosts}
  • - *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem#getApplications Applications}
  • * * * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem() @@ -75,38 +73,4 @@ public interface CyberPhysicalSystem extends EObject { */ EList getHostTypes(); - /** - * Returns the value of the 'Hosts' reference list. - * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance}. - * - *

    - * If the meaning of the 'Hosts' reference list isn't clear, - * there really should be more of a description here... - *

    - * - * @return the value of the 'Hosts' reference list. - * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_Hosts() - * @model transient="true" changeable="false" volatile="true" derived="true" - * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts'" - * @generated - */ - EList getHosts(); - - /** - * Returns the value of the 'Applications' reference list. - * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. - * - *

    - * If the meaning of the 'Applications' reference list isn't clear, - * there really should be more of a description here... - *

    - * - * @return the value of the 'Applications' reference list. - * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getCyberPhysicalSystem_Applications() - * @model transient="true" changeable="false" volatile="true" derived="true" - * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications'" - * @generated - */ - EList getApplications(); - } // CyberPhysicalSystem diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java index 43379e0f..b4721842 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/HostInstance.java @@ -16,10 +16,6 @@ import org.eclipse.emf.ecore.EObject; *

    *
      *
    • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getType Type}
    • - *
    • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableMemory Available Memory}
    • - *
    • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getAvailableHdd Available Hdd}
    • - *
    • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalMemory Total Memory}
    • - *
    • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getTotalHdd Total Hdd}
    • *
    • {@link hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance#getApplications Applications}
    • *
    * @@ -56,70 +52,6 @@ public interface HostInstance extends EObject { */ void setType(HostType value); - /** - * Returns the value of the 'Available Memory' attribute. - * - *

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

    - * - * @return the value of the 'Available Memory' attribute. - * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_AvailableMemory() - * @model transient="true" changeable="false" volatile="true" derived="true" - * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory'" - * @generated - */ - int getAvailableMemory(); - - /** - * Returns the value of the 'Available Hdd' attribute. - * - *

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

    - * - * @return the value of the 'Available Hdd' attribute. - * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_AvailableHdd() - * @model transient="true" changeable="false" volatile="true" derived="true" - * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd'" - * @generated - */ - int getAvailableHdd(); - - /** - * Returns the value of the 'Total Memory' attribute. - * - *

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

    - * - * @return the value of the 'Total Memory' attribute. - * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_TotalMemory() - * @model transient="true" changeable="false" volatile="true" derived="true" - * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory'" - * @generated - */ - int getTotalMemory(); - - /** - * Returns the value of the 'Total Hdd' attribute. - * - *

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

    - * - * @return the value of the 'Total Hdd' attribute. - * @see hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage#getHostInstance_TotalHdd() - * @model transient="true" changeable="false" volatile="true" derived="true" - * annotation="org.eclipse.viatra.query.querybasedfeature patternFQN='hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd'" - * @generated - */ - int getTotalHdd(); - /** * Returns the value of the 'Applications' reference list. * The list contents are of type {@link hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance}. diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java index 1f143a64..e29ccccd 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CpsPackageImpl.java @@ -187,26 +187,6 @@ public class CpsPackageImpl extends EPackageImpl implements CpsPackage { return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(2); } - /** - * - * - * @generated - */ - @Override - public EReference getCyberPhysicalSystem_Hosts() { - return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(3); - } - - /** - * - * - * @generated - */ - @Override - public EReference getCyberPhysicalSystem_Applications() { - return (EReference) cyberPhysicalSystemEClass.getEStructuralFeatures().get(4); - } - /** * * @@ -457,46 +437,6 @@ public class CpsPackageImpl extends EPackageImpl implements CpsPackage { return (EReference) hostInstanceEClass.getEStructuralFeatures().get(0); } - /** - * - * - * @generated - */ - @Override - public EAttribute getHostInstance_AvailableMemory() { - return (EAttribute) hostInstanceEClass.getEStructuralFeatures().get(1); - } - - /** - * - * - * @generated - */ - @Override - public EAttribute getHostInstance_AvailableHdd() { - return (EAttribute) hostInstanceEClass.getEStructuralFeatures().get(2); - } - - /** - * - * - * @generated - */ - @Override - public EAttribute getHostInstance_TotalMemory() { - return (EAttribute) hostInstanceEClass.getEStructuralFeatures().get(3); - } - - /** - * - * - * @generated - */ - @Override - public EAttribute getHostInstance_TotalHdd() { - return (EAttribute) hostInstanceEClass.getEStructuralFeatures().get(4); - } - /** * * @@ -504,7 +444,7 @@ public class CpsPackageImpl extends EPackageImpl implements CpsPackage { */ @Override public EReference getHostInstance_Applications() { - return (EReference) hostInstanceEClass.getEStructuralFeatures().get(5); + return (EReference) hostInstanceEClass.getEStructuralFeatures().get(1); } /** @@ -541,8 +481,6 @@ public class CpsPackageImpl extends EPackageImpl implements CpsPackage { createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__REQUESTS); createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__APPLICATION_TYPES); createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__HOST_TYPES); - createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__HOSTS); - createEReference(cyberPhysicalSystemEClass, CYBER_PHYSICAL_SYSTEM__APPLICATIONS); applicationTypeEClass = createEClass(APPLICATION_TYPE); createEReference(applicationTypeEClass, APPLICATION_TYPE__INSTANCES); @@ -575,10 +513,6 @@ public class CpsPackageImpl extends EPackageImpl implements CpsPackage { hostInstanceEClass = createEClass(HOST_INSTANCE); createEReference(hostInstanceEClass, HOST_INSTANCE__TYPE); - createEAttribute(hostInstanceEClass, HOST_INSTANCE__AVAILABLE_MEMORY); - createEAttribute(hostInstanceEClass, HOST_INSTANCE__AVAILABLE_HDD); - createEAttribute(hostInstanceEClass, HOST_INSTANCE__TOTAL_MEMORY); - createEAttribute(hostInstanceEClass, HOST_INSTANCE__TOTAL_HDD); createEReference(hostInstanceEClass, HOST_INSTANCE__APPLICATIONS); } @@ -624,12 +558,6 @@ public class CpsPackageImpl extends EPackageImpl implements CpsPackage { initEReference(getCyberPhysicalSystem_HostTypes(), this.getHostType(), null, "hostTypes", null, 0, -1, CyberPhysicalSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getCyberPhysicalSystem_Hosts(), this.getHostInstance(), null, "hosts", null, 0, -1, - CyberPhysicalSystem.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, - !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); - initEReference(getCyberPhysicalSystem_Applications(), this.getApplicationInstance(), null, "applications", null, - 0, -1, CyberPhysicalSystem.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, - IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEClass(applicationTypeEClass, ApplicationType.class, "ApplicationType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); @@ -703,17 +631,6 @@ public class CpsPackageImpl extends EPackageImpl implements CpsPackage { initEReference(getHostInstance_Type(), this.getHostType(), this.getHostType_Instances(), "type", null, 1, 1, HostInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getHostInstance_AvailableMemory(), ecorePackage.getEInt(), "availableMemory", null, 0, 1, - HostInstance.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - IS_DERIVED, IS_ORDERED); - initEAttribute(getHostInstance_AvailableHdd(), ecorePackage.getEInt(), "availableHdd", null, 0, 1, - HostInstance.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - IS_DERIVED, IS_ORDERED); - initEAttribute(getHostInstance_TotalMemory(), ecorePackage.getEInt(), "totalMemory", null, 0, 1, - HostInstance.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - IS_DERIVED, IS_ORDERED); - initEAttribute(getHostInstance_TotalHdd(), ecorePackage.getEInt(), "totalHdd", null, 0, 1, HostInstance.class, - IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEReference(getHostInstance_Applications(), this.getApplicationInstance(), this.getApplicationInstance_AllocatedTo(), "applications", null, 0, -1, HostInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, @@ -721,45 +638,6 @@ public class CpsPackageImpl extends EPackageImpl implements CpsPackage { // Create resource createResource(eNS_URI); - - // Create annotations - // http://www.eclipse.org/emf/2002/Ecore - createEcoreAnnotations(); - // org.eclipse.viatra.query.querybasedfeature - createOrgAnnotations(); - } - - /** - * Initializes the annotations for http://www.eclipse.org/emf/2002/Ecore. - * - * - * @generated - */ - protected void createEcoreAnnotations() { - String source = "http://www.eclipse.org/emf/2002/Ecore"; - addAnnotation(this, source, new String[] { "settingDelegates", "org.eclipse.viatra.query.querybasedfeature" }); - } - - /** - * Initializes the annotations for org.eclipse.viatra.query.querybasedfeature. - * - * - * @generated - */ - protected void createOrgAnnotations() { - String source = "org.eclipse.viatra.query.querybasedfeature"; - addAnnotation(getCyberPhysicalSystem_Hosts(), source, - new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts" }); - addAnnotation(getCyberPhysicalSystem_Applications(), source, - new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications" }); - addAnnotation(getHostInstance_AvailableMemory(), source, - new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory" }); - addAnnotation(getHostInstance_AvailableHdd(), source, - new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd" }); - addAnnotation(getHostInstance_TotalMemory(), source, - new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory" }); - addAnnotation(getHostInstance_TotalHdd(), source, - new String[] { "patternFQN", "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd" }); } } //CpsPackageImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java index 4d254f25..3ba111af 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/CyberPhysicalSystemImpl.java @@ -2,11 +2,9 @@ */ package hu.bme.mit.inf.dslreasoner.domains.cps.impl; -import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; -import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; import hu.bme.mit.inf.dslreasoner.domains.cps.Request; @@ -17,7 +15,6 @@ import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; @@ -36,8 +33,6 @@ import org.eclipse.emf.ecore.util.InternalEList; *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getRequests Requests}
  • *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getApplicationTypes Application Types}
  • *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getHostTypes Host Types}
  • - *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getHosts Hosts}
  • - *
  • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.CyberPhysicalSystemImpl#getApplications Applications}
  • * * * @generated @@ -73,28 +68,6 @@ public class CyberPhysicalSystemImpl extends MinimalEObjectImpl.Container implem */ protected EList hostTypes; - /** - * The cached setting delegate for the '{@link #getHosts() Hosts}' reference list. - * - * - * @see #getHosts() - * @generated - * @ordered - */ - protected EStructuralFeature.Internal.SettingDelegate HOSTS__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.CYBER_PHYSICAL_SYSTEM__HOSTS) - .getSettingDelegate(); - - /** - * The cached setting delegate for the '{@link #getApplications() Applications}' reference list. - * - * - * @see #getApplications() - * @generated - * @ordered - */ - protected EStructuralFeature.Internal.SettingDelegate APPLICATIONS__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.CYBER_PHYSICAL_SYSTEM__APPLICATIONS) - .getSettingDelegate(); - /** * * @@ -156,28 +129,6 @@ public class CyberPhysicalSystemImpl extends MinimalEObjectImpl.Container implem return hostTypes; } - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public EList getHosts() { - return (EList) HOSTS__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public EList getApplications() { - return (EList) APPLICATIONS__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); - } - /** * * @@ -210,10 +161,6 @@ public class CyberPhysicalSystemImpl extends MinimalEObjectImpl.Container implem return getApplicationTypes(); case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: return getHostTypes(); - case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOSTS: - return getHosts(); - case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATIONS: - return getApplications(); } return super.eGet(featureID, resolve, coreType); } @@ -278,10 +225,6 @@ public class CyberPhysicalSystemImpl extends MinimalEObjectImpl.Container implem return applicationTypes != null && !applicationTypes.isEmpty(); case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOST_TYPES: return hostTypes != null && !hostTypes.isEmpty(); - case CpsPackage.CYBER_PHYSICAL_SYSTEM__HOSTS: - return HOSTS__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); - case CpsPackage.CYBER_PHYSICAL_SYSTEM__APPLICATIONS: - return APPLICATIONS__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); } return super.eIsSet(featureID); } diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java index bbaca59c..551f2ed6 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/ecore-gen/hu/bme/mit/inf/dslreasoner/domains/cps/impl/HostInstanceImpl.java @@ -15,7 +15,6 @@ import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; @@ -34,60 +33,12 @@ import org.eclipse.emf.ecore.util.InternalEList; *

    *
      *
    • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getType Type}
    • - *
    • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getAvailableMemory Available Memory}
    • - *
    • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getAvailableHdd Available Hdd}
    • - *
    • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getTotalMemory Total Memory}
    • - *
    • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getTotalHdd Total Hdd}
    • *
    • {@link hu.bme.mit.inf.dslreasoner.domains.cps.impl.HostInstanceImpl#getApplications Applications}
    • *
    * * @generated */ public class HostInstanceImpl extends MinimalEObjectImpl.Container implements HostInstance { - /** - * The cached setting delegate for the '{@link #getAvailableMemory() Available Memory}' attribute. - * - * - * @see #getAvailableMemory() - * @generated - * @ordered - */ - protected EStructuralFeature.Internal.SettingDelegate AVAILABLE_MEMORY__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.HOST_INSTANCE__AVAILABLE_MEMORY) - .getSettingDelegate(); - - /** - * The cached setting delegate for the '{@link #getAvailableHdd() Available Hdd}' attribute. - * - * - * @see #getAvailableHdd() - * @generated - * @ordered - */ - protected EStructuralFeature.Internal.SettingDelegate AVAILABLE_HDD__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.HOST_INSTANCE__AVAILABLE_HDD) - .getSettingDelegate(); - - /** - * The cached setting delegate for the '{@link #getTotalMemory() Total Memory}' attribute. - * - * - * @see #getTotalMemory() - * @generated - * @ordered - */ - protected EStructuralFeature.Internal.SettingDelegate TOTAL_MEMORY__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.HOST_INSTANCE__TOTAL_MEMORY) - .getSettingDelegate(); - - /** - * The cached setting delegate for the '{@link #getTotalHdd() Total Hdd}' attribute. - * - * - * @see #getTotalHdd() - * @generated - * @ordered - */ - protected EStructuralFeature.Internal.SettingDelegate TOTAL_HDD__ESETTING_DELEGATE = ((EStructuralFeature.Internal) CpsPackage.Literals.HOST_INSTANCE__TOTAL_HDD) - .getSettingDelegate(); - /** * The cached value of the '{@link #getApplications() Applications}' reference list. * @@ -163,46 +114,6 @@ public class HostInstanceImpl extends MinimalEObjectImpl.Container implements Ho eNotify(new ENotificationImpl(this, Notification.SET, CpsPackage.HOST_INSTANCE__TYPE, newType, newType)); } - /** - * - * - * @generated - */ - @Override - public int getAvailableMemory() { - return (Integer) AVAILABLE_MEMORY__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); - } - - /** - * - * - * @generated - */ - @Override - public int getAvailableHdd() { - return (Integer) AVAILABLE_HDD__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); - } - - /** - * - * - * @generated - */ - @Override - public int getTotalMemory() { - return (Integer) TOTAL_MEMORY__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); - } - - /** - * - * - * @generated - */ - @Override - public int getTotalHdd() { - return (Integer) TOTAL_HDD__ESETTING_DELEGATE.dynamicGet(this, null, 0, true, false); - } - /** * * @@ -276,14 +187,6 @@ public class HostInstanceImpl extends MinimalEObjectImpl.Container implements Ho switch (featureID) { case CpsPackage.HOST_INSTANCE__TYPE: return getType(); - case CpsPackage.HOST_INSTANCE__AVAILABLE_MEMORY: - return getAvailableMemory(); - case CpsPackage.HOST_INSTANCE__AVAILABLE_HDD: - return getAvailableHdd(); - case CpsPackage.HOST_INSTANCE__TOTAL_MEMORY: - return getTotalMemory(); - case CpsPackage.HOST_INSTANCE__TOTAL_HDD: - return getTotalHdd(); case CpsPackage.HOST_INSTANCE__APPLICATIONS: return getApplications(); } @@ -338,14 +241,6 @@ public class HostInstanceImpl extends MinimalEObjectImpl.Container implements Ho switch (featureID) { case CpsPackage.HOST_INSTANCE__TYPE: return getType() != null; - case CpsPackage.HOST_INSTANCE__AVAILABLE_MEMORY: - return AVAILABLE_MEMORY__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); - case CpsPackage.HOST_INSTANCE__AVAILABLE_HDD: - return AVAILABLE_HDD__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); - case CpsPackage.HOST_INSTANCE__TOTAL_MEMORY: - return TOTAL_MEMORY__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); - case CpsPackage.HOST_INSTANCE__TOTAL_HDD: - return TOTAL_HDD__ESETTING_DELEGATE.dynamicIsSet(this, null, 0); case CpsPackage.HOST_INSTANCE__APPLICATIONS: return applications != null && !applications.isEmpty(); } diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.aird b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.aird deleted file mode 100644 index 3f1b0301..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.aird +++ /dev/null @@ -1,1705 +0,0 @@ - - - - cps.ecore - cps.genmodel - ../src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql - http://www.eclipse.org/emf/2002/Ecore - java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch - java:/Objects/java.lang.Object - java:/Objects/org.eclipse.viatra.query.runtime.api.IPatternMatch - java:/Primitives - java:/Objects/java.lang.SafeVarargs - java:/Objects/java.util.List - java:/Objects/java.lang.String - java:/Objects/java.lang.CloneNotSupportedException - java:/Objects/java.lang.Throwable - java:/Objects/java.lang.Class - java:/Objects/java.lang.InterruptedException - java:/Objects/java.lang.Exception - java:/Objects/java.io.Serializable - java:/Objects/java.io.PrintWriter - java:/Objects/java.io.PrintStream - java:/Objects/java.lang.StackTraceElement - java:/Objects/java.util.Set - java:/Objects/java.io.ObjectInputStream - java:/Objects/java.io.IOException - java:/Objects/java.lang.ClassNotFoundException - java:/Objects/java.io.ObjectOutputStream - java:/Objects/java.io.Writer - java:/Objects/java.io.OutputStream - java:/Objects/java.io.FileNotFoundException - java:/Objects/java.io.File - java:/Objects/java.nio.charset.Charset - java:/Objects/java.io.UnsupportedEncodingException - java:/Objects/java.lang.CharSequence - java:/Objects/java.util.Locale - java:/Objects/java.util.Formatter - java:/Objects/java.lang.Appendable - java:/Objects/java.io.Closeable - java:/Objects/java.io.Flushable - java:/Objects/java.lang.AutoCloseable - java:/Objects/java.lang.Comparable - java:/Objects/java.security.SecureRandom - java:/Objects/java.lang.Enum - java:/Objects/java.net.URI - java:/Objects/java.io.FilenameFilter - java:/Objects/java.io.FileFilter - java:/Objects/java.nio.file.Path - java:/Objects/java.lang.Deprecated - java:/Objects/java.net.MalformedURLException - java:/Objects/java.net.URL - java:/Objects/sun.misc.Unsafe - java:/Objects/java.io.FileSystem - java:/Objects/java.util.Random - java:/Objects/java.util.regex.Pattern - java:/Objects/java.security.SecureRandomSpi - java:/Objects/java.security.Provider - java:/Objects/java.security.NoSuchAlgorithmException - java:/Objects/java.security.NoSuchProviderException - java:/Objects/java.security.MessageDigest - java:/Objects/sun.security.util.Debug - java:/Objects/java.util.Spliterator - java:/Objects/java.util.function.DoubleConsumer - java:/Objects/java.util.function.LongConsumer - java:/Objects/java.util.function.IntConsumer - java:/Objects/java.util.stream.DoubleStream - java:/Objects/java.util.stream.IntStream - java:/Objects/java.util.stream.LongStream - java:/Objects/java.util.concurrent.atomic.AtomicLong - java:/Objects/java.io.ObjectStreamField - java:/Objects/java.lang.Double - java:/Objects/java.util.function.Consumer - java:/Objects/java.lang.Long - java:/Objects/java.lang.Integer - java:/Objects/java.util.Comparator - java:/Objects/java.lang.Number - java:/Objects/java.lang.NumberFormatException - java:/Objects/java.lang.IllegalArgumentException - java:/Objects/java.lang.RuntimeException - java:/Objects/java.lang.FunctionalInterface - java:/Objects/java.lang.annotation.Target - java:/Objects/java.lang.annotation.ElementType - java:/Objects/java.lang.annotation.Retention - java:/Objects/java.lang.annotation.RetentionPolicy - java:/Objects/java.lang.annotation.Documented - java:/Objects/java.lang.annotation.Annotation - java:/Objects/java.math.BigInteger - java:/Objects/java.lang.StringBuilder - java:/Objects/java.lang.AbstractStringBuilder - java:/Objects/java.lang.StringBuffer - java:/Objects/java.util.function.Function - java:/Objects/java.util.function.ToDoubleFunction - java:/Objects/java.util.function.ToIntFunction - java:/Objects/java.util.function.ToLongFunction - java:/Objects/java.util.stream.BaseStream - java:/Objects/java.util.function.DoublePredicate - java:/Objects/java.util.OptionalDouble - java:/Objects/java.util.stream.Stream - java:/Objects/java.util.function.Supplier - java:/Objects/java.util.function.ObjDoubleConsumer - java:/Objects/java.util.function.BiConsumer - java:/Objects/java.util.function.DoubleFunction - java:/Objects/java.util.function.DoubleSupplier - java:/Objects/java.util.function.DoubleUnaryOperator - java:/Objects/java.util.PrimitiveIterator - java:/Objects/java.util.function.DoubleToIntFunction - java:/Objects/java.util.function.DoubleToLongFunction - java:/Objects/java.util.function.DoubleBinaryOperator - java:/Objects/java.util.DoubleSummaryStatistics - java:/Objects/java.util.Iterator - java:/Objects/java.lang.Runnable - java:/Objects/java.util.function.Predicate - java:/Objects/java.util.stream.Collector - java:/Objects/java.util.Optional - java:/Objects/java.util.function.UnaryOperator - java:/Objects/java.util.function.BinaryOperator - java:/Objects/java.util.function.BiFunction - java:/Objects/java.util.function.IntFunction - java:/Objects/java.util.function.IntPredicate - java:/Objects/java.util.function.ObjIntConsumer - java:/Objects/java.util.OptionalInt - java:/Objects/java.util.function.IntSupplier - java:/Objects/java.util.function.IntUnaryOperator - java:/Objects/java.util.function.IntToDoubleFunction - java:/Objects/java.util.function.IntToLongFunction - java:/Objects/java.util.function.IntBinaryOperator - java:/Objects/java.util.IntSummaryStatistics - java:/Objects/java.util.function.LongPredicate - java:/Objects/java.util.function.ObjLongConsumer - java:/Objects/java.util.OptionalLong - java:/Objects/java.util.function.LongFunction - java:/Objects/java.util.function.LongSupplier - java:/Objects/java.util.function.LongUnaryOperator - java:/Objects/java.util.function.LongToDoubleFunction - java:/Objects/java.util.function.LongToIntFunction - java:/Objects/java.util.function.LongBinaryOperator - java:/Objects/java.util.LongSummaryStatistics - java:/Objects/java.lang.reflect.Field - java:/Objects/sun.reflect.CallerSensitive - java:/Objects/java.lang.reflect.AccessibleObject - java:/Objects/java.lang.reflect.Member - java:/Objects/sun.reflect.FieldAccessor - java:/Objects/java.util.Map - java:/Objects/java.lang.IllegalAccessException - java:/Objects/java.lang.reflect.AnnotatedType - java:/Objects/sun.reflect.generics.factory.GenericsFactory - java:/Objects/sun.reflect.generics.repository.FieldRepository - java:/Objects/java.lang.reflect.Type - java:/Objects/java.lang.reflect.AnnotatedElement - java:/Objects/java.lang.SecurityException - java:/Objects/java.security.Permission - java:/Objects/sun.reflect.ReflectionFactory - java:/Objects/java.security.Guard - java:/Objects/java.security.PermissionCollection - java:/Objects/java.util.Enumeration - java:/Objects/java.security.PrivilegedAction - java:/Objects/java.lang.reflect.Constructor - java:/Objects/java.lang.reflect.Method - java:/Objects/java.lang.invoke.MethodHandle - java:/Objects/sun.reflect.ConstructorAccessor - java:/Objects/java.lang.reflect.Executable - java:/Objects/sun.reflect.MethodAccessor - java:/Objects/sun.reflect.LangReflectAccess - java:/Objects/java.io.OptionalDataException - java:/Objects/sun.reflect.generics.repository.ConstructorRepository - java:/Objects/java.lang.reflect.TypeVariable - java:/Objects/java.lang.InstantiationException - java:/Objects/java.lang.reflect.InvocationTargetException - java:/Objects/sun.reflect.generics.repository.GenericDeclRepository - java:/Objects/sun.reflect.generics.tree.MethodTypeSignature - java:/Objects/sun.reflect.generics.repository.AbstractRepository - java:/Objects/sun.reflect.generics.tree.Signature - java:/Objects/sun.reflect.generics.visitor.Reifier - java:/Objects/sun.reflect.generics.tree.Tree - java:/Objects/sun.reflect.generics.visitor.TypeTreeVisitor - java:/Objects/sun.reflect.generics.tree.TypeArgument - java:/Objects/sun.reflect.generics.tree.ArrayTypeSignature - java:/Objects/sun.reflect.generics.tree.BooleanSignature - java:/Objects/sun.reflect.generics.tree.BottomSignature - java:/Objects/sun.reflect.generics.tree.ByteSignature - java:/Objects/sun.reflect.generics.tree.CharSignature - java:/Objects/sun.reflect.generics.tree.ClassTypeSignature - java:/Objects/sun.reflect.generics.tree.DoubleSignature - java:/Objects/sun.reflect.generics.tree.FloatSignature - java:/Objects/sun.reflect.generics.tree.FormalTypeParameter - java:/Objects/sun.reflect.generics.tree.IntSignature - java:/Objects/sun.reflect.generics.tree.LongSignature - java:/Objects/sun.reflect.generics.tree.ShortSignature - java:/Objects/sun.reflect.generics.tree.SimpleClassTypeSignature - java:/Objects/sun.reflect.generics.tree.TypeVariableSignature - java:/Objects/sun.reflect.generics.tree.VoidDescriptor - java:/Objects/sun.reflect.generics.tree.Wildcard - java:/Objects/sun.reflect.generics.tree.TypeTree - java:/Objects/sun.reflect.generics.tree.FieldTypeSignature - java:/Objects/sun.reflect.generics.tree.TypeSignature - java:/Objects/sun.reflect.generics.tree.BaseType - java:/Objects/sun.reflect.generics.tree.ReturnType - java:/Objects/sun.reflect.generics.visitor.Visitor - java:/Objects/sun.reflect.generics.tree.ClassSignature - java:/Objects/java.lang.reflect.GenericDeclaration - java:/Objects/java.lang.ReflectiveOperationException - java:/Objects/sun.reflect.generics.repository.MethodRepository - java:/Objects/java.lang.invoke.MethodType - java:/Objects/java.lang.invoke.LambdaForm - java:/Objects/java.lang.invoke.BoundMethodHandle - java:/Objects/java.lang.invoke.MemberName - java:/Objects/java.lang.invoke.MethodHandleImpl - java:/Objects/java.lang.ref.WeakReference - java:/Objects/java.lang.ref.ReferenceQueue - java:/Objects/java.util.concurrent.ConcurrentMap - java:/Objects/java.lang.invoke.MethodTypeForm - java:/Objects/java.lang.ClassLoader - java:/Objects/java.lang.TypeNotPresentException - java:/Objects/java.lang.invoke.Invokers - java:/Objects/java.lang.IndexOutOfBoundsException - java:/Objects/java.lang.invoke.Stable - java:/Objects/java.lang.ref.Reference - java:/Objects/java.lang.Thread - java:/Objects/java.lang.ThreadGroup - java:/Objects/java.lang.Boolean - java:/Objects/java.security.AccessControlContext - java:/Objects/sun.nio.ch.Interruptible - java:/Objects/java.lang.RuntimePermission - java:/Objects/java.lang.ThreadLocal - java:/Objects/sun.misc.Contended - java:/Objects/java.security.ProtectionDomain - java:/Objects/java.security.DomainCombiner - java:/Objects/java.security.AccessControlException - java:/Objects/sun.misc.JavaSecurityAccess - java:/Objects/java.security.CodeSource - java:/Objects/java.security.Principal - java:/Objects/java.security.cert.Certificate - java:/Objects/java.security.CodeSigner - java:/Objects/java.security.cert.CertificateFactory - java:/Objects/java.net.SocketPermission - java:/Objects/java.io.ObjectStreamException - java:/Objects/java.security.cert.CertificateEncodingException - java:/Objects/java.security.PublicKey - java:/Objects/java.security.cert.CertificateException - java:/Objects/java.security.InvalidKeyException - java:/Objects/java.security.SignatureException - java:/Objects/java.security.Key - java:/Objects/java.security.GeneralSecurityException - java:/Objects/java.security.KeyException - java:/Objects/java.security.cert.CertPath - java:/Objects/java.security.Timestamp - java:/Objects/java.util.Date - java:/Objects/java.lang.Cloneable - java:/Objects/java.time.Instant - java:/Objects/sun.util.calendar.BaseCalendar - java:/Objects/java.time.temporal.Temporal - java:/Objects/java.time.temporal.TemporalAdjuster - java:/Objects/java.time.ZoneOffset - java:/Objects/java.time.OffsetDateTime - java:/Objects/java.time.ZoneId - java:/Objects/java.time.ZonedDateTime - java:/Objects/java.time.temporal.TemporalAccessor - java:/Objects/java.time.temporal.TemporalField - java:/Objects/java.time.temporal.TemporalUnit - java:/Objects/java.time.temporal.TemporalAmount - java:/Objects/java.time.Clock - java:/Objects/java.time.temporal.TemporalQuery - java:/Objects/java.time.temporal.ValueRange - java:/Objects/java.io.DataInput - java:/Objects/java.io.InvalidObjectException - java:/Objects/java.io.DataOutput - java:/Objects/java.time.zone.ZoneRules - java:/Objects/java.time.zone.ZoneOffsetTransition - java:/Objects/java.time.zone.ZoneOffsetTransitionRule - java:/Objects/java.time.LocalDateTime - java:/Objects/java.time.Duration - java:/Objects/java.time.Month - java:/Objects/java.time.DayOfWeek - java:/Objects/java.time.LocalTime - java:/Objects/java.time.format.TextStyle - java:/Objects/java.time.LocalDate - java:/Objects/java.time.OffsetTime - java:/Objects/java.time.format.DateTimeFormatter - java:/Objects/java.time.chrono.ChronoLocalDate - java:/Objects/java.time.chrono.IsoChronology - java:/Objects/java.time.chrono.Era - java:/Objects/java.time.Period - java:/Objects/java.time.chrono.ChronoLocalDateTime - java:/Objects/java.time.chrono.Chronology - java:/Objects/java.time.chrono.ChronoPeriod - java:/Objects/java.time.chrono.ChronoZonedDateTime - java:/Objects/java.time.temporal.ChronoField - java:/Objects/java.time.format.ResolverStyle - java:/Objects/java.time.chrono.AbstractChronology - java:/Objects/java.time.chrono.IsoEra - java:/Objects/java.util.concurrent.ConcurrentHashMap - java:/Objects/java.util.AbstractMap - java:/Objects/java.util.function.ToIntBiFunction - java:/Objects/java.util.function.ToLongBiFunction - java:/Objects/java.util.function.ToDoubleBiFunction - java:/Objects/java.util.concurrent.atomic.AtomicReference - java:/Objects/java.lang.Void - java:/Objects/java.util.concurrent.CountedCompleter - java:/Objects/java.util.Collection - java:/Objects/java.util.concurrent.locks.ReentrantLock - java:/Objects/java.util.concurrent.ForkJoinTask - java:/Objects/java.util.concurrent.Future - java:/Objects/java.util.concurrent.RunnableFuture - java:/Objects/java.util.concurrent.Callable - java:/Objects/java.util.concurrent.ExecutionException - java:/Objects/java.util.concurrent.TimeUnit - java:/Objects/java.util.concurrent.TimeoutException - java:/Objects/java.util.concurrent.ForkJoinPool - java:/Objects/java.util.concurrent.AbstractExecutorService - java:/Objects/java.util.concurrent.ForkJoinWorkerThread - java:/Objects/java.util.concurrent.ExecutorService - java:/Objects/java.util.concurrent.Executor - java:/Objects/java.lang.Iterable - java:/Objects/java.util.concurrent.locks.Lock - java:/Objects/java.util.concurrent.locks.AbstractQueuedSynchronizer - java:/Objects/java.util.concurrent.locks.Condition - java:/Objects/java.util.concurrent.locks.AbstractOwnableSynchronizer - java:/Objects/java.lang.NullPointerException - java:/Objects/java.io.ObjectInput - java:/Objects/java.io.ObjectOutput - java:/Objects/java.text.Format - java:/Objects/java.text.FieldPosition - java:/Objects/java.text.ParseException - java:/Objects/java.text.ParsePosition - java:/Objects/java.time.format.DateTimeFormatterBuilder - java:/Objects/java.time.format.DecimalStyle - java:/Objects/java.time.format.DateTimeParseException - java:/Objects/java.time.format.FormatStyle - java:/Objects/java.time.format.DateTimeParseContext - java:/Objects/java.text.AttributedCharacterIterator - java:/Objects/java.text.CharacterIterator - java:/Objects/java.time.format.DateTimePrintContext - java:/Objects/java.lang.ref.SoftReference - java:/Objects/java.time.format.DateTimeTextProvider - java:/Objects/java.math.BigDecimal - java:/Objects/java.time.format.SignStyle - java:/Objects/java.lang.Character - java:/Objects/java.math.MathContext - java:/Objects/java.math.RoundingMode - java:/Objects/java.math.MutableBigInteger - java:/Objects/java.util.HashMap - java:/Objects/java.util.LinkedHashMap - java:/Objects/java.util.AbstractSet - java:/Objects/java.util.AbstractCollection - java:/Objects/java.time.DateTimeException - java:/Objects/java.time.format.Parsed - java:/Objects/java.util.ArrayList - java:/Objects/java.util.AbstractList - java:/Objects/java.util.RandomAccess - java:/Objects/java.util.ListIterator - java:/Objects/sun.util.calendar.AbstractCalendar - java:/Objects/sun.util.calendar.CalendarDate - java:/Objects/java.util.TimeZone - java:/Objects/sun.util.calendar.CalendarSystem - java:/Objects/sun.util.calendar.Era - java:/Objects/java.util.Properties - java:/Objects/sun.util.calendar.Gregorian - java:/Objects/java.util.Hashtable - java:/Objects/java.io.InputStream - java:/Objects/java.util.InvalidPropertiesFormatException - java:/Objects/sun.util.spi.XmlPropertiesProvider - java:/Objects/java.io.Reader - java:/Objects/java.io.BufferedWriter - java:/Objects/java.util.Dictionary - java:/Objects/java.io.StreamCorruptedException - java:/Objects/java.io.NotSerializableException - java:/Objects/java.lang.Readable - java:/Objects/java.nio.CharBuffer - java:/Objects/java.nio.Buffer - java:/Objects/java.nio.ByteOrder - java:/Objects/java.security.cert.CertificateFactorySpi - java:/Objects/java.security.cert.CRLException - java:/Objects/java.security.cert.CRL - java:/Objects/java.net.UnknownHostException - java:/Objects/java.net.InetAddress - java:/Objects/sun.net.spi.nameservice.NameService - java:/Objects/java.net.NetworkInterface - java:/Objects/java.net.InetAddressImpl - java:/Objects/java.net.SocketException - java:/Objects/java.net.InterfaceAddress - java:/Objects/java.net.Inet4Address - java:/Objects/javax.security.auth.Subject - java:/Objects/javax.security.auth.AuthPermission - java:/Objects/java.util.LinkedList - java:/Objects/java.security.PrivilegedExceptionAction - java:/Objects/java.security.PrivilegedActionException - java:/Objects/java.security.BasicPermission - java:/Objects/java.util.AbstractSequentialList - java:/Objects/java.util.Deque - java:/Objects/java.util.Queue - java:/Objects/java.util.concurrent.atomic.AtomicInteger - java:/Objects/java.lang.ClassFormatError - java:/Objects/java.nio.ByteBuffer - java:/Objects/java.lang.Package - java:/Objects/sun.misc.URLClassPath - java:/Objects/java.lang.AssertionStatusDirectives - java:/Objects/java.util.Vector - java:/Objects/java.util.Stack - java:/Objects/java.lang.LinkageError - java:/Objects/java.lang.Error - java:/Objects/java.nio.DoubleBuffer - java:/Objects/java.nio.FloatBuffer - java:/Objects/java.nio.IntBuffer - java:/Objects/java.nio.LongBuffer - java:/Objects/java.nio.ShortBuffer - java:/Objects/java.util.jar.Manifest - java:/Objects/java.io.FilterInputStream - java:/Objects/java.util.jar.JarVerifier - java:/Objects/java.util.jar.Attributes - java:/Objects/java.util.jar.JarEntry - java:/Objects/sun.security.util.ManifestEntryVerifier - java:/Objects/java.util.jar.JarFile - java:/Objects/java.util.zip.ZipEntry - java:/Objects/java.io.ByteArrayOutputStream - java:/Objects/sun.security.util.ManifestDigester - java:/Objects/sun.security.util.SignatureFileVerifier - java:/Objects/java.util.jar.JarException - java:/Objects/java.util.zip.ZipException - java:/Objects/java.util.zip.ZipFile - java:/Objects/java.util.zip.ZipConstants - java:/Objects/java.util.zip.InflaterInputStream - java:/Objects/java.util.zip.Inflater - java:/Objects/java.util.zip.ZipCoder - java:/Objects/java.util.zip.DataFormatException - java:/Objects/java.util.zip.ZStreamRef - java:/Objects/java.nio.charset.CharsetDecoder - java:/Objects/java.nio.charset.CharsetEncoder - java:/Objects/java.nio.charset.CharacterCodingException - java:/Objects/java.nio.charset.CoderResult - java:/Objects/java.nio.charset.CodingErrorAction - java:/Objects/java.nio.file.attribute.FileTime - java:/Objects/sun.security.pkcs.SignerInfo - java:/Objects/sun.security.pkcs.PKCS7 - java:/Objects/sun.security.util.DisabledAlgorithmConstraints - java:/Objects/sun.security.util.DerEncoder - java:/Objects/sun.security.util.DerInputStream - java:/Objects/sun.security.pkcs.ParsingException - java:/Objects/sun.security.x509.X500Name - java:/Objects/sun.security.x509.AlgorithmId - java:/Objects/sun.security.pkcs.PKCS9Attributes - java:/Objects/sun.security.util.DerOutputStream - java:/Objects/java.security.cert.X509Certificate - java:/Objects/sun.security.timestamp.TimestampToken - java:/Objects/java.security.CryptoPrimitive - java:/Objects/sun.security.util.DerInputBuffer - java:/Objects/sun.security.util.DerValue - java:/Objects/sun.security.util.ObjectIdentifier - java:/Objects/sun.security.util.BitArray - java:/Objects/java.io.ByteArrayInputStream - java:/Objects/java.lang.ArrayIndexOutOfBoundsException - java:/Objects/sun.security.x509.GeneralNameInterface - java:/Objects/sun.security.x509.RDN - java:/Objects/sun.security.x509.AVA - java:/Objects/javax.security.auth.x500.X500Principal - java:/Objects/java.lang.UnsupportedOperationException - java:/Objects/java.lang.Byte - java:/Objects/java.io.NotActiveException - java:/Objects/java.security.AlgorithmParameters - java:/Objects/java.security.AlgorithmParametersSpi - java:/Objects/java.security.spec.AlgorithmParameterSpec - java:/Objects/java.security.spec.InvalidParameterSpecException - java:/Objects/sun.security.pkcs.PKCS9Attribute - java:/Objects/sun.security.util.ByteArrayLexOrder - java:/Objects/sun.security.util.ByteArrayTagOrder - java:/Objects/java.security.cert.X509Extension - java:/Objects/java.security.cert.CertificateExpiredException - java:/Objects/java.security.cert.CertificateNotYetValidException - java:/Objects/java.security.cert.CertificateParsingException - java:/Objects/sun.security.pkcs.ContentInfo - java:/Objects/java.security.cert.X509CRL - java:/Objects/sun.security.timestamp.Timestamper - java:/Objects/java.security.cert.X509CRLEntry - java:/Objects/java.security.cert.CRLReason - java:/Objects/sun.security.timestamp.TSRequest - java:/Objects/sun.security.timestamp.TSResponse - java:/Objects/sun.security.util.AbstractAlgorithmConstraints - java:/Objects/sun.security.util.ConstraintsParameters - java:/Objects/java.security.cert.CertPathValidatorException - java:/Objects/java.text.SimpleDateFormat - java:/Objects/sun.security.util.AlgorithmDecomposer - java:/Objects/java.security.AlgorithmConstraints - java:/Objects/java.text.DateFormat - java:/Objects/java.text.DateFormatSymbols - java:/Objects/java.text.CalendarBuilder - java:/Objects/java.text.NumberFormat - java:/Objects/sun.util.locale.provider.LocaleProviderAdapter - java:/Objects/java.util.Calendar - java:/Objects/java.util.spi.LocaleServiceProvider - java:/Objects/java.text.spi.BreakIteratorProvider - java:/Objects/java.util.spi.CalendarDataProvider - java:/Objects/java.util.spi.CalendarNameProvider - java:/Objects/sun.util.spi.CalendarProvider - java:/Objects/java.text.spi.CollatorProvider - java:/Objects/java.util.spi.CurrencyNameProvider - java:/Objects/java.text.spi.DateFormatProvider - java:/Objects/java.text.spi.DateFormatSymbolsProvider - java:/Objects/java.text.spi.DecimalFormatSymbolsProvider - java:/Objects/java.util.spi.LocaleNameProvider - java:/Objects/sun.util.locale.provider.LocaleResources - java:/Objects/java.text.spi.NumberFormatProvider - java:/Objects/java.util.spi.TimeZoneNameProvider - java:/Objects/java.text.BreakIterator - java:/Objects/java.text.Collator - java:/Objects/java.text.CollationKey - java:/Objects/java.text.DecimalFormatSymbols - java:/Objects/java.util.Currency - java:/Objects/sun.util.locale.provider.LocaleServiceProviderPool - java:/Objects/java.io.DataInputStream - java:/Objects/java.util.HashSet - java:/Objects/sun.util.locale.provider.ResourceBundleBasedAdapter - java:/Objects/java.util.ResourceBundle - java:/Objects/sun.util.resources.LocaleData - java:/Objects/sun.util.locale.LocaleObjectCache - java:/Objects/sun.util.locale.BaseLocale - java:/Objects/java.util.spi.ResourceBundleControlProvider - java:/Objects/sun.util.resources.OpenListResourceBundle - java:/Objects/sun.util.resources.TimeZoneNamesBundle - java:/Objects/sun.util.resources.ParallelListResourceBundle - java:/Objects/java.util.concurrent.atomic.AtomicMarkableReference - java:/Objects/java.io.DataOutputStream - java:/Objects/java.io.FilterOutputStream - java:/Objects/sun.misc.Resource - java:/Objects/java.net.URLStreamHandler - java:/Objects/sun.misc.JarIndex - java:/Objects/sun.misc.MetaIndex - java:/Objects/sun.misc.JavaUtilZipFileAccess - java:/Objects/java.net.URLStreamHandlerFactory - java:/Objects/java.net.URLConnection - java:/Objects/java.net.Proxy - java:/Objects/java.net.UnknownServiceException - java:/Objects/java.net.ContentHandler - java:/Objects/java.net.FileNameMap - java:/Objects/java.net.ContentHandlerFactory - java:/Objects/sun.net.www.MessageHeader - java:/Objects/java.net.SocketAddress - java:/Objects/java.lang.invoke.ForceInline - java:/Objects/java.lang.invoke.DontInline - java:/Objects/java.lang.invoke.WrongMethodTypeException - java:/Objects/sun.invoke.util.Wrapper - java:/Objects/java.lang.invoke.LambdaFormEditor - java:/Objects/java.lang.ClassCastException - java:/Objects/java.lang.invoke.LambdaFormBuffer - java:/Objects/jdk.internal.org.objectweb.asm.MethodVisitor - java:/Objects/java.lang.invoke.MethodHandles - java:/Objects/jdk.internal.org.objectweb.asm.AnnotationVisitor - java:/Objects/jdk.internal.org.objectweb.asm.Attribute - java:/Objects/jdk.internal.org.objectweb.asm.TypePath - java:/Objects/jdk.internal.org.objectweb.asm.Handle - java:/Objects/jdk.internal.org.objectweb.asm.Label - java:/Objects/jdk.internal.org.objectweb.asm.ClassWriter - java:/Objects/jdk.internal.org.objectweb.asm.ByteVector - java:/Objects/jdk.internal.org.objectweb.asm.ClassReader - java:/Objects/jdk.internal.org.objectweb.asm.ClassVisitor - java:/Objects/jdk.internal.org.objectweb.asm.Item - java:/Objects/jdk.internal.org.objectweb.asm.FieldVisitor - java:/Objects/jdk.internal.org.objectweb.asm.AnnotationWriter - java:/Objects/jdk.internal.org.objectweb.asm.FieldWriter - java:/Objects/jdk.internal.org.objectweb.asm.MethodWriter - java:/Objects/jdk.internal.org.objectweb.asm.Frame - java:/Objects/jdk.internal.org.objectweb.asm.Handler - java:/Objects/jdk.internal.org.objectweb.asm.Type - java:/Objects/jdk.internal.org.objectweb.asm.Context - java:/Objects/jdk.internal.org.objectweb.asm.Edge - java:/Objects/java.lang.NoSuchMethodException - java:/Objects/java.lang.NoSuchFieldException - java:/Objects/java.lang.invoke.DirectMethodHandle - java:/Objects/java.lang.invoke.MethodHandleInfo - java:/Objects/java.lang.ClassValue - java:/Objects/java.util.WeakHashMap - java:/Objects/java.lang.invoke.DelegatingMethodHandle - java:/Objects/sun.invoke.empty.Empty - java:/Objects/java.lang.reflect.Parameter - java:/Objects/java.lang.reflect.ParameterizedType - java:/Objects/java.lang.reflect.WildcardType - java:/Objects/java.util.regex.Matcher - java:/Objects/java.util.regex.UnicodeProp - java:/Objects/java.util.regex.PatternSyntaxException - java:/Objects/java.util.regex.MatchResult - java:/Objects/java.security.MessageDigestSpi - java:/Objects/java.security.DigestException - java:/Objects/java.net.URISyntaxException - java:/Objects/java.nio.file.Watchable - java:/Objects/java.nio.file.FileSystem - java:/Objects/java.nio.file.WatchService - java:/Objects/java.nio.file.WatchEvent - java:/Objects/java.nio.file.WatchKey - java:/Objects/java.nio.file.LinkOption - java:/Objects/java.nio.file.FileStore - java:/Objects/java.nio.file.PathMatcher - java:/Objects/java.nio.file.attribute.UserPrincipalLookupService - java:/Objects/java.nio.file.spi.FileSystemProvider - java:/Objects/java.nio.file.attribute.FileStoreAttributeView - java:/Objects/java.nio.file.attribute.FileAttributeView - java:/Objects/java.nio.file.attribute.AttributeView - java:/Objects/java.nio.file.attribute.GroupPrincipal - java:/Objects/java.nio.file.attribute.UserPrincipal - java:/Objects/java.nio.file.AccessMode - java:/Objects/java.nio.file.CopyOption - java:/Objects/java.nio.file.attribute.FileAttribute - java:/Objects/java.nio.file.OpenOption - java:/Objects/java.nio.channels.AsynchronousFileChannel - java:/Objects/java.nio.channels.SeekableByteChannel - java:/Objects/java.nio.file.DirectoryStream - java:/Objects/java.nio.channels.FileChannel - java:/Objects/java.nio.file.attribute.BasicFileAttributes - java:/Objects/java.nio.channels.AsynchronousChannel - java:/Objects/java.nio.channels.FileLock - java:/Objects/java.nio.channels.CompletionHandler - java:/Objects/java.nio.channels.Channel - java:/Objects/java.nio.channels.ByteChannel - java:/Objects/java.nio.channels.ReadableByteChannel - java:/Objects/java.nio.channels.WritableByteChannel - java:/Objects/java.nio.channels.spi.AbstractInterruptibleChannel - java:/Objects/java.nio.channels.GatheringByteChannel - java:/Objects/java.nio.channels.ScatteringByteChannel - java:/Objects/java.nio.MappedByteBuffer - java:/Objects/java.nio.channels.InterruptibleChannel - java:/Objects/java.nio.channels.AsynchronousCloseException - java:/Objects/java.nio.channels.ClosedChannelException - java:/Objects/java.io.FileDescriptor - java:/Objects/java.io.SyncFailedException - java:/Objects/java.lang.SecurityManager - java:/Objects/java.net.UrlDeserializedState - java:/Objects/java.nio.charset.spi.CharsetProvider - java:/Objects/java.util.SortedMap - java:/Objects/sun.util.locale.InternalLocaleBuilder - java:/Objects/sun.util.locale.LocaleExtensions - java:/Objects/java.text.MessageFormat - java:/Objects/java.util.MissingResourceException - java:/Objects/sun.util.locale.LocaleSyntaxException - java:/Objects/sun.util.locale.LanguageTag - java:/Objects/sun.util.locale.ParseStatus - java:/Objects/sun.util.locale.StringTokenIterator - java:/Objects/sun.util.locale.Extension - java:/Objects/java.io.OutputStreamWriter - java:/Objects/sun.nio.cs.StreamEncoder - java:/Objects/java.io.ObjectStreamConstants - java:/Objects/sun.misc.ObjectInputFilter - java:/Objects/java.io.ObjectInputValidation - java:/Objects/java.io.ObjectStreamClass - java:/Objects/sun.util.logging.PlatformLogger - java:/Objects/java.io.InvalidClassException - java:/Objects/java.io.Externalizable - java:/Objects/sun.misc.ObjectStreamClassValidator - java:/Objects/java.io.SerialCallbackContext - java:/Objects/java.io.SerializablePermission - java:/Objects/sun.reflect.annotation.AnnotationType - java:/Objects/sun.reflect.ConstantPool - java:/Objects/sun.reflect.generics.repository.ClassRepository - java:/Objects/org.eclipse.viatra.query.runtime.api.IQuerySpecification - java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQueryHeader - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery - java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryEngine - java:/Objects/org.eclipse.viatra.query.runtime.api.scope.QueryScope - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility - java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IInputKey - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PTraceable - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PDisjunction - java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.PProblem - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.TypeJudgement - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PBody - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PVariable - java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryMetaContext - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter - java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.InputKeyImplication - java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IPosetComparator - java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.Tuple - java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.AbstractTuple - java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.ITuple - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.VariableDeferredPConstraint - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.DeferredPConstraint - java:/Objects/org.eclipse.viatra.query.runtime.matchers.planning.SubPlan - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.BasePConstraint - java:/Objects/org.eclipse.viatra.query.runtime.matchers.planning.operations.POperation - java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.QueryHintOption - java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendFactory - java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IMatcherCapability - java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryBackendContext - java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackend - java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryBackendHintProvider - java:/Objects/org.apache.log4j.Logger - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.analysis.QueryAnalyzer - java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryCacheContext - java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryResultProviderAccess - java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContext - java:/Objects/org.apache.log4j.Category - java:/Objects/org.apache.log4j.spi.LoggerFactory - java:/Objects/org.apache.log4j.spi.AppenderAttachable - java:/Objects/org.apache.log4j.Appender - java:/Objects/org.apache.log4j.spi.LoggingEvent - java:/Objects/org.apache.log4j.Priority - java:/Objects/org.apache.log4j.spi.LoggerRepository - java:/Objects/org.apache.log4j.Level - java:/Objects/org.apache.log4j.helpers.AppenderAttachableImpl - java:/Objects/org.apache.log4j.spi.Filter - java:/Objects/org.apache.log4j.spi.ErrorHandler - java:/Objects/org.apache.log4j.Layout - java:/Objects/org.apache.log4j.spi.OptionHandler - java:/Objects/org.apache.log4j.spi.ThrowableInformation - java:/Objects/org.apache.log4j.spi.LocationInfo - java:/Objects/java.io.StringWriter - java:/Objects/org.apache.log4j.spi.HierarchyEventListener - java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IQueryResultProvider - java:/Objects/org.eclipse.viatra.query.runtime.matchers.backend.IUpdateable - java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.TupleMask - java:/Objects/org.eclipse.viatra.query.runtime.matchers.util.Accuracy - java:/Objects/org.eclipse.viatra.query.runtime.matchers.tuple.IModifiableTuple - java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContextListener - java:/Objects/org.eclipse.viatra.query.runtime.matchers.context.IndexingService - java:/Objects/org.eclipse.viatra.query.runtime.matchers.planning.QueryProcessingException - java:/Objects/org.eclipse.viatra.query.runtime.matchers.ViatraQueryRuntimeException - java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IBaseIndex - java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions - java:/Objects/org.eclipse.viatra.query.runtime.api.scope.ViatraBaseIndexChangeListener - java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IIndexingErrorListener - java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IInstanceObserver - java:/Objects/org.eclipse.viatra.query.runtime.internal.apiimpl.EngineContextFactory - java:/Objects/org.eclipse.viatra.query.runtime.api.scope.IEngineContext - java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseMatcher - java:/Objects/org.eclipse.viatra.query.runtime.internal.apiimpl.QueryResultWrapper - java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification - java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseQuerySpecification - java:/Objects/java.lang.ExceptionInInitializerError - java:/Objects/org.eclipse.viatra.query.runtime.exception.ViatraQueryException - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.QueryInitializationException - java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup - java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseQueryGroup - java:/Objects/org.eclipse.viatra.query.runtime.api.IQueryGroup - java:/Objects/org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine - java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryEngineLifecycleListener - java:/Objects/org.eclipse.viatra.query.runtime.api.IMatchUpdateListener - java:/Objects/org.eclipse.viatra.query.runtime.api.ViatraQueryModelUpdateListener - java:/Objects/java.lang.Override - java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.queries.BasePQuery - java:/Objects/org.eclipse.emf.ecore.EClassifier - java:/Objects/org.eclipse.emf.ecore.EEnumLiteral - java:/Objects/org.eclipse.emf.ecore.EStructuralFeature - java:/Objects/org.eclipse.emf.ecore.ENamedElement - java:/Objects/org.eclipse.emf.ecore.EPackage - java:/Objects/org.eclipse.emf.common.util.EList - java:/Objects/org.eclipse.emf.ecore.ETypeParameter - java:/Objects/org.eclipse.emf.ecore.EModelElement - java:/Objects/org.eclipse.emf.ecore.EObject - java:/Objects/org.eclipse.emf.ecore.EAnnotation - java:/Objects/org.eclipse.emf.common.notify.Notifier - java:/Objects/org.eclipse.emf.common.util.TreeIterator - java:/Objects/org.eclipse.emf.ecore.EClass - java:/Objects/org.eclipse.emf.ecore.EReference - java:/Objects/org.eclipse.emf.ecore.EOperation - java:/Objects/org.eclipse.emf.ecore.resource.Resource - java:/Objects/org.eclipse.emf.common.notify.Adapter - java:/Objects/org.eclipse.emf.common.notify.Notification - java:/Objects/org.eclipse.emf.ecore.EAttribute - java:/Objects/org.eclipse.emf.ecore.EGenericType - java:/Objects/org.eclipse.emf.ecore.EDataType - java:/Objects/org.eclipse.emf.ecore.InternalEObject - java:/Objects/org.eclipse.emf.common.CommonPlugin - java:/Objects/org.eclipse.emf.common.notify.NotificationChain - java:/Objects/org.eclipse.emf.common.util.URI - java:/Objects/org.eclipse.emf.common.util.Pool - java:/Objects/org.eclipse.emf.common.util.SegmentSequence - java:/Objects/org.eclipse.emf.common.util.CommonUtil - java:/Objects/org.eclipse.emf.common.util.WeakInterningHashSet - java:/Objects/java.util.concurrent.locks.ReentrantReadWriteLock - java:/Objects/org.eclipse.emf.common.util.InterningSet - java:/Objects/java.util.concurrent.locks.ReadWriteLock - java:/Objects/java.lang.IllegalMonitorStateException - java:/Objects/org.eclipse.emf.common.EMFPlugin - java:/Objects/org.osgi.framework.BundleActivator - java:/Objects/org.eclipse.emf.common.util.ResourceLocator - java:/Objects/org.eclipse.emf.common.util.DelegatingResourceLocator - java:/Objects/org.eclipse.emf.common.util.Logger - java:/Objects/org.eclipse.core.runtime.Plugin - java:/Objects/org.eclipse.core.runtime.IPluginDescriptor - java:/Objects/org.osgi.framework.Bundle - java:/Objects/org.eclipse.core.runtime.ILog - java:/Objects/org.osgi.framework.BundleContext - java:/Objects/org.eclipse.core.runtime.IPath - java:/Objects/org.eclipse.osgi.service.debug.DebugOptions - java:/Objects/org.eclipse.core.runtime.Preferences - java:/Objects/java.lang.IllegalStateException - java:/Objects/org.eclipse.core.runtime.CoreException - java:/Objects/org.osgi.util.tracker.ServiceTracker - java:/Objects/org.eclipse.osgi.service.debug.DebugTrace - java:/Objects/java.util.EventListener - java:/Objects/java.util.EventObject - java:/Objects/org.eclipse.core.runtime.IStatus - java:/Objects/org.eclipse.core.runtime.ListenerList - java:/Objects/org.osgi.util.tracker.ServiceTrackerCustomizer - java:/Objects/org.osgi.framework.AllServiceListener - java:/Objects/org.osgi.util.tracker.AbstractTracked - java:/Objects/org.osgi.framework.ServiceReference - java:/Objects/org.osgi.framework.ServiceEvent - java:/Objects/org.osgi.framework.ServiceListener - java:/Objects/org.osgi.framework.Filter - java:/Objects/org.osgi.framework.InvalidSyntaxException - java:/Objects/org.eclipse.core.runtime.IExtension - java:/Objects/org.eclipse.core.runtime.IExtensionPoint - java:/Objects/org.eclipse.core.runtime.IPluginPrerequisite - java:/Objects/org.eclipse.core.runtime.ILibrary - java:/Objects/org.eclipse.core.runtime.PluginVersionIdentifier - java:/Objects/org.eclipse.core.runtime.InvalidRegistryObjectException - java:/Objects/org.eclipse.core.runtime.IConfigurationElement - java:/Objects/org.eclipse.core.runtime.IContributor - java:/Objects/org.osgi.framework.Version - java:/Objects/org.osgi.framework.BundleException - java:/Objects/org.eclipse.core.runtime.ILogListener - java:/Objects/org.osgi.framework.BundleReference - java:/Objects/org.osgi.framework.BundleListener - java:/Objects/org.osgi.framework.FrameworkListener - java:/Objects/org.osgi.framework.ServiceObjects - java:/Objects/org.osgi.framework.ServiceRegistration - java:/Objects/org.osgi.framework.ServiceFactory - java:/Objects/org.osgi.framework.BundleEvent - java:/Objects/org.osgi.framework.FrameworkEvent - java:/Objects/org.eclipse.emf.ecore.ETypedElement - java:/Objects/org.eclipse.emf.ecore.EParameter - java:/Objects/org.eclipse.emf.ecore.resource.ResourceSet - java:/Objects/org.eclipse.emf.common.notify.AdapterFactory - java:/Objects/org.eclipse.emf.ecore.resource.URIConverter - java:/Objects/java.io.InputStreamReader - java:/Objects/org.eclipse.emf.ecore.resource.ContentHandler - java:/Objects/org.eclipse.emf.ecore.resource.URIHandler - java:/Objects/sun.nio.cs.StreamDecoder - java:/Objects/java.io.FileInputStream - java:/Objects/org.eclipse.emf.common.util.EMap - java:/Objects/org.eclipse.emf.ecore.EFactory - java:/Objects/org.eclipse.emf.common.util.Enumerator - java:/Objects/org.eclipse.emf.ecore.EEnum - java:/Objects/org.eclipse.emf.ecore.util.FeatureMap - java:/Objects/org.eclipse.emf.ecore.util.InternalEList - java:/Objects/org.eclipse.emf.ecore.util.EContentsEList - java:/Objects/org.eclipse.emf.ecore.util.AbstractSequentialInternalEList - java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem - java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType - java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance - java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.HostType - java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance - java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.Request - java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement - java:/Objects/hu.bme.mit.inf.dslreasoner.domains.cps.Requirement - java:/Objects/java.lang.SuppressWarnings - java:/Objects/javax.annotation.Generated - java:/Objects/org.eclipse.viatra.query.runtime.api.GenericPatternMatcher - java:/Objects/org.eclipse.viatra.query.runtime.api.GenericPatternMatch - java:/Objects/org.eclipse.viatra.query.runtime.api.GenericQuerySpecification - java:/Objects/org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher - java:/Objects/org.eclipse.viatra.query.runtime.matchers.aggregators.sum - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.AggregatorType - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IAggregatorFactory - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.BoundAggregator - java:/Objects/java.lang.annotation.Inherited - java:/Objects/org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator - java:/Objects/org.eclipse.xtext.xbase.lib.ArrayLiterals - java:/Objects/com.google.common.annotations.GwtCompatible - java:/Objects/org.eclipse.xtext.xbase.lib.Pure - java:/Objects/org.eclipse.xtext.xbase.lib.Inline - java:/Objects/com.google.common.annotations.Beta - java:/Objects/org.eclipse.xtext.xbase.lib.CollectionLiterals - java:/Objects/org.eclipse.xtext.xbase.lib.Pair - java:/Objects/java.util.LinkedHashSet - java:/Objects/java.util.TreeMap - java:/Objects/java.util.TreeSet - java:/Objects/java.util.NavigableMap - java:/Objects/java.util.NavigableSet - java:/Objects/java.util.SortedSet - java:/Objects/org.eclipse.xtext.xbase.lib.InputOutput - java:/Objects/org.eclipse.xtext.xbase.lib.ArrayExtensions - java:/Objects/com.google.common.annotations.GwtIncompatible - java:/Objects/org.eclipse.xtext.xbase.lib.BigDecimalExtensions - java:/Objects/org.eclipse.xtext.xbase.lib.BigIntegerExtensions - java:/Objects/org.eclipse.xtext.xbase.lib.BooleanExtensions - java:/Objects/com.google.common.primitives.Booleans - java:/Objects/org.eclipse.xtext.xbase.lib.ByteExtensions - java:/Objects/java.lang.Math - java:/Objects/org.eclipse.xtext.xbase.lib.CharacterExtensions - java:/Objects/org.eclipse.xtext.xbase.lib.CollectionExtensions - java:/Objects/com.google.common.collect.Iterables - java:/Objects/com.google.common.collect.ImmutableList - java:/Objects/com.google.common.collect.ImmutableSet - java:/Objects/com.google.common.collect.ImmutableSortedSet - java:/Objects/com.google.common.collect.ImmutableMap - java:/Objects/com.google.common.collect.ImmutableSortedMap - java:/Objects/java.util.Collections - java:/Objects/com.google.common.collect.FluentIterable - java:/Objects/com.google.common.base.Predicate - java:/Objects/com.google.common.base.Function - java:/Objects/com.google.common.base.Optional - java:/Objects/com.google.common.collect.ImmutableCollection - java:/Objects/com.google.common.collect.ImmutableListMultimap - java:/Objects/com.google.common.base.Joiner - java:/Objects/com.google.common.collect.ImmutableMultiset - java:/Objects/com.google.common.collect.ImmutableMultimap - java:/Objects/com.google.common.collect.ListMultimap - java:/Objects/com.google.common.collect.Multimap - java:/Objects/com.google.common.collect.AbstractMultimap - java:/Objects/com.google.common.collect.UnmodifiableIterator - java:/Objects/com.google.common.collect.Serialization - java:/Objects/com.google.common.collect.ImmutableSetMultimap - java:/Objects/com.google.common.collect.Multiset - java:/Objects/com.google.common.collect.Multimaps - java:/Objects/com.google.common.collect.Maps - java:/Objects/com.google.common.collect.AbstractListMultimap - java:/Objects/com.google.common.base.Supplier - java:/Objects/com.google.common.collect.AbstractMapBasedMultimap - java:/Objects/com.google.common.collect.AbstractSetMultimap - java:/Objects/com.google.common.collect.AbstractSortedSetMultimap - java:/Objects/com.google.common.collect.AbstractMultiset - java:/Objects/com.google.common.collect.Multisets - java:/Objects/com.google.common.collect.SetMultimap - java:/Objects/com.google.common.collect.ForwardingMultimap - java:/Objects/com.google.common.collect.SortedSetMultimap - java:/Objects/com.google.common.collect.FilteredMultimap - java:/Objects/com.google.common.collect.FilteredSetMultimap - java:/Objects/java.util.EnumMap - java:/Objects/com.google.common.base.Converter - java:/Objects/com.google.common.collect.BiMap - java:/Objects/com.google.common.collect.ForwardingMap - java:/Objects/com.google.common.collect.Ordering - java:/Objects/com.google.common.collect.Sets - java:/Objects/com.google.common.collect.ForwardingSet - java:/Objects/com.google.common.collect.AbstractNavigableMap - java:/Objects/com.google.common.collect.MapDifference - java:/Objects/com.google.common.collect.SortedMapDifference - java:/Objects/com.google.common.collect.ForwardingCollection - java:/Objects/com.google.common.collect.ForwardingSortedMap - java:/Objects/com.google.common.base.Equivalence - java:/Objects/java.util.IdentityHashMap - java:/Objects/com.google.common.collect.Range - java:/Objects/com.google.common.collect.ForwardingObject - java:/Objects/com.google.common.annotations.VisibleForTesting - java:/Objects/java.util.EnumSet - java:/Objects/com.google.common.collect.CartesianList - java:/Objects/com.google.common.collect.ForwardingNavigableSet - java:/Objects/com.google.common.collect.Collections2 - java:/Objects/com.google.common.collect.ForwardingSortedSet - java:/Objects/java.util.concurrent.CopyOnWriteArraySet - java:/Objects/com.google.common.collect.AbstractIterator - java:/Objects/java.util.concurrent.CopyOnWriteArrayList - java:/Objects/java.util.function.BiPredicate - java:/Objects/com.google.common.collect.Cut - java:/Objects/com.google.common.collect.DiscreteDomain - java:/Objects/com.google.common.collect.BoundType - java:/Objects/com.google.common.collect.ForwardingMultiset - java:/Objects/com.google.common.collect.SortedMultiset - java:/Objects/com.google.common.collect.SortedMultisetBridge - java:/Objects/com.google.common.collect.SortedIterable - java:/Objects/com.google.common.collect.UnmodifiableListIterator - java:/Objects/com.google.common.collect.ImmutableSortedSetFauxverideShim - java:/Objects/com.google.common.collect.RegularImmutableSortedSet - java:/Objects/com.google.common.collect.ImmutableMapEntry - java:/Objects/com.google.common.collect.ImmutableEntry - java:/Objects/com.google.common.collect.AbstractMapEntry - java:/Objects/com.google.common.collect.ImmutableSortedMapFauxverideShim - java:/Objects/java.util.AbstractQueue - java:/Objects/org.eclipse.xtext.xbase.lib.ComparableExtensions - java:/Objects/org.eclipse.xtext.xbase.lib.DoubleExtensions - java:/Objects/org.eclipse.xtext.xbase.lib.FloatExtensions - java:/Objects/java.lang.Float - java:/Objects/org.eclipse.xtext.xbase.lib.FunctionExtensions - java:/Objects/org.eclipse.xtext.xbase.lib.Functions - java:/Objects/org.eclipse.xtext.xbase.lib.Procedures - java:/Objects/org.eclipse.xtext.xbase.lib.IntegerExtensions - java:/Objects/org.eclipse.xtext.xbase.lib.ExclusiveRange - java:/Objects/org.eclipse.xtext.xbase.lib.IntegerRange - java:/Objects/org.eclipse.xtext.xbase.lib.IterableExtensions - java:/Objects/org.eclipse.xtext.xbase.lib.IteratorExtensions - java:/Objects/com.google.common.collect.Iterators - java:/Objects/com.google.common.collect.MultitransformedIterator - java:/Objects/com.google.common.collect.PeekingIterator - java:/Objects/org.eclipse.xtext.xbase.lib.ListExtensions - java:/Objects/org.eclipse.xtext.xbase.lib.LongExtensions - java:/Objects/org.eclipse.xtext.xbase.lib.MapExtensions - java:/Objects/org.eclipse.xtext.xbase.lib.internal.UnmodifiableMergingMapView - java:/Objects/org.eclipse.xtext.xbase.lib.ObjectExtensions - java:/Objects/com.google.common.base.Objects - java:/Objects/com.google.common.base.ExtraObjectsMethodsForWeb - java:/Objects/org.eclipse.xtext.xbase.lib.ProcedureExtensions - java:/Objects/org.eclipse.xtext.xbase.lib.ShortExtensions - java:/Objects/java.lang.Short - java:/Objects/org.eclipse.xtext.xbase.lib.StringExtensions - java:/Objects/org.eclipse.viatra.query.runtime.matchers.aggregators.count - java:/Objects/org.eclipse.viatra.query.runtime.matchers.aggregators.avg - - - - - - - - - - - - - - bold - - - - - - - - - - - - - - - - - - - - - - - - - bold - - - - - - - - - - - - - - - - - - - - - - - - bold - - - - bold - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - KEEP_LOCATION - KEEP_SIZE - KEEP_RATIO - - - - - - - - - KEEP_LOCATION - KEEP_SIZE - KEEP_RATIO - - - - - - - - - KEEP_LOCATION - KEEP_SIZE - KEEP_RATIO - - - - - - - - - bold - - - - - - - - bold - - - - - - - - bold - - - - - - - - KEEP_LOCATION - KEEP_SIZE - KEEP_RATIO - - - - - - - - - KEEP_LOCATION - KEEP_SIZE - KEEP_RATIO - - - - - - - - - bold - - - - - - - - KEEP_LOCATION - KEEP_SIZE - KEEP_RATIO - - - - - - - - - KEEP_LOCATION - KEEP_SIZE - KEEP_RATIO - - - - - - - - - bold - - - - - - - - bold - - - - - - - - - - labelSize - - - labelSize - - - - - - - - - - - - - - - - - - - - - labelSize - - - labelSize - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - labelSize - - - labelSize - - - - - - - - - - bold - - - - - - - - - KEEP_LOCATION - KEEP_SIZE - KEEP_RATIO - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bold - - - bold - - - - - - - - - - labelSize - - - labelSize - - - - - - - - - - labelSize - - - labelSize - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore index 36db23be..0f52d8ee 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.ecore @@ -1,9 +1,6 @@ - -
    - @@ -11,20 +8,6 @@ eType="#//ApplicationType" containment="true"/> - - -
    - - - - -
    - - - - -
    - - - - -
    - - - - -
    - - - - -
    - - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel index a0ccec7f..09ed2e0c 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/model/cps.genmodel @@ -15,8 +15,6 @@ - - @@ -49,10 +47,6 @@ - - - - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml index a7e8c387..5a0fee8d 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/plugin.xml @@ -4,32 +4,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - + @@ -40,6 +17,11 @@ + + + + + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/representations.aird b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/representations.aird new file mode 100644 index 00000000..dbaf9f8c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/representations.aird @@ -0,0 +1,600 @@ + + + + model/cps.ecore + http://www.eclipse.org/emf/2002/Ecore + model/cps.genmodel + src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.xtend + src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend + src/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.xtend + src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.xtend + + + + + + + + + + + + + + bold + + + + + + + + + + + + + + + + bold + + + + + + + + + + bold + + + + bold + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bold + + + + + + + + bold + + + + + + + + bold + + + + + + + + + + + + + + + + + + + + + + + + bold + + + + + + + + + + + + + + + + + + + + + + + + bold + + + + + + + + bold + + + + + + + + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + bold + + + bold + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore index b634f74b..4e059848 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/.gitignore @@ -15,3 +15,13 @@ /.CostMetric.java._trace /.CpsCost.java._trace /.RedundantInstancesOnSameHost.java._trace +/.Allocate.java._trace +/.CpsTransformationRules.java._trace +/.ResourceRequirement.java._trace +/.CreateInstance.java._trace +/.CreateHostInstance.java._trace +/.UnallocatedAppInstance.java._trace +/.RequiredAppInstances.java._trace +/.GuidanceObjective.java._trace +/.RemoveHostInstance.java._trace +/.UnallocateAppInstance.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/Allocate.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/Allocate.java new file mode 100644 index 00000000..830dc8a0 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/Allocate.java @@ -0,0 +1,862 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +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.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; +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.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.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.NegativePatternCall; +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.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: + *

    + *         //
    + *         // Transformation rule preconditions for rule-based DSE
    + *         //
    + *         
    + *         pattern allocate(App : ApplicationInstance, Host : HostInstance) {
    + *         	ApplicationInstance.type.requirements(App, Req);
    + *         	ResourceRequirement.hostType.instances(Req, Host);
    + *         	find unallocatedAppInstance(App);
    + *         	find availableMemory(Host, AvailableMem);
    + *         	find availableHdd(Host, AvailableHdd);
    + *         	ResourceRequirement.requiredMemory(Req, RequiredMem);
    + *         	ResourceRequirement.requiredHdd(Req, RequiredHdd);
    + *         	check(AvailableMem {@literal >}= RequiredMem);
    + *         	check(AvailableHdd {@literal >}= RequiredHdd);
    + *         	neg ApplicationInstance.requirement.instances.allocatedTo(App, Host);
    + *         }
    + * 
    + * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class Allocate extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate 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 ApplicationInstance fApp; + + private HostInstance fHost; + + private static List parameterNames = makeImmutableList("App", "Host"); + + private Match(final ApplicationInstance pApp, final HostInstance pHost) { + this.fApp = pApp; + this.fHost = pHost; + } + + @Override + public Object get(final String parameterName) { + if ("App".equals(parameterName)) return this.fApp; + if ("Host".equals(parameterName)) return this.fHost; + return null; + } + + public ApplicationInstance getApp() { + return this.fApp; + } + + public HostInstance getHost() { + return this.fHost; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("App".equals(parameterName) ) { + this.fApp = (ApplicationInstance) newValue; + return true; + } + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + return false; + } + + public void setApp(final ApplicationInstance pApp) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fApp = pApp; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate"; + } + + @Override + public List parameterNames() { + return Allocate.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fApp, fHost}; + } + + @Override + public Allocate.Match toImmutable() { + return isMutable() ? newMatch(fApp, fHost) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"App\"=" + prettyPrintValue(fApp) + ", "); + result.append("\"Host\"=" + prettyPrintValue(fHost)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fApp, fHost); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof Allocate.Match)) { + Allocate.Match other = (Allocate.Match) obj; + return Objects.equals(fApp, other.fApp) && Objects.equals(fHost, other.fHost); + } 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 Allocate specification() { + return Allocate.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 Allocate.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static Allocate.Match newMutableMatch(final ApplicationInstance pApp, final HostInstance pHost) { + return new Mutable(pApp, pHost); + } + + /** + * 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 pApp the fixed value of pattern parameter App, or null if not bound. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the (partial) match object. + * + */ + public static Allocate.Match newMatch(final ApplicationInstance pApp, final HostInstance pHost) { + return new Immutable(pApp, pHost); + } + + private static final class Mutable extends Allocate.Match { + Mutable(final ApplicationInstance pApp, final HostInstance pHost) { + super(pApp, pHost); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends Allocate.Match { + Immutable(final ApplicationInstance pApp, final HostInstance pHost) { + super(pApp, pHost); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate 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: + *

    +   * //
    +   * // Transformation rule preconditions for rule-based DSE
    +   * //
    +   * 
    +   * pattern allocate(App : ApplicationInstance, Host : HostInstance) {
    +   * 	ApplicationInstance.type.requirements(App, Req);
    +   * 	ResourceRequirement.hostType.instances(Req, Host);
    +   * 	find unallocatedAppInstance(App);
    +   * 	find availableMemory(Host, AvailableMem);
    +   * 	find availableHdd(Host, AvailableHdd);
    +   * 	ResourceRequirement.requiredMemory(Req, RequiredMem);
    +   * 	ResourceRequirement.requiredHdd(Req, RequiredHdd);
    +   * 	check(AvailableMem {@literal >}= RequiredMem);
    +   * 	check(AvailableHdd {@literal >}= RequiredHdd);
    +   * 	neg ApplicationInstance.requirement.instances.allocatedTo(App, Host);
    +   * }
    +   * 
    + * + * @see Match + * @see Allocate + * + */ + 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 Allocate.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 Allocate.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_APP = 0; + + private static final int POSITION_HOST = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Allocate.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 pApp the fixed value of pattern parameter App, or null if not bound. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final ApplicationInstance pApp, final HostInstance pHost) { + return rawStreamAllMatches(new Object[]{pApp, pHost}).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 pApp the fixed value of pattern parameter App, or null if not bound. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final ApplicationInstance pApp, final HostInstance pHost) { + return rawStreamAllMatches(new Object[]{pApp, pHost}); + } + + /** + * 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 pApp the fixed value of pattern parameter App, or null if not bound. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final ApplicationInstance pApp, final HostInstance pHost) { + return rawGetOneArbitraryMatch(new Object[]{pApp, pHost}); + } + + /** + * 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 pApp the fixed value of pattern parameter App, or null if not bound. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final ApplicationInstance pApp, final HostInstance pHost) { + return rawHasMatch(new Object[]{pApp, pHost}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final ApplicationInstance pApp, final HostInstance pHost) { + return rawCountMatches(new Object[]{pApp, pHost}); + } + + /** + * 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 pApp the fixed value of pattern parameter App, or null if not bound. + * @param pHost the fixed value of pattern parameter Host, 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 ApplicationInstance pApp, final HostInstance pHost, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pApp, pHost}, 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 pApp the fixed value of pattern parameter App, or null if not bound. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @return the (partial) match object. + * + */ + public Allocate.Match newMatch(final ApplicationInstance pApp, final HostInstance pHost) { + return Allocate.Match.newMatch(pApp, pHost); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfApp(final Object[] parameters) { + return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for App. + *

    + * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp(final Allocate.Match partialMatch) { + return rawStreamAllValuesOfApp(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for App. + *

    + * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp(final HostInstance pHost) { + return rawStreamAllValuesOfApp(new Object[]{null, pHost}); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp(final Allocate.Match partialMatch) { + return rawStreamAllValuesOfApp(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp(final HostInstance pHost) { + return rawStreamAllValuesOfApp(new Object[]{null, pHost}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

    + * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final Allocate.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

    + * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final ApplicationInstance pApp) { + return rawStreamAllValuesOfHost(new Object[]{pApp, null}); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final Allocate.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final ApplicationInstance pApp) { + return rawStreamAllValuesOfHost(new Object[]{pApp, null}).collect(Collectors.toSet()); + } + + @Override + protected Allocate.Match tupleToMatch(final Tuple t) { + try { + return Allocate.Match.newMatch((ApplicationInstance) t.get(POSITION_APP), (HostInstance) t.get(POSITION_HOST)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected Allocate.Match arrayToMatch(final Object[] match) { + try { + return Allocate.Match.newMatch((ApplicationInstance) match[POSITION_APP], (HostInstance) match[POSITION_HOST]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected Allocate.Match arrayToMatchMutable(final Object[] match) { + try { + return Allocate.Match.newMutableMatch((ApplicationInstance) match[POSITION_APP], (HostInstance) match[POSITION_HOST]); + } 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 Allocate.instance(); + } + } + + private Allocate() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static Allocate instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected Allocate.Matcher instantiate(final ViatraQueryEngine engine) { + return Allocate.Matcher.on(engine); + } + + @Override + public Allocate.Matcher instantiate() { + return Allocate.Matcher.create(); + } + + @Override + public Allocate.Match newEmptyMatch() { + return Allocate.Match.newEmptyMatch(); + } + + @Override + public Allocate.Match newMatch(final Object... parameters) { + return Allocate.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate (visibility: PUBLIC, simpleName: Allocate, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.Allocate (visibility: PUBLIC, simpleName: Allocate, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final Allocate INSTANCE = new Allocate(); + + /** + * 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 Allocate.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_App, parameter_Host); + + private class Embedded_1_ApplicationInstance_requirement_instances_allocatedTo extends BaseGeneratedEMFPQuery { + private final PParameter parameter_p0 = new PParameter("p0", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_p1 = new PParameter("p1", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final List embeddedParameters = Arrays.asList(parameter_p0, parameter_p1); + + public Embedded_1_ApplicationInstance_requirement_instances_allocatedTo() { + super(PVisibility.EMBEDDED); + } + + @Override + public String getFullyQualifiedName() { + return GeneratedPQuery.this.getFullyQualifiedName() + "$Embedded_1_ApplicationInstance_requirement_instances_allocatedTo"; + } + + @Override + public List getParameters() { + return embeddedParameters; + } + + @Override + public Set doGetContainedBodies() { + PBody body = new PBody(this); + PVariable var_p0 = body.getOrCreateVariableByName("p0"); + PVariable var_p1 = body.getOrCreateVariableByName("p1"); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_p0, parameter_p0), + new ExportedParameter(body, var_p1, parameter_p1) + )); + // ApplicationInstance.requirement.instances.allocatedTo(App, Host) + new TypeConstraint(body, Tuples.flatTupleOf(var_p0), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_p0, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "requirement"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "instances"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + 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/cps", "ApplicationInstance", "allocatedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new Equality(body, var__virtual_2_, var_p1); + return Collections.singleton(body); + } + } + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.allocate"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("App","Host"); + } + + @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_App = body.getOrCreateVariableByName("App"); + PVariable var_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Req = body.getOrCreateVariableByName("Req"); + PVariable var_AvailableMem = body.getOrCreateVariableByName("AvailableMem"); + PVariable var_AvailableHdd = body.getOrCreateVariableByName("AvailableHdd"); + PVariable var_RequiredMem = body.getOrCreateVariableByName("RequiredMem"); + PVariable var_RequiredHdd = body.getOrCreateVariableByName("RequiredHdd"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_App, parameter_App), + new ExportedParameter(body, var_Host, parameter_Host) + )); + // ApplicationInstance.type.requirements(App, Req) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "requirements"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + new Equality(body, var__virtual_1_, var_Req); + // ResourceRequirement.hostType.instances(Req, Host) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "instances"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new Equality(body, var__virtual_3_, var_Host); + // find unallocatedAppInstance(App) + new PositivePatternCall(body, Tuples.flatTupleOf(var_App), UnallocatedAppInstance.instance().getInternalQueryRepresentation()); + // find availableMemory(Host, AvailableMem) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_AvailableMem), AvailableMemory.instance().getInternalQueryRepresentation()); + // find availableHdd(Host, AvailableHdd) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_AvailableHdd), AvailableHdd.instance().getInternalQueryRepresentation()); + // ResourceRequirement.requiredMemory(Req, RequiredMem) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredMemory"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_4_, var_RequiredMem); + // ResourceRequirement.requiredHdd(Req, RequiredHdd) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + PVariable var__virtual_5_ = body.getOrCreateVariableByName(".virtual{5}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_5_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "requiredHdd"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_5_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_5_, var_RequiredHdd); + // check(AvailableMem >= RequiredMem) + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern allocate"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("AvailableMem", "RequiredMem");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer AvailableMem = (Integer) provider.getValue("AvailableMem"); + Integer RequiredMem = (Integer) provider.getValue("RequiredMem"); + return evaluateExpression_1_1(AvailableMem, RequiredMem); + } + }, null); + // check(AvailableHdd >= RequiredHdd) + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern allocate"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("AvailableHdd", "RequiredHdd");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer AvailableHdd = (Integer) provider.getValue("AvailableHdd"); + Integer RequiredHdd = (Integer) provider.getValue("RequiredHdd"); + return evaluateExpression_1_2(AvailableHdd, RequiredHdd); + } + }, null); + // neg ApplicationInstance.requirement.instances.allocatedTo(App, Host) + new NegativePatternCall(body, Tuples.flatTupleOf(var_App, var_Host), new Allocate.GeneratedPQuery.Embedded_1_ApplicationInstance_requirement_instances_allocatedTo()); + bodies.add(body); + } + return bodies; + } + } + + private static boolean evaluateExpression_1_1(final Integer AvailableMem, final Integer RequiredMem) { + boolean _greaterEqualsThan = (AvailableMem.compareTo(RequiredMem) >= 0); + return _greaterEqualsThan; + } + + private static boolean evaluateExpression_1_2(final Integer AvailableHdd, final Integer RequiredHdd) { + boolean _greaterEqualsThan = (AvailableHdd.compareTo(RequiredHdd) >= 0); + return _greaterEqualsThan; + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java index be7488b6..6da5f76d 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AllocationWithoutResourceRequirement.java @@ -5,7 +5,7 @@ package hu.bme.mit.inf.dslreasoner.domains.cps.queries; import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement; import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashSet; diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java deleted file mode 100644 index 22821c4a..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableHdd.java +++ /dev/null @@ -1,743 +0,0 @@ -/** - * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql - */ -package hu.bme.mit.inf.dslreasoner.domains.cps.queries; - -import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement; -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.emf.ecore.EClass; -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.emf.types.EClassTransitiveInstancesKey; -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.annotations.PAnnotation; -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.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: - *

    - *         {@literal @}QueryBasedFeature(feature = "availableHdd")
    - *         pattern availableHdd(Host : HostInstance, Hdd : java Integer) {
    - *         	find totalHdd(Host, TotalHdd);
    - *         	RequiredHdd == sum find hddRequirement(Host, _, #_);
    - *         	Hdd == eval(TotalHdd - RequiredHdd);
    - *         }
    - * 
    - * - * @see Matcher - * @see Match - * - */ -@SuppressWarnings("all") -public final class AvailableHdd extends BaseGeneratedEMFQuerySpecification { - /** - * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd 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 HostInstance fHost; - - private Integer fHdd; - - private static List parameterNames = makeImmutableList("Host", "Hdd"); - - private Match(final HostInstance pHost, final Integer pHdd) { - this.fHost = pHost; - this.fHdd = pHdd; - } - - @Override - public Object get(final String parameterName) { - if ("Host".equals(parameterName)) return this.fHost; - if ("Hdd".equals(parameterName)) return this.fHdd; - return null; - } - - public HostInstance getHost() { - return this.fHost; - } - - public Integer getHdd() { - return this.fHdd; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("Host".equals(parameterName) ) { - this.fHost = (HostInstance) newValue; - return true; - } - if ("Hdd".equals(parameterName) ) { - this.fHdd = (Integer) newValue; - return true; - } - return false; - } - - public void setHost(final HostInstance pHost) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fHost = pHost; - } - - public void setHdd(final Integer pHdd) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fHdd = pHdd; - } - - @Override - public String patternName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd"; - } - - @Override - public List parameterNames() { - return AvailableHdd.Match.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fHost, fHdd}; - } - - @Override - public AvailableHdd.Match toImmutable() { - return isMutable() ? newMatch(fHost, fHdd) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); - result.append("\"Hdd\"=" + prettyPrintValue(fHdd)); - return result.toString(); - } - - @Override - public int hashCode() { - return Objects.hash(fHost, fHdd); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) { - return false; - } - if ((obj instanceof AvailableHdd.Match)) { - AvailableHdd.Match other = (AvailableHdd.Match) obj; - return Objects.equals(fHost, other.fHost) && Objects.equals(fHdd, other.fHdd); - } 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 AvailableHdd specification() { - return AvailableHdd.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 AvailableHdd.Match newEmptyMatch() { - return new Mutable(null, null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static AvailableHdd.Match newMutableMatch(final HostInstance pHost, final Integer pHdd) { - return new Mutable(pHost, pHdd); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return the (partial) match object. - * - */ - public static AvailableHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) { - return new Immutable(pHost, pHdd); - } - - private static final class Mutable extends AvailableHdd.Match { - Mutable(final HostInstance pHost, final Integer pHdd) { - super(pHost, pHdd); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends AvailableHdd.Match { - Immutable(final HostInstance pHost, final Integer pHdd) { - super(pHost, pHdd); - } - - @Override - public boolean isMutable() { - return false; - } - } - } - - /** - * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd 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: - *

    -   * {@literal @}QueryBasedFeature(feature = "availableHdd")
    -   * pattern availableHdd(Host : HostInstance, Hdd : java Integer) {
    -   * 	find totalHdd(Host, TotalHdd);
    -   * 	RequiredHdd == sum find hddRequirement(Host, _, #_);
    -   * 	Hdd == eval(TotalHdd - RequiredHdd);
    -   * }
    -   * 
    - * - * @see Match - * @see AvailableHdd - * - */ - 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 AvailableHdd.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 AvailableHdd.Matcher create() { - return new Matcher(); - } - - private static final int POSITION_HOST = 0; - - private static final int POSITION_HDD = 1; - - private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AvailableHdd.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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return matches represented as a Match object. - * - */ - public Collection getAllMatches(final HostInstance pHost, final Integer pHdd) { - return rawStreamAllMatches(new Object[]{pHost, pHdd}).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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return a stream of matches represented as a Match object. - * - */ - public Stream streamAllMatches(final HostInstance pHost, final Integer pHdd) { - return rawStreamAllMatches(new Object[]{pHost, pHdd}); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return a match represented as a Match object, or null if no match is found. - * - */ - public Optional getOneArbitraryMatch(final HostInstance pHost, final Integer pHdd) { - return rawGetOneArbitraryMatch(new Object[]{pHost, pHdd}); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final HostInstance pHost, final Integer pHdd) { - return rawHasMatch(new Object[]{pHost, pHdd}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final HostInstance pHost, final Integer pHdd) { - return rawCountMatches(new Object[]{pHost, pHdd}); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, 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 HostInstance pHost, final Integer pHdd, final Consumer processor) { - return rawForOneArbitraryMatch(new Object[]{pHost, pHdd}, 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return the (partial) match object. - * - */ - public AvailableHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) { - return AvailableHdd.Match.newMatch(pHost, pHdd); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { - return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHost() { - return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHost() { - return rawStreamAllValuesOfHost(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHost(final AvailableHdd.Match partialMatch) { - return rawStreamAllValuesOfHost(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHost(final Integer pHdd) { - return rawStreamAllValuesOfHost(new Object[]{null, pHdd}); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHost(final AvailableHdd.Match partialMatch) { - return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHost(final Integer pHdd) { - return rawStreamAllValuesOfHost(new Object[]{null, pHdd}).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - * @return the Set of all values or empty set if there are no matches - * - */ - protected Stream rawStreamAllValuesOfHdd(final Object[] parameters) { - return rawStreamAllValues(POSITION_HDD, parameters).map(Integer.class::cast); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHdd() { - return rawStreamAllValuesOfHdd(emptyArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - * @return the Set of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHdd() { - return rawStreamAllValuesOfHdd(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHdd(final AvailableHdd.Match partialMatch) { - return rawStreamAllValuesOfHdd(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHdd(final HostInstance pHost) { - return rawStreamAllValuesOfHdd(new Object[]{pHost, null}); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHdd(final AvailableHdd.Match partialMatch) { - return rawStreamAllValuesOfHdd(partialMatch.toArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHdd(final HostInstance pHost) { - return rawStreamAllValuesOfHdd(new Object[]{pHost, null}).collect(Collectors.toSet()); - } - - @Override - protected AvailableHdd.Match tupleToMatch(final Tuple t) { - try { - return AvailableHdd.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_HDD)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected AvailableHdd.Match arrayToMatch(final Object[] match) { - try { - return AvailableHdd.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected AvailableHdd.Match arrayToMatchMutable(final Object[] match) { - try { - return AvailableHdd.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]); - } 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 AvailableHdd.instance(); - } - } - - private AvailableHdd() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded - * - */ - public static AvailableHdd instance() { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected AvailableHdd.Matcher instantiate(final ViatraQueryEngine engine) { - return AvailableHdd.Matcher.on(engine); - } - - @Override - public AvailableHdd.Matcher instantiate() { - return AvailableHdd.Matcher.create(); - } - - @Override - public AvailableHdd.Match newEmptyMatch() { - return AvailableHdd.Match.newEmptyMatch(); - } - - @Override - public AvailableHdd.Match newMatch(final Object... parameters) { - return AvailableHdd.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]); - } - - /** - * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd (visibility: PUBLIC, simpleName: AvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.AvailableHdd (visibility: PUBLIC, simpleName: AvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. - * - *

    This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private static final AvailableHdd INSTANCE = new AvailableHdd(); - - /** - * 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 AvailableHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); - - private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); - - private final List parameters = Arrays.asList(parameter_Host, parameter_Hdd); - - private GeneratedPQuery() { - super(PVisibility.PUBLIC); - } - - @Override - public String getFullyQualifiedName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd"; - } - - @Override - public List getParameterNames() { - return Arrays.asList("Host","Hdd"); - } - - @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_Host = body.getOrCreateVariableByName("Host"); - PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); - PVariable var_TotalHdd = body.getOrCreateVariableByName("TotalHdd"); - PVariable var_RequiredHdd = body.getOrCreateVariableByName("RequiredHdd"); - PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); - PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); - new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Hdd), new JavaTransitiveInstancesKey(java.lang.Integer.class)); - body.setSymbolicParameters(Arrays.asList( - new ExportedParameter(body, var_Host, parameter_Host), - new ExportedParameter(body, var_Hdd, parameter_Hdd) - )); - // find totalHdd(Host, TotalHdd) - new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_TotalHdd), TotalHdd.instance().getInternalQueryRepresentation()); - // RequiredHdd == sum find hddRequirement(Host, _, #_) - PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); - new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Host, var___0_, var___1_), HddRequirement.instance().getInternalQueryRepresentation(), var__virtual_0_, 2); - new Equality(body, var_RequiredHdd, var__virtual_0_); - // Hdd == eval(TotalHdd - RequiredHdd) - PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); - new ExpressionEvaluation(body, new IExpressionEvaluator() { - - @Override - public String getShortDescription() { - return "Expression evaluation from pattern availableHdd"; - } - - @Override - public Iterable getInputParameterNames() { - return Arrays.asList("RequiredHdd", "TotalHdd");} - - @Override - public Object evaluateExpression(IValueProvider provider) throws Exception { - Integer RequiredHdd = (Integer) provider.getValue("RequiredHdd"); - Integer TotalHdd = (Integer) provider.getValue("TotalHdd"); - return evaluateExpression_1_1(RequiredHdd, TotalHdd); - } - }, var__virtual_1_ ); - new Equality(body, var_Hdd, var__virtual_1_); - bodies.add(body); - } - { - PAnnotation annotation = new PAnnotation("QueryBasedFeature"); - annotation.addAttribute("feature", "availableHdd"); - addAnnotation(annotation); - } - return bodies; - } - } - - private static int evaluateExpression_1_1(final Integer RequiredHdd, final Integer TotalHdd) { - return ((TotalHdd).intValue() - (RequiredHdd).intValue()); - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java deleted file mode 100644 index 930a24ba..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AvailableMemory.java +++ /dev/null @@ -1,743 +0,0 @@ -/** - * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql - */ -package hu.bme.mit.inf.dslreasoner.domains.cps.queries; - -import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement; -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.emf.ecore.EClass; -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.emf.types.EClassTransitiveInstancesKey; -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.annotations.PAnnotation; -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.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: - *

    - *         {@literal @}QueryBasedFeature(feature = "availableMemory")
    - *         pattern availableMemory(Host : HostInstance, Memory : java Integer) {
    - *         	find totalMemory(Host, TotalMemory);
    - *         	RequiredMemory == sum find memoryRequirement(Host, _, #_);
    - *         	Memory == eval(TotalMemory - RequiredMemory);
    - *         }
    - * 
    - * - * @see Matcher - * @see Match - * - */ -@SuppressWarnings("all") -public final class AvailableMemory extends BaseGeneratedEMFQuerySpecification { - /** - * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory 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 HostInstance fHost; - - private Integer fMemory; - - private static List parameterNames = makeImmutableList("Host", "Memory"); - - private Match(final HostInstance pHost, final Integer pMemory) { - this.fHost = pHost; - this.fMemory = pMemory; - } - - @Override - public Object get(final String parameterName) { - if ("Host".equals(parameterName)) return this.fHost; - if ("Memory".equals(parameterName)) return this.fMemory; - return null; - } - - public HostInstance getHost() { - return this.fHost; - } - - public Integer getMemory() { - return this.fMemory; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("Host".equals(parameterName) ) { - this.fHost = (HostInstance) newValue; - return true; - } - if ("Memory".equals(parameterName) ) { - this.fMemory = (Integer) newValue; - return true; - } - return false; - } - - public void setHost(final HostInstance pHost) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fHost = pHost; - } - - public void setMemory(final Integer pMemory) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fMemory = pMemory; - } - - @Override - public String patternName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory"; - } - - @Override - public List parameterNames() { - return AvailableMemory.Match.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fHost, fMemory}; - } - - @Override - public AvailableMemory.Match toImmutable() { - return isMutable() ? newMatch(fHost, fMemory) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); - result.append("\"Memory\"=" + prettyPrintValue(fMemory)); - return result.toString(); - } - - @Override - public int hashCode() { - return Objects.hash(fHost, fMemory); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) { - return false; - } - if ((obj instanceof AvailableMemory.Match)) { - AvailableMemory.Match other = (AvailableMemory.Match) obj; - return Objects.equals(fHost, other.fHost) && Objects.equals(fMemory, other.fMemory); - } 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 AvailableMemory specification() { - return AvailableMemory.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 AvailableMemory.Match newEmptyMatch() { - return new Mutable(null, null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static AvailableMemory.Match newMutableMatch(final HostInstance pHost, final Integer pMemory) { - return new Mutable(pHost, pMemory); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return the (partial) match object. - * - */ - public static AvailableMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) { - return new Immutable(pHost, pMemory); - } - - private static final class Mutable extends AvailableMemory.Match { - Mutable(final HostInstance pHost, final Integer pMemory) { - super(pHost, pMemory); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends AvailableMemory.Match { - Immutable(final HostInstance pHost, final Integer pMemory) { - super(pHost, pMemory); - } - - @Override - public boolean isMutable() { - return false; - } - } - } - - /** - * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory 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: - *

    -   * {@literal @}QueryBasedFeature(feature = "availableMemory")
    -   * pattern availableMemory(Host : HostInstance, Memory : java Integer) {
    -   * 	find totalMemory(Host, TotalMemory);
    -   * 	RequiredMemory == sum find memoryRequirement(Host, _, #_);
    -   * 	Memory == eval(TotalMemory - RequiredMemory);
    -   * }
    -   * 
    - * - * @see Match - * @see AvailableMemory - * - */ - 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 AvailableMemory.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 AvailableMemory.Matcher create() { - return new Matcher(); - } - - private static final int POSITION_HOST = 0; - - private static final int POSITION_MEMORY = 1; - - private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AvailableMemory.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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return matches represented as a Match object. - * - */ - public Collection getAllMatches(final HostInstance pHost, final Integer pMemory) { - return rawStreamAllMatches(new Object[]{pHost, pMemory}).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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return a stream of matches represented as a Match object. - * - */ - public Stream streamAllMatches(final HostInstance pHost, final Integer pMemory) { - return rawStreamAllMatches(new Object[]{pHost, pMemory}); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return a match represented as a Match object, or null if no match is found. - * - */ - public Optional getOneArbitraryMatch(final HostInstance pHost, final Integer pMemory) { - return rawGetOneArbitraryMatch(new Object[]{pHost, pMemory}); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final HostInstance pHost, final Integer pMemory) { - return rawHasMatch(new Object[]{pHost, pMemory}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final HostInstance pHost, final Integer pMemory) { - return rawCountMatches(new Object[]{pHost, pMemory}); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, 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 HostInstance pHost, final Integer pMemory, final Consumer processor) { - return rawForOneArbitraryMatch(new Object[]{pHost, pMemory}, 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return the (partial) match object. - * - */ - public AvailableMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) { - return AvailableMemory.Match.newMatch(pHost, pMemory); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { - return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHost() { - return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHost() { - return rawStreamAllValuesOfHost(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHost(final AvailableMemory.Match partialMatch) { - return rawStreamAllValuesOfHost(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHost(final Integer pMemory) { - return rawStreamAllValuesOfHost(new Object[]{null, pMemory}); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHost(final AvailableMemory.Match partialMatch) { - return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHost(final Integer pMemory) { - return rawStreamAllValuesOfHost(new Object[]{null, pMemory}).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - * @return the Set of all values or empty set if there are no matches - * - */ - protected Stream rawStreamAllValuesOfMemory(final Object[] parameters) { - return rawStreamAllValues(POSITION_MEMORY, parameters).map(Integer.class::cast); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfMemory() { - return rawStreamAllValuesOfMemory(emptyArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - * @return the Set of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfMemory() { - return rawStreamAllValuesOfMemory(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfMemory(final AvailableMemory.Match partialMatch) { - return rawStreamAllValuesOfMemory(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfMemory(final HostInstance pHost) { - return rawStreamAllValuesOfMemory(new Object[]{pHost, null}); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfMemory(final AvailableMemory.Match partialMatch) { - return rawStreamAllValuesOfMemory(partialMatch.toArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfMemory(final HostInstance pHost) { - return rawStreamAllValuesOfMemory(new Object[]{pHost, null}).collect(Collectors.toSet()); - } - - @Override - protected AvailableMemory.Match tupleToMatch(final Tuple t) { - try { - return AvailableMemory.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_MEMORY)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected AvailableMemory.Match arrayToMatch(final Object[] match) { - try { - return AvailableMemory.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected AvailableMemory.Match arrayToMatchMutable(final Object[] match) { - try { - return AvailableMemory.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]); - } 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 AvailableMemory.instance(); - } - } - - private AvailableMemory() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded - * - */ - public static AvailableMemory instance() { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected AvailableMemory.Matcher instantiate(final ViatraQueryEngine engine) { - return AvailableMemory.Matcher.on(engine); - } - - @Override - public AvailableMemory.Matcher instantiate() { - return AvailableMemory.Matcher.create(); - } - - @Override - public AvailableMemory.Match newEmptyMatch() { - return AvailableMemory.Match.newEmptyMatch(); - } - - @Override - public AvailableMemory.Match newMatch(final Object... parameters) { - return AvailableMemory.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]); - } - - /** - * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory (visibility: PUBLIC, simpleName: AvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.AvailableMemory (visibility: PUBLIC, simpleName: AvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. - * - *

    This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private static final AvailableMemory INSTANCE = new AvailableMemory(); - - /** - * 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 AvailableMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); - - private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); - - private final List parameters = Arrays.asList(parameter_Host, parameter_Memory); - - private GeneratedPQuery() { - super(PVisibility.PUBLIC); - } - - @Override - public String getFullyQualifiedName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory"; - } - - @Override - public List getParameterNames() { - return Arrays.asList("Host","Memory"); - } - - @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_Host = body.getOrCreateVariableByName("Host"); - PVariable var_Memory = body.getOrCreateVariableByName("Memory"); - PVariable var_TotalMemory = body.getOrCreateVariableByName("TotalMemory"); - PVariable var_RequiredMemory = body.getOrCreateVariableByName("RequiredMemory"); - PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); - PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); - new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Memory), new JavaTransitiveInstancesKey(java.lang.Integer.class)); - body.setSymbolicParameters(Arrays.asList( - new ExportedParameter(body, var_Host, parameter_Host), - new ExportedParameter(body, var_Memory, parameter_Memory) - )); - // find totalMemory(Host, TotalMemory) - new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_TotalMemory), TotalMemory.instance().getInternalQueryRepresentation()); - // RequiredMemory == sum find memoryRequirement(Host, _, #_) - PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); - new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Host, var___0_, var___1_), MemoryRequirement.instance().getInternalQueryRepresentation(), var__virtual_0_, 2); - new Equality(body, var_RequiredMemory, var__virtual_0_); - // Memory == eval(TotalMemory - RequiredMemory) - PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); - new ExpressionEvaluation(body, new IExpressionEvaluator() { - - @Override - public String getShortDescription() { - return "Expression evaluation from pattern availableMemory"; - } - - @Override - public Iterable getInputParameterNames() { - return Arrays.asList("RequiredMemory", "TotalMemory");} - - @Override - public Object evaluateExpression(IValueProvider provider) throws Exception { - Integer RequiredMemory = (Integer) provider.getValue("RequiredMemory"); - Integer TotalMemory = (Integer) provider.getValue("TotalMemory"); - return evaluateExpression_1_1(RequiredMemory, TotalMemory); - } - }, var__virtual_1_ ); - new Equality(body, var_Memory, var__virtual_1_); - bodies.add(body); - } - { - PAnnotation annotation = new PAnnotation("QueryBasedFeature"); - annotation.addAttribute("feature", "availableMemory"); - addAnnotation(annotation); - } - return bodies; - } - } - - private static int evaluateExpression_1_1(final Integer RequiredMemory, final Integer TotalMemory) { - return ((TotalMemory).intValue() - (RequiredMemory).intValue()); - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java index 59d4ad27..bc38b60b 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java @@ -43,6 +43,8 @@ import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; * *

    Original source: *

    + *         // Free HDD
    + *         
      *         pattern averageFreeHddMetric(Average : java Double) {
      *         	Average == avg find freeHddPercentage(_, #_);
      *         }
    @@ -226,6 +228,8 @@ public final class AverageFreeHddMetric extends BaseGeneratedEMFQuerySpecificati
        * 
        * 

    Original source: *

    +   * // Free HDD
    +   * 
        * pattern averageFreeHddMetric(Average : java Double) {
        * 	Average == avg find freeHddPercentage(_, #_);
        * }
    diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java
    index a0d087f4..98974ea5 100644
    --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java
    +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeMemoryMetric.java
    @@ -43,6 +43,12 @@ import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
      * 
      * 

    Original source: *

    + *         //
    + *         // Metrics
    + *         //
    + *         
    + *         // Free memory
    + *         
      *         pattern averageFreeMemoryMetric(Average : java Double) {
      *         	Average == avg find freeMemoryPercentage(_, #_);
      *         }
    @@ -226,6 +232,12 @@ public final class AverageFreeMemoryMetric extends BaseGeneratedEMFQuerySpecific
        * 
        * 

    Original source: *

    +   * //
    +   * // Metrics
    +   * //
    +   * 
    +   * // Free memory
    +   * 
        * pattern averageFreeMemoryMetric(Average : java Double) {
        * 	Average == avg find freeMemoryPercentage(_, #_);
        * }
    diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java
    index 4d8ca4cc..bf886ec0 100644
    --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java
    +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CostMetric.java
    @@ -43,6 +43,8 @@ import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
      * 
      * 

    Original source: *

    + *         // Total cost
    + *         
      *         pattern costMetric(Cost : java Integer) {
      *         	Cost == sum find cpsCost(_, #_);
      *         }
    @@ -226,6 +228,8 @@ public final class CostMetric extends BaseGeneratedEMFQuerySpecificationOriginal source:
        * 
    +   * // Total cost
    +   * 
        * pattern costMetric(Cost : java Integer) {
        * 	Cost == sum find cpsCost(_, #_);
        * }
    diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java
    deleted file mode 100644
    index 2c20b38e..00000000
    --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java
    +++ /dev/null
    @@ -1,705 +0,0 @@
    -/**
    - * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql
    - */
    -package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
    -
    -import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance;
    -import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem;
    -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.emf.ecore.EClass;
    -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.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.annotations.PAnnotation;
    -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.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: - *

    - *         {@literal @}QueryBasedFeature(feature = "applications")
    - *         pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) {
    - *         	CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance);
    - *         }
    - * 
    - * - * @see Matcher - * @see Match - * - */ -@SuppressWarnings("all") -public final class CpsApplications extends BaseGeneratedEMFQuerySpecification { - /** - * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications 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 CyberPhysicalSystem fCps; - - private ApplicationInstance fAppInstance; - - private static List parameterNames = makeImmutableList("Cps", "AppInstance"); - - private Match(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { - this.fCps = pCps; - this.fAppInstance = pAppInstance; - } - - @Override - public Object get(final String parameterName) { - if ("Cps".equals(parameterName)) return this.fCps; - if ("AppInstance".equals(parameterName)) return this.fAppInstance; - return null; - } - - public CyberPhysicalSystem getCps() { - return this.fCps; - } - - public ApplicationInstance getAppInstance() { - return this.fAppInstance; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("Cps".equals(parameterName) ) { - this.fCps = (CyberPhysicalSystem) newValue; - return true; - } - if ("AppInstance".equals(parameterName) ) { - this.fAppInstance = (ApplicationInstance) newValue; - return true; - } - return false; - } - - public void setCps(final CyberPhysicalSystem pCps) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fCps = pCps; - } - - public void setAppInstance(final ApplicationInstance pAppInstance) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fAppInstance = pAppInstance; - } - - @Override - public String patternName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications"; - } - - @Override - public List parameterNames() { - return CpsApplications.Match.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fCps, fAppInstance}; - } - - @Override - public CpsApplications.Match toImmutable() { - return isMutable() ? newMatch(fCps, fAppInstance) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"Cps\"=" + prettyPrintValue(fCps) + ", "); - result.append("\"AppInstance\"=" + prettyPrintValue(fAppInstance)); - return result.toString(); - } - - @Override - public int hashCode() { - return Objects.hash(fCps, fAppInstance); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) { - return false; - } - if ((obj instanceof CpsApplications.Match)) { - CpsApplications.Match other = (CpsApplications.Match) obj; - return Objects.equals(fCps, other.fCps) && Objects.equals(fAppInstance, other.fAppInstance); - } 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 CpsApplications specification() { - return CpsApplications.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 CpsApplications.Match newEmptyMatch() { - return new Mutable(null, null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static CpsApplications.Match newMutableMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { - return new Mutable(pCps, pAppInstance); - } - - /** - * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. - * @return the (partial) match object. - * - */ - public static CpsApplications.Match newMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { - return new Immutable(pCps, pAppInstance); - } - - private static final class Mutable extends CpsApplications.Match { - Mutable(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { - super(pCps, pAppInstance); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends CpsApplications.Match { - Immutable(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { - super(pCps, pAppInstance); - } - - @Override - public boolean isMutable() { - return false; - } - } - } - - /** - * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications 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: - *

    -   * {@literal @}QueryBasedFeature(feature = "applications")
    -   * pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) {
    -   * 	CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance);
    -   * }
    -   * 
    - * - * @see Match - * @see CpsApplications - * - */ - 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 CpsApplications.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 CpsApplications.Matcher create() { - return new Matcher(); - } - - private static final int POSITION_CPS = 0; - - private static final int POSITION_APPINSTANCE = 1; - - private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CpsApplications.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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. - * @return matches represented as a Match object. - * - */ - public Collection getAllMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { - return rawStreamAllMatches(new Object[]{pCps, pAppInstance}).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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. - * @return a stream of matches represented as a Match object. - * - */ - public Stream streamAllMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { - return rawStreamAllMatches(new Object[]{pCps, pAppInstance}); - } - - /** - * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. - * @return a match represented as a Match object, or null if no match is found. - * - */ - public Optional getOneArbitraryMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { - return rawGetOneArbitraryMatch(new Object[]{pCps, pAppInstance}); - } - - /** - * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { - return rawHasMatch(new Object[]{pCps, pAppInstance}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { - return rawCountMatches(new Object[]{pCps, pAppInstance}); - } - - /** - * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pAppInstance the fixed value of pattern parameter AppInstance, 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 CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance, final Consumer processor) { - return rawForOneArbitraryMatch(new Object[]{pCps, pAppInstance}, 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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound. - * @return the (partial) match object. - * - */ - public CpsApplications.Match newMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) { - return CpsApplications.Match.newMatch(pCps, pAppInstance); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - * @return the Set of all values or empty set if there are no matches - * - */ - protected Stream rawStreamAllValuesOfCps(final Object[] parameters) { - return rawStreamAllValues(POSITION_CPS, parameters).map(CyberPhysicalSystem.class::cast); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfCps() { - return rawStreamAllValuesOfCps(emptyArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - * @return the Set of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfCps() { - return rawStreamAllValuesOfCps(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfCps(final CpsApplications.Match partialMatch) { - return rawStreamAllValuesOfCps(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfCps(final ApplicationInstance pAppInstance) { - return rawStreamAllValuesOfCps(new Object[]{null, pAppInstance}); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfCps(final CpsApplications.Match partialMatch) { - return rawStreamAllValuesOfCps(partialMatch.toArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfCps(final ApplicationInstance pAppInstance) { - return rawStreamAllValuesOfCps(new Object[]{null, pAppInstance}).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for AppInstance. - * @return the Set of all values or empty set if there are no matches - * - */ - protected Stream rawStreamAllValuesOfAppInstance(final Object[] parameters) { - return rawStreamAllValues(POSITION_APPINSTANCE, parameters).map(ApplicationInstance.class::cast); - } - - /** - * Retrieve the set of values that occur in matches for AppInstance. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfAppInstance() { - return rawStreamAllValuesOfAppInstance(emptyArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for AppInstance. - * @return the Set of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfAppInstance() { - return rawStreamAllValuesOfAppInstance(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for AppInstance. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfAppInstance(final CpsApplications.Match partialMatch) { - return rawStreamAllValuesOfAppInstance(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for AppInstance. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfAppInstance(final CyberPhysicalSystem pCps) { - return rawStreamAllValuesOfAppInstance(new Object[]{pCps, null}); - } - - /** - * Retrieve the set of values that occur in matches for AppInstance. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfAppInstance(final CpsApplications.Match partialMatch) { - return rawStreamAllValuesOfAppInstance(partialMatch.toArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for AppInstance. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfAppInstance(final CyberPhysicalSystem pCps) { - return rawStreamAllValuesOfAppInstance(new Object[]{pCps, null}).collect(Collectors.toSet()); - } - - @Override - protected CpsApplications.Match tupleToMatch(final Tuple t) { - try { - return CpsApplications.Match.newMatch((CyberPhysicalSystem) t.get(POSITION_CPS), (ApplicationInstance) t.get(POSITION_APPINSTANCE)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected CpsApplications.Match arrayToMatch(final Object[] match) { - try { - return CpsApplications.Match.newMatch((CyberPhysicalSystem) match[POSITION_CPS], (ApplicationInstance) match[POSITION_APPINSTANCE]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected CpsApplications.Match arrayToMatchMutable(final Object[] match) { - try { - return CpsApplications.Match.newMutableMatch((CyberPhysicalSystem) match[POSITION_CPS], (ApplicationInstance) match[POSITION_APPINSTANCE]); - } 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 CpsApplications.instance(); - } - } - - private CpsApplications() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded - * - */ - public static CpsApplications instance() { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected CpsApplications.Matcher instantiate(final ViatraQueryEngine engine) { - return CpsApplications.Matcher.on(engine); - } - - @Override - public CpsApplications.Matcher instantiate() { - return CpsApplications.Matcher.create(); - } - - @Override - public CpsApplications.Match newEmptyMatch() { - return CpsApplications.Match.newEmptyMatch(); - } - - @Override - public CpsApplications.Match newMatch(final Object... parameters) { - return CpsApplications.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1]); - } - - /** - * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. - * - *

    This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private static final CpsApplications INSTANCE = new CpsApplications(); - - /** - * 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 CpsApplications.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); - - private final PParameter parameter_AppInstance = new PParameter("AppInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); - - private final List parameters = Arrays.asList(parameter_Cps, parameter_AppInstance); - - private GeneratedPQuery() { - super(PVisibility.PUBLIC); - } - - @Override - public String getFullyQualifiedName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications"; - } - - @Override - public List getParameterNames() { - return Arrays.asList("Cps","AppInstance"); - } - - @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_Cps = body.getOrCreateVariableByName("Cps"); - PVariable var_AppInstance = body.getOrCreateVariableByName("AppInstance"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); - new TypeConstraint(body, Tuples.flatTupleOf(var_AppInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); - body.setSymbolicParameters(Arrays.asList( - new ExportedParameter(body, var_Cps, parameter_Cps), - new ExportedParameter(body, var_AppInstance, parameter_AppInstance) - )); - // CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance) - new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); - PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "applicationTypes"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); - PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "instances"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); - new Equality(body, var__virtual_1_, var_AppInstance); - bodies.add(body); - } - { - PAnnotation annotation = new PAnnotation("QueryBasedFeature"); - annotation.addAttribute("feature", "applications"); - addAnnotation(annotation); - } - return bodies; - } - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java index 169a30e5..fc90ef12 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsCost.java @@ -4,7 +4,7 @@ package hu.bme.mit.inf.dslreasoner.domains.cps.queries; import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsApplications; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost; import java.util.Arrays; import java.util.Collection; diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java deleted file mode 100644 index e1abf758..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsHosts.java +++ /dev/null @@ -1,705 +0,0 @@ -/** - * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql - */ -package hu.bme.mit.inf.dslreasoner.domains.cps.queries; - -import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; -import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; -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.emf.ecore.EClass; -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.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.annotations.PAnnotation; -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.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: - *

    - *         {@literal @}QueryBasedFeature(feature = "hosts")
    - *         pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) {
    - *         	CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance);
    - *         }
    - * 
    - * - * @see Matcher - * @see Match - * - */ -@SuppressWarnings("all") -public final class CpsHosts extends BaseGeneratedEMFQuerySpecification { - /** - * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts 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 CyberPhysicalSystem fCps; - - private HostInstance fHostInstance; - - private static List parameterNames = makeImmutableList("Cps", "HostInstance"); - - private Match(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { - this.fCps = pCps; - this.fHostInstance = pHostInstance; - } - - @Override - public Object get(final String parameterName) { - if ("Cps".equals(parameterName)) return this.fCps; - if ("HostInstance".equals(parameterName)) return this.fHostInstance; - return null; - } - - public CyberPhysicalSystem getCps() { - return this.fCps; - } - - public HostInstance getHostInstance() { - return this.fHostInstance; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("Cps".equals(parameterName) ) { - this.fCps = (CyberPhysicalSystem) newValue; - return true; - } - if ("HostInstance".equals(parameterName) ) { - this.fHostInstance = (HostInstance) newValue; - return true; - } - return false; - } - - public void setCps(final CyberPhysicalSystem pCps) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fCps = pCps; - } - - public void setHostInstance(final HostInstance pHostInstance) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fHostInstance = pHostInstance; - } - - @Override - public String patternName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts"; - } - - @Override - public List parameterNames() { - return CpsHosts.Match.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fCps, fHostInstance}; - } - - @Override - public CpsHosts.Match toImmutable() { - return isMutable() ? newMatch(fCps, fHostInstance) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"Cps\"=" + prettyPrintValue(fCps) + ", "); - result.append("\"HostInstance\"=" + prettyPrintValue(fHostInstance)); - return result.toString(); - } - - @Override - public int hashCode() { - return Objects.hash(fCps, fHostInstance); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) { - return false; - } - if ((obj instanceof CpsHosts.Match)) { - CpsHosts.Match other = (CpsHosts.Match) obj; - return Objects.equals(fCps, other.fCps) && Objects.equals(fHostInstance, other.fHostInstance); - } 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 CpsHosts specification() { - return CpsHosts.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 CpsHosts.Match newEmptyMatch() { - return new Mutable(null, null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static CpsHosts.Match newMutableMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { - return new Mutable(pCps, pHostInstance); - } - - /** - * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. - * @return the (partial) match object. - * - */ - public static CpsHosts.Match newMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { - return new Immutable(pCps, pHostInstance); - } - - private static final class Mutable extends CpsHosts.Match { - Mutable(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { - super(pCps, pHostInstance); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends CpsHosts.Match { - Immutable(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { - super(pCps, pHostInstance); - } - - @Override - public boolean isMutable() { - return false; - } - } - } - - /** - * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts 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: - *

    -   * {@literal @}QueryBasedFeature(feature = "hosts")
    -   * pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) {
    -   * 	CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance);
    -   * }
    -   * 
    - * - * @see Match - * @see CpsHosts - * - */ - 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 CpsHosts.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 CpsHosts.Matcher create() { - return new Matcher(); - } - - private static final int POSITION_CPS = 0; - - private static final int POSITION_HOSTINSTANCE = 1; - - private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CpsHosts.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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. - * @return matches represented as a Match object. - * - */ - public Collection getAllMatches(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { - return rawStreamAllMatches(new Object[]{pCps, pHostInstance}).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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. - * @return a stream of matches represented as a Match object. - * - */ - public Stream streamAllMatches(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { - return rawStreamAllMatches(new Object[]{pCps, pHostInstance}); - } - - /** - * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. - * @return a match represented as a Match object, or null if no match is found. - * - */ - public Optional getOneArbitraryMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { - return rawGetOneArbitraryMatch(new Object[]{pCps, pHostInstance}); - } - - /** - * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { - return rawHasMatch(new Object[]{pCps, pHostInstance}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { - return rawCountMatches(new Object[]{pCps, pHostInstance}); - } - - /** - * 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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pHostInstance the fixed value of pattern parameter HostInstance, 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 CyberPhysicalSystem pCps, final HostInstance pHostInstance, final Consumer processor) { - return rawForOneArbitraryMatch(new Object[]{pCps, pHostInstance}, 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 pCps the fixed value of pattern parameter Cps, or null if not bound. - * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. - * @return the (partial) match object. - * - */ - public CpsHosts.Match newMatch(final CyberPhysicalSystem pCps, final HostInstance pHostInstance) { - return CpsHosts.Match.newMatch(pCps, pHostInstance); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - * @return the Set of all values or empty set if there are no matches - * - */ - protected Stream rawStreamAllValuesOfCps(final Object[] parameters) { - return rawStreamAllValues(POSITION_CPS, parameters).map(CyberPhysicalSystem.class::cast); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfCps() { - return rawStreamAllValuesOfCps(emptyArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - * @return the Set of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfCps() { - return rawStreamAllValuesOfCps(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfCps(final CpsHosts.Match partialMatch) { - return rawStreamAllValuesOfCps(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfCps(final HostInstance pHostInstance) { - return rawStreamAllValuesOfCps(new Object[]{null, pHostInstance}); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfCps(final CpsHosts.Match partialMatch) { - return rawStreamAllValuesOfCps(partialMatch.toArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Cps. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfCps(final HostInstance pHostInstance) { - return rawStreamAllValuesOfCps(new Object[]{null, pHostInstance}).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for HostInstance. - * @return the Set of all values or empty set if there are no matches - * - */ - protected Stream rawStreamAllValuesOfHostInstance(final Object[] parameters) { - return rawStreamAllValues(POSITION_HOSTINSTANCE, parameters).map(HostInstance.class::cast); - } - - /** - * Retrieve the set of values that occur in matches for HostInstance. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHostInstance() { - return rawStreamAllValuesOfHostInstance(emptyArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for HostInstance. - * @return the Set of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHostInstance() { - return rawStreamAllValuesOfHostInstance(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for HostInstance. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHostInstance(final CpsHosts.Match partialMatch) { - return rawStreamAllValuesOfHostInstance(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for HostInstance. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHostInstance(final CyberPhysicalSystem pCps) { - return rawStreamAllValuesOfHostInstance(new Object[]{pCps, null}); - } - - /** - * Retrieve the set of values that occur in matches for HostInstance. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHostInstance(final CpsHosts.Match partialMatch) { - return rawStreamAllValuesOfHostInstance(partialMatch.toArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for HostInstance. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHostInstance(final CyberPhysicalSystem pCps) { - return rawStreamAllValuesOfHostInstance(new Object[]{pCps, null}).collect(Collectors.toSet()); - } - - @Override - protected CpsHosts.Match tupleToMatch(final Tuple t) { - try { - return CpsHosts.Match.newMatch((CyberPhysicalSystem) t.get(POSITION_CPS), (HostInstance) t.get(POSITION_HOSTINSTANCE)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected CpsHosts.Match arrayToMatch(final Object[] match) { - try { - return CpsHosts.Match.newMatch((CyberPhysicalSystem) match[POSITION_CPS], (HostInstance) match[POSITION_HOSTINSTANCE]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected CpsHosts.Match arrayToMatchMutable(final Object[] match) { - try { - return CpsHosts.Match.newMutableMatch((CyberPhysicalSystem) match[POSITION_CPS], (HostInstance) match[POSITION_HOSTINSTANCE]); - } 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 CpsHosts.instance(); - } - } - - private CpsHosts() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded - * - */ - public static CpsHosts instance() { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected CpsHosts.Matcher instantiate(final ViatraQueryEngine engine) { - return CpsHosts.Matcher.on(engine); - } - - @Override - public CpsHosts.Matcher instantiate() { - return CpsHosts.Matcher.create(); - } - - @Override - public CpsHosts.Match newEmptyMatch() { - return CpsHosts.Match.newEmptyMatch(); - } - - @Override - public CpsHosts.Match newMatch(final Object... parameters) { - return CpsHosts.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[1]); - } - - /** - * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts (visibility: PUBLIC, simpleName: CpsHosts, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.CpsHosts (visibility: PUBLIC, simpleName: CpsHosts, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. - * - *

    This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private static final CpsHosts INSTANCE = new CpsHosts(); - - /** - * 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 CpsHosts.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); - - private final PParameter parameter_HostInstance = new PParameter("HostInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); - - private final List parameters = Arrays.asList(parameter_Cps, parameter_HostInstance); - - private GeneratedPQuery() { - super(PVisibility.PUBLIC); - } - - @Override - public String getFullyQualifiedName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts"; - } - - @Override - public List getParameterNames() { - return Arrays.asList("Cps","HostInstance"); - } - - @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_Cps = body.getOrCreateVariableByName("Cps"); - PVariable var_HostInstance = body.getOrCreateVariableByName("HostInstance"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); - new TypeConstraint(body, Tuples.flatTupleOf(var_HostInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); - body.setSymbolicParameters(Arrays.asList( - new ExportedParameter(body, var_Cps, parameter_Cps), - new ExportedParameter(body, var_HostInstance, parameter_HostInstance) - )); - // CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance) - new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); - PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "hostTypes"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); - PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "instances"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); - new Equality(body, var__virtual_1_, var_HostInstance); - bodies.add(body); - } - { - PAnnotation annotation = new PAnnotation("QueryBasedFeature"); - annotation.addAttribute("feature", "hosts"); - addAnnotation(annotation); - } - return bodies; - } - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java index 916f35f7..c889fbe0 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.java @@ -3,22 +3,22 @@ */ package hu.bme.mit.inf.dslreasoner.domains.cps.queries; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RedundantInstancesOnSameHost; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance; import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; @@ -30,12 +30,7 @@ import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; * in order to achieve better performance than one-by-one on-demand matcher initialization. * *

    From package hu.bme.mit.inf.dslreasoner.domains.cps.queries, the group contains the definition of the following patterns:

      - *
    • cpsApplications
    • - *
    • cpsHosts
    • - *
    • totalMemory
    • - *
    • totalHdd
    • - *
    • availableMemory
    • - *
    • availableHdd
    • + *
    • resourceRequirement
    • *
    • allocationWithoutResourceRequirement
    • *
    • notEnoughAvailableMemory
    • *
    • notEnoughAvailableHdd
    • @@ -46,6 +41,11 @@ import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; *
    • averageFreeHddMetric
    • *
    • costMetric
    • *
    • cpsCost
    • + *
    • allocate
    • + *
    • unallocateAppInstance
    • + *
    • createHostInstance
    • + *
    • removeHostInstance
    • + *
    • guidanceObjective
    • *
    * * @see IQueryGroup @@ -70,12 +70,7 @@ public final class CpsQueries extends BaseGeneratedPatternGroup { private static CpsQueries INSTANCE; private CpsQueries() { - querySpecifications.add(CpsApplications.instance()); - querySpecifications.add(CpsHosts.instance()); - querySpecifications.add(TotalMemory.instance()); - querySpecifications.add(TotalHdd.instance()); - querySpecifications.add(AvailableMemory.instance()); - querySpecifications.add(AvailableHdd.instance()); + querySpecifications.add(ResourceRequirement.instance()); querySpecifications.add(AllocationWithoutResourceRequirement.instance()); querySpecifications.add(NotEnoughAvailableMemory.instance()); querySpecifications.add(NotEnoughAvailableHdd.instance()); @@ -86,54 +81,19 @@ public final class CpsQueries extends BaseGeneratedPatternGroup { querySpecifications.add(AverageFreeHddMetric.instance()); querySpecifications.add(CostMetric.instance()); querySpecifications.add(CpsCost.instance()); + querySpecifications.add(Allocate.instance()); + querySpecifications.add(UnallocateAppInstance.instance()); + querySpecifications.add(CreateHostInstance.instance()); + querySpecifications.add(RemoveHostInstance.instance()); + querySpecifications.add(GuidanceObjective.instance()); } - public CpsApplications getCpsApplications() { - return CpsApplications.instance(); + public ResourceRequirement getResourceRequirement() { + return ResourceRequirement.instance(); } - public CpsApplications.Matcher getCpsApplications(final ViatraQueryEngine engine) { - return CpsApplications.Matcher.on(engine); - } - - public CpsHosts getCpsHosts() { - return CpsHosts.instance(); - } - - public CpsHosts.Matcher getCpsHosts(final ViatraQueryEngine engine) { - return CpsHosts.Matcher.on(engine); - } - - public TotalMemory getTotalMemory() { - return TotalMemory.instance(); - } - - public TotalMemory.Matcher getTotalMemory(final ViatraQueryEngine engine) { - return TotalMemory.Matcher.on(engine); - } - - public TotalHdd getTotalHdd() { - return TotalHdd.instance(); - } - - public TotalHdd.Matcher getTotalHdd(final ViatraQueryEngine engine) { - return TotalHdd.Matcher.on(engine); - } - - public AvailableMemory getAvailableMemory() { - return AvailableMemory.instance(); - } - - public AvailableMemory.Matcher getAvailableMemory(final ViatraQueryEngine engine) { - return AvailableMemory.Matcher.on(engine); - } - - public AvailableHdd getAvailableHdd() { - return AvailableHdd.instance(); - } - - public AvailableHdd.Matcher getAvailableHdd(final ViatraQueryEngine engine) { - return AvailableHdd.Matcher.on(engine); + public ResourceRequirement.Matcher getResourceRequirement(final ViatraQueryEngine engine) { + return ResourceRequirement.Matcher.on(engine); } public AllocationWithoutResourceRequirement getAllocationWithoutResourceRequirement() { @@ -215,4 +175,44 @@ public final class CpsQueries extends BaseGeneratedPatternGroup { public CpsCost.Matcher getCpsCost(final ViatraQueryEngine engine) { return CpsCost.Matcher.on(engine); } + + public Allocate getAllocate() { + return Allocate.instance(); + } + + public Allocate.Matcher getAllocate(final ViatraQueryEngine engine) { + return Allocate.Matcher.on(engine); + } + + public UnallocateAppInstance getUnallocateAppInstance() { + return UnallocateAppInstance.instance(); + } + + public UnallocateAppInstance.Matcher getUnallocateAppInstance(final ViatraQueryEngine engine) { + return UnallocateAppInstance.Matcher.on(engine); + } + + public CreateHostInstance getCreateHostInstance() { + return CreateHostInstance.instance(); + } + + public CreateHostInstance.Matcher getCreateHostInstance(final ViatraQueryEngine engine) { + return CreateHostInstance.Matcher.on(engine); + } + + public RemoveHostInstance getRemoveHostInstance() { + return RemoveHostInstance.instance(); + } + + public RemoveHostInstance.Matcher getRemoveHostInstance(final ViatraQueryEngine engine) { + return RemoveHostInstance.Matcher.on(engine); + } + + public GuidanceObjective getGuidanceObjective() { + return GuidanceObjective.instance(); + } + + public GuidanceObjective.Matcher getGuidanceObjective(final ViatraQueryEngine engine) { + return GuidanceObjective.Matcher.on(engine); + } } diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CreateHostInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CreateHostInstance.java new file mode 100644 index 00000000..f475c9e9 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CreateHostInstance.java @@ -0,0 +1,553 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance; +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.emf.ecore.EClass; +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.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.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.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: + *

    + *         pattern createHostInstance(HostType : HostType) {
    + *         	find unallocatedAppInstance(App);
    + *         	ApplicationInstance.type.requirements.hostType(App, HostType);
    + *         }
    + * 
    + * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class CreateHostInstance extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.createHostInstance 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 HostType fHostType; + + private static List parameterNames = makeImmutableList("HostType"); + + private Match(final HostType pHostType) { + this.fHostType = pHostType; + } + + @Override + public Object get(final String parameterName) { + if ("HostType".equals(parameterName)) return this.fHostType; + return null; + } + + public HostType getHostType() { + return this.fHostType; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("HostType".equals(parameterName) ) { + this.fHostType = (HostType) newValue; + return true; + } + return false; + } + + public void setHostType(final HostType pHostType) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHostType = pHostType; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.createHostInstance"; + } + + @Override + public List parameterNames() { + return CreateHostInstance.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHostType}; + } + + @Override + public CreateHostInstance.Match toImmutable() { + return isMutable() ? newMatch(fHostType) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"HostType\"=" + prettyPrintValue(fHostType)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHostType); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof CreateHostInstance.Match)) { + CreateHostInstance.Match other = (CreateHostInstance.Match) obj; + return Objects.equals(fHostType, other.fHostType); + } 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 CreateHostInstance specification() { + return CreateHostInstance.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 CreateHostInstance.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 pHostType the fixed value of pattern parameter HostType, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static CreateHostInstance.Match newMutableMatch(final HostType pHostType) { + return new Mutable(pHostType); + } + + /** + * 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 pHostType the fixed value of pattern parameter HostType, or null if not bound. + * @return the (partial) match object. + * + */ + public static CreateHostInstance.Match newMatch(final HostType pHostType) { + return new Immutable(pHostType); + } + + private static final class Mutable extends CreateHostInstance.Match { + Mutable(final HostType pHostType) { + super(pHostType); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends CreateHostInstance.Match { + Immutable(final HostType pHostType) { + super(pHostType); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.createHostInstance 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: + *

    +   * pattern createHostInstance(HostType : HostType) {
    +   * 	find unallocatedAppInstance(App);
    +   * 	ApplicationInstance.type.requirements.hostType(App, HostType);
    +   * }
    +   * 
    + * + * @see Match + * @see CreateHostInstance + * + */ + 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 CreateHostInstance.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 CreateHostInstance.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOSTTYPE = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CreateHostInstance.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 pHostType the fixed value of pattern parameter HostType, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostType pHostType) { + return rawStreamAllMatches(new Object[]{pHostType}).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 pHostType the fixed value of pattern parameter HostType, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostType pHostType) { + return rawStreamAllMatches(new Object[]{pHostType}); + } + + /** + * 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 pHostType the fixed value of pattern parameter HostType, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostType pHostType) { + return rawGetOneArbitraryMatch(new Object[]{pHostType}); + } + + /** + * 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 pHostType the fixed value of pattern parameter HostType, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostType pHostType) { + return rawHasMatch(new Object[]{pHostType}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHostType the fixed value of pattern parameter HostType, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostType pHostType) { + return rawCountMatches(new Object[]{pHostType}); + } + + /** + * 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 pHostType the fixed value of pattern parameter HostType, 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 HostType pHostType, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHostType}, 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 pHostType the fixed value of pattern parameter HostType, or null if not bound. + * @return the (partial) match object. + * + */ + public CreateHostInstance.Match newMatch(final HostType pHostType) { + return CreateHostInstance.Match.newMatch(pHostType); + } + + /** + * Retrieve the set of values that occur in matches for HostType. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHostType(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOSTTYPE, parameters).map(HostType.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for HostType. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHostType() { + return rawStreamAllValuesOfHostType(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for HostType. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHostType() { + return rawStreamAllValuesOfHostType(emptyArray()); + } + + @Override + protected CreateHostInstance.Match tupleToMatch(final Tuple t) { + try { + return CreateHostInstance.Match.newMatch((HostType) t.get(POSITION_HOSTTYPE)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected CreateHostInstance.Match arrayToMatch(final Object[] match) { + try { + return CreateHostInstance.Match.newMatch((HostType) match[POSITION_HOSTTYPE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected CreateHostInstance.Match arrayToMatchMutable(final Object[] match) { + try { + return CreateHostInstance.Match.newMutableMatch((HostType) match[POSITION_HOSTTYPE]); + } 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 CreateHostInstance.instance(); + } + } + + private CreateHostInstance() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static CreateHostInstance instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected CreateHostInstance.Matcher instantiate(final ViatraQueryEngine engine) { + return CreateHostInstance.Matcher.on(engine); + } + + @Override + public CreateHostInstance.Matcher instantiate() { + return CreateHostInstance.Matcher.create(); + } + + @Override + public CreateHostInstance.Match newEmptyMatch() { + return CreateHostInstance.Match.newEmptyMatch(); + } + + @Override + public CreateHostInstance.Match newMatch(final Object... parameters) { + return CreateHostInstance.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostType) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance (visibility: PUBLIC, simpleName: CreateHostInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.CreateHostInstance (visibility: PUBLIC, simpleName: CreateHostInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final CreateHostInstance INSTANCE = new CreateHostInstance(); + + /** + * 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 CreateHostInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_HostType = new PParameter("HostType", "hu.bme.mit.inf.dslreasoner.domains.cps.HostType", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostType")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_HostType); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.createHostInstance"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("HostType"); + } + + @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_HostType = body.getOrCreateVariableByName("HostType"); + PVariable var_App = body.getOrCreateVariableByName("App"); + new TypeConstraint(body, Tuples.flatTupleOf(var_HostType), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_HostType, parameter_HostType) + )); + // find unallocatedAppInstance(App) + new PositivePatternCall(body, Tuples.flatTupleOf(var_App), UnallocatedAppInstance.instance().getInternalQueryRepresentation()); + // ApplicationInstance.type.requirements.hostType(App, HostType) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "requirements"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + 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/cps", "ResourceRequirement", "hostType"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + new Equality(body, var__virtual_2_, var_HostType); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/GuidanceObjective.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/GuidanceObjective.java new file mode 100644 index 00000000..cfed0c4b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/GuidanceObjective.java @@ -0,0 +1,591 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.NoHostToAllocateTo; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.RequiredAppInstances; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance; +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.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.PatternMatchCounter; +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: + *

    + *         pattern guidanceObjective(Value : java Integer) {
    + *         	UnallocatedInstances == count find unallocatedAppInstance(_);
    + *         	RequiredInstances == sum find requiredAppInstances(_, #_);
    + *         	NoHostToAllocate == count find noHostToAllocateTo(_);
    + *         	Value == eval(2  UnallocatedInstances + 4  RequiredInstances + NoHostToAllocate);
    + *         }
    + * 
    + * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class GuidanceObjective extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.guidanceObjective 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 Integer fValue; + + private static List parameterNames = makeImmutableList("Value"); + + private Match(final Integer pValue) { + this.fValue = pValue; + } + + @Override + public Object get(final String parameterName) { + if ("Value".equals(parameterName)) return this.fValue; + return null; + } + + public Integer getValue() { + return this.fValue; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Value".equals(parameterName) ) { + this.fValue = (Integer) newValue; + return true; + } + return false; + } + + public void setValue(final Integer pValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fValue = pValue; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.guidanceObjective"; + } + + @Override + public List parameterNames() { + return GuidanceObjective.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fValue}; + } + + @Override + public GuidanceObjective.Match toImmutable() { + return isMutable() ? newMatch(fValue) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Value\"=" + prettyPrintValue(fValue)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fValue); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof GuidanceObjective.Match)) { + GuidanceObjective.Match other = (GuidanceObjective.Match) obj; + return Objects.equals(fValue, other.fValue); + } 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 GuidanceObjective specification() { + return GuidanceObjective.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 GuidanceObjective.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 pValue the fixed value of pattern parameter Value, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static GuidanceObjective.Match newMutableMatch(final Integer pValue) { + return new Mutable(pValue); + } + + /** + * 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 pValue the fixed value of pattern parameter Value, or null if not bound. + * @return the (partial) match object. + * + */ + public static GuidanceObjective.Match newMatch(final Integer pValue) { + return new Immutable(pValue); + } + + private static final class Mutable extends GuidanceObjective.Match { + Mutable(final Integer pValue) { + super(pValue); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends GuidanceObjective.Match { + Immutable(final Integer pValue) { + super(pValue); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.guidanceObjective 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: + *

    +   * pattern guidanceObjective(Value : java Integer) {
    +   * 	UnallocatedInstances == count find unallocatedAppInstance(_);
    +   * 	RequiredInstances == sum find requiredAppInstances(_, #_);
    +   * 	NoHostToAllocate == count find noHostToAllocateTo(_);
    +   * 	Value == eval(2  UnallocatedInstances + 4  RequiredInstances + NoHostToAllocate);
    +   * }
    +   * 
    + * + * @see Match + * @see GuidanceObjective + * + */ + 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 GuidanceObjective.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 GuidanceObjective.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_VALUE = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(GuidanceObjective.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 pValue the fixed value of pattern parameter Value, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final Integer pValue) { + return rawStreamAllMatches(new Object[]{pValue}).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 pValue the fixed value of pattern parameter Value, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final Integer pValue) { + return rawStreamAllMatches(new Object[]{pValue}); + } + + /** + * 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 pValue the fixed value of pattern parameter Value, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final Integer pValue) { + return rawGetOneArbitraryMatch(new Object[]{pValue}); + } + + /** + * 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 pValue the fixed value of pattern parameter Value, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final Integer pValue) { + return rawHasMatch(new Object[]{pValue}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pValue the fixed value of pattern parameter Value, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final Integer pValue) { + return rawCountMatches(new Object[]{pValue}); + } + + /** + * 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 pValue the fixed value of pattern parameter Value, 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 Integer pValue, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pValue}, 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 pValue the fixed value of pattern parameter Value, or null if not bound. + * @return the (partial) match object. + * + */ + public GuidanceObjective.Match newMatch(final Integer pValue) { + return GuidanceObjective.Match.newMatch(pValue); + } + + /** + * Retrieve the set of values that occur in matches for Value. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfValue(final Object[] parameters) { + return rawStreamAllValues(POSITION_VALUE, parameters).map(Integer.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Value. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfValue() { + return rawStreamAllValuesOfValue(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Value. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfValue() { + return rawStreamAllValuesOfValue(emptyArray()); + } + + @Override + protected GuidanceObjective.Match tupleToMatch(final Tuple t) { + try { + return GuidanceObjective.Match.newMatch((Integer) t.get(POSITION_VALUE)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected GuidanceObjective.Match arrayToMatch(final Object[] match) { + try { + return GuidanceObjective.Match.newMatch((Integer) match[POSITION_VALUE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected GuidanceObjective.Match arrayToMatchMutable(final Object[] match) { + try { + return GuidanceObjective.Match.newMutableMatch((Integer) match[POSITION_VALUE]); + } 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 GuidanceObjective.instance(); + } + } + + private GuidanceObjective() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static GuidanceObjective instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected GuidanceObjective.Matcher instantiate(final ViatraQueryEngine engine) { + return GuidanceObjective.Matcher.on(engine); + } + + @Override + public GuidanceObjective.Matcher instantiate() { + return GuidanceObjective.Matcher.create(); + } + + @Override + public GuidanceObjective.Match newEmptyMatch() { + return GuidanceObjective.Match.newEmptyMatch(); + } + + @Override + public GuidanceObjective.Match newMatch(final Object... parameters) { + return GuidanceObjective.Match.newMatch((java.lang.Integer) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective (visibility: PUBLIC, simpleName: GuidanceObjective, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.GuidanceObjective (visibility: PUBLIC, simpleName: GuidanceObjective, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final GuidanceObjective INSTANCE = new GuidanceObjective(); + + /** + * 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 GuidanceObjective.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Value = new PParameter("Value", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Value); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.guidanceObjective"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Value"); + } + + @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_Value = body.getOrCreateVariableByName("Value"); + PVariable var_UnallocatedInstances = body.getOrCreateVariableByName("UnallocatedInstances"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var_RequiredInstances = body.getOrCreateVariableByName("RequiredInstances"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + PVariable var___2_ = body.getOrCreateVariableByName("_<2>"); + PVariable var_NoHostToAllocate = body.getOrCreateVariableByName("NoHostToAllocate"); + PVariable var___3_ = body.getOrCreateVariableByName("_<3>"); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Value), new JavaTransitiveInstancesKey(java.lang.Integer.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Value, parameter_Value) + )); + // UnallocatedInstances == count find unallocatedAppInstance(_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new PatternMatchCounter(body, Tuples.flatTupleOf(var___0_), UnallocatedAppInstance.instance().getInternalQueryRepresentation(), var__virtual_0_); + new Equality(body, var_UnallocatedInstances, var__virtual_0_); + // RequiredInstances == sum find requiredAppInstances(_, #_) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var___1_, var___2_), RequiredAppInstances.instance().getInternalQueryRepresentation(), var__virtual_1_, 1); + new Equality(body, var_RequiredInstances, var__virtual_1_); + // NoHostToAllocate == count find noHostToAllocateTo(_) + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new PatternMatchCounter(body, Tuples.flatTupleOf(var___3_), NoHostToAllocateTo.instance().getInternalQueryRepresentation(), var__virtual_2_); + new Equality(body, var_NoHostToAllocate, var__virtual_2_); + // Value == eval(2 * UnallocatedInstances + 4 * RequiredInstances + NoHostToAllocate) + PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern guidanceObjective"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("NoHostToAllocate", "RequiredInstances", "UnallocatedInstances");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer NoHostToAllocate = (Integer) provider.getValue("NoHostToAllocate"); + Integer RequiredInstances = (Integer) provider.getValue("RequiredInstances"); + Integer UnallocatedInstances = (Integer) provider.getValue("UnallocatedInstances"); + return evaluateExpression_1_1(NoHostToAllocate, RequiredInstances, UnallocatedInstances); + } + }, var__virtual_3_ ); + new Equality(body, var_Value, var__virtual_3_); + bodies.add(body); + } + return bodies; + } + } + + private static int evaluateExpression_1_1(final Integer NoHostToAllocate, final Integer RequiredInstances, final Integer UnallocatedInstances) { + return (((2 * (UnallocatedInstances).intValue()) + (4 * (RequiredInstances).intValue())) + (NoHostToAllocate).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java index 41615598..0c0d57a6 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableHdd.java @@ -4,7 +4,7 @@ package hu.bme.mit.inf.dslreasoner.domains.cps.queries; import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd; import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashSet; diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java index 4803ec3a..9f091a95 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java @@ -4,7 +4,7 @@ package hu.bme.mit.inf.dslreasoner.domains.cps.queries; import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory; import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashSet; diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RemoveHostInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RemoveHostInstance.java new file mode 100644 index 00000000..1141e898 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RemoveHostInstance.java @@ -0,0 +1,579 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +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.emf.ecore.EClass; +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.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.NegativePatternCall; +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.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: + *

    + *         pattern removeHostInstance(HostInstance : HostInstance) {
    + *         	neg HostInstance.applications(HostInstance, _);
    + *         }
    + * 
    + * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class RemoveHostInstance extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance 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 HostInstance fHostInstance; + + private static List parameterNames = makeImmutableList("HostInstance"); + + private Match(final HostInstance pHostInstance) { + this.fHostInstance = pHostInstance; + } + + @Override + public Object get(final String parameterName) { + if ("HostInstance".equals(parameterName)) return this.fHostInstance; + return null; + } + + public HostInstance getHostInstance() { + return this.fHostInstance; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("HostInstance".equals(parameterName) ) { + this.fHostInstance = (HostInstance) newValue; + return true; + } + return false; + } + + public void setHostInstance(final HostInstance pHostInstance) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHostInstance = pHostInstance; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance"; + } + + @Override + public List parameterNames() { + return RemoveHostInstance.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHostInstance}; + } + + @Override + public RemoveHostInstance.Match toImmutable() { + return isMutable() ? newMatch(fHostInstance) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"HostInstance\"=" + prettyPrintValue(fHostInstance)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHostInstance); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof RemoveHostInstance.Match)) { + RemoveHostInstance.Match other = (RemoveHostInstance.Match) obj; + return Objects.equals(fHostInstance, other.fHostInstance); + } 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 RemoveHostInstance specification() { + return RemoveHostInstance.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 RemoveHostInstance.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 pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static RemoveHostInstance.Match newMutableMatch(final HostInstance pHostInstance) { + return new Mutable(pHostInstance); + } + + /** + * 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 pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return the (partial) match object. + * + */ + public static RemoveHostInstance.Match newMatch(final HostInstance pHostInstance) { + return new Immutable(pHostInstance); + } + + private static final class Mutable extends RemoveHostInstance.Match { + Mutable(final HostInstance pHostInstance) { + super(pHostInstance); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends RemoveHostInstance.Match { + Immutable(final HostInstance pHostInstance) { + super(pHostInstance); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance 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: + *

    +   * pattern removeHostInstance(HostInstance : HostInstance) {
    +   * 	neg HostInstance.applications(HostInstance, _);
    +   * }
    +   * 
    + * + * @see Match + * @see RemoveHostInstance + * + */ + 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 RemoveHostInstance.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 RemoveHostInstance.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOSTINSTANCE = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(RemoveHostInstance.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 pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHostInstance) { + return rawStreamAllMatches(new Object[]{pHostInstance}).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 pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHostInstance) { + return rawStreamAllMatches(new Object[]{pHostInstance}); + } + + /** + * 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 pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHostInstance) { + return rawGetOneArbitraryMatch(new Object[]{pHostInstance}); + } + + /** + * 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 pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHostInstance) { + return rawHasMatch(new Object[]{pHostInstance}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHostInstance) { + return rawCountMatches(new Object[]{pHostInstance}); + } + + /** + * 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 pHostInstance the fixed value of pattern parameter HostInstance, 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 HostInstance pHostInstance, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHostInstance}, 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 pHostInstance the fixed value of pattern parameter HostInstance, or null if not bound. + * @return the (partial) match object. + * + */ + public RemoveHostInstance.Match newMatch(final HostInstance pHostInstance) { + return RemoveHostInstance.Match.newMatch(pHostInstance); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHostInstance(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOSTINSTANCE, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHostInstance() { + return rawStreamAllValuesOfHostInstance(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for HostInstance. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHostInstance() { + return rawStreamAllValuesOfHostInstance(emptyArray()); + } + + @Override + protected RemoveHostInstance.Match tupleToMatch(final Tuple t) { + try { + return RemoveHostInstance.Match.newMatch((HostInstance) t.get(POSITION_HOSTINSTANCE)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected RemoveHostInstance.Match arrayToMatch(final Object[] match) { + try { + return RemoveHostInstance.Match.newMatch((HostInstance) match[POSITION_HOSTINSTANCE]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected RemoveHostInstance.Match arrayToMatchMutable(final Object[] match) { + try { + return RemoveHostInstance.Match.newMutableMatch((HostInstance) match[POSITION_HOSTINSTANCE]); + } 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 RemoveHostInstance.instance(); + } + } + + private RemoveHostInstance() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static RemoveHostInstance instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected RemoveHostInstance.Matcher instantiate(final ViatraQueryEngine engine) { + return RemoveHostInstance.Matcher.on(engine); + } + + @Override + public RemoveHostInstance.Matcher instantiate() { + return RemoveHostInstance.Matcher.create(); + } + + @Override + public RemoveHostInstance.Match newEmptyMatch() { + return RemoveHostInstance.Match.newEmptyMatch(); + } + + @Override + public RemoveHostInstance.Match newMatch(final Object... parameters) { + return RemoveHostInstance.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance (visibility: PUBLIC, simpleName: RemoveHostInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.RemoveHostInstance (visibility: PUBLIC, simpleName: RemoveHostInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final RemoveHostInstance INSTANCE = new RemoveHostInstance(); + + /** + * 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 RemoveHostInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_HostInstance = new PParameter("HostInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_HostInstance); + + private class Embedded_1_HostInstance_applications extends BaseGeneratedEMFPQuery { + private final PParameter parameter_p0 = new PParameter("p0", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_p1 = new PParameter("p1", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List embeddedParameters = Arrays.asList(parameter_p0, parameter_p1); + + public Embedded_1_HostInstance_applications() { + super(PVisibility.EMBEDDED); + } + + @Override + public String getFullyQualifiedName() { + return GeneratedPQuery.this.getFullyQualifiedName() + "$Embedded_1_HostInstance_applications"; + } + + @Override + public List getParameters() { + return embeddedParameters; + } + + @Override + public Set doGetContainedBodies() { + PBody body = new PBody(this); + PVariable var_p0 = body.getOrCreateVariableByName("p0"); + PVariable var_p1 = body.getOrCreateVariableByName("p1"); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_p0, parameter_p0), + new ExportedParameter(body, var_p1, parameter_p1) + )); + // HostInstance.applications(HostInstance, _) + new TypeConstraint(body, Tuples.flatTupleOf(var_p0), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_p0, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "applications"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new Equality(body, var__virtual_0_, var_p1); + return Collections.singleton(body); + } + } + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.removeHostInstance"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("HostInstance"); + } + + @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_HostInstance = body.getOrCreateVariableByName("HostInstance"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_HostInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_HostInstance, parameter_HostInstance) + )); + // neg HostInstance.applications(HostInstance, _) + new NegativePatternCall(body, Tuples.flatTupleOf(var_HostInstance, var___0_), new RemoveHostInstance.GeneratedPQuery.Embedded_1_HostInstance_applications()); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/ResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/ResourceRequirement.java new file mode 100644 index 00000000..db7710f5 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/ResourceRequirement.java @@ -0,0 +1,829 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +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.emf.ecore.EClass; +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.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.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.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: + *

    + *         pattern resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) {
    + *         	ApplicationInstance.allocatedTo(App, Host);
    + *         	ApplicationInstance.type.requirements(App, Req);
    + *         	HostInstance.type(Host, HostType);
    + *         	ResourceRequirement.hostType(Req, HostType);
    + *         }
    + * 
    + * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class ResourceRequirement extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement 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 HostInstance fHost; + + private ApplicationInstance fApp; + + private hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement fReq; + + private static List parameterNames = makeImmutableList("Host", "App", "Req"); + + private Match(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + this.fHost = pHost; + this.fApp = pApp; + this.fReq = pReq; + } + + @Override + public Object get(final String parameterName) { + if ("Host".equals(parameterName)) return this.fHost; + if ("App".equals(parameterName)) return this.fApp; + if ("Req".equals(parameterName)) return this.fReq; + return null; + } + + public HostInstance getHost() { + return this.fHost; + } + + public ApplicationInstance getApp() { + return this.fApp; + } + + public hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement getReq() { + return this.fReq; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("Host".equals(parameterName) ) { + this.fHost = (HostInstance) newValue; + return true; + } + if ("App".equals(parameterName) ) { + this.fApp = (ApplicationInstance) newValue; + return true; + } + if ("Req".equals(parameterName) ) { + this.fReq = (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) newValue; + return true; + } + return false; + } + + public void setHost(final HostInstance pHost) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fHost = pHost; + } + + public void setApp(final ApplicationInstance pApp) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fApp = pApp; + } + + public void setReq(final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fReq = pReq; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement"; + } + + @Override + public List parameterNames() { + return ResourceRequirement.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fHost, fApp, fReq}; + } + + @Override + public ResourceRequirement.Match toImmutable() { + return isMutable() ? newMatch(fHost, fApp, fReq) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); + result.append("\"App\"=" + prettyPrintValue(fApp) + ", "); + result.append("\"Req\"=" + prettyPrintValue(fReq)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fHost, fApp, fReq); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof ResourceRequirement.Match)) { + ResourceRequirement.Match other = (ResourceRequirement.Match) obj; + return Objects.equals(fHost, other.fHost) && Objects.equals(fApp, other.fApp) && Objects.equals(fReq, other.fReq); + } 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 ResourceRequirement specification() { + return ResourceRequirement.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 ResourceRequirement.Match newEmptyMatch() { + return new Mutable(null, null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static ResourceRequirement.Match newMutableMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + return new Mutable(pHost, pApp, pReq); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return the (partial) match object. + * + */ + public static ResourceRequirement.Match newMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + return new Immutable(pHost, pApp, pReq); + } + + private static final class Mutable extends ResourceRequirement.Match { + Mutable(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + super(pHost, pApp, pReq); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends ResourceRequirement.Match { + Immutable(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + super(pHost, pApp, pReq); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement 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: + *

    +   * pattern resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) {
    +   * 	ApplicationInstance.allocatedTo(App, Host);
    +   * 	ApplicationInstance.type.requirements(App, Req);
    +   * 	HostInstance.type(Host, HostType);
    +   * 	ResourceRequirement.hostType(Req, HostType);
    +   * }
    +   * 
    + * + * @see Match + * @see ResourceRequirement + * + */ + 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 ResourceRequirement.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 ResourceRequirement.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_HOST = 0; + + private static final int POSITION_APP = 1; + + private static final int POSITION_REQ = 2; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ResourceRequirement.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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + return rawStreamAllMatches(new Object[]{pHost, pApp, pReq}).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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + return rawStreamAllMatches(new Object[]{pHost, pApp, pReq}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + return rawGetOneArbitraryMatch(new Object[]{pHost, pApp, pReq}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + return rawHasMatch(new Object[]{pHost, pApp, pReq}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + return rawCountMatches(new Object[]{pHost, pApp, pReq}); + } + + /** + * 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param pReq the fixed value of pattern parameter Req, 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 HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pHost, pApp, pReq}, 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 pHost the fixed value of pattern parameter Host, or null if not bound. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @param pReq the fixed value of pattern parameter Req, or null if not bound. + * @return the (partial) match object. + * + */ + public ResourceRequirement.Match newMatch(final HostInstance pHost, final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + return ResourceRequirement.Match.newMatch(pHost, pApp, pReq); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { + return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost() { + return rawStreamAllValuesOfHost(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

    + * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final ResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + *

    + * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfHost(final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + return rawStreamAllValuesOfHost(new Object[]{null, pApp, pReq}); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final ResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Host. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfHost(final ApplicationInstance pApp, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + return rawStreamAllValuesOfHost(new Object[]{null, pApp, pReq}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfApp(final Object[] parameters) { + return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for App. + *

    + * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp(final ResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfApp(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for App. + *

    + * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp(final HostInstance pHost, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + return rawStreamAllValuesOfApp(new Object[]{pHost, null, pReq}); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp(final ResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfApp(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp(final HostInstance pHost, final hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement pReq) { + return rawStreamAllValuesOfApp(new Object[]{pHost, null, pReq}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfReq(final Object[] parameters) { + return rawStreamAllValues(POSITION_REQ, parameters).map(hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfReq() { + return rawStreamAllValuesOfReq(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfReq() { + return rawStreamAllValuesOfReq(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + *

    + * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfReq(final ResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfReq(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + *

    + * 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. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfReq(final HostInstance pHost, final ApplicationInstance pApp) { + return rawStreamAllValuesOfReq(new Object[]{pHost, pApp, null}); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfReq(final ResourceRequirement.Match partialMatch) { + return rawStreamAllValuesOfReq(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for Req. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfReq(final HostInstance pHost, final ApplicationInstance pApp) { + return rawStreamAllValuesOfReq(new Object[]{pHost, pApp, null}).collect(Collectors.toSet()); + } + + @Override + protected ResourceRequirement.Match tupleToMatch(final Tuple t) { + try { + return ResourceRequirement.Match.newMatch((HostInstance) t.get(POSITION_HOST), (ApplicationInstance) t.get(POSITION_APP), (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) t.get(POSITION_REQ)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected ResourceRequirement.Match arrayToMatch(final Object[] match) { + try { + return ResourceRequirement.Match.newMatch((HostInstance) match[POSITION_HOST], (ApplicationInstance) match[POSITION_APP], (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) match[POSITION_REQ]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected ResourceRequirement.Match arrayToMatchMutable(final Object[] match) { + try { + return ResourceRequirement.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (ApplicationInstance) match[POSITION_APP], (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) match[POSITION_REQ]); + } 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 ResourceRequirement.instance(); + } + } + + private ResourceRequirement() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static ResourceRequirement instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected ResourceRequirement.Matcher instantiate(final ViatraQueryEngine engine) { + return ResourceRequirement.Matcher.on(engine); + } + + @Override + public ResourceRequirement.Matcher instantiate() { + return ResourceRequirement.Matcher.create(); + } + + @Override + public ResourceRequirement.Match newEmptyMatch() { + return ResourceRequirement.Match.newEmptyMatch(); + } + + @Override + public ResourceRequirement.Match newMatch(final Object... parameters) { + return ResourceRequirement.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1], (hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement) parameters[2]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement (visibility: PUBLIC, simpleName: ResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.ResourceRequirement (visibility: PUBLIC, simpleName: ResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final ResourceRequirement INSTANCE = new ResourceRequirement(); + + /** + * 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 ResourceRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ResourceRequirement")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Req); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","App","Req"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_App = body.getOrCreateVariableByName("App"); + PVariable var_Req = body.getOrCreateVariableByName("Req"); + PVariable var_HostType = body.getOrCreateVariableByName("HostType"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_App, parameter_App), + new ExportedParameter(body, var_Req, parameter_Req) + )); + // ApplicationInstance.allocatedTo(App, Host) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new Equality(body, var__virtual_0_, var_Host); + // ApplicationInstance.type.requirements(App, Req) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); + 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/cps", "ApplicationType", "requirements"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + new Equality(body, var__virtual_2_, var_Req); + // HostInstance.type(Host, HostType) + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + new Equality(body, var__virtual_3_, var_HostType); + // ResourceRequirement.hostType(Req, HostType) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); + PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + new Equality(body, var__virtual_4_, var_HostType); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java deleted file mode 100644 index f91853de..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalHdd.java +++ /dev/null @@ -1,706 +0,0 @@ -/** - * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql - */ -package hu.bme.mit.inf.dslreasoner.domains.cps.queries; - -import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; -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.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; -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.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.annotations.PAnnotation; -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.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: - *

    - *         {@literal @}QueryBasedFeature(feature = "totalHdd")
    - *         pattern totalHdd(Host : HostInstance, Hdd : EInt) {
    - *         	HostInstance.type.defaultHdd(Host, Hdd);
    - *         }
    - * 
    - * - * @see Matcher - * @see Match - * - */ -@SuppressWarnings("all") -public final class TotalHdd extends BaseGeneratedEMFQuerySpecification { - /** - * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd 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 HostInstance fHost; - - private Integer fHdd; - - private static List parameterNames = makeImmutableList("Host", "Hdd"); - - private Match(final HostInstance pHost, final Integer pHdd) { - this.fHost = pHost; - this.fHdd = pHdd; - } - - @Override - public Object get(final String parameterName) { - if ("Host".equals(parameterName)) return this.fHost; - if ("Hdd".equals(parameterName)) return this.fHdd; - return null; - } - - public HostInstance getHost() { - return this.fHost; - } - - public Integer getHdd() { - return this.fHdd; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("Host".equals(parameterName) ) { - this.fHost = (HostInstance) newValue; - return true; - } - if ("Hdd".equals(parameterName) ) { - this.fHdd = (Integer) newValue; - return true; - } - return false; - } - - public void setHost(final HostInstance pHost) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fHost = pHost; - } - - public void setHdd(final Integer pHdd) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fHdd = pHdd; - } - - @Override - public String patternName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd"; - } - - @Override - public List parameterNames() { - return TotalHdd.Match.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fHost, fHdd}; - } - - @Override - public TotalHdd.Match toImmutable() { - return isMutable() ? newMatch(fHost, fHdd) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); - result.append("\"Hdd\"=" + prettyPrintValue(fHdd)); - return result.toString(); - } - - @Override - public int hashCode() { - return Objects.hash(fHost, fHdd); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) { - return false; - } - if ((obj instanceof TotalHdd.Match)) { - TotalHdd.Match other = (TotalHdd.Match) obj; - return Objects.equals(fHost, other.fHost) && Objects.equals(fHdd, other.fHdd); - } 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 TotalHdd specification() { - return TotalHdd.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 TotalHdd.Match newEmptyMatch() { - return new Mutable(null, null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static TotalHdd.Match newMutableMatch(final HostInstance pHost, final Integer pHdd) { - return new Mutable(pHost, pHdd); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return the (partial) match object. - * - */ - public static TotalHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) { - return new Immutable(pHost, pHdd); - } - - private static final class Mutable extends TotalHdd.Match { - Mutable(final HostInstance pHost, final Integer pHdd) { - super(pHost, pHdd); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends TotalHdd.Match { - Immutable(final HostInstance pHost, final Integer pHdd) { - super(pHost, pHdd); - } - - @Override - public boolean isMutable() { - return false; - } - } - } - - /** - * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd 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: - *

    -   * {@literal @}QueryBasedFeature(feature = "totalHdd")
    -   * pattern totalHdd(Host : HostInstance, Hdd : EInt) {
    -   * 	HostInstance.type.defaultHdd(Host, Hdd);
    -   * }
    -   * 
    - * - * @see Match - * @see TotalHdd - * - */ - 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 TotalHdd.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 TotalHdd.Matcher create() { - return new Matcher(); - } - - private static final int POSITION_HOST = 0; - - private static final int POSITION_HDD = 1; - - private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TotalHdd.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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return matches represented as a Match object. - * - */ - public Collection getAllMatches(final HostInstance pHost, final Integer pHdd) { - return rawStreamAllMatches(new Object[]{pHost, pHdd}).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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return a stream of matches represented as a Match object. - * - */ - public Stream streamAllMatches(final HostInstance pHost, final Integer pHdd) { - return rawStreamAllMatches(new Object[]{pHost, pHdd}); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return a match represented as a Match object, or null if no match is found. - * - */ - public Optional getOneArbitraryMatch(final HostInstance pHost, final Integer pHdd) { - return rawGetOneArbitraryMatch(new Object[]{pHost, pHdd}); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final HostInstance pHost, final Integer pHdd) { - return rawHasMatch(new Object[]{pHost, pHdd}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final HostInstance pHost, final Integer pHdd) { - return rawCountMatches(new Object[]{pHost, pHdd}); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, 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 HostInstance pHost, final Integer pHdd, final Consumer processor) { - return rawForOneArbitraryMatch(new Object[]{pHost, pHdd}, 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pHdd the fixed value of pattern parameter Hdd, or null if not bound. - * @return the (partial) match object. - * - */ - public TotalHdd.Match newMatch(final HostInstance pHost, final Integer pHdd) { - return TotalHdd.Match.newMatch(pHost, pHdd); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { - return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHost() { - return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHost() { - return rawStreamAllValuesOfHost(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHost(final TotalHdd.Match partialMatch) { - return rawStreamAllValuesOfHost(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHost(final Integer pHdd) { - return rawStreamAllValuesOfHost(new Object[]{null, pHdd}); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHost(final TotalHdd.Match partialMatch) { - return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHost(final Integer pHdd) { - return rawStreamAllValuesOfHost(new Object[]{null, pHdd}).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - * @return the Set of all values or empty set if there are no matches - * - */ - protected Stream rawStreamAllValuesOfHdd(final Object[] parameters) { - return rawStreamAllValues(POSITION_HDD, parameters).map(Integer.class::cast); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHdd() { - return rawStreamAllValuesOfHdd(emptyArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - * @return the Set of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHdd() { - return rawStreamAllValuesOfHdd(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHdd(final TotalHdd.Match partialMatch) { - return rawStreamAllValuesOfHdd(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHdd(final HostInstance pHost) { - return rawStreamAllValuesOfHdd(new Object[]{pHost, null}); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHdd(final TotalHdd.Match partialMatch) { - return rawStreamAllValuesOfHdd(partialMatch.toArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Hdd. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHdd(final HostInstance pHost) { - return rawStreamAllValuesOfHdd(new Object[]{pHost, null}).collect(Collectors.toSet()); - } - - @Override - protected TotalHdd.Match tupleToMatch(final Tuple t) { - try { - return TotalHdd.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_HDD)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected TotalHdd.Match arrayToMatch(final Object[] match) { - try { - return TotalHdd.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected TotalHdd.Match arrayToMatchMutable(final Object[] match) { - try { - return TotalHdd.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_HDD]); - } 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 TotalHdd.instance(); - } - } - - private TotalHdd() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded - * - */ - public static TotalHdd instance() { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected TotalHdd.Matcher instantiate(final ViatraQueryEngine engine) { - return TotalHdd.Matcher.on(engine); - } - - @Override - public TotalHdd.Matcher instantiate() { - return TotalHdd.Matcher.create(); - } - - @Override - public TotalHdd.Match newEmptyMatch() { - return TotalHdd.Match.newEmptyMatch(); - } - - @Override - public TotalHdd.Match newMatch(final Object... parameters) { - return TotalHdd.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]); - } - - /** - * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd (visibility: PUBLIC, simpleName: TotalHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.TotalHdd (visibility: PUBLIC, simpleName: TotalHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. - * - *

    This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private static final TotalHdd INSTANCE = new TotalHdd(); - - /** - * 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 TotalHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); - - private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); - - private final List parameters = Arrays.asList(parameter_Host, parameter_Hdd); - - private GeneratedPQuery() { - super(PVisibility.PUBLIC); - } - - @Override - public String getFullyQualifiedName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd"; - } - - @Override - public List getParameterNames() { - return Arrays.asList("Host","Hdd"); - } - - @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_Host = body.getOrCreateVariableByName("Host"); - PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); - new TypeConstraint(body, Tuples.flatTupleOf(var_Hdd), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); - body.setSymbolicParameters(Arrays.asList( - new ExportedParameter(body, var_Host, parameter_Host), - new ExportedParameter(body, var_Hdd, parameter_Hdd) - )); - // HostInstance.type.defaultHdd(Host, Hdd) - new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); - PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); - PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "defaultHdd"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); - new Equality(body, var__virtual_1_, var_Hdd); - bodies.add(body); - } - { - PAnnotation annotation = new PAnnotation("QueryBasedFeature"); - annotation.addAttribute("feature", "totalHdd"); - addAnnotation(annotation); - } - return bodies; - } - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java deleted file mode 100644 index e8a11e36..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/TotalMemory.java +++ /dev/null @@ -1,706 +0,0 @@ -/** - * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql - */ -package hu.bme.mit.inf.dslreasoner.domains.cps.queries; - -import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; -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.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; -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.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.annotations.PAnnotation; -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.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: - *

    - *         {@literal @}QueryBasedFeature(feature = "totalMemory")
    - *         pattern totalMemory(Host : HostInstance, Memory : EInt) {
    - *         	HostInstance.type.defaultMemory(Host, Memory);
    - *         }
    - * 
    - * - * @see Matcher - * @see Match - * - */ -@SuppressWarnings("all") -public final class TotalMemory extends BaseGeneratedEMFQuerySpecification { - /** - * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory 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 HostInstance fHost; - - private Integer fMemory; - - private static List parameterNames = makeImmutableList("Host", "Memory"); - - private Match(final HostInstance pHost, final Integer pMemory) { - this.fHost = pHost; - this.fMemory = pMemory; - } - - @Override - public Object get(final String parameterName) { - if ("Host".equals(parameterName)) return this.fHost; - if ("Memory".equals(parameterName)) return this.fMemory; - return null; - } - - public HostInstance getHost() { - return this.fHost; - } - - public Integer getMemory() { - return this.fMemory; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("Host".equals(parameterName) ) { - this.fHost = (HostInstance) newValue; - return true; - } - if ("Memory".equals(parameterName) ) { - this.fMemory = (Integer) newValue; - return true; - } - return false; - } - - public void setHost(final HostInstance pHost) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fHost = pHost; - } - - public void setMemory(final Integer pMemory) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fMemory = pMemory; - } - - @Override - public String patternName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory"; - } - - @Override - public List parameterNames() { - return TotalMemory.Match.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fHost, fMemory}; - } - - @Override - public TotalMemory.Match toImmutable() { - return isMutable() ? newMatch(fHost, fMemory) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"Host\"=" + prettyPrintValue(fHost) + ", "); - result.append("\"Memory\"=" + prettyPrintValue(fMemory)); - return result.toString(); - } - - @Override - public int hashCode() { - return Objects.hash(fHost, fMemory); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) { - return false; - } - if ((obj instanceof TotalMemory.Match)) { - TotalMemory.Match other = (TotalMemory.Match) obj; - return Objects.equals(fHost, other.fHost) && Objects.equals(fMemory, other.fMemory); - } 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 TotalMemory specification() { - return TotalMemory.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 TotalMemory.Match newEmptyMatch() { - return new Mutable(null, null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static TotalMemory.Match newMutableMatch(final HostInstance pHost, final Integer pMemory) { - return new Mutable(pHost, pMemory); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return the (partial) match object. - * - */ - public static TotalMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) { - return new Immutable(pHost, pMemory); - } - - private static final class Mutable extends TotalMemory.Match { - Mutable(final HostInstance pHost, final Integer pMemory) { - super(pHost, pMemory); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends TotalMemory.Match { - Immutable(final HostInstance pHost, final Integer pMemory) { - super(pHost, pMemory); - } - - @Override - public boolean isMutable() { - return false; - } - } - } - - /** - * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory 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: - *

    -   * {@literal @}QueryBasedFeature(feature = "totalMemory")
    -   * pattern totalMemory(Host : HostInstance, Memory : EInt) {
    -   * 	HostInstance.type.defaultMemory(Host, Memory);
    -   * }
    -   * 
    - * - * @see Match - * @see TotalMemory - * - */ - 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 TotalMemory.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 TotalMemory.Matcher create() { - return new Matcher(); - } - - private static final int POSITION_HOST = 0; - - private static final int POSITION_MEMORY = 1; - - private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TotalMemory.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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return matches represented as a Match object. - * - */ - public Collection getAllMatches(final HostInstance pHost, final Integer pMemory) { - return rawStreamAllMatches(new Object[]{pHost, pMemory}).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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return a stream of matches represented as a Match object. - * - */ - public Stream streamAllMatches(final HostInstance pHost, final Integer pMemory) { - return rawStreamAllMatches(new Object[]{pHost, pMemory}); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return a match represented as a Match object, or null if no match is found. - * - */ - public Optional getOneArbitraryMatch(final HostInstance pHost, final Integer pMemory) { - return rawGetOneArbitraryMatch(new Object[]{pHost, pMemory}); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final HostInstance pHost, final Integer pMemory) { - return rawHasMatch(new Object[]{pHost, pMemory}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final HostInstance pHost, final Integer pMemory) { - return rawCountMatches(new Object[]{pHost, pMemory}); - } - - /** - * 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, 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 HostInstance pHost, final Integer pMemory, final Consumer processor) { - return rawForOneArbitraryMatch(new Object[]{pHost, pMemory}, 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 pHost the fixed value of pattern parameter Host, or null if not bound. - * @param pMemory the fixed value of pattern parameter Memory, or null if not bound. - * @return the (partial) match object. - * - */ - public TotalMemory.Match newMatch(final HostInstance pHost, final Integer pMemory) { - return TotalMemory.Match.newMatch(pHost, pMemory); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - protected Stream rawStreamAllValuesOfHost(final Object[] parameters) { - return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHost() { - return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHost() { - return rawStreamAllValuesOfHost(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHost(final TotalMemory.Match partialMatch) { - return rawStreamAllValuesOfHost(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfHost(final Integer pMemory) { - return rawStreamAllValuesOfHost(new Object[]{null, pMemory}); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHost(final TotalMemory.Match partialMatch) { - return rawStreamAllValuesOfHost(partialMatch.toArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Host. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfHost(final Integer pMemory) { - return rawStreamAllValuesOfHost(new Object[]{null, pMemory}).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - * @return the Set of all values or empty set if there are no matches - * - */ - protected Stream rawStreamAllValuesOfMemory(final Object[] parameters) { - return rawStreamAllValues(POSITION_MEMORY, parameters).map(Integer.class::cast); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfMemory() { - return rawStreamAllValuesOfMemory(emptyArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - * @return the Set of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfMemory() { - return rawStreamAllValuesOfMemory(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfMemory(final TotalMemory.Match partialMatch) { - return rawStreamAllValuesOfMemory(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - *

    - * 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. - * - * @return the Stream of all values or empty set if there are no matches - * - */ - public Stream streamAllValuesOfMemory(final HostInstance pHost) { - return rawStreamAllValuesOfMemory(new Object[]{pHost, null}); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfMemory(final TotalMemory.Match partialMatch) { - return rawStreamAllValuesOfMemory(partialMatch.toArray()).collect(Collectors.toSet()); - } - - /** - * Retrieve the set of values that occur in matches for Memory. - * @return the Set of all values or empty set if there are no matches - * - */ - public Set getAllValuesOfMemory(final HostInstance pHost) { - return rawStreamAllValuesOfMemory(new Object[]{pHost, null}).collect(Collectors.toSet()); - } - - @Override - protected TotalMemory.Match tupleToMatch(final Tuple t) { - try { - return TotalMemory.Match.newMatch((HostInstance) t.get(POSITION_HOST), (Integer) t.get(POSITION_MEMORY)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected TotalMemory.Match arrayToMatch(final Object[] match) { - try { - return TotalMemory.Match.newMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected TotalMemory.Match arrayToMatchMutable(final Object[] match) { - try { - return TotalMemory.Match.newMutableMatch((HostInstance) match[POSITION_HOST], (Integer) match[POSITION_MEMORY]); - } 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 TotalMemory.instance(); - } - } - - private TotalMemory() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded - * - */ - public static TotalMemory instance() { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected TotalMemory.Matcher instantiate(final ViatraQueryEngine engine) { - return TotalMemory.Matcher.on(engine); - } - - @Override - public TotalMemory.Matcher instantiate() { - return TotalMemory.Matcher.create(); - } - - @Override - public TotalMemory.Match newEmptyMatch() { - return TotalMemory.Match.newEmptyMatch(); - } - - @Override - public TotalMemory.Match newMatch(final Object... parameters) { - return TotalMemory.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0], (java.lang.Integer) parameters[1]); - } - - /** - * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory (visibility: PUBLIC, simpleName: TotalMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.TotalMemory (visibility: PUBLIC, simpleName: TotalMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. - * - *

    This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private static final TotalMemory INSTANCE = new TotalMemory(); - - /** - * 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 TotalMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); - - private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); - - private final List parameters = Arrays.asList(parameter_Host, parameter_Memory); - - private GeneratedPQuery() { - super(PVisibility.PUBLIC); - } - - @Override - public String getFullyQualifiedName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory"; - } - - @Override - public List getParameterNames() { - return Arrays.asList("Host","Memory"); - } - - @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_Host = body.getOrCreateVariableByName("Host"); - PVariable var_Memory = body.getOrCreateVariableByName("Memory"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); - new TypeConstraint(body, Tuples.flatTupleOf(var_Memory), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); - body.setSymbolicParameters(Arrays.asList( - new ExportedParameter(body, var_Host, parameter_Host), - new ExportedParameter(body, var_Memory, parameter_Memory) - )); - // HostInstance.type.defaultMemory(Host, Memory) - new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); - PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); - PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "defaultMemory"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); - new Equality(body, var__virtual_1_, var_Memory); - bodies.add(body); - } - { - PAnnotation annotation = new PAnnotation("QueryBasedFeature"); - annotation.addAttribute("feature", "totalMemory"); - addAnnotation(annotation); - } - return bodies; - } - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/UnallocateAppInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/UnallocateAppInstance.java new file mode 100644 index 00000000..ccc0ba22 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/UnallocateAppInstance.java @@ -0,0 +1,541 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +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.emf.ecore.EClass; +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.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.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.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: + *

    + *         pattern unallocateAppInstance(App : ApplicationInstance) {
    + *         	ApplicationInstance.allocatedTo(App, _);
    + *         }
    + * 
    + * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class UnallocateAppInstance extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocateAppInstance 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 ApplicationInstance fApp; + + private static List parameterNames = makeImmutableList("App"); + + private Match(final ApplicationInstance pApp) { + this.fApp = pApp; + } + + @Override + public Object get(final String parameterName) { + if ("App".equals(parameterName)) return this.fApp; + return null; + } + + public ApplicationInstance getApp() { + return this.fApp; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("App".equals(parameterName) ) { + this.fApp = (ApplicationInstance) newValue; + return true; + } + return false; + } + + public void setApp(final ApplicationInstance pApp) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fApp = pApp; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocateAppInstance"; + } + + @Override + public List parameterNames() { + return UnallocateAppInstance.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fApp}; + } + + @Override + public UnallocateAppInstance.Match toImmutable() { + return isMutable() ? newMatch(fApp) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"App\"=" + prettyPrintValue(fApp)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fApp); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof UnallocateAppInstance.Match)) { + UnallocateAppInstance.Match other = (UnallocateAppInstance.Match) obj; + return Objects.equals(fApp, other.fApp); + } 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 UnallocateAppInstance specification() { + return UnallocateAppInstance.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 UnallocateAppInstance.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 pApp the fixed value of pattern parameter App, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static UnallocateAppInstance.Match newMutableMatch(final ApplicationInstance pApp) { + return new Mutable(pApp); + } + + /** + * 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 pApp the fixed value of pattern parameter App, or null if not bound. + * @return the (partial) match object. + * + */ + public static UnallocateAppInstance.Match newMatch(final ApplicationInstance pApp) { + return new Immutable(pApp); + } + + private static final class Mutable extends UnallocateAppInstance.Match { + Mutable(final ApplicationInstance pApp) { + super(pApp); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends UnallocateAppInstance.Match { + Immutable(final ApplicationInstance pApp) { + super(pApp); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocateAppInstance 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: + *

    +   * pattern unallocateAppInstance(App : ApplicationInstance) {
    +   * 	ApplicationInstance.allocatedTo(App, _);
    +   * }
    +   * 
    + * + * @see Match + * @see UnallocateAppInstance + * + */ + 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 UnallocateAppInstance.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 UnallocateAppInstance.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_APP = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(UnallocateAppInstance.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 pApp the fixed value of pattern parameter App, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final ApplicationInstance pApp) { + return rawStreamAllMatches(new Object[]{pApp}).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 pApp the fixed value of pattern parameter App, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final ApplicationInstance pApp) { + return rawStreamAllMatches(new Object[]{pApp}); + } + + /** + * 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 pApp the fixed value of pattern parameter App, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final ApplicationInstance pApp) { + return rawGetOneArbitraryMatch(new Object[]{pApp}); + } + + /** + * 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 pApp the fixed value of pattern parameter App, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final ApplicationInstance pApp) { + return rawHasMatch(new Object[]{pApp}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pApp the fixed value of pattern parameter App, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final ApplicationInstance pApp) { + return rawCountMatches(new Object[]{pApp}); + } + + /** + * 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 pApp the fixed value of pattern parameter App, 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 ApplicationInstance pApp, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pApp}, 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 pApp the fixed value of pattern parameter App, or null if not bound. + * @return the (partial) match object. + * + */ + public UnallocateAppInstance.Match newMatch(final ApplicationInstance pApp) { + return UnallocateAppInstance.Match.newMatch(pApp); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfApp(final Object[] parameters) { + return rawStreamAllValues(POSITION_APP, parameters).map(ApplicationInstance.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for App. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfApp() { + return rawStreamAllValuesOfApp(emptyArray()); + } + + @Override + protected UnallocateAppInstance.Match tupleToMatch(final Tuple t) { + try { + return UnallocateAppInstance.Match.newMatch((ApplicationInstance) t.get(POSITION_APP)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected UnallocateAppInstance.Match arrayToMatch(final Object[] match) { + try { + return UnallocateAppInstance.Match.newMatch((ApplicationInstance) match[POSITION_APP]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected UnallocateAppInstance.Match arrayToMatchMutable(final Object[] match) { + try { + return UnallocateAppInstance.Match.newMutableMatch((ApplicationInstance) match[POSITION_APP]); + } 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 UnallocateAppInstance.instance(); + } + } + + private UnallocateAppInstance() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static UnallocateAppInstance instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected UnallocateAppInstance.Matcher instantiate(final ViatraQueryEngine engine) { + return UnallocateAppInstance.Matcher.on(engine); + } + + @Override + public UnallocateAppInstance.Matcher instantiate() { + return UnallocateAppInstance.Matcher.create(); + } + + @Override + public UnallocateAppInstance.Match newEmptyMatch() { + return UnallocateAppInstance.Match.newEmptyMatch(); + } + + @Override + public UnallocateAppInstance.Match newMatch(final Object... parameters) { + return UnallocateAppInstance.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance (visibility: PUBLIC, simpleName: UnallocateAppInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.UnallocateAppInstance (visibility: PUBLIC, simpleName: UnallocateAppInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final UnallocateAppInstance INSTANCE = new UnallocateAppInstance(); + + /** + * 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 UnallocateAppInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_App); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocateAppInstance"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("App"); + } + + @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_App = body.getOrCreateVariableByName("App"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_App, parameter_App) + )); + // ApplicationInstance.allocatedTo(App, _) + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new Equality(body, var__virtual_0_, var___0_); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore index 2f593811..c903a5e9 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/.gitignore @@ -9,3 +9,12 @@ /.FreeHddPercentage.java._trace /.ApplicationInstance.java._trace /.HostInstanceCost.java._trace +/.AvailableHdd.java._trace +/.AvailableMemory.java._trace +/.CpsApplications.java._trace +/.CpsHosts.java._trace +/.TotalHdd.java._trace +/.TotalMemory.java._trace +/.RequiredAppInstances.java._trace +/.UnallocatedAppInstance.java._trace +/.NoHostToAllocateTo.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableHdd.java new file mode 100644 index 00000000..7d07b83a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableHdd.java @@ -0,0 +1,178 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd; +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.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; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern availableHdd(Host : HostInstance, Hdd : java Integer) {
    + *         	find totalHdd(Host, TotalHdd);
    + *         	RequiredHdd == sum find hddRequirement(Host, _, #_);
    + *         	Hdd == eval(TotalHdd - RequiredHdd);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class AvailableHdd extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private AvailableHdd() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AvailableHdd 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.cps.queries.internal.AvailableHdd (visibility: PUBLIC, simpleName: AvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.AvailableHdd (visibility: PUBLIC, simpleName: AvailableHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 AvailableHdd INSTANCE = new AvailableHdd(); + + /** + * 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 AvailableHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Hdd); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableHdd"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Hdd"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); + PVariable var_TotalHdd = body.getOrCreateVariableByName("TotalHdd"); + PVariable var_RequiredHdd = body.getOrCreateVariableByName("RequiredHdd"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Hdd), new JavaTransitiveInstancesKey(java.lang.Integer.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Hdd, parameter_Hdd) + )); + // find totalHdd(Host, TotalHdd) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_TotalHdd), TotalHdd.instance().getInternalQueryRepresentation()); + // RequiredHdd == sum find hddRequirement(Host, _, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Host, var___0_, var___1_), HddRequirement.instance().getInternalQueryRepresentation(), var__virtual_0_, 2); + new Equality(body, var_RequiredHdd, var__virtual_0_); + // Hdd == eval(TotalHdd - RequiredHdd) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern availableHdd"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("RequiredHdd", "TotalHdd");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer RequiredHdd = (Integer) provider.getValue("RequiredHdd"); + Integer TotalHdd = (Integer) provider.getValue("TotalHdd"); + return evaluateExpression_1_1(RequiredHdd, TotalHdd); + } + }, var__virtual_1_ ); + new Equality(body, var_Hdd, var__virtual_1_); + bodies.add(body); + } + return bodies; + } + } + + private static int evaluateExpression_1_1(final Integer RequiredHdd, final Integer TotalHdd) { + return ((TotalHdd).intValue() - (RequiredHdd).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableMemory.java new file mode 100644 index 00000000..b06544d5 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/AvailableMemory.java @@ -0,0 +1,178 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory; +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.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; + +/** + * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way. + * + *

    Original source: + *

    + *         private pattern availableMemory(Host : HostInstance, Memory : java Integer) {
    + *         	find totalMemory(Host, TotalMemory);
    + *         	RequiredMemory == sum find memoryRequirement(Host, _, #_);
    + *         	Memory == eval(TotalMemory - RequiredMemory);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class AvailableMemory extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private AvailableMemory() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static AvailableMemory 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.cps.queries.internal.AvailableMemory (visibility: PUBLIC, simpleName: AvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.AvailableMemory (visibility: PUBLIC, simpleName: AvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 AvailableMemory INSTANCE = new AvailableMemory(); + + /** + * 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 AvailableMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Memory); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.availableMemory"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Memory"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Memory = body.getOrCreateVariableByName("Memory"); + PVariable var_TotalMemory = body.getOrCreateVariableByName("TotalMemory"); + PVariable var_RequiredMemory = body.getOrCreateVariableByName("RequiredMemory"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Memory), new JavaTransitiveInstancesKey(java.lang.Integer.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Memory, parameter_Memory) + )); + // find totalMemory(Host, TotalMemory) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_TotalMemory), TotalMemory.instance().getInternalQueryRepresentation()); + // RequiredMemory == sum find memoryRequirement(Host, _, #_) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var_Host, var___0_, var___1_), MemoryRequirement.instance().getInternalQueryRepresentation(), var__virtual_0_, 2); + new Equality(body, var_RequiredMemory, var__virtual_0_); + // Memory == eval(TotalMemory - RequiredMemory) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern availableMemory"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("RequiredMemory", "TotalMemory");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer RequiredMemory = (Integer) provider.getValue("RequiredMemory"); + Integer TotalMemory = (Integer) provider.getValue("TotalMemory"); + return evaluateExpression_1_1(RequiredMemory, TotalMemory); + } + }, var__virtual_1_ ); + new Equality(body, var_Memory, var__virtual_1_); + bodies.add(body); + } + return bodies; + } + } + + private static int evaluateExpression_1_1(final Integer RequiredMemory, final Integer TotalMemory) { + return ((TotalMemory).intValue() - (RequiredMemory).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsApplications.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsApplications.java new file mode 100644 index 00000000..23867558 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsApplications.java @@ -0,0 +1,141 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.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.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 cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) {
    + *         	CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class CpsApplications extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private CpsApplications() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static CpsApplications 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.cps.queries.internal.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsApplications, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsApplications, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 CpsApplications INSTANCE = new CpsApplications(); + + /** + * 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 CpsApplications.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); + + private final PParameter parameter_AppInstance = new PParameter("AppInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Cps, parameter_AppInstance); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Cps","AppInstance"); + } + + @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_Cps = body.getOrCreateVariableByName("Cps"); + PVariable var_AppInstance = body.getOrCreateVariableByName("AppInstance"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_AppInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cps, parameter_Cps), + new ExportedParameter(body, var_AppInstance, parameter_AppInstance) + )); + // CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance) + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "applicationTypes"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "instances"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + new Equality(body, var__virtual_1_, var_AppInstance); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsHosts.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsHosts.java new file mode 100644 index 00000000..e55bddff --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsHosts.java @@ -0,0 +1,141 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.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.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 cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) {
    + *         	CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class CpsHosts extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private CpsHosts() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static CpsHosts 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.cps.queries.internal.CpsHosts (visibility: PUBLIC, simpleName: CpsHosts, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsHosts, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.CpsHosts (visibility: PUBLIC, simpleName: CpsHosts, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsHosts, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 CpsHosts INSTANCE = new CpsHosts(); + + /** + * 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 CpsHosts.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT); + + private final PParameter parameter_HostInstance = new PParameter("HostInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Cps, parameter_HostInstance); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsHosts"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Cps","HostInstance"); + } + + @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_Cps = body.getOrCreateVariableByName("Cps"); + PVariable var_HostInstance = body.getOrCreateVariableByName("HostInstance"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_HostInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Cps, parameter_Cps), + new ExportedParameter(body, var_HostInstance, parameter_HostInstance) + )); + // CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance) + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "hostTypes"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "instances"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new Equality(body, var__virtual_1_, var_HostInstance); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java index 58b113eb..67f75e1d 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/CpsQueriesAll.java @@ -3,29 +3,37 @@ */ package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AllocationWithoutResourceRequirement; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsCost; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.InstanceDoesNotSatisfyRequirement; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableHdd; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RedundantInstancesOnSameHost; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RemoveHostInstance; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.UnallocateAppInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsApplications; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsHosts; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeHddPercentage; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.FreeMemoryPercentage; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HddRequirement; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.HostInstanceCost; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.MemoryRequirement; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.NoHostToAllocateTo; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.RequiredAppInstances; import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance; import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; /** @@ -57,6 +65,14 @@ import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; *

  • costMetric
  • *
  • cpsCost
  • *
  • hostInstanceCost
  • + *
  • allocate
  • + *
  • unallocateAppInstance
  • + *
  • createHostInstance
  • + *
  • removeHostInstance
  • + *
  • unallocatedAppInstance
  • + *
  • requiredAppInstances
  • + *
  • noHostToAllocateTo
  • + *
  • guidanceObjective
  • * * * @see IQueryGroup @@ -104,5 +120,13 @@ public final class CpsQueriesAll extends BaseGeneratedPatternGroup { querySpecifications.add(CostMetric.instance()); querySpecifications.add(CpsCost.instance()); querySpecifications.add(HostInstanceCost.instance()); + querySpecifications.add(Allocate.instance()); + querySpecifications.add(UnallocateAppInstance.instance()); + querySpecifications.add(CreateHostInstance.instance()); + querySpecifications.add(RemoveHostInstance.instance()); + querySpecifications.add(UnallocatedAppInstance.instance()); + querySpecifications.add(RequiredAppInstances.instance()); + querySpecifications.add(NoHostToAllocateTo.instance()); + querySpecifications.add(GuidanceObjective.instance()); } } diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java index 366677b5..c24f46a1 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeHddPercentage.java @@ -3,8 +3,8 @@ */ package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableHdd; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableHdd; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java index bd151ea6..c2bb2bb3 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java @@ -3,8 +3,8 @@ */ package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.TotalMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.AvailableMemory; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java index fbe7a46b..68448930 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HddRequirement.java @@ -3,7 +3,7 @@ */ package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java index 767ca342..db7f7021 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/HostInstanceCost.java @@ -3,7 +3,7 @@ */ package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsHosts; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.CpsHosts; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java index 0a24d105..d15f9bfa 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/MemoryRequirement.java @@ -3,7 +3,7 @@ */ package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; -import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.ResourceRequirement; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/NoHostToAllocateTo.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/NoHostToAllocateTo.java new file mode 100644 index 00000000..50597805 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/NoHostToAllocateTo.java @@ -0,0 +1,135 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance; +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.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.NegativePatternCall; +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 noHostToAllocateTo(App : ApplicationInstance) {
    + *         	find unallocatedAppInstance(App);
    + *         	neg find allocate(App, _);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class NoHostToAllocateTo extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private NoHostToAllocateTo() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static NoHostToAllocateTo 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.cps.queries.internal.NoHostToAllocateTo (visibility: PUBLIC, simpleName: NoHostToAllocateTo, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.NoHostToAllocateTo, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.NoHostToAllocateTo (visibility: PUBLIC, simpleName: NoHostToAllocateTo, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.NoHostToAllocateTo, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 NoHostToAllocateTo INSTANCE = new NoHostToAllocateTo(); + + /** + * 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 NoHostToAllocateTo.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_App); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.noHostToAllocateTo"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("App"); + } + + @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_App = body.getOrCreateVariableByName("App"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_App, parameter_App) + )); + // find unallocatedAppInstance(App) + new PositivePatternCall(body, Tuples.flatTupleOf(var_App), UnallocatedAppInstance.instance().getInternalQueryRepresentation()); + // neg find allocate(App, _) + new NegativePatternCall(body, Tuples.flatTupleOf(var_App, var___0_), Allocate.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/RequiredAppInstances.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/RequiredAppInstances.java new file mode 100644 index 00000000..dc76cbde --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/RequiredAppInstances.java @@ -0,0 +1,181 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.SatisfyingInstance; +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 requiredAppInstances(Req : Requirement, Remaining : java Integer) {
    + *         	Instances == count find satisfyingInstance(Req, _);
    + *         	Requirement.count(Req, RequiredCount);
    + *         	Remaining == eval(RequiredCount - Instances);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class RequiredAppInstances extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private RequiredAppInstances() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static RequiredAppInstances 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.cps.queries.internal.RequiredAppInstances (visibility: PUBLIC, simpleName: RequiredAppInstances, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.RequiredAppInstances, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.RequiredAppInstances (visibility: PUBLIC, simpleName: RequiredAppInstances, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.RequiredAppInstances, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 RequiredAppInstances INSTANCE = new RequiredAppInstances(); + + /** + * 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 RequiredAppInstances.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.Requirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "Requirement")), PParameterDirection.INOUT); + + private final PParameter parameter_Remaining = new PParameter("Remaining", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Req, parameter_Remaining); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.requiredAppInstances"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Req","Remaining"); + } + + @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_Req = body.getOrCreateVariableByName("Req"); + PVariable var_Remaining = body.getOrCreateVariableByName("Remaining"); + PVariable var_Instances = body.getOrCreateVariableByName("Instances"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var_RequiredCount = body.getOrCreateVariableByName("RequiredCount"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Remaining), new JavaTransitiveInstancesKey(java.lang.Integer.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Req, parameter_Req), + new ExportedParameter(body, var_Remaining, parameter_Remaining) + )); + // Instances == count find satisfyingInstance(Req, _) + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new PatternMatchCounter(body, Tuples.flatTupleOf(var_Req, var___0_), SatisfyingInstance.instance().getInternalQueryRepresentation(), var__virtual_0_); + new Equality(body, var_Instances, var__virtual_0_); + // Requirement.count(Req, RequiredCount) + new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "Requirement"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "Requirement", "count"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_1_, var_RequiredCount); + // Remaining == eval(RequiredCount - Instances) + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern requiredAppInstances"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("Instances", "RequiredCount");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Integer Instances = (Integer) provider.getValue("Instances"); + Integer RequiredCount = (Integer) provider.getValue("RequiredCount"); + return evaluateExpression_1_1(Instances, RequiredCount); + } + }, var__virtual_2_ ); + new Equality(body, var_Remaining, var__virtual_2_); + bodies.add(body); + } + return bodies; + } + } + + private static int evaluateExpression_1_1(final Integer Instances, final Integer RequiredCount) { + return ((RequiredCount).intValue() - (Instances).intValue()); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java deleted file mode 100644 index 8c5bdefe..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/ResourceRequirement.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql - */ -package hu.bme.mit.inf.dslreasoner.domains.cps.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.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 resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) {
    - *         	ApplicationInstance.allocatedTo(App, Host);
    - *         	ApplicationInstance.type.requirements(App, Req);
    - *         	HostInstance.type(Host, HostType);
    - *         	ResourceRequirement.hostType(Req, HostType);
    - *         }
    - * 
    - * - * @see GenericPatternMatcher - * @see GenericPatternMatch - * - */ -@SuppressWarnings("all") -public final class ResourceRequirement extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { - private ResourceRequirement() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded - * - */ - public static ResourceRequirement 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.cps.queries.internal.ResourceRequirement (visibility: PUBLIC, simpleName: ResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.ResourceRequirement (visibility: PUBLIC, simpleName: ResourceRequirement, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.ResourceRequirement, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 ResourceRequirement INSTANCE = new ResourceRequirement(); - - /** - * 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 ResourceRequirement.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); - - private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); - - private final PParameter parameter_Req = new PParameter("Req", "hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ResourceRequirement")), PParameterDirection.INOUT); - - private final List parameters = Arrays.asList(parameter_Host, parameter_App, parameter_Req); - - private GeneratedPQuery() { - super(PVisibility.PRIVATE); - } - - @Override - public String getFullyQualifiedName() { - return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.resourceRequirement"; - } - - @Override - public List getParameterNames() { - return Arrays.asList("Host","App","Req"); - } - - @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_Host = body.getOrCreateVariableByName("Host"); - PVariable var_App = body.getOrCreateVariableByName("App"); - PVariable var_Req = body.getOrCreateVariableByName("Req"); - PVariable var_HostType = body.getOrCreateVariableByName("HostType"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); - new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); - new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); - body.setSymbolicParameters(Arrays.asList( - new ExportedParameter(body, var_Host, parameter_Host), - new ExportedParameter(body, var_App, parameter_App), - new ExportedParameter(body, var_Req, parameter_Req) - )); - // ApplicationInstance.allocatedTo(App, Host) - new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); - PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); - new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); - new Equality(body, var__virtual_0_, var_Host); - // ApplicationInstance.type.requirements(App, Req) - new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); - PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); - new TypeConstraint(body, Tuples.flatTupleOf(var_App, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "type"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType"))); - 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/cps", "ApplicationType", "requirements"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); - new Equality(body, var__virtual_2_, var_Req); - // HostInstance.type(Host, HostType) - new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); - PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); - new Equality(body, var__virtual_3_, var_HostType); - // ResourceRequirement.hostType(Req, HostType) - new TypeConstraint(body, Tuples.flatTupleOf(var_Req), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ResourceRequirement"))); - PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}"); - new TypeConstraint(body, Tuples.flatTupleOf(var_Req, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ResourceRequirement", "hostType"))); - new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); - new Equality(body, var__virtual_4_, var_HostType); - bodies.add(body); - } - return bodies; - } - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalHdd.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalHdd.java new file mode 100644 index 00000000..f250f76d --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalHdd.java @@ -0,0 +1,143 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.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 totalHdd(Host : HostInstance, Hdd : EInt) {
    + *         	HostInstance.type.defaultHdd(Host, Hdd);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class TotalHdd extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private TotalHdd() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TotalHdd 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.cps.queries.internal.TotalHdd (visibility: PUBLIC, simpleName: TotalHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.TotalHdd (visibility: PUBLIC, simpleName: TotalHdd, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalHdd, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 TotalHdd INSTANCE = new TotalHdd(); + + /** + * 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 TotalHdd.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Hdd = new PParameter("Hdd", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Hdd); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalHdd"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Hdd"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Hdd = body.getOrCreateVariableByName("Hdd"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Hdd), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Hdd, parameter_Hdd) + )); + // HostInstance.type.defaultHdd(Host, Hdd) + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "defaultHdd"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_1_, var_Hdd); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalMemory.java new file mode 100644 index 00000000..aecd97e2 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/TotalMemory.java @@ -0,0 +1,143 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.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 totalMemory(Host : HostInstance, Memory : EInt) {
    + *         	HostInstance.type.defaultMemory(Host, Memory);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class TotalMemory extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private TotalMemory() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static TotalMemory 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.cps.queries.internal.TotalMemory (visibility: PUBLIC, simpleName: TotalMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.TotalMemory (visibility: PUBLIC, simpleName: TotalMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.TotalMemory, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 TotalMemory INSTANCE = new TotalMemory(); + + /** + * 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 TotalMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_Memory = new PParameter("Memory", "java.lang.Integer", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EInt")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Host, parameter_Memory); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.totalMemory"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Host","Memory"); + } + + @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_Host = body.getOrCreateVariableByName("Host"); + PVariable var_Memory = body.getOrCreateVariableByName("Memory"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Memory), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Host, parameter_Host), + new ExportedParameter(body, var_Memory, parameter_Memory) + )); + // HostInstance.type.defaultMemory(Host, Memory) + new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Host, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostInstance", "type"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostType"))); + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "HostType", "defaultMemory"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); + new Equality(body, var__virtual_1_, var_Memory); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/UnallocatedAppInstance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/UnallocatedAppInstance.java new file mode 100644 index 00000000..a20b534c --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/UnallocatedAppInstance.java @@ -0,0 +1,172 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal; + +import java.util.Arrays; +import java.util.Collections; +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.NegativePatternCall; +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 unallocatedAppInstance(App : ApplicationInstance) {
    + *         	neg ApplicationInstance.allocatedTo(App, _);
    + *         }
    + * 
    + * + * @see GenericPatternMatcher + * @see GenericPatternMatch + * + */ +@SuppressWarnings("all") +public final class UnallocatedAppInstance extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher { + private UnallocatedAppInstance() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static UnallocatedAppInstance 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.cps.queries.internal.UnallocatedAppInstance (visibility: PUBLIC, simpleName: UnallocatedAppInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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.cps.queries.internal.UnallocatedAppInstance (visibility: PUBLIC, simpleName: UnallocatedAppInstance, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.internal.UnallocatedAppInstance, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.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 UnallocatedAppInstance INSTANCE = new UnallocatedAppInstance(); + + /** + * 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 UnallocatedAppInstance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_App = new PParameter("App", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_App); + + private class Embedded_1_ApplicationInstance_allocatedTo extends BaseGeneratedEMFPQuery { + private final PParameter parameter_p0 = new PParameter("p0", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT); + + private final PParameter parameter_p1 = new PParameter("p1", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT); + + private final List embeddedParameters = Arrays.asList(parameter_p0, parameter_p1); + + public Embedded_1_ApplicationInstance_allocatedTo() { + super(PVisibility.EMBEDDED); + } + + @Override + public String getFullyQualifiedName() { + return GeneratedPQuery.this.getFullyQualifiedName() + "$Embedded_1_ApplicationInstance_allocatedTo"; + } + + @Override + public List getParameters() { + return embeddedParameters; + } + + @Override + public Set doGetContainedBodies() { + PBody body = new PBody(this); + PVariable var_p0 = body.getOrCreateVariableByName("p0"); + PVariable var_p1 = body.getOrCreateVariableByName("p1"); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_p0, parameter_p0), + new ExportedParameter(body, var_p1, parameter_p1) + )); + // ApplicationInstance.allocatedTo(App, _) + new TypeConstraint(body, Tuples.flatTupleOf(var_p0), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_p0, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationInstance", "allocatedTo"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance"))); + new Equality(body, var__virtual_0_, var_p1); + return Collections.singleton(body); + } + } + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.unallocatedAppInstance"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("App"); + } + + @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_App = body.getOrCreateVariableByName("App"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_App), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_App, parameter_App) + )); + // neg ApplicationInstance.allocatedTo(App, _) + new NegativePatternCall(body, Tuples.flatTupleOf(var_App, var___0_), new UnallocatedAppInstance.GeneratedPQuery.Embedded_1_ApplicationInstance_allocatedTo()); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.xtend new file mode 100644 index 00000000..7ec0f84d --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.xtend @@ -0,0 +1,53 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.cplex + +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage +import hu.bme.mit.inf.dslreasoner.domains.cps.generator.CpsGenerator +import java.io.BufferedReader +import java.io.BufferedWriter +import java.io.FileReader +import java.io.FileWriter +import org.eclipse.emf.ecore.EPackage +import org.eclipse.emf.ecore.resource.Resource +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl +import java.util.concurrent.TimeUnit + +class CbcCpsMain { + static val PROBLEM_FILE = "problem.lp" + static val SOLUTION_FILE = "solution.txt" + + private new() { + new IllegalStateException("This is a static utility class and should not be instantiated directly.") + } + + static def void main(String[] args) { + Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, + new XMIResourceFactoryImpl) + EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE) + val generator = new CpsGenerator(1, 4, 1) + val problem = generator.generateCpsProblem + val toLp = new CpsToLpTranslator(problem, 10, true) + val lp = toLp.lpProblem + val writer = new BufferedWriter(new FileWriter(PROBLEM_FILE)) + try { + writer.append(lp) + } finally { + writer.close + } + val process = new ProcessBuilder().inheritIO.command("cbc", PROBLEM_FILE, "solve", "solu", SOLUTION_FILE).start + if (!process.waitFor(120, TimeUnit.SECONDS)) { + System.err.println("Timeout reached") + process.destroyForcibly + System.exit(-1) + } + if (process.exitValue != 0) { + System.err.println("Unexpected exit value " + process.exitValue) + System.exit(-1) + } + val reader = new BufferedReader(new FileReader(SOLUTION_FILE)) + try { + reader.lines.forEach[println(it)] + } finally { + reader.close + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.xtend new file mode 100644 index 00000000..c38af3a0 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.xtend @@ -0,0 +1,171 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.cplex + +import com.google.common.collect.ImmutableList +import com.google.common.collect.ImmutableMap +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement +import java.util.List +import java.util.Map + +class CpsToLpTranslator { + static val MINIMUM_MEMORY_USAGE = 0.25 + static val MINIMUM_HDD_USAGE = 0.25 + + val CyberPhysicalSystem cps + val Map> appInstances + val Map> hostInstances + val boolean breakSymmetry + + new(CyberPhysicalSystem cps, int hostInstanceCount, boolean breakSymmetry) { + this.cps = cps + appInstances = createAppInstances + hostInstances = createHostInstances(hostInstanceCount) + this.breakSymmetry = breakSymmetry + } + + private def createAppInstances() { + val builder = ImmutableMap.builder + var int i = 0 + for (req : requirements) { + val listBuilder = ImmutableList.builder + for (var int j = 0; j < req.count; j++) { + listBuilder.add('''r«i»a«j»''') + } + builder.put(req, listBuilder.build) + i++ + } + builder.build + } + + private def createHostInstances(int hostInstanceCount) { + val builder = ImmutableMap.builder + var int i = 0 + for (hostType : cps.hostTypes) { + val listBuilder = ImmutableList.builder + for (var int j = 0; j < hostInstanceCount; j++) { + listBuilder.add('''h«i»i«j»''') + } + builder.put(hostType, listBuilder.build) + i++ + } + builder.build + } + + def getLpProblem() { + ''' + Minimize + total_cost: «objective» + Subject To + «constraints» + Bounds + «bounds» + Binary + «binaryVariables» + End + ''' + } + + private def getObjective() { + '''«FOR pair : hostInstancesWithType SEPARATOR " + "»«pair.key.cost» «pair.value.existsVariable»«ENDFOR»''' + } + + private def getConstraints() { + ''' + «FOR appPair : appInstancesWithType» + «appPair.value»_allocated: «FOR host : appPair.key.possibleHostInstances SEPARATOR " + "»«getAllocatedToVariable(appPair.value, host)»«ENDFOR» = 1 + «FOR host : appPair.key.possibleHostInstances» + «appPair.value»_to_«host»_exists: «host.existsVariable» - «getAllocatedToVariable(appPair.value, host)» >= 0 + «ENDFOR» + «ENDFOR» + «FOR hostPair : hostInstancesWithType» + «hostPair.value»_mem_use: «FOR appPair : hostPair.key.possibleAppInstancesWithRequirements SEPARATOR " + "»«appPair.key.requiredMemory» «getAllocatedToVariable(appPair.value, hostPair.value)»«ENDFOR» - «hostPair.key.defaultMemory» «hostPair.value.memoryUsageVariable» = 0 + «hostPair.value»_hdd_use: «FOR appPair : hostPair.key.possibleAppInstancesWithRequirements SEPARATOR " + "»«appPair.key.requiredHdd» «getAllocatedToVariable(appPair.value, hostPair.value)»«ENDFOR» - «hostPair.key.defaultHdd» «hostPair.value.hddUsageVariable» = 0 + «ENDFOR» + average_mem: «FOR host : allHostInstances SEPARATOR " + "»«host.memoryUsageVariable» - «MINIMUM_MEMORY_USAGE» «host.existsVariable»«ENDFOR» >= 0 + average_hdd: «FOR host : allHostInstances SEPARATOR " + "»«host.memoryUsageVariable» - «MINIMUM_HDD_USAGE» «host.existsVariable»«ENDFOR» >= 0 + «FOR reqPair : requirements.filter[count > 1].indexed» + «FOR host : reqPair.value.type.requirements.flatMap[hostInstances.get(hostType)]» + r«reqPair.key»_«host»_redundant: «FOR app : appInstances.get(reqPair.value) SEPARATOR " + "»«getAllocatedToVariable(app, host)»«ENDFOR» <= 1 + «ENDFOR» + «ENDFOR» + «IF breakSymmetry» + «FOR hosts : hostInstances.values» + «FOR i : 0 ..< (hosts.size - 1)» + «hosts.get(i + 1)»_after_«hosts.get(i)»: «hosts.get(i).existsVariable» - «hosts.get(i + 1).existsVariable» >= 0 + «ENDFOR» + «ENDFOR» + «ENDIF» + ''' + } + + private def getBounds() { + ''' + «FOR host : allHostInstances» + 0 <= «host.memoryUsageVariable» <= 1 + 0 <= «host.hddUsageVariable» <= 1 + «ENDFOR» + ''' + } + + private def getBinaryVariables() { + ''' + «FOR host : allHostInstances» + «host.existsVariable» + «ENDFOR» + «FOR appPair : appInstancesWithType» + «FOR host : appPair.key.possibleHostInstances» + «getAllocatedToVariable(appPair.value, host)» + «ENDFOR» + «ENDFOR» + ''' + } + + private def getRequirements() { + cps.requests.flatMap[requirements] + } + + private def getAllHostInstances() { + hostInstances.values.flatMap[it] + } + + private def getHostInstancesWithType() { + hostInstances.entrySet.flatMap[pair|pair.value.map[pair.key -> it]] + } + + private def getAppInstancesWithType() { + appInstances.entrySet.flatMap[pair|pair.value.map[pair.key.type -> it]] + } + + private def getPossibleHostInstances(ApplicationType appType) { + appType.requirements.flatMap[req|hostInstances.get(req.hostType)] + } + + private def getPossibleAppInstancesWithRequirements(HostType hostType) { + appInstances.entrySet.flatMap [ pair | + val resourceReq = pair.key.type.requirements.findFirst[it.hostType == hostType] + if (resourceReq === null) { + emptyList + } else { + pair.value.map[resourceReq -> it] + } + ] + } + + private def getExistsVariable(String hostInstance) { + '''«hostInstance»_exists''' + } + + private def getMemoryUsageVariable(String hostInstance) { + '''«hostInstance»_mem''' + } + + private def getHddUsageVariable(String hostInstance) { + '''«hostInstance»_hdd''' + } + + private def getAllocatedToVariable(String appInstance, String hostInstance) { + '''«appInstance»_to_«hostInstance»''' + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.xtend new file mode 100644 index 00000000..223cee03 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.xtend @@ -0,0 +1,134 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.dse + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType +import hu.bme.mit.inf.dslreasoner.domains.cps.Request +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement +import org.eclipse.emf.common.notify.Notifier +import org.eclipse.emf.ecore.resource.Resource +import org.eclipse.emf.ecore.resource.ResourceSet +import org.eclipse.viatra.dse.statecode.IStateCoder +import org.eclipse.viatra.dse.statecode.IStateCoderFactory +import org.eclipse.viatra.query.runtime.api.IPatternMatch +import org.eclipse.xtend2.lib.StringConcatenationClient + +class CpsStateCoder implements IStateCoder { + CyberPhysicalSystem cps + + protected new() { + } + + override init(Notifier notifier) { + cps = switch (notifier) { + ResourceSet: getCpsFromResourceSet(notifier) + Resource: getCpsFromResource(notifier) + CyberPhysicalSystem: notifier + default: throw new IllegalArgumentException("notifier is not a CyberPhysicalSystem") + } + } + + private def getCpsFromResourceSet(ResourceSet resourceSet) { + if (resourceSet.resources.empty) { + throw new IllegalArgumentException("No Resource in ResourceSet") + } + val resource = resourceSet.resources.head + getCpsFromResource(resource) + } + + private def getCpsFromResource(Resource resource) { + if (resource.contents.empty) { + throw new IllegalArgumentException("No EObject in Resource") + } + val cps = resource.contents.head + if (cps instanceof CyberPhysicalSystem) { + cps + } else { + throw new IllegalArgumentException("EObject in Resource is not a CyberPhysicalSystem") + } + } + + override String createStateCode() { + '''«createRequestsCode»«createHostTypesCode»''' + } + + private def StringConcatenationClient createRequestsCode() { + '''«FOR request : cps.requests»«createRequestCode(request)»«ENDFOR»''' + } + + private def StringConcatenationClient createRequestCode(Request request) { + '''[«FOR requirement : request.requirements»«createRequirementCode(requirement)»«ENDFOR»]''' + } + + private def StringConcatenationClient createRequirementCode(Requirement requirement) { + '''[«FOR app : requirement.instances SEPARATOR ","»«createAppCode(app)»«ENDFOR»]''' + } + + private def createAppCode(ApplicationInstance app) { + if (app.allocatedTo === null) { + "-" + } else { + createMatchArgumentCode(app.allocatedTo) + } + } + + private def createHostTypesCode() { + '''(«FOR hostType : cps.hostTypes SEPARATOR ","»«hostType.instances.size»«ENDFOR»)''' + } + + override String createActivationCode(IPatternMatch match) { + '''«match.specification.simpleName»(«FOR arg : match.toArray SEPARATOR ","»«createMatchArgumentCode(arg)»«ENDFOR»)''' + } + + protected dispatch def String createMatchArgumentCode(Requirement requirement) { + val request = requirement.eContainer + if (request instanceof Request) { + if (request.eContainer != cps) { + throw new IllegalArgumentException("Request is not contained in the CPS") + } + val requestIndex = cps.requests.indexOf(request) + val requirementIndex = request.requirements.indexOf(requirement) + requestIndex + "." + requirementIndex + } else { + throw new IllegalArgumentException("Requirement is not contained in a request") + } + } + + protected dispatch def String createMatchArgumentCode(ApplicationInstance app) { + val requirement = app.requirement + if (requirement === null) { + throw new IllegalArgumentException("Application instance is not associated with a requirement") + } + val instanceIndex = requirement.instances.indexOf(app) + createMatchArgumentCode(requirement) + "." + instanceIndex + } + + protected dispatch def String createMatchArgumentCode(HostInstance host) { + val hostType = host.eContainer + if (hostType instanceof HostType) { + val hostIndex = hostType.instances.indexOf(host) + createMatchArgumentCode(hostType) + "." + hostIndex + } else { + throw new IllegalArgumentException("Host is not contained in a host type") + } + } + + protected dispatch def String createMatchArgumentCode(HostType hostType) { + if (hostType.eContainer != cps) { + throw new IllegalArgumentException("Host type is not contained in the CPS") + } + val hostTypeIndex = cps.hostTypes.indexOf(hostType) + hostTypeIndex.toString + } + + protected dispatch def createMatchArgumentCode(Object object) { + throw new IllegalArgumentException("Unknown match argument: ") + } + + static class Factory implements IStateCoderFactory { + override createStateCoder() { + new CpsStateCoder + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.xtend new file mode 100644 index 00000000..b2cc0063 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.xtend @@ -0,0 +1,39 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.dse + +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage +import hu.bme.mit.inf.dslreasoner.domains.cps.generator.CpsGenerator +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsQueries +import org.eclipse.emf.ecore.EPackage +import org.eclipse.emf.ecore.EStructuralFeature +import org.eclipse.emf.ecore.resource.Resource +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl +import org.eclipse.viatra.addon.querybasedfeatures.runtime.QueryBasedFeatureSettingDelegateFactory +import org.eclipse.viatra.addon.querybasedfeatures.runtime.handler.QueryBasedFeatures +import org.eclipse.viatra.dse.api.DesignSpaceExplorer +import org.eclipse.viatra.dse.api.DesignSpaceExplorer.DseLoggingLevel +import org.eclipse.viatra.query.runtime.extensibility.SingletonQueryGroupProvider +import org.eclipse.viatra.query.runtime.registry.QuerySpecificationRegistry +import org.eclipse.viatra.query.runtime.registry.connector.QueryGroupProviderSourceConnector + +class RuleBasedCpsMain { + private new() { + new IllegalStateException("This is a static utility class and should not be instantiated directly.") + } + + static def void main(String[] args) { + DesignSpaceExplorer.turnOnLogging(DseLoggingLevel.VERBOSE_FULL) + Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, + new XMIResourceFactoryImpl) + EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(QueryBasedFeatures.ANNOTATION_SOURCE, + new QueryBasedFeatureSettingDelegateFactory) + EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE) + QuerySpecificationRegistry.instance.addSource( + new QueryGroupProviderSourceConnector("CpsQueries", new SingletonQueryGroupProvider(CpsQueries.instance), + true)) + val generator = new CpsGenerator(1, 4, 1) + val problem = generator.generateCpsProblem +// problem.eResource.save(emptyMap) + val solver = new RuleBasedCpsSolver + solver.solve(problem) + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend new file mode 100644 index 00000000..e4c758f0 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend @@ -0,0 +1,74 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.dse + +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CompositeDirectionalThresholdObjective +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.QueryBasedObjective +import org.eclipse.viatra.dse.api.DesignSpaceExplorer +import org.eclipse.viatra.dse.evolutionary.EvolutionaryStrategyBuilder +import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRuleFactory + +class RuleBasedCpsSolver { + extension val BatchTransformationRuleFactory = new BatchTransformationRuleFactory + extension val CpsFactory = CpsFactory.eINSTANCE + + def solve(CyberPhysicalSystem problem) { +// for (request : problem.requests) { +// for (req : request.requirements) { +// for (i : 0 ..< req.count) { +// val app = createApplicationInstance +// req.type.instances += app +// req.instances += app +// } +// } +// } + val dse = new DesignSpaceExplorer + dse.addMetaModelPackage(CpsPackage.eINSTANCE) + dse.initialModel = problem.eResource.resourceSet + dse.addTransformationRule(createRule(RequirementNotSatisfied.instance).action [ + val app = createApplicationInstance + req.type.instances += app + req.instances += app + ].build) + dse.addTransformationRule(createRule(Allocate.instance).action [ + app.allocatedTo = host + ].build) +// dse.addTransformationRule(createRule(UnallocateAppInstance.instance).action [ +// app.allocatedTo = null +// ].build) + dse.addTransformationRule(createRule(CreateHostInstance.instance).action [ + hostType.instances += createHostInstance + ].build) +// dse.addTransformationRule(createRule(RemoveHostInstance.instance).action [ +// hostInstance.type.instances -= hostInstance +// ].build) + dse.addObjective( + new CompositeDirectionalThresholdObjective("Composite", + new QueryBasedObjective(GuidanceObjective.instance, ObjectiveKind.LOWER_IS_BETTER, + new ObjectiveThreshold.Inclusive(0), 0), + new QueryBasedObjective(AverageFreeMemoryMetric.instance, ObjectiveKind.LOWER_IS_BETTER, + new ObjectiveThreshold.Inclusive(0.75), 0), + new QueryBasedObjective(AverageFreeHddMetric.instance, ObjectiveKind.LOWER_IS_BETTER, + new ObjectiveThreshold.Inclusive(0.75), 0))) + dse.addObjective( + new QueryBasedObjective(CostMetric.instance, ObjectiveKind.LOWER_IS_BETTER, + ObjectiveThreshold.NO_THRESHOLD, 0)) + dse.maxNumberOfThreads = 1 + dse.stateCoderFactory = new CpsStateCoder.Factory + val strategy = EvolutionaryStrategyBuilder.createNsga2Strategy(25) + dse.startExplorationWithTimeout(strategy, 2 * 60 * 1000) + for (solution : dse.solutions) { + println("Found solution: " + solution.stateCode + " " + solution.arbitraryTrajectory.fitness) + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.xtend index 0a510f0f..390d13d3 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.xtend +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.xtend @@ -5,6 +5,8 @@ import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem import hu.bme.mit.inf.dslreasoner.domains.cps.HostType import java.util.Collection import java.util.Random +import org.eclipse.emf.common.util.URI +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl class CpsGenerator { extension val CpsFactory = CpsFactory.eINSTANCE @@ -28,8 +30,11 @@ class CpsGenerator { } def generateCpsProblem() { + val resourceSet = new ResourceSetImpl + val resource = resourceSet.createResource(URI.createFileURI("dummy.dummyext")) createCyberPhysicalSystem => [ val cps = it + resource.contents += cps createLowCpuHostTypes val highCpuHostTypes = createHighCpuHostTypes for (var int i = 0; i < applicationTypeCount; i++) { @@ -58,6 +63,7 @@ class CpsGenerator { val hdd = nextInt(MIN_HDD, MAX_HDD) for (hostType : allowedHostTypes) { appType.requirements += createResourceRequirement => [ + it.hostType = hostType requiredMemory = memory requiredHdd = hdd ] @@ -83,6 +89,7 @@ class CpsGenerator { private def createHostType(CyberPhysicalSystem it, int cost, int memory, int hdd) { val hostType = createHostType => [ + it.cost = cost defaultMemory = memory defaultHdd = hdd ] diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql index 40337443..aa78dc38 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql @@ -3,28 +3,23 @@ package hu.bme.mit.inf.dslreasoner.domains.cps.queries import "http://www.eclipse.org/emf/2002/Ecore" import "http://www.example.org/cps" -@QueryBasedFeature(feature = "applications") -pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) { +private pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) { CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance); } -@QueryBasedFeature(feature = "hosts") -pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) { +private pattern cpsHosts(Cps : CyberPhysicalSystem, HostInstance : HostInstance) { CyberPhysicalSystem.hostTypes.instances(Cps, HostInstance); } -@QueryBasedFeature(feature = "totalMemory") -pattern totalMemory(Host : HostInstance, Memory : EInt) { +private pattern totalMemory(Host : HostInstance, Memory : EInt) { HostInstance.type.defaultMemory(Host, Memory); } -@QueryBasedFeature(feature = "totalHdd") -pattern totalHdd(Host : HostInstance, Hdd : EInt) { +private pattern totalHdd(Host : HostInstance, Hdd : EInt) { HostInstance.type.defaultHdd(Host, Hdd); } -@QueryBasedFeature(feature = "availableMemory") -pattern availableMemory(Host : HostInstance, Memory : java Integer) { +private pattern availableMemory(Host : HostInstance, Memory : java Integer) { find totalMemory(Host, TotalMemory); RequiredMemory == sum find memoryRequirement(Host, _, #_); Memory == eval(TotalMemory - RequiredMemory); @@ -35,8 +30,7 @@ private pattern memoryRequirement(Host : HostInstance, App : ApplicationInstance ResourceRequirement.requiredMemory(Req, Memory); } -@QueryBasedFeature(feature = "availableHdd") -pattern availableHdd(Host : HostInstance, Hdd : java Integer) { +private pattern availableHdd(Host : HostInstance, Hdd : java Integer) { find totalHdd(Host, TotalHdd); RequiredHdd == sum find hddRequirement(Host, _, #_); Hdd == eval(TotalHdd - RequiredHdd); @@ -47,7 +41,7 @@ private pattern hddRequirement(Host : HostInstance, App : ApplicationInstance, H ResourceRequirement.requiredHdd(Req, Hdd); } -private pattern resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) { +pattern resourceRequirement(Host : HostInstance, App : ApplicationInstance, Req : ResourceRequirement) { ApplicationInstance.allocatedTo(App, Host); ApplicationInstance.type.requirements(App, Req); HostInstance.type(Host, HostType); @@ -106,6 +100,12 @@ pattern redundantInstancesOnSameHost(Req : Requirement) { ApplicationInstance.allocatedTo(App2, Host); } +// +// Metrics +// + +// Free memory + pattern averageFreeMemoryMetric(Average : java Double) { Average == avg find freeMemoryPercentage(_, #_); } @@ -116,6 +116,8 @@ private pattern freeMemoryPercentage(Host : HostInstance, Free : java Double) { Free == eval((Available as double) / Total); } +// Free HDD + pattern averageFreeHddMetric(Average : java Double) { Average == avg find freeHddPercentage(_, #_); } @@ -126,6 +128,8 @@ private pattern freeHddPercentage(Host : HostInstance, Free : java Double) { Free == eval((Available as double) / Total); } +// Total cost + pattern costMetric(Cost : java Integer) { Cost == sum find cpsCost(_, #_); } @@ -140,3 +144,55 @@ private pattern hostInstanceCost(Cps : CyberPhysicalSystem, Host : HostInstance, find cpsHosts(Cps, Host); HostInstance.type.cost(Host, Cost); } + +// +// Transformation rule preconditions for rule-based DSE +// + +pattern allocate(App : ApplicationInstance, Host : HostInstance) { + ApplicationInstance.type.requirements(App, Req); + ResourceRequirement.hostType.instances(Req, Host); + find unallocatedAppInstance(App); + find availableMemory(Host, AvailableMem); + find availableHdd(Host, AvailableHdd); + ResourceRequirement.requiredMemory(Req, RequiredMem); + ResourceRequirement.requiredHdd(Req, RequiredHdd); + check(AvailableMem >= RequiredMem); + check(AvailableHdd >= RequiredHdd); + neg ApplicationInstance.requirement.instances.allocatedTo(App, Host); +} + +pattern unallocateAppInstance(App : ApplicationInstance) { + ApplicationInstance.allocatedTo(App, _); +} + +pattern createHostInstance(HostType : HostType) { + find unallocatedAppInstance(App); + ApplicationInstance.type.requirements.hostType(App, HostType); +} + +pattern removeHostInstance(HostInstance : HostInstance) { + neg HostInstance.applications(HostInstance, _); +} + +private pattern unallocatedAppInstance(App : ApplicationInstance) { + neg ApplicationInstance.allocatedTo(App, _); +} + +private pattern requiredAppInstances(Req : Requirement, Remaining : java Integer) { + Instances == count find satisfyingInstance(Req, _); + Requirement.count(Req, RequiredCount); + Remaining == eval(RequiredCount - Instances); +} + +private pattern noHostToAllocateTo(App : ApplicationInstance) { + find unallocatedAppInstance(App); + neg find allocate(App, _); +} + +pattern guidanceObjective(Value : java Integer) { + UnallocatedInstances == count find unallocatedAppInstance(_); + RequiredInstances == sum find requiredAppInstances(_, #_); + NoHostToAllocate == count find noHostToAllocateTo(_); + Value == eval(2 * UnallocatedInstances + 4 * RequiredInstances + NoHostToAllocate); +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CbcCpsMain.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CbcCpsMain.xtendbin new file mode 100644 index 00000000..3f9e895d Binary files /dev/null and b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CbcCpsMain.xtendbin differ diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CpsToLpTranslator.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CpsToLpTranslator.xtendbin new file mode 100644 index 00000000..d8814a3b Binary files /dev/null and b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.CpsToLpTranslator.xtendbin differ diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.gitignore new file mode 100644 index 00000000..9f908c7a --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/.gitignore @@ -0,0 +1,2 @@ +/.CpsToLpTranslator.java._trace +/.CbcCpsMain.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.java new file mode 100644 index 00000000..d36cdccd --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CbcCpsMain.java @@ -0,0 +1,77 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.cplex; + +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.cplex.CpsToLpTranslator; +import hu.bme.mit.inf.dslreasoner.domains.cps.generator.CpsGenerator; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.eclipse.xtext.xbase.lib.Exceptions; +import org.eclipse.xtext.xbase.lib.InputOutput; + +@SuppressWarnings("all") +public class CbcCpsMain { + private static final String PROBLEM_FILE = "problem.lp"; + + private static final String SOLUTION_FILE = "solution.txt"; + + private CbcCpsMain() { + new IllegalStateException("This is a static utility class and should not be instantiated directly."); + } + + public static void main(final String[] args) { + try { + Map _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); + XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); + _extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, _xMIResourceFactoryImpl); + EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE); + final CpsGenerator generator = new CpsGenerator(1, 4, 1); + final CyberPhysicalSystem problem = generator.generateCpsProblem(); + final CpsToLpTranslator toLp = new CpsToLpTranslator(problem, 10, true); + final CharSequence lp = toLp.getLpProblem(); + FileWriter _fileWriter = new FileWriter(CbcCpsMain.PROBLEM_FILE); + final BufferedWriter writer = new BufferedWriter(_fileWriter); + try { + writer.append(lp); + } finally { + writer.close(); + } + final Process process = new ProcessBuilder().inheritIO().command("cbc", CbcCpsMain.PROBLEM_FILE, "solve", "solu", CbcCpsMain.SOLUTION_FILE).start(); + boolean _waitFor = process.waitFor(120, TimeUnit.SECONDS); + boolean _not = (!_waitFor); + if (_not) { + System.err.println("Timeout reached"); + process.destroyForcibly(); + System.exit((-1)); + } + int _exitValue = process.exitValue(); + boolean _notEquals = (_exitValue != 0); + if (_notEquals) { + int _exitValue_1 = process.exitValue(); + String _plus = ("Unexpected exit value " + Integer.valueOf(_exitValue_1)); + System.err.println(_plus); + System.exit((-1)); + } + FileReader _fileReader = new FileReader(CbcCpsMain.SOLUTION_FILE); + final BufferedReader reader = new BufferedReader(_fileReader); + try { + final Consumer _function = (String it) -> { + InputOutput.println(it); + }; + reader.lines().forEach(_function); + } finally { + reader.close(); + } + } catch (Throwable _e) { + throw Exceptions.sneakyThrow(_e); + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.java new file mode 100644 index 00000000..20afeee6 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/cplex/CpsToLpTranslator.java @@ -0,0 +1,505 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.cplex; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; +import hu.bme.mit.inf.dslreasoner.domains.cps.Request; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import org.eclipse.emf.common.util.EList; +import org.eclipse.xtend2.lib.StringConcatenation; +import org.eclipse.xtext.xbase.lib.CollectionLiterals; +import org.eclipse.xtext.xbase.lib.ExclusiveRange; +import org.eclipse.xtext.xbase.lib.Functions.Function1; +import org.eclipse.xtext.xbase.lib.IterableExtensions; +import org.eclipse.xtext.xbase.lib.ListExtensions; +import org.eclipse.xtext.xbase.lib.Pair; + +@SuppressWarnings("all") +public class CpsToLpTranslator { + private static final double MINIMUM_MEMORY_USAGE = 0.25; + + private static final double MINIMUM_HDD_USAGE = 0.25; + + private final CyberPhysicalSystem cps; + + private final Map> appInstances; + + private final Map> hostInstances; + + private final boolean breakSymmetry; + + public CpsToLpTranslator(final CyberPhysicalSystem cps, final int hostInstanceCount, final boolean breakSymmetry) { + this.cps = cps; + this.appInstances = this.createAppInstances(); + this.hostInstances = this.createHostInstances(hostInstanceCount); + this.breakSymmetry = breakSymmetry; + } + + private ImmutableMap> createAppInstances() { + ImmutableMap> _xblockexpression = null; + { + final ImmutableMap.Builder> builder = ImmutableMap.>builder(); + int i = 0; + Iterable _requirements = this.getRequirements(); + for (final Requirement req : _requirements) { + { + final ImmutableList.Builder listBuilder = ImmutableList.builder(); + for (int j = 0; (j < req.getCount()); j++) { + StringConcatenation _builder = new StringConcatenation(); + _builder.append("r"); + _builder.append(i); + _builder.append("a"); + _builder.append(j); + listBuilder.add(_builder.toString()); + } + builder.put(req, listBuilder.build()); + i++; + } + } + _xblockexpression = builder.build(); + } + return _xblockexpression; + } + + private ImmutableMap> createHostInstances(final int hostInstanceCount) { + ImmutableMap> _xblockexpression = null; + { + final ImmutableMap.Builder> builder = ImmutableMap.>builder(); + int i = 0; + EList _hostTypes = this.cps.getHostTypes(); + for (final HostType hostType : _hostTypes) { + { + final ImmutableList.Builder listBuilder = ImmutableList.builder(); + for (int j = 0; (j < hostInstanceCount); j++) { + StringConcatenation _builder = new StringConcatenation(); + _builder.append("h"); + _builder.append(i); + _builder.append("i"); + _builder.append(j); + listBuilder.add(_builder.toString()); + } + builder.put(hostType, listBuilder.build()); + i++; + } + } + _xblockexpression = builder.build(); + } + return _xblockexpression; + } + + public CharSequence getLpProblem() { + StringConcatenation _builder = new StringConcatenation(); + _builder.append("Minimize"); + _builder.newLine(); + _builder.append("\t"); + _builder.append("total_cost: "); + CharSequence _objective = this.getObjective(); + _builder.append(_objective, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("Subject To"); + _builder.newLine(); + _builder.append("\t"); + CharSequence _constraints = this.getConstraints(); + _builder.append(_constraints, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("Bounds"); + _builder.newLine(); + _builder.append("\t"); + CharSequence _bounds = this.getBounds(); + _builder.append(_bounds, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("Binary"); + _builder.newLine(); + _builder.append("\t"); + CharSequence _binaryVariables = this.getBinaryVariables(); + _builder.append(_binaryVariables, "\t"); + _builder.newLineIfNotEmpty(); + _builder.append("End"); + _builder.newLine(); + return _builder; + } + + private CharSequence getObjective() { + StringConcatenation _builder = new StringConcatenation(); + { + Iterable> _hostInstancesWithType = this.getHostInstancesWithType(); + boolean _hasElements = false; + for(final Pair pair : _hostInstancesWithType) { + if (!_hasElements) { + _hasElements = true; + } else { + _builder.appendImmediate(" + ", ""); + } + int _cost = pair.getKey().getCost(); + _builder.append(_cost); + _builder.append(" "); + CharSequence _existsVariable = this.getExistsVariable(pair.getValue()); + _builder.append(_existsVariable); + } + } + return _builder; + } + + private CharSequence getConstraints() { + StringConcatenation _builder = new StringConcatenation(); + { + Iterable> _appInstancesWithType = this.getAppInstancesWithType(); + for(final Pair appPair : _appInstancesWithType) { + String _value = appPair.getValue(); + _builder.append(_value); + _builder.append("_allocated: "); + { + Iterable _possibleHostInstances = this.getPossibleHostInstances(appPair.getKey()); + boolean _hasElements = false; + for(final String host : _possibleHostInstances) { + if (!_hasElements) { + _hasElements = true; + } else { + _builder.appendImmediate(" + ", ""); + } + CharSequence _allocatedToVariable = this.getAllocatedToVariable(appPair.getValue(), host); + _builder.append(_allocatedToVariable); + } + } + _builder.append(" = 1"); + _builder.newLineIfNotEmpty(); + { + Iterable _possibleHostInstances_1 = this.getPossibleHostInstances(appPair.getKey()); + for(final String host_1 : _possibleHostInstances_1) { + String _value_1 = appPair.getValue(); + _builder.append(_value_1); + _builder.append("_to_"); + _builder.append(host_1); + _builder.append("_exists: "); + CharSequence _existsVariable = this.getExistsVariable(host_1); + _builder.append(_existsVariable); + _builder.append(" - "); + CharSequence _allocatedToVariable_1 = this.getAllocatedToVariable(appPair.getValue(), host_1); + _builder.append(_allocatedToVariable_1); + _builder.append(" >= 0"); + _builder.newLineIfNotEmpty(); + } + } + } + } + { + Iterable> _hostInstancesWithType = this.getHostInstancesWithType(); + for(final Pair hostPair : _hostInstancesWithType) { + String _value_2 = hostPair.getValue(); + _builder.append(_value_2); + _builder.append("_mem_use: "); + { + Iterable> _possibleAppInstancesWithRequirements = this.getPossibleAppInstancesWithRequirements(hostPair.getKey()); + boolean _hasElements_1 = false; + for(final Pair appPair_1 : _possibleAppInstancesWithRequirements) { + if (!_hasElements_1) { + _hasElements_1 = true; + } else { + _builder.appendImmediate(" + ", ""); + } + int _requiredMemory = appPair_1.getKey().getRequiredMemory(); + _builder.append(_requiredMemory); + _builder.append(" "); + CharSequence _allocatedToVariable_2 = this.getAllocatedToVariable(appPair_1.getValue(), hostPair.getValue()); + _builder.append(_allocatedToVariable_2); + } + } + _builder.append(" - "); + int _defaultMemory = hostPair.getKey().getDefaultMemory(); + _builder.append(_defaultMemory); + _builder.append(" "); + CharSequence _memoryUsageVariable = this.getMemoryUsageVariable(hostPair.getValue()); + _builder.append(_memoryUsageVariable); + _builder.append(" = 0"); + _builder.newLineIfNotEmpty(); + String _value_3 = hostPair.getValue(); + _builder.append(_value_3); + _builder.append("_hdd_use: "); + { + Iterable> _possibleAppInstancesWithRequirements_1 = this.getPossibleAppInstancesWithRequirements(hostPair.getKey()); + boolean _hasElements_2 = false; + for(final Pair appPair_2 : _possibleAppInstancesWithRequirements_1) { + if (!_hasElements_2) { + _hasElements_2 = true; + } else { + _builder.appendImmediate(" + ", ""); + } + int _requiredHdd = appPair_2.getKey().getRequiredHdd(); + _builder.append(_requiredHdd); + _builder.append(" "); + CharSequence _allocatedToVariable_3 = this.getAllocatedToVariable(appPair_2.getValue(), hostPair.getValue()); + _builder.append(_allocatedToVariable_3); + } + } + _builder.append(" - "); + int _defaultHdd = hostPair.getKey().getDefaultHdd(); + _builder.append(_defaultHdd); + _builder.append(" "); + CharSequence _hddUsageVariable = this.getHddUsageVariable(hostPair.getValue()); + _builder.append(_hddUsageVariable); + _builder.append(" = 0"); + _builder.newLineIfNotEmpty(); + } + } + _builder.append("average_mem: "); + { + Iterable _allHostInstances = this.getAllHostInstances(); + boolean _hasElements_3 = false; + for(final String host_2 : _allHostInstances) { + if (!_hasElements_3) { + _hasElements_3 = true; + } else { + _builder.appendImmediate(" + ", ""); + } + CharSequence _memoryUsageVariable_1 = this.getMemoryUsageVariable(host_2); + _builder.append(_memoryUsageVariable_1); + _builder.append(" - "); + _builder.append(CpsToLpTranslator.MINIMUM_MEMORY_USAGE); + _builder.append(" "); + CharSequence _existsVariable_1 = this.getExistsVariable(host_2); + _builder.append(_existsVariable_1); + } + } + _builder.append(" >= 0"); + _builder.newLineIfNotEmpty(); + _builder.append("average_hdd: "); + { + Iterable _allHostInstances_1 = this.getAllHostInstances(); + boolean _hasElements_4 = false; + for(final String host_3 : _allHostInstances_1) { + if (!_hasElements_4) { + _hasElements_4 = true; + } else { + _builder.appendImmediate(" + ", ""); + } + CharSequence _memoryUsageVariable_2 = this.getMemoryUsageVariable(host_3); + _builder.append(_memoryUsageVariable_2); + _builder.append(" - "); + _builder.append(CpsToLpTranslator.MINIMUM_HDD_USAGE); + _builder.append(" "); + CharSequence _existsVariable_2 = this.getExistsVariable(host_3); + _builder.append(_existsVariable_2); + } + } + _builder.append(" >= 0"); + _builder.newLineIfNotEmpty(); + { + final Function1 _function = (Requirement it) -> { + int _count = it.getCount(); + return Boolean.valueOf((_count > 1)); + }; + Iterable> _indexed = IterableExtensions.indexed(IterableExtensions.filter(this.getRequirements(), _function)); + for(final Pair reqPair : _indexed) { + { + final Function1> _function_1 = (ResourceRequirement it) -> { + return this.hostInstances.get(it.getHostType()); + }; + Iterable _flatMap = IterableExtensions.flatMap(reqPair.getValue().getType().getRequirements(), _function_1); + for(final String host_4 : _flatMap) { + _builder.append("r"); + Integer _key = reqPair.getKey(); + _builder.append(_key); + _builder.append("_"); + _builder.append(host_4); + _builder.append("_redundant: "); + { + List _get = this.appInstances.get(reqPair.getValue()); + boolean _hasElements_5 = false; + for(final String app : _get) { + if (!_hasElements_5) { + _hasElements_5 = true; + } else { + _builder.appendImmediate(" + ", ""); + } + CharSequence _allocatedToVariable_4 = this.getAllocatedToVariable(app, host_4); + _builder.append(_allocatedToVariable_4); + } + } + _builder.append(" <= 1"); + _builder.newLineIfNotEmpty(); + } + } + } + } + { + if (this.breakSymmetry) { + { + Collection> _values = this.hostInstances.values(); + for(final List hosts : _values) { + { + int _size = hosts.size(); + int _minus = (_size - 1); + ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _minus, true); + for(final Integer i : _doubleDotLessThan) { + String _get_1 = hosts.get(((i).intValue() + 1)); + _builder.append(_get_1); + _builder.append("_after_"); + String _get_2 = hosts.get((i).intValue()); + _builder.append(_get_2); + _builder.append(": "); + CharSequence _existsVariable_3 = this.getExistsVariable(hosts.get((i).intValue())); + _builder.append(_existsVariable_3); + _builder.append(" - "); + CharSequence _existsVariable_4 = this.getExistsVariable(hosts.get(((i).intValue() + 1))); + _builder.append(_existsVariable_4); + _builder.append(" >= 0"); + _builder.newLineIfNotEmpty(); + } + } + } + } + } + } + return _builder; + } + + private CharSequence getBounds() { + StringConcatenation _builder = new StringConcatenation(); + { + Iterable _allHostInstances = this.getAllHostInstances(); + for(final String host : _allHostInstances) { + _builder.append("0 <= "); + CharSequence _memoryUsageVariable = this.getMemoryUsageVariable(host); + _builder.append(_memoryUsageVariable); + _builder.append(" <= 1"); + _builder.newLineIfNotEmpty(); + _builder.append("0 <= "); + CharSequence _hddUsageVariable = this.getHddUsageVariable(host); + _builder.append(_hddUsageVariable); + _builder.append(" <= 1"); + _builder.newLineIfNotEmpty(); + } + } + return _builder; + } + + private CharSequence getBinaryVariables() { + StringConcatenation _builder = new StringConcatenation(); + { + Iterable _allHostInstances = this.getAllHostInstances(); + for(final String host : _allHostInstances) { + CharSequence _existsVariable = this.getExistsVariable(host); + _builder.append(_existsVariable); + _builder.newLineIfNotEmpty(); + } + } + { + Iterable> _appInstancesWithType = this.getAppInstancesWithType(); + for(final Pair appPair : _appInstancesWithType) { + { + Iterable _possibleHostInstances = this.getPossibleHostInstances(appPair.getKey()); + for(final String host_1 : _possibleHostInstances) { + CharSequence _allocatedToVariable = this.getAllocatedToVariable(appPair.getValue(), host_1); + _builder.append(_allocatedToVariable); + _builder.newLineIfNotEmpty(); + } + } + } + } + return _builder; + } + + private Iterable getRequirements() { + final Function1> _function = (Request it) -> { + return it.getRequirements(); + }; + return IterableExtensions.flatMap(this.cps.getRequests(), _function); + } + + private Iterable getAllHostInstances() { + final Function1, List> _function = (List it) -> { + return it; + }; + return IterableExtensions.flatMap(this.hostInstances.values(), _function); + } + + private Iterable> getHostInstancesWithType() { + final Function1>, List>> _function = (Map.Entry> pair) -> { + final Function1> _function_1 = (String it) -> { + HostType _key = pair.getKey(); + return Pair.of(_key, it); + }; + return ListExtensions.>map(pair.getValue(), _function_1); + }; + return IterableExtensions.flatMap(this.hostInstances.entrySet(), _function); + } + + private Iterable> getAppInstancesWithType() { + final Function1>, List>> _function = (Map.Entry> pair) -> { + final Function1> _function_1 = (String it) -> { + ApplicationType _type = pair.getKey().getType(); + return Pair.of(_type, it); + }; + return ListExtensions.>map(pair.getValue(), _function_1); + }; + return IterableExtensions.flatMap(this.appInstances.entrySet(), _function); + } + + private Iterable getPossibleHostInstances(final ApplicationType appType) { + final Function1> _function = (ResourceRequirement req) -> { + return this.hostInstances.get(req.getHostType()); + }; + return IterableExtensions.flatMap(appType.getRequirements(), _function); + } + + private Iterable> getPossibleAppInstancesWithRequirements(final HostType hostType) { + final Function1>, List>> _function = (Map.Entry> pair) -> { + List> _xblockexpression = null; + { + final Function1 _function_1 = (ResourceRequirement it) -> { + HostType _hostType = it.getHostType(); + return Boolean.valueOf(Objects.equal(_hostType, hostType)); + }; + final ResourceRequirement resourceReq = IterableExtensions.findFirst(pair.getKey().getType().getRequirements(), _function_1); + List> _xifexpression = null; + if ((resourceReq == null)) { + _xifexpression = CollectionLiterals.>emptyList(); + } else { + final Function1> _function_2 = (String it) -> { + return Pair.of(resourceReq, it); + }; + _xifexpression = ListExtensions.>map(pair.getValue(), _function_2); + } + _xblockexpression = _xifexpression; + } + return _xblockexpression; + }; + return IterableExtensions.flatMap(this.appInstances.entrySet(), _function); + } + + private CharSequence getExistsVariable(final String hostInstance) { + StringConcatenation _builder = new StringConcatenation(); + _builder.append(hostInstance); + _builder.append("_exists"); + return _builder; + } + + private CharSequence getMemoryUsageVariable(final String hostInstance) { + StringConcatenation _builder = new StringConcatenation(); + _builder.append(hostInstance); + _builder.append("_mem"); + return _builder; + } + + private CharSequence getHddUsageVariable(final String hostInstance) { + StringConcatenation _builder = new StringConcatenation(); + _builder.append(hostInstance); + _builder.append("_hdd"); + return _builder; + } + + private CharSequence getAllocatedToVariable(final String appInstance, final String hostInstance) { + StringConcatenation _builder = new StringConcatenation(); + _builder.append(appInstance); + _builder.append("_to_"); + _builder.append(hostInstance); + return _builder; + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.CpsStateCoder.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.CpsStateCoder.xtendbin new file mode 100644 index 00000000..cdfe3921 Binary files /dev/null and b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.CpsStateCoder.xtendbin differ diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsMain.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsMain.xtendbin new file mode 100644 index 00000000..9be64b30 Binary files /dev/null and b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsMain.xtendbin differ diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsSolver.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsSolver.xtendbin new file mode 100644 index 00000000..02fb74ef Binary files /dev/null and b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.RuleBasedCpsSolver.xtendbin differ diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.gitignore new file mode 100644 index 00000000..e24f10f4 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/.gitignore @@ -0,0 +1,3 @@ +/.RuleBasedCpsSolver.java._trace +/.RuleBasedCpsMain.java._trace +/.CpsStateCoder.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.java new file mode 100644 index 00000000..3ae8e828 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/CpsStateCoder.java @@ -0,0 +1,316 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.dse; + +import com.google.common.base.Objects; +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; +import hu.bme.mit.inf.dslreasoner.domains.cps.Request; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; +import java.util.Arrays; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.viatra.dse.statecode.IStateCoder; +import org.eclipse.viatra.dse.statecode.IStateCoderFactory; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.xtend2.lib.StringConcatenation; +import org.eclipse.xtend2.lib.StringConcatenationClient; +import org.eclipse.xtext.xbase.lib.IterableExtensions; + +@SuppressWarnings("all") +public class CpsStateCoder implements IStateCoder { + public static class Factory implements IStateCoderFactory { + @Override + public IStateCoder createStateCoder() { + return new CpsStateCoder(); + } + } + + private CyberPhysicalSystem cps; + + protected CpsStateCoder() { + } + + @Override + public void init(final Notifier notifier) { + CyberPhysicalSystem _switchResult = null; + boolean _matched = false; + if (notifier instanceof ResourceSet) { + _matched=true; + _switchResult = this.getCpsFromResourceSet(((ResourceSet)notifier)); + } + if (!_matched) { + if (notifier instanceof Resource) { + _matched=true; + _switchResult = this.getCpsFromResource(((Resource)notifier)); + } + } + if (!_matched) { + if (notifier instanceof CyberPhysicalSystem) { + _matched=true; + _switchResult = ((CyberPhysicalSystem)notifier); + } + } + if (!_matched) { + throw new IllegalArgumentException("notifier is not a CyberPhysicalSystem"); + } + this.cps = _switchResult; + } + + private CyberPhysicalSystem getCpsFromResourceSet(final ResourceSet resourceSet) { + CyberPhysicalSystem _xblockexpression = null; + { + boolean _isEmpty = resourceSet.getResources().isEmpty(); + if (_isEmpty) { + throw new IllegalArgumentException("No Resource in ResourceSet"); + } + final Resource resource = IterableExtensions.head(resourceSet.getResources()); + _xblockexpression = this.getCpsFromResource(resource); + } + return _xblockexpression; + } + + private CyberPhysicalSystem getCpsFromResource(final Resource resource) { + CyberPhysicalSystem _xblockexpression = null; + { + boolean _isEmpty = resource.getContents().isEmpty(); + if (_isEmpty) { + throw new IllegalArgumentException("No EObject in Resource"); + } + final EObject cps = IterableExtensions.head(resource.getContents()); + CyberPhysicalSystem _xifexpression = null; + if ((cps instanceof CyberPhysicalSystem)) { + _xifexpression = ((CyberPhysicalSystem)cps); + } else { + throw new IllegalArgumentException("EObject in Resource is not a CyberPhysicalSystem"); + } + _xblockexpression = _xifexpression; + } + return _xblockexpression; + } + + @Override + public String createStateCode() { + StringConcatenation _builder = new StringConcatenation(); + StringConcatenationClient _createRequestsCode = this.createRequestsCode(); + _builder.append(_createRequestsCode); + CharSequence _createHostTypesCode = this.createHostTypesCode(); + _builder.append(_createHostTypesCode); + return _builder.toString(); + } + + private StringConcatenationClient createRequestsCode() { + StringConcatenationClient _client = new StringConcatenationClient() { + @Override + protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { + { + EList _requests = CpsStateCoder.this.cps.getRequests(); + for(final Request request : _requests) { + StringConcatenationClient _createRequestCode = CpsStateCoder.this.createRequestCode(request); + _builder.append(_createRequestCode); + } + } + } + }; + return _client; + } + + private StringConcatenationClient createRequestCode(final Request request) { + StringConcatenationClient _client = new StringConcatenationClient() { + @Override + protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { + _builder.append("["); + { + EList _requirements = request.getRequirements(); + for(final Requirement requirement : _requirements) { + StringConcatenationClient _createRequirementCode = CpsStateCoder.this.createRequirementCode(requirement); + _builder.append(_createRequirementCode); + } + } + _builder.append("]"); + } + }; + return _client; + } + + private StringConcatenationClient createRequirementCode(final Requirement requirement) { + StringConcatenationClient _client = new StringConcatenationClient() { + @Override + protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { + _builder.append("["); + { + EList _instances = requirement.getInstances(); + boolean _hasElements = false; + for(final ApplicationInstance app : _instances) { + if (!_hasElements) { + _hasElements = true; + } else { + _builder.appendImmediate(",", ""); + } + String _createAppCode = CpsStateCoder.this.createAppCode(app); + _builder.append(_createAppCode); + } + } + _builder.append("]"); + } + }; + return _client; + } + + private String createAppCode(final ApplicationInstance app) { + String _xifexpression = null; + HostInstance _allocatedTo = app.getAllocatedTo(); + boolean _tripleEquals = (_allocatedTo == null); + if (_tripleEquals) { + _xifexpression = "-"; + } else { + _xifexpression = this.createMatchArgumentCode(app.getAllocatedTo()); + } + return _xifexpression; + } + + private CharSequence createHostTypesCode() { + StringConcatenation _builder = new StringConcatenation(); + _builder.append("("); + { + EList _hostTypes = this.cps.getHostTypes(); + boolean _hasElements = false; + for(final HostType hostType : _hostTypes) { + if (!_hasElements) { + _hasElements = true; + } else { + _builder.appendImmediate(",", ""); + } + int _size = hostType.getInstances().size(); + _builder.append(_size); + } + } + _builder.append(")"); + return _builder; + } + + @Override + public String createActivationCode(final IPatternMatch match) { + StringConcatenation _builder = new StringConcatenation(); + String _simpleName = match.specification().getSimpleName(); + _builder.append(_simpleName); + _builder.append("("); + { + Object[] _array = match.toArray(); + boolean _hasElements = false; + for(final Object arg : _array) { + if (!_hasElements) { + _hasElements = true; + } else { + _builder.appendImmediate(",", ""); + } + String _createMatchArgumentCode = this.createMatchArgumentCode(arg); + _builder.append(_createMatchArgumentCode); + } + } + _builder.append(")"); + return _builder.toString(); + } + + protected String _createMatchArgumentCode(final Requirement requirement) { + String _xblockexpression = null; + { + final EObject request = requirement.eContainer(); + String _xifexpression = null; + if ((request instanceof Request)) { + String _xblockexpression_1 = null; + { + EObject _eContainer = ((Request)request).eContainer(); + boolean _notEquals = (!Objects.equal(_eContainer, this.cps)); + if (_notEquals) { + throw new IllegalArgumentException("Request is not contained in the CPS"); + } + final int requestIndex = this.cps.getRequests().indexOf(request); + final int requirementIndex = ((Request)request).getRequirements().indexOf(requirement); + String _plus = (Integer.valueOf(requestIndex) + "."); + _xblockexpression_1 = (_plus + Integer.valueOf(requirementIndex)); + } + _xifexpression = _xblockexpression_1; + } else { + throw new IllegalArgumentException("Requirement is not contained in a request"); + } + _xblockexpression = _xifexpression; + } + return _xblockexpression; + } + + protected String _createMatchArgumentCode(final ApplicationInstance app) { + String _xblockexpression = null; + { + final Requirement requirement = app.getRequirement(); + if ((requirement == null)) { + throw new IllegalArgumentException("Application instance is not associated with a requirement"); + } + final int instanceIndex = requirement.getInstances().indexOf(app); + String _createMatchArgumentCode = this.createMatchArgumentCode(requirement); + String _plus = (_createMatchArgumentCode + "."); + _xblockexpression = (_plus + Integer.valueOf(instanceIndex)); + } + return _xblockexpression; + } + + protected String _createMatchArgumentCode(final HostInstance host) { + String _xblockexpression = null; + { + final EObject hostType = host.eContainer(); + String _xifexpression = null; + if ((hostType instanceof HostType)) { + String _xblockexpression_1 = null; + { + final int hostIndex = ((HostType)hostType).getInstances().indexOf(host); + String _createMatchArgumentCode = this.createMatchArgumentCode(hostType); + String _plus = (_createMatchArgumentCode + "."); + _xblockexpression_1 = (_plus + Integer.valueOf(hostIndex)); + } + _xifexpression = _xblockexpression_1; + } else { + throw new IllegalArgumentException("Host is not contained in a host type"); + } + _xblockexpression = _xifexpression; + } + return _xblockexpression; + } + + protected String _createMatchArgumentCode(final HostType hostType) { + String _xblockexpression = null; + { + EObject _eContainer = hostType.eContainer(); + boolean _notEquals = (!Objects.equal(_eContainer, this.cps)); + if (_notEquals) { + throw new IllegalArgumentException("Host type is not contained in the CPS"); + } + final int hostTypeIndex = this.cps.getHostTypes().indexOf(hostType); + _xblockexpression = Integer.valueOf(hostTypeIndex).toString(); + } + return _xblockexpression; + } + + protected String _createMatchArgumentCode(final Object object) { + throw new IllegalArgumentException("Unknown match argument: "); + } + + protected String createMatchArgumentCode(final Object app) { + if (app instanceof ApplicationInstance) { + return _createMatchArgumentCode((ApplicationInstance)app); + } else if (app instanceof HostInstance) { + return _createMatchArgumentCode((HostInstance)app); + } else if (app instanceof HostType) { + return _createMatchArgumentCode((HostType)app); + } else if (app instanceof Requirement) { + return _createMatchArgumentCode((Requirement)app); + } else if (app != null) { + return _createMatchArgumentCode(app); + } else { + throw new IllegalArgumentException("Unhandled parameter types: " + + Arrays.asList(app).toString()); + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.java new file mode 100644 index 00000000..7d81f84b --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsMain.java @@ -0,0 +1,46 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.dse; + +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.dse.RuleBasedCpsSolver; +import hu.bme.mit.inf.dslreasoner.domains.cps.generator.CpsGenerator; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsQueries; +import java.util.Map; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.eclipse.viatra.addon.querybasedfeatures.runtime.QueryBasedFeatureSettingDelegateFactory; +import org.eclipse.viatra.addon.querybasedfeatures.runtime.handler.QueryBasedFeatures; +import org.eclipse.viatra.dse.api.DesignSpaceExplorer; +import org.eclipse.viatra.query.runtime.extensibility.SingletonQueryGroupProvider; +import org.eclipse.viatra.query.runtime.registry.IQuerySpecificationRegistry; +import org.eclipse.viatra.query.runtime.registry.QuerySpecificationRegistry; +import org.eclipse.viatra.query.runtime.registry.connector.QueryGroupProviderSourceConnector; + +@SuppressWarnings("all") +public class RuleBasedCpsMain { + private RuleBasedCpsMain() { + new IllegalStateException("This is a static utility class and should not be instantiated directly."); + } + + public static void main(final String[] args) { + DesignSpaceExplorer.turnOnLogging(DesignSpaceExplorer.DseLoggingLevel.VERBOSE_FULL); + Map _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); + XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); + _extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, _xMIResourceFactoryImpl); + QueryBasedFeatureSettingDelegateFactory _queryBasedFeatureSettingDelegateFactory = new QueryBasedFeatureSettingDelegateFactory(); + EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(QueryBasedFeatures.ANNOTATION_SOURCE, _queryBasedFeatureSettingDelegateFactory); + EPackage.Registry.INSTANCE.put(CpsPackage.eNS_URI, CpsPackage.eINSTANCE); + IQuerySpecificationRegistry _instance = QuerySpecificationRegistry.getInstance(); + CpsQueries _instance_1 = CpsQueries.instance(); + SingletonQueryGroupProvider _singletonQueryGroupProvider = new SingletonQueryGroupProvider(_instance_1); + QueryGroupProviderSourceConnector _queryGroupProviderSourceConnector = new QueryGroupProviderSourceConnector("CpsQueries", _singletonQueryGroupProvider, + true); + _instance.addSource(_queryGroupProviderSourceConnector); + final CpsGenerator generator = new CpsGenerator(1, 4, 1); + final CyberPhysicalSystem problem = generator.generateCpsProblem(); + final RuleBasedCpsSolver solver = new RuleBasedCpsSolver(); + solver.solve(problem); + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.java new file mode 100644 index 00000000..fd348752 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.java @@ -0,0 +1,93 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.dse; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsPackage; +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.dse.CpsStateCoder; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.Allocate; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeHddMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AverageFreeMemoryMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CostMetric; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.CreateHostInstance; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.GuidanceObjective; +import hu.bme.mit.inf.dslreasoner.domains.cps.queries.RequirementNotSatisfied; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CompositeDirectionalThresholdObjective; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.QueryBasedObjective; +import java.util.Collection; +import java.util.function.Consumer; +import org.eclipse.emf.common.util.EList; +import org.eclipse.viatra.dse.api.DesignSpaceExplorer; +import org.eclipse.viatra.dse.api.Solution; +import org.eclipse.viatra.dse.evolutionary.EvolutionaryStrategy; +import org.eclipse.viatra.dse.evolutionary.EvolutionaryStrategyBuilder; +import org.eclipse.viatra.dse.objectives.Fitness; +import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRuleFactory; +import org.eclipse.xtext.xbase.lib.Extension; +import org.eclipse.xtext.xbase.lib.InputOutput; + +@SuppressWarnings("all") +public class RuleBasedCpsSolver { + @Extension + private final BatchTransformationRuleFactory _batchTransformationRuleFactory = new BatchTransformationRuleFactory(); + + @Extension + private final CpsFactory _cpsFactory = CpsFactory.eINSTANCE; + + public void solve(final CyberPhysicalSystem problem) { + final DesignSpaceExplorer dse = new DesignSpaceExplorer(); + dse.addMetaModelPackage(CpsPackage.eINSTANCE); + dse.setInitialModel(problem.eResource().getResourceSet()); + final Consumer _function = (RequirementNotSatisfied.Match it) -> { + final ApplicationInstance app = this._cpsFactory.createApplicationInstance(); + EList _instances = it.getReq().getType().getInstances(); + _instances.add(app); + EList _instances_1 = it.getReq().getInstances(); + _instances_1.add(app); + }; + dse.addTransformationRule(this._batchTransformationRuleFactory.createRule(RequirementNotSatisfied.instance()).action(_function).build()); + final Consumer _function_1 = (Allocate.Match it) -> { + ApplicationInstance _app = it.getApp(); + _app.setAllocatedTo(it.getHost()); + }; + dse.addTransformationRule(this._batchTransformationRuleFactory.createRule(Allocate.instance()).action(_function_1).build()); + final Consumer _function_2 = (CreateHostInstance.Match it) -> { + EList _instances = it.getHostType().getInstances(); + HostInstance _createHostInstance = this._cpsFactory.createHostInstance(); + _instances.add(_createHostInstance); + }; + dse.addTransformationRule(this._batchTransformationRuleFactory.createRule(CreateHostInstance.instance()).action(_function_2).build()); + GuidanceObjective _instance = GuidanceObjective.instance(); + ObjectiveThreshold.Inclusive _inclusive = new ObjectiveThreshold.Inclusive(0); + QueryBasedObjective _queryBasedObjective = new QueryBasedObjective(_instance, ObjectiveKind.LOWER_IS_BETTER, _inclusive, 0); + AverageFreeMemoryMetric _instance_1 = AverageFreeMemoryMetric.instance(); + ObjectiveThreshold.Inclusive _inclusive_1 = new ObjectiveThreshold.Inclusive(0.75); + QueryBasedObjective _queryBasedObjective_1 = new QueryBasedObjective(_instance_1, ObjectiveKind.LOWER_IS_BETTER, _inclusive_1, 0); + AverageFreeHddMetric _instance_2 = AverageFreeHddMetric.instance(); + ObjectiveThreshold.Inclusive _inclusive_2 = new ObjectiveThreshold.Inclusive(0.75); + QueryBasedObjective _queryBasedObjective_2 = new QueryBasedObjective(_instance_2, ObjectiveKind.LOWER_IS_BETTER, _inclusive_2, 0); + CompositeDirectionalThresholdObjective _compositeDirectionalThresholdObjective = new CompositeDirectionalThresholdObjective("Composite", _queryBasedObjective, _queryBasedObjective_1, _queryBasedObjective_2); + dse.addObjective(_compositeDirectionalThresholdObjective); + CostMetric _instance_3 = CostMetric.instance(); + QueryBasedObjective _queryBasedObjective_3 = new QueryBasedObjective(_instance_3, ObjectiveKind.LOWER_IS_BETTER, + ObjectiveThreshold.NO_THRESHOLD, 0); + dse.addObjective(_queryBasedObjective_3); + dse.setMaxNumberOfThreads(1); + CpsStateCoder.Factory _factory = new CpsStateCoder.Factory(); + dse.setStateCoderFactory(_factory); + final EvolutionaryStrategy strategy = EvolutionaryStrategyBuilder.createNsga2Strategy(25); + dse.startExplorationWithTimeout(strategy, ((2 * 60) * 1000)); + Collection _solutions = dse.getSolutions(); + for (final Solution solution : _solutions) { + Object _stateCode = solution.getStateCode(); + String _plus = ("Found solution: " + _stateCode); + String _plus_1 = (_plus + " "); + Fitness _fitness = solution.getArbitraryTrajectory().getFitness(); + String _plus_2 = (_plus_1 + _fitness); + InputOutput.println(_plus_2); + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/.CpsGenerator.xtendbin b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/.CpsGenerator.xtendbin new file mode 100644 index 00000000..d975ffab Binary files /dev/null and b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/.CpsGenerator.xtendbin differ diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.java new file mode 100644 index 00000000..e59ef004 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/xtend-gen/hu/bme/mit/inf/dslreasoner/domains/cps/generator/CpsGenerator.java @@ -0,0 +1,154 @@ +package hu.bme.mit.inf.dslreasoner.domains.cps.generator; + +import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationType; +import hu.bme.mit.inf.dslreasoner.domains.cps.CpsFactory; +import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem; +import hu.bme.mit.inf.dslreasoner.domains.cps.HostType; +import hu.bme.mit.inf.dslreasoner.domains.cps.Request; +import hu.bme.mit.inf.dslreasoner.domains.cps.Requirement; +import hu.bme.mit.inf.dslreasoner.domains.cps.ResourceRequirement; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Random; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.xtext.xbase.lib.CollectionLiterals; +import org.eclipse.xtext.xbase.lib.Extension; +import org.eclipse.xtext.xbase.lib.ObjectExtensions; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; + +@SuppressWarnings("all") +public class CpsGenerator { + @Extension + private final CpsFactory _cpsFactory = CpsFactory.eINSTANCE; + + private static final int MIN_MEMORY = 1; + + private static final int MAX_MEMORY = 6; + + private static final int MIN_HDD = 1; + + private static final int MAX_HDD = 30; + + private static final int HIGH_CPU_FRACTION = 4; + + private static final int MIN_REPLICAS = 1; + + private static final int MAX_REPLICAS = 4; + + private final Random random; + + private final int applicationTypeCount; + + private final int demandFactor; + + public CpsGenerator(final long randomSeed, final int applicationTypeCount, final int demandFactor) { + Random _random = new Random(randomSeed); + this.random = _random; + this.applicationTypeCount = applicationTypeCount; + this.demandFactor = demandFactor; + } + + public CyberPhysicalSystem generateCpsProblem() { + CyberPhysicalSystem _xblockexpression = null; + { + final ResourceSetImpl resourceSet = new ResourceSetImpl(); + final Resource resource = resourceSet.createResource(URI.createFileURI("dummy.dummyext")); + CyberPhysicalSystem _createCyberPhysicalSystem = this._cpsFactory.createCyberPhysicalSystem(); + final Procedure1 _function = (CyberPhysicalSystem it) -> { + final CyberPhysicalSystem cps = it; + EList _contents = resource.getContents(); + _contents.add(cps); + this.createLowCpuHostTypes(it); + final List highCpuHostTypes = this.createHighCpuHostTypes(it); + for (int i = 0; (i < this.applicationTypeCount); i++) { + if (((i % CpsGenerator.HIGH_CPU_FRACTION) == 0)) { + this.createRandomApplicationType(it, highCpuHostTypes); + } else { + this.createRandomApplicationType(it, it.getHostTypes()); + } + } + for (int i = 0; (i < this.demandFactor); i++) { + EList _requests = it.getRequests(); + Request _createRequest = this._cpsFactory.createRequest(); + final Procedure1 _function_1 = (Request it_1) -> { + EList _applicationTypes = cps.getApplicationTypes(); + for (final ApplicationType appType : _applicationTypes) { + EList _requirements = it_1.getRequirements(); + Requirement _createRequirement = this._cpsFactory.createRequirement(); + final Procedure1 _function_2 = (Requirement it_2) -> { + it_2.setCount(this.nextInt(CpsGenerator.MIN_REPLICAS, CpsGenerator.MAX_REPLICAS)); + it_2.setType(appType); + }; + Requirement _doubleArrow = ObjectExtensions.operator_doubleArrow(_createRequirement, _function_2); + _requirements.add(_doubleArrow); + } + }; + Request _doubleArrow = ObjectExtensions.operator_doubleArrow(_createRequest, _function_1); + _requests.add(_doubleArrow); + } + }; + _xblockexpression = ObjectExtensions.operator_doubleArrow(_createCyberPhysicalSystem, _function); + } + return _xblockexpression; + } + + private void createRandomApplicationType(final CyberPhysicalSystem it, final Collection allowedHostTypes) { + final ApplicationType appType = this._cpsFactory.createApplicationType(); + final int memory = this.nextInt(CpsGenerator.MIN_MEMORY, CpsGenerator.MAX_MEMORY); + final int hdd = this.nextInt(CpsGenerator.MIN_HDD, CpsGenerator.MAX_HDD); + for (final HostType hostType : allowedHostTypes) { + EList _requirements = appType.getRequirements(); + ResourceRequirement _createResourceRequirement = this._cpsFactory.createResourceRequirement(); + final Procedure1 _function = (ResourceRequirement it_1) -> { + it_1.setHostType(hostType); + it_1.setRequiredMemory(memory); + it_1.setRequiredHdd(hdd); + }; + ResourceRequirement _doubleArrow = ObjectExtensions.operator_doubleArrow(_createResourceRequirement, _function); + _requirements.add(_doubleArrow); + } + EList _applicationTypes = it.getApplicationTypes(); + _applicationTypes.add(appType); + } + + private List createLowCpuHostTypes(final CyberPhysicalSystem it) { + HostType _createHostType = this.createHostType(it, 2, 8, 75); + HostType _createHostType_1 = this.createHostType(it, 4, 16, 150); + HostType _createHostType_2 = this.createHostType(it, 3, 16, 75); + HostType _createHostType_3 = this.createHostType(it, 6, 32, 150); + return Collections.unmodifiableList(CollectionLiterals.newArrayList(_createHostType, _createHostType_1, _createHostType_2, _createHostType_3)); + } + + private List createHighCpuHostTypes(final CyberPhysicalSystem it) { + HostType _createHostType = this.createHostType(it, 2, 4, 50); + HostType _createHostType_1 = this.createHostType(it, 4, 8, 100); + return Collections.unmodifiableList(CollectionLiterals.newArrayList(_createHostType, _createHostType_1)); + } + + private HostType createHostType(final CyberPhysicalSystem it, final int cost, final int memory, final int hdd) { + HostType _xblockexpression = null; + { + HostType _createHostType = this._cpsFactory.createHostType(); + final Procedure1 _function = (HostType it_1) -> { + it_1.setCost(cost); + it_1.setDefaultMemory(memory); + it_1.setDefaultHdd(hdd); + }; + final HostType hostType = ObjectExtensions.operator_doubleArrow(_createHostType, _function); + EList _hostTypes = it.getHostTypes(); + _hostTypes.add(hostType); + _xblockexpression = hostType; + } + return _xblockexpression; + } + + private int nextInt(final int lower, final int upper) { + int _nextInt = this.random.nextInt(((upper - lower) + 1)); + return (lower + _nextInt); + } +} -- cgit v1.2.3-54-g00ecf