diff options
Diffstat (limited to 'subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/basicdeferred/RelationEvaluation.java')
-rw-r--r-- | subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/basicdeferred/RelationEvaluation.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/basicdeferred/RelationEvaluation.java b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/basicdeferred/RelationEvaluation.java new file mode 100644 index 00000000..336a83fb --- /dev/null +++ b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/basicdeferred/RelationEvaluation.java | |||
@@ -0,0 +1,57 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2022, Tamas Szabo, GitHub | ||
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 | *******************************************************************************/ | ||
9 | package tools.refinery.viatra.runtime.matchers.psystem.basicdeferred; | ||
10 | |||
11 | import java.util.List; | ||
12 | |||
13 | import tools.refinery.viatra.runtime.matchers.psystem.EnumerablePConstraint; | ||
14 | import tools.refinery.viatra.runtime.matchers.psystem.IMultiQueryReference; | ||
15 | import tools.refinery.viatra.runtime.matchers.psystem.IRelationEvaluator; | ||
16 | import tools.refinery.viatra.runtime.matchers.psystem.PBody; | ||
17 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PQuery; | ||
18 | import tools.refinery.viatra.runtime.matchers.tuple.Tuple; | ||
19 | |||
20 | /** | ||
21 | * A constraint which prescribes the evaluation of custom Java logic that takes an arbitrary number of input relations | ||
22 | * and produces one output relation. Contrast this to {@link ExpressionEvaluation}, which produces a single output value | ||
23 | * given an input tuple. | ||
24 | * | ||
25 | * The assumption is that the relation evaluation logic is not incremental, that is, it can only perform from-scratch | ||
26 | * computation of the output relation given the complete input relations. To this end, the relation evaluator always | ||
27 | * receives the complete input relations with all their contents as input. However, the evaluator engine makes sure that | ||
28 | * the output of the relation evaluation is at least "seemingly" incremental. This means that the underlying computation | ||
29 | * network computes the delta on the output compared to the previous output and only propagates the delta further. | ||
30 | * | ||
31 | * @author Tamas Szabo | ||
32 | * | ||
33 | * @since 2.8 | ||
34 | * | ||
35 | */ | ||
36 | public class RelationEvaluation extends EnumerablePConstraint implements IMultiQueryReference { | ||
37 | |||
38 | private final IRelationEvaluator evaluator; | ||
39 | private final List<PQuery> inputQueries; | ||
40 | |||
41 | public RelationEvaluation(final PBody body, final Tuple variablesTuple, final List<PQuery> inputQueries, | ||
42 | final IRelationEvaluator evaluator) { | ||
43 | super(body, variablesTuple); | ||
44 | this.evaluator = evaluator; | ||
45 | this.inputQueries = inputQueries; | ||
46 | } | ||
47 | |||
48 | public IRelationEvaluator getEvaluator() { | ||
49 | return this.evaluator; | ||
50 | } | ||
51 | |||
52 | @Override | ||
53 | public List<PQuery> getReferredQueries() { | ||
54 | return this.inputQueries; | ||
55 | } | ||
56 | |||
57 | } | ||