diff options
author | 2023-11-03 02:03:56 +0100 | |
---|---|---|
committer | 2023-11-03 02:03:56 +0100 | |
commit | eddf21f4b583fecb982c2c2f4ee733ee156371d7 (patch) | |
tree | b22730c84e63e6c32fc498edae6d565b7cadced9 /subprojects/language-semantics/src/main/java | |
parent | refactor(interpreter): aggreagator batching (diff) | |
download | refinery-eddf21f4b583fecb982c2c2f4ee733ee156371d7.tar.gz refinery-eddf21f4b583fecb982c2c2f4ee733ee156371d7.tar.zst refinery-eddf21f4b583fecb982c2c2f4ee733ee156371d7.zip |
feat: model generator facade
Diffstat (limited to 'subprojects/language-semantics/src/main/java')
-rw-r--r-- | subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/model/ModelInitializer.java | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/model/ModelInitializer.java b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/model/ModelInitializer.java index 85c8d701..a0081041 100644 --- a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/model/ModelInitializer.java +++ b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/model/ModelInitializer.java | |||
@@ -104,9 +104,8 @@ public class ModelInitializer { | |||
104 | return metamodel; | 104 | return metamodel; |
105 | } | 105 | } |
106 | 106 | ||
107 | public ModelSeed createModel(Problem problem, ModelStoreBuilder storeBuilder) { | 107 | public void readProblem(Problem problem) { |
108 | this.problem = problem; | 108 | this.problem = problem; |
109 | this.storeBuilder = storeBuilder; | ||
110 | builtinSymbols = desugarer.getBuiltinSymbols(problem).orElseThrow(() -> new IllegalArgumentException( | 109 | builtinSymbols = desugarer.getBuiltinSymbols(problem).orElseThrow(() -> new IllegalArgumentException( |
111 | "Problem has no builtin library")); | 110 | "Problem has no builtin library")); |
112 | var nodeInfo = collectPartialRelation(builtinSymbols.node(), 1, TruthValue.TRUE, TruthValue.TRUE); | 111 | var nodeInfo = collectPartialRelation(builtinSymbols.node(), 1, TruthValue.TRUE, TruthValue.TRUE); |
@@ -129,8 +128,6 @@ public class ModelInitializer { | |||
129 | collectMetamodel(); | 128 | collectMetamodel(); |
130 | metamodel = metamodelBuilder.build(); | 129 | metamodel = metamodelBuilder.build(); |
131 | collectAssertions(); | 130 | collectAssertions(); |
132 | storeBuilder.with(new MultiObjectTranslator()); | ||
133 | storeBuilder.with(new MetamodelTranslator(metamodel)); | ||
134 | relationTrace = new LinkedHashMap<>(relationInfoMap.size()); | 131 | relationTrace = new LinkedHashMap<>(relationInfoMap.size()); |
135 | int nodeCount = getNodeCount(); | 132 | int nodeCount = getNodeCount(); |
136 | var modelSeedBuilder = ModelSeed.builder(nodeCount); | 133 | var modelSeedBuilder = ModelSeed.builder(nodeCount); |
@@ -142,17 +139,32 @@ public class ModelInitializer { | |||
142 | modelSeedBuilder.seed(partialRelation, info.toSeed(nodeCount)); | 139 | modelSeedBuilder.seed(partialRelation, info.toSeed(nodeCount)); |
143 | } | 140 | } |
144 | collectScopes(); | 141 | collectScopes(); |
142 | modelSeedBuilder.seed(MultiObjectTranslator.COUNT_SYMBOL, builder -> builder | ||
143 | .reducedValue(CardinalityIntervals.SET) | ||
144 | .putAll(countSeed)); | ||
145 | modelSeed = modelSeedBuilder.build(); | ||
146 | } | ||
147 | |||
148 | public void configureStoreBuilder(ModelStoreBuilder storeBuilder) { | ||
149 | this.storeBuilder = storeBuilder; | ||
150 | storeBuilder.with(new MultiObjectTranslator()); | ||
151 | storeBuilder.with(new MetamodelTranslator(metamodel)); | ||
145 | if (scopePropagator != null) { | 152 | if (scopePropagator != null) { |
146 | if (storeBuilder.tryGetAdapter(PropagationBuilder.class).isEmpty()) { | 153 | if (storeBuilder.tryGetAdapter(PropagationBuilder.class).isEmpty()) { |
147 | throw new TracedException(problem, "Type scopes require a PropagationBuilder"); | 154 | throw new TracedException(problem, "Type scopes require a PropagationBuilder"); |
148 | } | 155 | } |
149 | storeBuilder.with(scopePropagator); | 156 | storeBuilder.with(scopePropagator); |
150 | } | 157 | } |
151 | modelSeedBuilder.seed(MultiObjectTranslator.COUNT_SYMBOL, builder -> builder | ||
152 | .reducedValue(CardinalityIntervals.SET) | ||
153 | .putAll(countSeed)); | ||
154 | modelSeed = modelSeedBuilder.build(); | ||
155 | collectPredicates(); | 158 | collectPredicates(); |
159 | } | ||
160 | |||
161 | public ModelSeed createModel(Problem problem, ModelStoreBuilder storeBuilder) { | ||
162 | readProblem(problem); | ||
163 | configureStoreBuilder(storeBuilder); | ||
164 | return getModelSeed(); | ||
165 | } | ||
166 | |||
167 | public ModelSeed getModelSeed() { | ||
156 | return modelSeed; | 168 | return modelSeed; |
157 | } | 169 | } |
158 | 170 | ||