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 --- .../domains/satellite/queries/CostMetric.java | 544 ++++++++++++++++++++ .../domains/satellite/queries/CoverageMetric.java | 552 +++++++++++++++++++++ .../satellite/queries/SatelliteQueries.java | 33 ++ .../domains/satellite/queries/TimeMetric.java | 544 ++++++++++++++++++++ .../internal/AdditionalCommSubsystemCost.java | 173 +++++++ .../satellite/queries/internal/BasePrice.java | 195 ++++++++ .../satellite/queries/internal/IncomingData.java | 145 ++++++ .../internal/InterferometryPayloadCost.java | 175 +++++++ .../satellite/queries/internal/MissionCost.java | 183 +++++++ .../queries/internal/MissionCoverage.java | 183 +++++++ .../satellite/queries/internal/MissionTime.java | 183 +++++++ .../queries/internal/SatelliteQueriesAll.java | 48 ++ .../satellite/queries/internal/ScienceData.java | 179 +++++++ .../satellite/queries/internal/SpacecraftCost.java | 209 ++++++++ .../queries/internal/SpacecraftUplink.java | 171 +++++++ .../internal/SpacecraftWithTwoCommSubsystems.java | 146 ++++++ .../satellite/queries/internal/TransmitRate.java | 277 +++++++++++ .../satellite/queries/internal/TransmitTime.java | 200 ++++++++ 18 files changed, 4140 insertions(+) create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CostMetric.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CoverageMetric.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/TimeMetric.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/AdditionalCommSubsystemCost.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/BasePrice.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/IncomingData.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/InterferometryPayloadCost.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCost.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionCoverage.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/MissionTime.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/ScienceData.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftCost.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftUplink.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/SpacecraftWithTwoCommSubsystems.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitRate.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/internal/TransmitTime.java (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu') diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CostMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CostMetric.java new file mode 100644 index 00000000..474719b2 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/CostMetric.java @@ -0,0 +1,544 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionCost; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

Original source: + *

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

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

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

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

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

Original source: + *

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

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

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

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

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

Original source: + *

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

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

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

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

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

Original source: + *

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

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

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

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

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

  • cubeSatWithKaAntenna
  • *
  • smallSat
  • *
  • spacecraftOfKind
  • + *
  • coverageMetric
  • + *
  • timeMetric
  • + *
  • costMetric
  • * * * @see IQueryGroup @@ -80,6 +86,9 @@ public final class SatelliteQueries extends BaseGeneratedPatternGroup { querySpecifications.add(CubeSatWithKaAntenna.instance()); querySpecifications.add(SmallSat.instance()); querySpecifications.add(SpacecraftOfKind.instance()); + querySpecifications.add(CoverageMetric.instance()); + querySpecifications.add(TimeMetric.instance()); + querySpecifications.add(CostMetric.instance()); } public CommunicationLinkDoesNotStartAtContainingElement getCommunicationLinkDoesNotStartAtContainingElement() { @@ -193,4 +202,28 @@ public final class SatelliteQueries extends BaseGeneratedPatternGroup { public SpacecraftOfKind.Matcher getSpacecraftOfKind(final ViatraQueryEngine engine) { return SpacecraftOfKind.Matcher.on(engine); } + + public CoverageMetric getCoverageMetric() { + return CoverageMetric.instance(); + } + + public CoverageMetric.Matcher getCoverageMetric(final ViatraQueryEngine engine) { + return CoverageMetric.Matcher.on(engine); + } + + public TimeMetric getTimeMetric() { + return TimeMetric.instance(); + } + + public TimeMetric.Matcher getTimeMetric(final ViatraQueryEngine engine) { + return TimeMetric.Matcher.on(engine); + } + + public CostMetric getCostMetric() { + return CostMetric.instance(); + } + + public CostMetric.Matcher getCostMetric(final ViatraQueryEngine engine) { + return CostMetric.Matcher.on(engine); + } } diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/TimeMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/TimeMetric.java new file mode 100644 index 00000000..45d4cc35 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src-gen/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/TimeMetric.java @@ -0,0 +1,544 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.satellite.queries; + +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.MissionTime; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.matchers.aggregators.sum; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

    Original source: + *

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

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

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

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

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

    Original source: + *

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

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

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

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

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

    Original source: + *

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

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

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

    Original source: + *

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

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

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

    Original source: + *

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

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

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

    Original source: + *

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

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

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

    Original source: + *

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

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

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

    Original source: + *

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

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

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

    Original source: + *

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

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

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

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

    Original source: + *

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

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

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

    Original source: + *

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

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

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

    Original source: + *

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

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

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

    Original source: + *

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

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

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

    Original source: + *

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

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

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

    Original source: + *

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

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

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final TransmitTime.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_Mission = new PParameter("Mission", "satellite.InterferometryMission", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "InterferometryMission")), PParameterDirection.INOUT); + + private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT); + + private final PParameter parameter_TransmitTime = new PParameter("TransmitTime", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_Mission, parameter_Spacecraft, parameter_TransmitTime); + + private GeneratedPQuery() { + super(PVisibility.PRIVATE); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.transmitTime"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("Mission","Spacecraft","TransmitTime"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_Mission = body.getOrCreateVariableByName("Mission"); + PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft"); + PVariable var_TransmitTime = body.getOrCreateVariableByName("TransmitTime"); + PVariable var_ScienceData = body.getOrCreateVariableByName("ScienceData"); + PVariable var_IncomingData = body.getOrCreateVariableByName("IncomingData"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + PVariable var_TransmitRate = body.getOrCreateVariableByName("TransmitRate"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "InterferometryMission"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new TypeFilterConstraint(body, Tuples.flatTupleOf(var_TransmitTime), new JavaTransitiveInstancesKey(java.lang.Double.class)); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_Mission, parameter_Mission), + new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft), + new ExportedParameter(body, var_TransmitTime, parameter_TransmitTime) + )); + // ConstellationMission.spacecraft(Mission, Spacecraft) + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "ConstellationMission"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_Mission, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "ConstellationMission", "spacecraft"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft"))); + new Equality(body, var__virtual_0_, var_Spacecraft); + // find scienceData(Spacecraft, ScienceData) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_ScienceData), ScienceData.instance().getInternalQueryRepresentation()); + // IncomingData == sum find incomingData(Spacecraft, _, #_) + PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); + new AggregatorConstraint(new sum().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var_Spacecraft, var___0_, var___1_), IncomingData.instance().getInternalQueryRepresentation(), var__virtual_1_, 2); + new Equality(body, var_IncomingData, var__virtual_1_); + // find transmitRate(Spacecraft, TransmitRate) + new PositivePatternCall(body, Tuples.flatTupleOf(var_Spacecraft, var_TransmitRate), TransmitRate.instance().getInternalQueryRepresentation()); + // TransmitTime == eval((ScienceData + IncomingData) / (7.5 * TransmitRate)) + PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); + new ExpressionEvaluation(body, new IExpressionEvaluator() { + + @Override + public String getShortDescription() { + return "Expression evaluation from pattern transmitTime"; + } + + @Override + public Iterable getInputParameterNames() { + return Arrays.asList("IncomingData", "ScienceData", "TransmitRate");} + + @Override + public Object evaluateExpression(IValueProvider provider) throws Exception { + Double IncomingData = (Double) provider.getValue("IncomingData"); + Double ScienceData = (Double) provider.getValue("ScienceData"); + Double TransmitRate = (Double) provider.getValue("TransmitRate"); + return evaluateExpression_1_1(IncomingData, ScienceData, TransmitRate); + } + }, var__virtual_2_ ); + new Equality(body, var_TransmitTime, var__virtual_2_); + bodies.add(body); + } + return bodies; + } + } + + private static double evaluateExpression_1_1(final Double IncomingData, final Double ScienceData, final Double TransmitRate) { + double _plus = DoubleExtensions.operator_plus(ScienceData, IncomingData); + double _divide = (_plus / (7.5 * (TransmitRate).doubleValue())); + return _divide; + } +} -- cgit v1.2.3-70-g09d2