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 --- .../cps/queries/internal/FreeMemoryPercentage.java | 172 +++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java') 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()); + } +} -- 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/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java') 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 From d46494bb753225652f48e42f47411297693a03ab Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Tue, 29 Oct 2019 16:40:23 +0100 Subject: Remove MDEOptimiser dependency --- .../META-INF/MANIFEST.MF | 15 +----- .../dslreasoner/domains/cps/queries/Allocate.java | 21 ++++++-- .../AllocationWithoutResourceRequirement.java | 21 ++++++-- .../domains/cps/queries/AverageFreeHddMetric.java | 18 +++++-- .../cps/queries/AverageFreeMemoryMetric.java | 18 +++++-- .../domains/cps/queries/CostMetric.java | 18 +++++-- .../dslreasoner/domains/cps/queries/CpsCost.java | 21 ++++++-- .../domains/cps/queries/CreateHostInstance.java | 18 +++++-- .../domains/cps/queries/GuidanceObjective.java | 18 +++++-- .../queries/InstanceDoesNotSatisfyRequirement.java | 21 ++++++-- .../domains/cps/queries/NotEnoughAvailableHdd.java | 18 +++++-- .../cps/queries/NotEnoughAvailableMemory.java | 18 +++++-- .../cps/queries/RedundantInstancesOnSameHost.java | 18 +++++-- .../domains/cps/queries/RemoveHostInstance.java | 18 +++++-- .../cps/queries/RequirementNotSatisfied.java | 18 +++++-- .../domains/cps/queries/ResourceRequirement.java | 24 ++++++--- .../domains/cps/queries/UnallocateAppInstance.java | 18 +++++-- .../domains/cps/queries/internal/AvailableHdd.java | 4 +- .../cps/queries/internal/AvailableMemory.java | 4 +- .../cps/queries/internal/CpsApplications.java | 4 +- .../domains/cps/queries/internal/CpsHosts.java | 4 +- .../cps/queries/internal/FreeHddPercentage.java | 4 +- .../cps/queries/internal/FreeMemoryPercentage.java | 4 +- .../cps/queries/internal/HddRequirement.java | 4 +- .../cps/queries/internal/HostInstanceCost.java | 4 +- .../cps/queries/internal/MemoryRequirement.java | 4 +- .../cps/queries/internal/NoHostToAllocateTo.java | 4 +- .../cps/queries/internal/RequiredAppInstances.java | 4 +- .../cps/queries/internal/SatisfyingInstance.java | 4 +- .../domains/cps/queries/internal/TotalHdd.java | 4 +- .../domains/cps/queries/internal/TotalMemory.java | 4 +- .../queries/internal/UnallocatedAppInstance.java | 4 +- .../domains/cps/mdeo/CpsMdeOptimiserMain.xtend | 57 ---------------------- .../mdeo/NonRedundantAllocationsConstraint.xtend | 29 ----------- .../mdeo/NotAllocatedAppInstancesConstraint.xtend | 24 --------- .../mdeo/NotSatisfiedRequirementsConstraint.xtend | 27 ---------- .../domains/cps/mdeo/ResourceUtilizationUtil.xtend | 31 ------------ .../cps/mdeo/TooLowAverageHddConstraint.xtend | 33 ------------- .../cps/mdeo/TooLowAverageMemoryConstraint.xtend | 33 ------------- .../cps/mdeo/TotalCostFitnessFunction.xtend | 23 --------- .../cps/mdeo/UnavailableHddConstraint.xtend | 27 ---------- .../cps/mdeo/UnavailableMemoryConstraint.xtend | 27 ---------- .../mit/inf/dslreasoner/domains/cps/mdeo/cps.mopt | 43 ---------------- 43 files changed, 267 insertions(+), 468 deletions(-) delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/CpsMdeOptimiserMain.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotAllocatedAppInstancesConstraint.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotSatisfiedRequirementsConstraint.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/ResourceUtilizationUtil.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageHddConstraint.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageMemoryConstraint.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TotalCostFitnessFunction.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableHddConstraint.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/cps.mopt (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/internal/FreeMemoryPercentage.java') 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 e13a18cf..275a988a 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 @@ -23,20 +23,7 @@ Require-Bundle: org.eclipse.viatra.addon.querybasedfeatures.runtime, org.eclipse.viatra.dse, org.eclipse.viatra.dse.genetic, hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner;bundle-version="1.0.0", - org.eclipse.emf.ecore.xmi;bundle-version="2.15.0", - uk.ac.kcl.inf.mdeoptimiser.libraries.core;bundle-version="1.0.0", - uk.ac.kcl.inf.mdeoptimiser.interfaces.cli;bundle-version="1.0.0", - org.eclipse.emf.henshin.interpreter;bundle-version="1.5.0", - uk.ac.kcl.inf.mdeoptimiser.libraries.rulegen;bundle-version="1.0.0", - org.sidiff.common;bundle-version="1.0.0", - org.sidiff.common.emf;bundle-version="1.0.0", - org.sidiff.common.emf.extensions;bundle-version="1.0.0", - org.moeaframework;bundle-version="2.13.0", - org.apache.commons.math3;bundle-version="3.6.1", - org.apache.commons.lang3;bundle-version="3.8.1", - com.google.inject;bundle-version="3.0.0", - org.sidiff.common.henshin;bundle-version="1.0.0", - org.sidiff.serge;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/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 index 830dc8a0..1fc70124 100644 --- 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 @@ -105,9 +105,20 @@ public final class Allocate extends BaseGeneratedEMFQuerySpecification) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * Inner class allowing the singleton instance of {@link Allocate} 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()}. + * but rather at the first call to {@link Allocate#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 6da5f76d..b49fee74 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 @@ -88,9 +88,20 @@ public final class AllocationWithoutResourceRequirement extends BaseGeneratedEMF @Override public Object get(final String parameterName) { - if ("Host".equals(parameterName)) return this.fHost; - if ("App".equals(parameterName)) return this.fApp; - return null; + switch(parameterName) { + case "Host": return this.fHost; + case "App": return this.fApp; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fHost; + case 1: return this.fApp; + default: return null; + } } public HostInstance getHost() { @@ -623,9 +634,9 @@ public final class AllocationWithoutResourceRequirement extends BaseGeneratedEMF } /** - * 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 + * Inner class allowing the singleton instance of {@link AllocationWithoutResourceRequirement} 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()}. + * but rather at the first call to {@link AllocationWithoutResourceRequirement#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 bc38b60b..607854bf 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 @@ -79,8 +79,18 @@ public final class AverageFreeHddMetric extends BaseGeneratedEMFQuerySpecificati @Override public Object get(final String parameterName) { - if ("Average".equals(parameterName)) return this.fAverage; - return null; + switch(parameterName) { + case "Average": return this.fAverage; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fAverage; + default: return null; + } } public Double getAverage() { @@ -468,9 +478,9 @@ public final class AverageFreeHddMetric extends BaseGeneratedEMFQuerySpecificati } /** - * 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 + * Inner class allowing the singleton instance of {@link AverageFreeHddMetric} 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()}. + * but rather at the first call to {@link AverageFreeHddMetric#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 98974ea5..627a5f89 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 @@ -83,8 +83,18 @@ public final class AverageFreeMemoryMetric extends BaseGeneratedEMFQuerySpecific @Override public Object get(final String parameterName) { - if ("Average".equals(parameterName)) return this.fAverage; - return null; + switch(parameterName) { + case "Average": return this.fAverage; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fAverage; + default: return null; + } } public Double getAverage() { @@ -476,9 +486,9 @@ public final class AverageFreeMemoryMetric extends BaseGeneratedEMFQuerySpecific } /** - * 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 + * Inner class allowing the singleton instance of {@link AverageFreeMemoryMetric} 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()}. + * but rather at the first call to {@link AverageFreeMemoryMetric#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 bf886ec0..eff44f0a 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 @@ -79,8 +79,18 @@ public final class CostMetric extends BaseGeneratedEMFQuerySpecification) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * Inner class allowing the singleton instance of {@link CostMetric} 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()}. + * but rather at the first call to {@link CostMetric#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 fc90ef12..1cf09b0d 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 @@ -91,9 +91,20 @@ public final class CpsCost extends BaseGeneratedEMFQuerySpecification) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created + * Inner class allowing the singleton instance of {@link CpsCost} 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()}. + * but rather at the first call to {@link CpsCost#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index f475c9e9..04036e11 100644 --- 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 @@ -80,8 +80,18 @@ public final class CreateHostInstance extends BaseGeneratedEMFQuerySpecification @Override public Object get(final String parameterName) { - if ("HostType".equals(parameterName)) return this.fHostType; - return null; + switch(parameterName) { + case "HostType": return this.fHostType; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fHostType; + default: return null; + } } public HostType getHostType() { @@ -468,9 +478,9 @@ public final class CreateHostInstance extends BaseGeneratedEMFQuerySpecification } /** - * 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 + * Inner class allowing the singleton instance of {@link CreateHostInstance} 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()}. + * but rather at the first call to {@link CreateHostInstance#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index cfed0c4b..1ed6c9cc 100644 --- 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 @@ -86,8 +86,18 @@ public final class GuidanceObjective extends BaseGeneratedEMFQuerySpecification< @Override public Object get(final String parameterName) { - if ("Value".equals(parameterName)) return this.fValue; - return null; + switch(parameterName) { + case "Value": return this.fValue; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fValue; + default: return null; + } } public Integer getValue() { @@ -476,9 +486,9 @@ public final class GuidanceObjective extends BaseGeneratedEMFQuerySpecification< } /** - * 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 + * Inner class allowing the singleton instance of {@link GuidanceObjective} 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()}. + * but rather at the first call to {@link GuidanceObjective#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index 14deb337..932501ff 100644 --- 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 @@ -88,9 +88,20 @@ public final class InstanceDoesNotSatisfyRequirement extends BaseGeneratedEMFQue @Override public Object get(final String parameterName) { - if ("Req".equals(parameterName)) return this.fReq; - if ("App".equals(parameterName)) return this.fApp; - return null; + switch(parameterName) { + case "Req": return this.fReq; + case "App": return this.fApp; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fReq; + case 1: return this.fApp; + default: return null; + } } public Requirement getReq() { @@ -623,9 +634,9 @@ public final class InstanceDoesNotSatisfyRequirement extends BaseGeneratedEMFQue } /** - * 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 + * Inner class allowing the singleton instance of {@link InstanceDoesNotSatisfyRequirement} 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()}. + * but rather at the first call to {@link InstanceDoesNotSatisfyRequirement#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 0c0d57a6..4077c103 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 @@ -85,8 +85,18 @@ public final class NotEnoughAvailableHdd extends BaseGeneratedEMFQuerySpecificat @Override public Object get(final String parameterName) { - if ("Host".equals(parameterName)) return this.fHost; - return null; + switch(parameterName) { + case "Host": return this.fHost; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fHost; + default: return null; + } } public HostInstance getHost() { @@ -475,9 +485,9 @@ public final class NotEnoughAvailableHdd extends BaseGeneratedEMFQuerySpecificat } /** - * 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 + * Inner class allowing the singleton instance of {@link NotEnoughAvailableHdd} 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()}. + * but rather at the first call to {@link NotEnoughAvailableHdd#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 9f091a95..6e52bee8 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 @@ -85,8 +85,18 @@ public final class NotEnoughAvailableMemory extends BaseGeneratedEMFQuerySpecifi @Override public Object get(final String parameterName) { - if ("Host".equals(parameterName)) return this.fHost; - return null; + switch(parameterName) { + case "Host": return this.fHost; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fHost; + default: return null; + } } public HostInstance getHost() { @@ -475,9 +485,9 @@ public final class NotEnoughAvailableMemory extends BaseGeneratedEMFQuerySpecifi } /** - * 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 + * Inner class allowing the singleton instance of {@link NotEnoughAvailableMemory} 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()}. + * but rather at the first call to {@link NotEnoughAvailableMemory#instance()}. * *

    This workaround is required e.g. to support recursion. * diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RedundantInstancesOnSameHost.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RedundantInstancesOnSameHost.java index bbb55158..2a40ac57 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RedundantInstancesOnSameHost.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/RedundantInstancesOnSameHost.java @@ -86,8 +86,18 @@ public final class RedundantInstancesOnSameHost extends BaseGeneratedEMFQuerySpe @Override public Object get(final String parameterName) { - if ("Req".equals(parameterName)) return this.fReq; - return null; + switch(parameterName) { + case "Req": return this.fReq; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fReq; + default: return null; + } } public Requirement getReq() { @@ -479,9 +489,9 @@ public final class RedundantInstancesOnSameHost extends BaseGeneratedEMFQuerySpe } /** - * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RedundantInstancesOnSameHost (visibility: PUBLIC, simpleName: RedundantInstancesOnSameHost, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RedundantInstancesOnSameHost, 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 + * Inner class allowing the singleton instance of {@link RedundantInstancesOnSameHost} 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.RedundantInstancesOnSameHost (visibility: PUBLIC, simpleName: RedundantInstancesOnSameHost, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.RedundantInstancesOnSameHost, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}. + * but rather at the first call to {@link RedundantInstancesOnSameHost#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index 1141e898..ed3c903c 100644 --- 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 @@ -79,8 +79,18 @@ public final class RemoveHostInstance extends BaseGeneratedEMFQuerySpecification @Override public Object get(final String parameterName) { - if ("HostInstance".equals(parameterName)) return this.fHostInstance; - return null; + switch(parameterName) { + case "HostInstance": return this.fHostInstance; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fHostInstance; + default: return null; + } } public HostInstance getHostInstance() { @@ -466,9 +476,9 @@ public final class RemoveHostInstance extends BaseGeneratedEMFQuerySpecification } /** - * 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 + * Inner class allowing the singleton instance of {@link RemoveHostInstance} 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()}. + * but rather at the first call to {@link RemoveHostInstance#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index 04066c50..eaceec5f 100644 --- 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 @@ -90,8 +90,18 @@ public final class RequirementNotSatisfied extends BaseGeneratedEMFQuerySpecific @Override public Object get(final String parameterName) { - if ("Req".equals(parameterName)) return this.fReq; - return null; + switch(parameterName) { + case "Req": return this.fReq; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fReq; + default: return null; + } } public Requirement getReq() { @@ -481,9 +491,9 @@ public final class RequirementNotSatisfied extends BaseGeneratedEMFQuerySpecific } /** - * 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 + * Inner class allowing the singleton instance of {@link RequirementNotSatisfied} 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()}. + * but rather at the first call to {@link RequirementNotSatisfied#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index db7710f5..23b578ea 100644 --- 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 @@ -87,10 +87,22 @@ public final class ResourceRequirement extends BaseGeneratedEMFQuerySpecificatio @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; + switch(parameterName) { + case "Host": return this.fHost; + case "App": return this.fApp; + case "Req": return this.fReq; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fHost; + case 1: return this.fApp; + case 2: return this.fReq; + default: return null; + } } public HostInstance getHost() { @@ -721,9 +733,9 @@ public final class ResourceRequirement extends BaseGeneratedEMFQuerySpecificatio } /** - * 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 + * Inner class allowing the singleton instance of {@link ResourceRequirement} 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()}. + * but rather at the first call to {@link ResourceRequirement#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index ccc0ba22..9f3d74b6 100644 --- 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 @@ -77,8 +77,18 @@ public final class UnallocateAppInstance extends BaseGeneratedEMFQuerySpecificat @Override public Object get(final String parameterName) { - if ("App".equals(parameterName)) return this.fApp; - return null; + switch(parameterName) { + case "App": return this.fApp; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fApp; + default: return null; + } } public ApplicationInstance getApp() { @@ -464,9 +474,9 @@ public final class UnallocateAppInstance extends BaseGeneratedEMFQuerySpecificat } /** - * 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 + * Inner class allowing the singleton instance of {@link UnallocateAppInstance} 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()}. + * but rather at the first call to {@link UnallocateAppInstance#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index 7d07b83a..8a150288 100644 --- 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 @@ -68,9 +68,9 @@ public final class AvailableHdd extends BaseGeneratedEMFQuerySpecificationWithGe } /** - * 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 + * Inner class allowing the singleton instance of {@link AvailableHdd} 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()}. + * but rather at the first call to {@link AvailableHdd#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index b06544d5..c89872e6 100644 --- 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 @@ -68,9 +68,9 @@ public final class AvailableMemory extends BaseGeneratedEMFQuerySpecificationWit } /** - * 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 + * Inner class allowing the singleton instance of {@link AvailableMemory} 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()}. + * but rather at the first call to {@link AvailableMemory#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index 23867558..fe115086 100644 --- 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 @@ -57,9 +57,9 @@ public final class CpsApplications extends BaseGeneratedEMFQuerySpecificationWit } /** - * 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 + * Inner class allowing the singleton instance of {@link CpsApplications} 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()}. + * but rather at the first call to {@link CpsApplications#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index e55bddff..cea8c097 100644 --- 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 @@ -57,9 +57,9 @@ public final class CpsHosts extends BaseGeneratedEMFQuerySpecificationWithGeneri } /** - * 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 + * Inner class allowing the singleton instance of {@link CpsHosts} 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()}. + * but rather at the first call to {@link CpsHosts#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 c24f46a1..ed5c9cda 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 @@ -66,9 +66,9 @@ public final class FreeHddPercentage extends BaseGeneratedEMFQuerySpecificationW } /** - * 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 + * Inner class allowing the singleton instance of {@link FreeHddPercentage} 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()}. + * but rather at the first call to {@link FreeHddPercentage#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 c2bb2bb3..b5923ba9 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 @@ -66,9 +66,9 @@ public final class FreeMemoryPercentage extends BaseGeneratedEMFQuerySpecificati } /** - * 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 + * Inner class allowing the singleton instance of {@link FreeMemoryPercentage} 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()}. + * but rather at the first call to {@link FreeMemoryPercentage#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 68448930..4e6a2d10 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 @@ -62,9 +62,9 @@ public final class HddRequirement extends BaseGeneratedEMFQuerySpecificationWith } /** - * 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 + * Inner class allowing the singleton instance of {@link HddRequirement} 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()}. + * but rather at the first call to {@link HddRequirement#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 db7f7021..429817ce 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 @@ -62,9 +62,9 @@ public final class HostInstanceCost extends BaseGeneratedEMFQuerySpecificationWi } /** - * 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 + * Inner class allowing the singleton instance of {@link HostInstanceCost} 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()}. + * but rather at the first call to {@link HostInstanceCost#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 d15f9bfa..98924467 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 @@ -62,9 +62,9 @@ public final class MemoryRequirement extends BaseGeneratedEMFQuerySpecificationW } /** - * 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 + * Inner class allowing the singleton instance of {@link MemoryRequirement} 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()}. + * but rather at the first call to {@link MemoryRequirement#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index 50597805..155ed09b 100644 --- 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 @@ -60,9 +60,9 @@ public final class NoHostToAllocateTo extends BaseGeneratedEMFQuerySpecification } /** - * 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 + * Inner class allowing the singleton instance of {@link NoHostToAllocateTo} 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()}. + * but rather at the first call to {@link NoHostToAllocateTo#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index dc76cbde..ffce9148 100644 --- 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 @@ -68,9 +68,9 @@ public final class RequiredAppInstances extends BaseGeneratedEMFQuerySpecificati } /** - * 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 + * Inner class allowing the singleton instance of {@link RequiredAppInstances} 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()}. + * but rather at the first call to {@link RequiredAppInstances#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index 4285101c..dea68f94 100644 --- 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 @@ -59,9 +59,9 @@ public final class SatisfyingInstance extends BaseGeneratedEMFQuerySpecification } /** - * 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 + * Inner class allowing the singleton instance of {@link SatisfyingInstance} 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()}. + * but rather at the first call to {@link SatisfyingInstance#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index f250f76d..efa13033 100644 --- 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 @@ -59,9 +59,9 @@ public final class TotalHdd extends BaseGeneratedEMFQuerySpecificationWithGeneri } /** - * 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 + * Inner class allowing the singleton instance of {@link TotalHdd} 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()}. + * but rather at the first call to {@link TotalHdd#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index aecd97e2..2fe3e741 100644 --- 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 @@ -59,9 +59,9 @@ public final class TotalMemory extends BaseGeneratedEMFQuerySpecificationWithGen } /** - * 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 + * Inner class allowing the singleton instance of {@link TotalMemory} 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()}. + * but rather at the first call to {@link TotalMemory#instance()}. * *

    This workaround is required e.g. to support recursion. * 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 index a20b534c..66b315f4 100644 --- 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 @@ -59,9 +59,9 @@ public final class UnallocatedAppInstance extends BaseGeneratedEMFQuerySpecifica } /** - * 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 + * Inner class allowing the singleton instance of {@link UnallocatedAppInstance} 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()}. + * but rather at the first call to {@link UnallocatedAppInstance#instance()}. * *

    This workaround is required e.g. to support recursion. * diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/CpsMdeOptimiserMain.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/CpsMdeOptimiserMain.xtend deleted file mode 100644 index 4a4b7a87..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/CpsMdeOptimiserMain.xtend +++ /dev/null @@ -1,57 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo - -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 java.util.Map -import org.eclipse.emf.common.util.URI -import org.eclipse.emf.ecore.EPackage -import org.eclipse.emf.ecore.resource.Resource -import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl -import uk.ac.kcl.inf.mdeoptimiser.interfaces.cli.Run - -class CpsMdeOptimiserMain { - static val PROJECT_PATH = "." - static val PROBLEM_PATH = "model/problem.xmi" - static val MOPT_PATH = "src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/cps.mopt" - - private new() { - new IllegalStateException("This is a static utility class and should not be instantiated directly.") - } - - public 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 - problem.eResource.URI = URI.createFileURI(PROBLEM_PATH) - problem.eResource.save(emptyMap) - fixupHenshinModel("model/cps.henshin", "model/cps_fixup.henshin", #{"cps.ecore" -> CpsPackage.eNS_URI}) - Run.main(#["-p", PROJECT_PATH, "-m", MOPT_PATH]) - } - - private def static void fixupHenshinModel(String originalPath, String outputPath, Map remapMap) { - val reader = new BufferedReader(new FileReader(originalPath)) - try { - val writer = new BufferedWriter(new FileWriter(outputPath)) - try { - var String line - while ((line = reader.readLine) !== null) { - for (entry : remapMap.entrySet) { - line = line.replace(entry.key, entry.value) - } - writer.write(line) - writer.write("\n") - } - } finally { - writer.close - } - } finally { - reader.close - } - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.xtend deleted file mode 100644 index 1a9286b3..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NonRedundantAllocationsConstraint.xtend +++ /dev/null @@ -1,29 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo - -import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution -import com.google.common.collect.HashMultiset - -class NonRedundantAllocationsConstraint implements IGuidanceFunction { - override getName() { - "NonRedundantAllocations" - } - - override computeFitness(Solution solution) { - val cps = solution.model as CyberPhysicalSystem - var int cost = 0 - for (hostType : cps.hostTypes) { - for (host : hostType.instances) { - val bins = HashMultiset.create - for (app : host.applications) { - bins.add(app.requirement) - } - for (entry : bins.entrySet) { - cost += entry.count - 1 - } - } - } - cost - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotAllocatedAppInstancesConstraint.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotAllocatedAppInstancesConstraint.xtend deleted file mode 100644 index 663aa26c..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotAllocatedAppInstancesConstraint.xtend +++ /dev/null @@ -1,24 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo - -import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution - -class NotAllocatedAppInstancesConstraint implements IGuidanceFunction { - override getName() { - "NotAllocatedAppInstances" - } - - override computeFitness(Solution solution) { - val cps = solution.model as CyberPhysicalSystem - var int cost = 0 - for (appType : cps.applicationTypes) { - for (app : appType.instances) { - if (app.allocatedTo === null || !appType.requirements.exists[hostType == app.allocatedTo.type]) { - cost++ - } - } - } - cost - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotSatisfiedRequirementsConstraint.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotSatisfiedRequirementsConstraint.xtend deleted file mode 100644 index e44381ec..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/NotSatisfiedRequirementsConstraint.xtend +++ /dev/null @@ -1,27 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo - -import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution - -class NotSatisfiedRequirementsConstraint implements IGuidanceFunction { - override getName() { - "NotSatisfiedRequirements" - } - - override computeFitness(Solution solution) { - val cps = solution.model as CyberPhysicalSystem - var int cost = 0 - for (request : cps.requests) { - for (requirement : request.requirements) { - cost += Math.abs(requirement.count - requirement.instances.size) - for (app : requirement.instances) { - if (app.type != requirement.type) { - cost++ - } - } - } - } - cost - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/ResourceUtilizationUtil.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/ResourceUtilizationUtil.xtend deleted file mode 100644 index fc1d666f..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/ResourceUtilizationUtil.xtend +++ /dev/null @@ -1,31 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo - -import hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance - -class ResourceUtilizationUtil { - private new() { - new IllegalStateException("This is a static utility class and should not be instantiated directly.") - } - - static def getMemoryUtilization(HostInstance host) { - var int utilization = 0 - for (app : host.applications) { - val req = app.type.requirements.findFirst[hostType == host.type] - if (req !== null) { - utilization += req.requiredMemory - } - } - utilization - } - - static def getHddUtilization(HostInstance host) { - var int utilization = 0 - for (app : host.applications) { - val req = app.type.requirements.findFirst[hostType == host.type] - if (req !== null) { - utilization += req.requiredHdd - } - } - utilization - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageHddConstraint.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageHddConstraint.xtend deleted file mode 100644 index 85cc8115..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageHddConstraint.xtend +++ /dev/null @@ -1,33 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo - -import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution - -class TooLowAverageHddConstraint implements IGuidanceFunction { - static val THRESHOLD = 0.25 - - override getName() { - "TooLowAverageHdd" - } - - override computeFitness(Solution solution) { - val cps = solution.model as CyberPhysicalSystem - var double sumUtilization - var int numHosts - for (hostType : cps.hostTypes) { - numHosts += hostType.instances.size - for (host : hostType.instances) { - val utilization = ResourceUtilizationUtil.getHddUtilization(host) - sumUtilization += (utilization as double) / hostType.defaultHdd - } - } - val averageUtilization = sumUtilization / numHosts - val difference = THRESHOLD - averageUtilization - if (difference > 0) { - difference - } else { - 0 - } - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageMemoryConstraint.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageMemoryConstraint.xtend deleted file mode 100644 index e9b47d4c..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TooLowAverageMemoryConstraint.xtend +++ /dev/null @@ -1,33 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo - -import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution - -class TooLowAverageMemoryConstraint implements IGuidanceFunction { - static val THRESHOLD = 0.25 - - override getName() { - "TooLowAverageMemory" - } - - override computeFitness(Solution solution) { - val cps = solution.model as CyberPhysicalSystem - var double sumUtilization - var int numHosts - for (hostType : cps.hostTypes) { - numHosts += hostType.instances.size - for (host : hostType.instances) { - val utilization = ResourceUtilizationUtil.getMemoryUtilization(host) - sumUtilization += (utilization as double) / hostType.defaultMemory - } - } - val averageUtilization = sumUtilization / numHosts - val difference = THRESHOLD - averageUtilization - if (difference > 0) { - difference - } else { - 0 - } - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TotalCostFitnessFunction.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TotalCostFitnessFunction.xtend deleted file mode 100644 index af65e442..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/TotalCostFitnessFunction.xtend +++ /dev/null @@ -1,23 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo - -import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution - -class TotalCostFitnessFunction implements IGuidanceFunction { - override getName() { - "TotalCost" - } - - override computeFitness(Solution solution) { - val cps = solution.model as CyberPhysicalSystem - var int cost = 0 - for (appType : cps.applicationTypes) { - cost += 5 * appType.instances.size - } - for (hostType : cps.hostTypes) { - cost += hostType.cost * hostType.instances.size - } - cost - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableHddConstraint.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableHddConstraint.xtend deleted file mode 100644 index 08450f45..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableHddConstraint.xtend +++ /dev/null @@ -1,27 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo - -import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution - -class UnavailableHddConstraint implements IGuidanceFunction { - override getName() { - "UnavailableHdd" - } - - override computeFitness(Solution solution) { - val cps = solution.model as CyberPhysicalSystem - var int cost = 0 - for (hostType : cps.hostTypes) { - for (host : hostType.instances) { - val utilization = ResourceUtilizationUtil.getHddUtilization(host) - val difference = utilization - hostType.defaultHdd - if (difference > 0) { - cost += difference - } - } - } - cost - } - -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.xtend deleted file mode 100644 index e46d59a6..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/UnavailableMemoryConstraint.xtend +++ /dev/null @@ -1,27 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.cps.mdeo - -import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution - -class UnavailableMemoryConstraint implements IGuidanceFunction { - override getName() { - "UnavailableMemory" - } - - override computeFitness(Solution solution) { - val cps = solution.model as CyberPhysicalSystem - var int cost = 0 - for (hostType : cps.hostTypes) { - for (host : hostType.instances) { - val utilization = ResourceUtilizationUtil.getMemoryUtilization(host) - val difference = utilization - hostType.defaultMemory - if (difference > 0) { - cost += difference - } - } - } - cost - } - -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/cps.mopt b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/cps.mopt deleted file mode 100644 index 67fe7508..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/mdeo/cps.mopt +++ /dev/null @@ -1,43 +0,0 @@ -problem { - basepath - metamodel - model -} - -goal { - objective TotalCost minimise java { "hu.bme.mit.inf.dslreasoner.domains.cps.mdeo.TotalCostFitnessFunction" } - constraint NotSatisfiedRequriements java { "hu.bme.mit.inf.dslreasoner.domains.cps.mdeo.NotSatisfiedRequirementsConstraint" } - constraint NotAllocatedAppInstances java { "hu.bme.mit.inf.dslreasoner.domains.cps.mdeo.NotAllocatedAppInstancesConstraint" } - constraint NonRedundantAllocations java { "hu.bme.mit.inf.dslreasoner.domains.cps.mdeo.NonRedundantAllocationsConstraint" } - constraint UnavailableMemory java { "hu.bme.mit.inf.dslreasoner.domains.cps.mdeo.UnavailableMemoryConstraint" } - constraint UnavailableHdd java { "hu.bme.mit.inf.dslreasoner.domains.cps.mdeo.UnavailableHddConstraint" } - constraint TooLowAverageMemory java { "hu.bme.mit.inf.dslreasoner.domains.cps.mdeo.TooLowAverageMemoryConstraint" } - constraint TooLowAverageHdd java { "hu.bme.mit.inf.dslreasoner.domains.cps.mdeo.TooLowAverageHddConstraint" } -} - -search { -// mutate using unit "createAppInstance" -// mutate using unit "deleteAppInstance" -// mutate using unit "createHostInstance" -// mutate using unit "deleteHostInstance" -// mutate using unit "allocate" -// mutate using unit "unallocate" -// mutate using unit "reallocate" - mutate { "ApplicationInstance" } - mutate { "HostInstance" } -} - -solver { - optimisation provider moea algorithm NSGAII { - variation: mutation - population: 25 - mutation.step: 3 - mutation.strategy: random - } - - termination { - time: 120 - } - - batches 1 -} -- cgit v1.2.3-54-g00ecf