aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/CompiledSubPlan.java
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <marussy@mit.bme.hu>2023-09-14 19:29:36 +0200
committerLibravatar GitHub <noreply@github.com>2023-09-14 19:29:36 +0200
commit98ed3b6db5f4e51961a161050cc31c66015116e8 (patch)
tree8bfd6d9bc8d6ed23b9eb0f889dd40b6c24fe8f92 /subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/CompiledSubPlan.java
parentMerge pull request #38 from nagilooh/design-space-exploration (diff)
parentMerge remote-tracking branch 'upstream/main' into partial-interpretation (diff)
downloadrefinery-98ed3b6db5f4e51961a161050cc31c66015116e8.tar.gz
refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.tar.zst
refinery-98ed3b6db5f4e51961a161050cc31c66015116e8.zip
Merge pull request #39 from kris7t/partial-interpretation
Implement partial interpretation based model generation
Diffstat (limited to 'subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/CompiledSubPlan.java')
-rw-r--r--subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/CompiledSubPlan.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/CompiledSubPlan.java b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/CompiledSubPlan.java
new file mode 100644
index 00000000..572e943c
--- /dev/null
+++ b/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/traceability/CompiledSubPlan.java
@@ -0,0 +1,51 @@
1/*******************************************************************************
2 * Copyright (c) 2010-2014, Bergmann Gabor, Istvan Rath and Daniel Varro
3 * This program and the accompanying materials are made available under the
4 * terms of the Eclipse Public License v. 2.0 which is available at
5 * http://www.eclipse.org/legal/epl-v20.html.
6 *
7 * SPDX-License-Identifier: EPL-2.0
8 *******************************************************************************/
9package tools.refinery.viatra.runtime.rete.traceability;
10
11import java.util.Arrays;
12import java.util.Collection;
13import java.util.HashSet;
14import java.util.List;
15import java.util.Set;
16import java.util.stream.Collectors;
17
18import tools.refinery.viatra.runtime.matchers.planning.SubPlan;
19import tools.refinery.viatra.runtime.matchers.psystem.PVariable;
20import tools.refinery.viatra.runtime.matchers.util.Preconditions;
21import tools.refinery.viatra.runtime.rete.recipes.ReteNodeRecipe;
22
23/**
24 * A trace marker associating a Rete recipe with a query SubPlan.
25 *
26 * <p> The Rete node represented by the recipe is equivalent to the SubPlan.
27 * <p> Invariant: each variable has at most one index associated with it in the tuple, i.e. no duplicates.
28 */
29public class CompiledSubPlan extends PlanningTrace {
30
31 public CompiledSubPlan(SubPlan subPlan, List<PVariable> variablesTuple,
32 ReteNodeRecipe recipe,
33 Collection<? extends RecipeTraceInfo> parentRecipeTraces) {
34 super(subPlan, variablesTuple, recipe, parentRecipeTraces);
35
36 // Make sure that each variable occurs only once
37 Set<PVariable> variablesSet = new HashSet<PVariable>(variablesTuple);
38 Preconditions.checkState(variablesSet.size() == variablesTuple.size(),
39 () -> String.format(
40 "Illegal column duplication (%s) while the query plan %s was compiled into a Rete Recipe %s",
41 variablesTuple.stream().map(PVariable::getName).collect(Collectors.joining(",")),
42 subPlan.toShortString(), recipe));
43 }
44
45 public CompiledSubPlan(SubPlan subPlan, List<PVariable> variablesTuple,
46 ReteNodeRecipe recipe,
47 RecipeTraceInfo... parentRecipeTraces) {
48 this(subPlan, variablesTuple, recipe, Arrays.asList(parentRecipeTraces));
49 }
50
51}