diff options
Diffstat (limited to 'subprojects/store-dse/src/test/java/tools/refinery/store/dse/DesignSpaceExplorationTest.java')
-rw-r--r-- | subprojects/store-dse/src/test/java/tools/refinery/store/dse/DesignSpaceExplorationTest.java | 596 |
1 files changed, 0 insertions, 596 deletions
diff --git a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/DesignSpaceExplorationTest.java b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/DesignSpaceExplorationTest.java deleted file mode 100644 index f5f13433..00000000 --- a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/DesignSpaceExplorationTest.java +++ /dev/null | |||
@@ -1,596 +0,0 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.store.dse; | ||
7 | |||
8 | import tools.refinery.store.query.view.AnySymbolView; | ||
9 | import tools.refinery.store.query.view.KeyOnlyView; | ||
10 | import tools.refinery.store.representation.Symbol; | ||
11 | |||
12 | class DesignSpaceExplorationTest { | ||
13 | // private static final Symbol<Boolean> namedElement = Symbol.of("NamedElement", 1); | ||
14 | // private static final Symbol<Boolean> attribute = Symbol.of("Attribute", 1); | ||
15 | // private static final Symbol<Boolean> method = Symbol.of("Method", 1); | ||
16 | // private static final Symbol<Boolean> dataDependency = Symbol.of("DataDependency", 2); | ||
17 | // private static final Symbol<Boolean> functionalDependency = Symbol.of("FunctionalDependency", 2); | ||
18 | |||
19 | private static final Symbol<Boolean> classModel = Symbol.of("ClassModel", 1); | ||
20 | private static final Symbol<Boolean> classElement = Symbol.of("ClassElement", 1); | ||
21 | private static final Symbol<Boolean> feature = Symbol.of("Feature", 1); | ||
22 | |||
23 | private static final Symbol<Boolean> isEncapsulatedBy = Symbol.of("IsEncapsulatedBy", 2); | ||
24 | private static final Symbol<Boolean> encapsulates = Symbol.of("Encapsulates", 2); | ||
25 | |||
26 | private static final Symbol<Boolean> features = Symbol.of("Features", 2); | ||
27 | private static final Symbol<Boolean> classes = Symbol.of("Classes", 2); | ||
28 | |||
29 | private static final AnySymbolView classModelView = new KeyOnlyView<>(classModel); | ||
30 | private static final AnySymbolView classElementView = new KeyOnlyView<>(classElement); | ||
31 | private static final AnySymbolView featureView = new KeyOnlyView<>(feature); | ||
32 | private static final AnySymbolView isEncapsulatedByView = new KeyOnlyView<>(isEncapsulatedBy); | ||
33 | private static final AnySymbolView encapsulatesView = new KeyOnlyView<>(encapsulates); | ||
34 | private static final AnySymbolView featuresView = new KeyOnlyView<>(features); | ||
35 | private static final AnySymbolView classesView = new KeyOnlyView<>(classes); | ||
36 | |||
37 | // @Test | ||
38 | // void createObjectTest() { | ||
39 | // var store = ModelStore.builder() | ||
40 | // .with(ViatraModelQueryAdapter.builder()) | ||
41 | // .with(DesignSpaceExplorationAdapter.builder() | ||
42 | // .strategy(new DepthFirstStrategy().withDepthLimit(0))) | ||
43 | // .build(); | ||
44 | // | ||
45 | // var model = store.createEmptyModel(); | ||
46 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
47 | // | ||
48 | // assertEquals(0, dseAdapter.getModelSize()); | ||
49 | // | ||
50 | // var newModel = dseAdapter.createObject(); | ||
51 | // var newModelId = newModel.get(0); | ||
52 | // var newClass1 = dseAdapter.createObject(); | ||
53 | // var newClass1Id = newClass1.get(0); | ||
54 | // var newClass2 = dseAdapter.createObject(); | ||
55 | // var newClass2Id = newClass2.get(0); | ||
56 | // var newField = dseAdapter.createObject(); | ||
57 | // var newFieldId = newField.get(0); | ||
58 | // | ||
59 | // assertEquals(0, newModelId); | ||
60 | // assertEquals(1, newClass1Id); | ||
61 | // assertEquals(2, newClass2Id); | ||
62 | // assertEquals(3, newFieldId); | ||
63 | // assertEquals(4, dseAdapter.getModelSize()); | ||
64 | // } | ||
65 | |||
66 | // @Test | ||
67 | // void deleteMiddleObjectTest() { | ||
68 | // var store = ModelStore.builder() | ||
69 | // .with(ViatraModelQueryAdapter.builder()) | ||
70 | // .with(DesignSpaceExplorationAdapter.builder() | ||
71 | // .strategy(new DepthFirstStrategy())) | ||
72 | // .build(); | ||
73 | // | ||
74 | // var model = store.createEmptyModel(); | ||
75 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
76 | // | ||
77 | // assertEquals(0, dseAdapter.getModelSize()); | ||
78 | // | ||
79 | // var newObject0 = dseAdapter.createObject(); | ||
80 | // var newObject0Id = newObject0.get(0); | ||
81 | // var newObject1 = dseAdapter.createObject(); | ||
82 | // var newObject1Id = newObject1.get(0); | ||
83 | // var newObject2 = dseAdapter.createObject(); | ||
84 | // var newObject2Id = newObject2.get(0); | ||
85 | // var newObject3 = dseAdapter.createObject(); | ||
86 | // var newObject3Id = newObject3.get(0); | ||
87 | // | ||
88 | // assertEquals(0, newObject0Id); | ||
89 | // assertEquals(1, newObject1Id); | ||
90 | // assertEquals(2, newObject2Id); | ||
91 | // assertEquals(3, newObject3Id); | ||
92 | // assertEquals(4, dseAdapter.getModelSize()); | ||
93 | // | ||
94 | // dseAdapter.deleteObject(newObject1); | ||
95 | // assertEquals(4, dseAdapter.getModelSize()); | ||
96 | // | ||
97 | // var newObject4 = dseAdapter.createObject(); | ||
98 | // var newObject4Id = newObject4.get(0); | ||
99 | // assertEquals(4, newObject4Id); | ||
100 | // assertEquals(5, dseAdapter.getModelSize()); | ||
101 | // | ||
102 | // dseAdapter.deleteObject(newObject4); | ||
103 | // assertEquals(5, dseAdapter.getModelSize()); | ||
104 | // } | ||
105 | // | ||
106 | // @Test | ||
107 | // void DFSTrivialTest() { | ||
108 | // var store = ModelStore.builder() | ||
109 | // .symbols(classModel) | ||
110 | // .with(ViatraModelQueryAdapter.builder()) | ||
111 | // .with(DesignSpaceExplorationAdapter.builder() | ||
112 | // .strategy(new DepthFirstStrategy().withDepthLimit(0))) | ||
113 | // .build(); | ||
114 | // | ||
115 | // var model = store.createEmptyModel(); | ||
116 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
117 | // | ||
118 | // var states = dseAdapter.explore(); | ||
119 | // assertEquals(1, states.size()); | ||
120 | // } | ||
121 | // | ||
122 | // @Test | ||
123 | // void DFSOneRuleTest() { | ||
124 | // var createClassPrecondition = Query.of("CreateClassPrecondition", | ||
125 | // (builder, model) -> builder.clause( | ||
126 | // classModelView.call(model) | ||
127 | // )); | ||
128 | // | ||
129 | // var createClassRule = new TransformationRule("CreateClass", | ||
130 | // createClassPrecondition, | ||
131 | // (model) -> { | ||
132 | // var classesInterpretation = model.getInterpretation(classes); | ||
133 | // var classElementInterpretation = model.getInterpretation(classElement); | ||
134 | // return ((Tuple activation) -> { | ||
135 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
136 | // var modelElement = activation.get(0); | ||
137 | // | ||
138 | // var newClassElement = dseAdapter.createObject(); | ||
139 | // var newClassElementId = newClassElement.get(0); | ||
140 | // | ||
141 | // classesInterpretation.put(Tuple.of(modelElement, newClassElementId), true); | ||
142 | // classElementInterpretation.put(Tuple.of(newClassElementId), true); | ||
143 | // }); | ||
144 | // }); | ||
145 | // | ||
146 | // var store = ModelStore.builder() | ||
147 | // .symbols(classModel, classElement, classes) | ||
148 | // .with(ViatraModelQueryAdapter.builder() | ||
149 | // .queries(createClassPrecondition)) | ||
150 | // .with(DesignSpaceExplorationAdapter.builder() | ||
151 | // .transformations(createClassRule) | ||
152 | // .strategy(new DepthFirstStrategy().withDepthLimit(0) | ||
153 | // )) | ||
154 | // .build(); | ||
155 | // | ||
156 | // var model = store.createEmptyModel(); | ||
157 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
158 | // var queryEngine = model.getAdapter(ModelQueryAdapter.class); | ||
159 | // | ||
160 | // var modelElementInterpretation = model.getInterpretation(classModel); | ||
161 | // modelElementInterpretation.put(dseAdapter.createObject(), true); | ||
162 | // queryEngine.flushChanges(); | ||
163 | // | ||
164 | // var states = dseAdapter.explore(); | ||
165 | // assertEquals(1, states.size()); | ||
166 | // } | ||
167 | // | ||
168 | // @Test | ||
169 | // void DFSContinueTest() { | ||
170 | // var createClassPrecondition = Query.of("CreateClassPrecondition", | ||
171 | // (builder, model) -> builder.clause( | ||
172 | // classModelView.call(model) | ||
173 | // )); | ||
174 | // | ||
175 | // var createClassRule = new TransformationRule("CreateClass", | ||
176 | // createClassPrecondition, | ||
177 | // (model) -> { | ||
178 | // var classesInterpretation = model.getInterpretation(classes); | ||
179 | // var classElementInterpretation = model.getInterpretation(classElement); | ||
180 | // return ((Tuple activation) -> { | ||
181 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
182 | // var modelElement = activation.get(0); | ||
183 | // | ||
184 | // var newClassElement = dseAdapter.createObject(); | ||
185 | // var newClassElementId = newClassElement.get(0); | ||
186 | // | ||
187 | // classesInterpretation.put(Tuple.of(modelElement, newClassElementId), true); | ||
188 | // classElementInterpretation.put(Tuple.of(newClassElementId), true); | ||
189 | // }); | ||
190 | // }); | ||
191 | // | ||
192 | // var store = ModelStore.builder() | ||
193 | // .symbols(classModel, classElement, classes) | ||
194 | // .with(ViatraModelQueryAdapter.builder() | ||
195 | // .queries(createClassPrecondition)) | ||
196 | // .with(DesignSpaceExplorationAdapter.builder() | ||
197 | // .transformations(createClassRule) | ||
198 | // .strategy(new DepthFirstStrategy().withDepthLimit(4).continueIfHardObjectivesFulfilled() | ||
199 | // )) | ||
200 | // .build(); | ||
201 | // | ||
202 | // var model = store.createEmptyModel(); | ||
203 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
204 | // var queryEngine = model.getAdapter(ModelQueryAdapter.class); | ||
205 | // | ||
206 | // var modelElementInterpretation = model.getInterpretation(classModel); | ||
207 | // modelElementInterpretation.put(dseAdapter.createObject(), true); | ||
208 | // queryEngine.flushChanges(); | ||
209 | // | ||
210 | // var states = dseAdapter.explore(); | ||
211 | // assertEquals(5, states.size()); | ||
212 | // } | ||
213 | // | ||
214 | // @Test | ||
215 | // void DFSCompletenessTest() { | ||
216 | // var createClassPrecondition = Query.of("CreateClassPrecondition", | ||
217 | // (builder, model) -> builder.clause( | ||
218 | // classModelView.call(model) | ||
219 | // )); | ||
220 | // | ||
221 | // var createClassRule = new TransformationRule("CreateClass", | ||
222 | // createClassPrecondition, | ||
223 | // (model) -> { | ||
224 | // var classesInterpretation = model.getInterpretation(classes); | ||
225 | // var classElementInterpretation = model.getInterpretation(classElement); | ||
226 | // return ((Tuple activation) -> { | ||
227 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
228 | // var modelElement = activation.get(0); | ||
229 | // | ||
230 | // var newClassElement = dseAdapter.createObject(); | ||
231 | // var newClassElementId = newClassElement.get(0); | ||
232 | // | ||
233 | // classesInterpretation.put(Tuple.of(modelElement, newClassElementId), true); | ||
234 | // classElementInterpretation.put(Tuple.of(newClassElementId), true); | ||
235 | // }); | ||
236 | // }); | ||
237 | // | ||
238 | // var createFeaturePrecondition = Query.of("CreateFeaturePrecondition", | ||
239 | // (builder, model) -> builder.clause( | ||
240 | // classModelView.call(model) | ||
241 | // )); | ||
242 | // | ||
243 | // var createFeatureRule = new TransformationRule("CreateFeature", | ||
244 | // createFeaturePrecondition, | ||
245 | // (model) -> { | ||
246 | // var featuresInterpretation = model.getInterpretation(features); | ||
247 | // var featureInterpretation = model.getInterpretation(feature); | ||
248 | // return ((Tuple activation) -> { | ||
249 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
250 | // var modelElement = activation.get(0); | ||
251 | // | ||
252 | // var newClassElement = dseAdapter.createObject(); | ||
253 | // var newClassElementId = newClassElement.get(0); | ||
254 | // | ||
255 | // featuresInterpretation.put(Tuple.of(modelElement, newClassElementId), true); | ||
256 | // featureInterpretation.put(Tuple.of(newClassElementId), true); | ||
257 | // }); | ||
258 | // }); | ||
259 | // | ||
260 | // var store = ModelStore.builder() | ||
261 | // .symbols(classModel, classElement, classes, feature, features, isEncapsulatedBy, encapsulates) | ||
262 | // .with(ViatraModelQueryAdapter.builder() | ||
263 | // .queries(createClassPrecondition, createFeaturePrecondition)) | ||
264 | // .with(DesignSpaceExplorationAdapter.builder() | ||
265 | // .transformations(createClassRule, createFeatureRule) | ||
266 | // .strategy(new DepthFirstStrategy().withDepthLimit(10).continueIfHardObjectivesFulfilled() | ||
267 | // )) | ||
268 | // .build(); | ||
269 | // | ||
270 | // var model = store.createEmptyModel(); | ||
271 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
272 | // var queryEngine = model.getAdapter(ModelQueryAdapter.class); | ||
273 | // | ||
274 | // var modelElementInterpretation = model.getInterpretation(classModel); | ||
275 | // modelElementInterpretation.put(dseAdapter.createObject(), true); | ||
276 | // queryEngine.flushChanges(); | ||
277 | // | ||
278 | // var states = dseAdapter.explore(); | ||
279 | // assertEquals(2047, states.size()); | ||
280 | // } | ||
281 | // | ||
282 | // @Test | ||
283 | // void DFSSolutionLimitTest() { | ||
284 | // var createClassPrecondition = Query.of("CreateClassPrecondition", | ||
285 | // (builder, model) -> builder.clause( | ||
286 | // classModelView.call(model) | ||
287 | // )); | ||
288 | // | ||
289 | // var createClassRule = new TransformationRule("CreateClass", | ||
290 | // createClassPrecondition, | ||
291 | // (model) -> { | ||
292 | // var classesInterpretation = model.getInterpretation(classes); | ||
293 | // var classElementInterpretation = model.getInterpretation(classElement); | ||
294 | // return ((Tuple activation) -> { | ||
295 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
296 | // var modelElement = activation.get(0); | ||
297 | // | ||
298 | // var newClassElement = dseAdapter.createObject(); | ||
299 | // var newClassElementId = newClassElement.get(0); | ||
300 | // | ||
301 | // classesInterpretation.put(Tuple.of(modelElement, newClassElementId), true); | ||
302 | // classElementInterpretation.put(Tuple.of(newClassElementId), true); | ||
303 | // }); | ||
304 | // }); | ||
305 | // | ||
306 | // var createFeaturePrecondition = Query.of("CreateFeaturePrecondition", | ||
307 | // (builder, model) -> builder.clause( | ||
308 | // classModelView.call(model) | ||
309 | // )); | ||
310 | // | ||
311 | // var createFeatureRule = new TransformationRule("CreateFeature", | ||
312 | // createFeaturePrecondition, | ||
313 | // (model) -> { | ||
314 | // var featuresInterpretation = model.getInterpretation(features); | ||
315 | // var featureInterpretation = model.getInterpretation(feature); | ||
316 | // return ((Tuple activation) -> { | ||
317 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
318 | // var modelElement = activation.get(0); | ||
319 | // | ||
320 | // var newClassElement = dseAdapter.createObject(); | ||
321 | // var newClassElementId = newClassElement.get(0); | ||
322 | // | ||
323 | // featuresInterpretation.put(Tuple.of(modelElement, newClassElementId), true); | ||
324 | // featureInterpretation.put(Tuple.of(newClassElementId), true); | ||
325 | // }); | ||
326 | // }); | ||
327 | // | ||
328 | // var store = ModelStore.builder() | ||
329 | // .symbols(classModel, classElement, classes, feature, features, isEncapsulatedBy, encapsulates) | ||
330 | // .with(ViatraModelQueryAdapter.builder() | ||
331 | // .queries(createClassPrecondition, createFeaturePrecondition)) | ||
332 | // .with(DesignSpaceExplorationAdapter.builder() | ||
333 | // .transformations(createClassRule, createFeatureRule) | ||
334 | // .strategy(new DepthFirstStrategy().withSolutionLimit(222) | ||
335 | // .continueIfHardObjectivesFulfilled() | ||
336 | // )) | ||
337 | // .build(); | ||
338 | // | ||
339 | // var model = store.createEmptyModel(); | ||
340 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
341 | // var queryEngine = model.getAdapter(ModelQueryAdapter.class); | ||
342 | // | ||
343 | // var modelElementInterpretation = model.getInterpretation(classModel); | ||
344 | // modelElementInterpretation.put(dseAdapter.createObject(), true); | ||
345 | // queryEngine.flushChanges(); | ||
346 | // | ||
347 | // var states = dseAdapter.explore(); | ||
348 | // assertEquals(222, states.size()); | ||
349 | // } | ||
350 | // | ||
351 | // @Test | ||
352 | // void BeFSTrivialTest() { | ||
353 | // var store = ModelStore.builder() | ||
354 | // .symbols(classModel) | ||
355 | // .with(ViatraModelQueryAdapter.builder()) | ||
356 | // .with(DesignSpaceExplorationAdapter.builder() | ||
357 | // .strategy(new BestFirstStrategy().withDepthLimit(0))) | ||
358 | // .build(); | ||
359 | // | ||
360 | // var model = store.createEmptyModel(); | ||
361 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
362 | // | ||
363 | // var states = dseAdapter.explore(); | ||
364 | // assertEquals(1, states.size()); | ||
365 | // } | ||
366 | // | ||
367 | // @Test | ||
368 | // void BeFSOneRuleTest() { | ||
369 | // var createClassPrecondition = Query.of("CreateClassPrecondition", | ||
370 | // (builder, model) -> builder.clause( | ||
371 | // classModelView.call(model) | ||
372 | // )); | ||
373 | // | ||
374 | // var createClassRule = new TransformationRule("CreateClass", | ||
375 | // createClassPrecondition, | ||
376 | // (model) -> { | ||
377 | // var classesInterpretation = model.getInterpretation(classes); | ||
378 | // var classElementInterpretation = model.getInterpretation(classElement); | ||
379 | // return ((Tuple activation) -> { | ||
380 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
381 | // var modelElement = activation.get(0); | ||
382 | // | ||
383 | // var newClassElement = dseAdapter.createObject(); | ||
384 | // var newClassElementId = newClassElement.get(0); | ||
385 | // | ||
386 | // classesInterpretation.put(Tuple.of(modelElement, newClassElementId), true); | ||
387 | // classElementInterpretation.put(Tuple.of(newClassElementId), true); | ||
388 | // }); | ||
389 | // }); | ||
390 | // | ||
391 | // var store = ModelStore.builder() | ||
392 | // .symbols(classModel, classElement, classes) | ||
393 | // .with(ViatraModelQueryAdapter.builder() | ||
394 | // .queries(createClassPrecondition)) | ||
395 | // .with(DesignSpaceExplorationAdapter.builder() | ||
396 | // .transformations(createClassRule) | ||
397 | // .strategy(new BestFirstStrategy().withDepthLimit(4) | ||
398 | // )) | ||
399 | // .build(); | ||
400 | // | ||
401 | // var model = store.createEmptyModel(); | ||
402 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
403 | // var queryEngine = model.getAdapter(ModelQueryAdapter.class); | ||
404 | // | ||
405 | // var modelElementInterpretation = model.getInterpretation(classModel); | ||
406 | // modelElementInterpretation.put(dseAdapter.createObject(), true); | ||
407 | // queryEngine.flushChanges(); | ||
408 | // | ||
409 | // var states = dseAdapter.explore(); | ||
410 | // assertEquals(1, states.size()); | ||
411 | // } | ||
412 | // | ||
413 | // @Test | ||
414 | // void BeFSContinueTest() { | ||
415 | // var createClassPrecondition = Query.of("CreateClassPrecondition", | ||
416 | // (builder, model) -> builder.clause( | ||
417 | // classModelView.call(model) | ||
418 | // )); | ||
419 | // | ||
420 | // var createClassRule = new TransformationRule("CreateClass", | ||
421 | // createClassPrecondition, | ||
422 | // (model) -> { | ||
423 | // var classesInterpretation = model.getInterpretation(classes); | ||
424 | // var classElementInterpretation = model.getInterpretation(classElement); | ||
425 | // return ((Tuple activation) -> { | ||
426 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
427 | // var modelElement = activation.get(0); | ||
428 | // | ||
429 | // var newClassElement = dseAdapter.createObject(); | ||
430 | // var newClassElementId = newClassElement.get(0); | ||
431 | // | ||
432 | // classesInterpretation.put(Tuple.of(modelElement, newClassElementId), true); | ||
433 | // classElementInterpretation.put(Tuple.of(newClassElementId), true); | ||
434 | // }); | ||
435 | // }); | ||
436 | // | ||
437 | // var store = ModelStore.builder() | ||
438 | // .symbols(classModel, classElement, classes) | ||
439 | // .with(ViatraModelQueryAdapter.builder() | ||
440 | // .queries(createClassPrecondition)) | ||
441 | // .with(DesignSpaceExplorationAdapter.builder() | ||
442 | // .transformations(createClassRule) | ||
443 | // .strategy(new BestFirstStrategy().withDepthLimit(4).continueIfHardObjectivesFulfilled() | ||
444 | // )) | ||
445 | // .build(); | ||
446 | // | ||
447 | // var model = store.createEmptyModel(); | ||
448 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
449 | // var queryEngine = model.getAdapter(ModelQueryAdapter.class); | ||
450 | // | ||
451 | // var modelElementInterpretation = model.getInterpretation(classModel); | ||
452 | // modelElementInterpretation.put(dseAdapter.createObject(), true); | ||
453 | // queryEngine.flushChanges(); | ||
454 | // | ||
455 | // var states = dseAdapter.explore(); | ||
456 | // assertEquals(5, states.size()); | ||
457 | // } | ||
458 | // | ||
459 | // @Test | ||
460 | // void BeFSCompletenessTest() { | ||
461 | // var createClassPrecondition = Query.of("CreateClassPrecondition", | ||
462 | // (builder, model) -> builder.clause( | ||
463 | // classModelView.call(model) | ||
464 | // )); | ||
465 | // | ||
466 | // var createClassRule = new TransformationRule("CreateClass", | ||
467 | // createClassPrecondition, | ||
468 | // (model) -> { | ||
469 | // var classesInterpretation = model.getInterpretation(classes); | ||
470 | // var classElementInterpretation = model.getInterpretation(classElement); | ||
471 | // return ((Tuple activation) -> { | ||
472 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
473 | // var modelElement = activation.get(0); | ||
474 | // | ||
475 | // var newClassElement = dseAdapter.createObject(); | ||
476 | // var newClassElementId = newClassElement.get(0); | ||
477 | // | ||
478 | // classesInterpretation.put(Tuple.of(modelElement, newClassElementId), true); | ||
479 | // classElementInterpretation.put(Tuple.of(newClassElementId), true); | ||
480 | // }); | ||
481 | // }); | ||
482 | // | ||
483 | // var createFeaturePrecondition = Query.of("CreateFeaturePrecondition", | ||
484 | // (builder, model) -> builder.clause( | ||
485 | // classModelView.call(model) | ||
486 | // )); | ||
487 | // | ||
488 | // var createFeatureRule = new TransformationRule("CreateFeature", | ||
489 | // createFeaturePrecondition, | ||
490 | // (model) -> { | ||
491 | // var featuresInterpretation = model.getInterpretation(features); | ||
492 | // var featureInterpretation = model.getInterpretation(feature); | ||
493 | // return ((Tuple activation) -> { | ||
494 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
495 | // var modelElement = activation.get(0); | ||
496 | // | ||
497 | // var newClassElement = dseAdapter.createObject(); | ||
498 | // var newClassElementId = newClassElement.get(0); | ||
499 | // | ||
500 | // featuresInterpretation.put(Tuple.of(modelElement, newClassElementId), true); | ||
501 | // featureInterpretation.put(Tuple.of(newClassElementId), true); | ||
502 | // }); | ||
503 | // }); | ||
504 | // | ||
505 | // var store = ModelStore.builder() | ||
506 | // .symbols(classModel, classElement, classes, feature, features, isEncapsulatedBy, encapsulates) | ||
507 | // .with(ViatraModelQueryAdapter.builder() | ||
508 | // .queries(createClassPrecondition, createFeaturePrecondition)) | ||
509 | // .with(DesignSpaceExplorationAdapter.builder() | ||
510 | // .transformations(createClassRule, createFeatureRule) | ||
511 | // .strategy(new BestFirstStrategy().withDepthLimit(10).continueIfHardObjectivesFulfilled() | ||
512 | // )) | ||
513 | // .build(); | ||
514 | // | ||
515 | // var model = store.createEmptyModel(); | ||
516 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
517 | // var queryEngine = model.getAdapter(ModelQueryAdapter.class); | ||
518 | // | ||
519 | // var modelElementInterpretation = model.getInterpretation(classModel); | ||
520 | // modelElementInterpretation.put(dseAdapter.createObject(), true); | ||
521 | // queryEngine.flushChanges(); | ||
522 | // | ||
523 | // var states = dseAdapter.explore(); | ||
524 | // assertEquals(2047, states.size()); | ||
525 | // } | ||
526 | // | ||
527 | // @Test | ||
528 | // void BeFSSolutionLimitTest() { | ||
529 | // var createClassPrecondition = Query.of("CreateClassPrecondition", | ||
530 | // (builder, model) -> builder.clause( | ||
531 | // classModelView.call(model) | ||
532 | // )); | ||
533 | // | ||
534 | // var createClassRule = new TransformationRule("CreateClass", | ||
535 | // createClassPrecondition, | ||
536 | // (model) -> { | ||
537 | // var classesInterpretation = model.getInterpretation(classes); | ||
538 | // var classElementInterpretation = model.getInterpretation(classElement); | ||
539 | // return ((Tuple activation) -> { | ||
540 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
541 | // var modelElement = activation.get(0); | ||
542 | // | ||
543 | // var newClassElement = dseAdapter.createObject(); | ||
544 | // var newClassElementId = newClassElement.get(0); | ||
545 | // | ||
546 | // classesInterpretation.put(Tuple.of(modelElement, newClassElementId), true); | ||
547 | // classElementInterpretation.put(Tuple.of(newClassElementId), true); | ||
548 | // }); | ||
549 | // }); | ||
550 | // | ||
551 | // var createFeaturePrecondition = Query.of("CreateFeaturePrecondition", | ||
552 | // (builder, model) -> builder.clause( | ||
553 | // classModelView.call(model) | ||
554 | // )); | ||
555 | // | ||
556 | // var createFeatureRule = new TransformationRule("CreateFeature", | ||
557 | // createFeaturePrecondition, | ||
558 | // (model) -> { | ||
559 | // var featuresInterpretation = model.getInterpretation(features); | ||
560 | // var featureInterpretation = model.getInterpretation(feature); | ||
561 | // return ((Tuple activation) -> { | ||
562 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
563 | // var modelElement = activation.get(0); | ||
564 | // | ||
565 | // var newClassElement = dseAdapter.createObject(); | ||
566 | // var newClassElementId = newClassElement.get(0); | ||
567 | // | ||
568 | // featuresInterpretation.put(Tuple.of(modelElement, newClassElementId), true); | ||
569 | // featureInterpretation.put(Tuple.of(newClassElementId), true); | ||
570 | // }); | ||
571 | // }); | ||
572 | // | ||
573 | // var store = ModelStore.builder() | ||
574 | // .symbols(classModel, classElement, classes, feature, features, isEncapsulatedBy, encapsulates) | ||
575 | // .with(ViatraModelQueryAdapter.builder() | ||
576 | // .queries(createClassPrecondition, createFeaturePrecondition)) | ||
577 | // .with(DesignSpaceExplorationAdapter.builder() | ||
578 | // .transformations(createClassRule, createFeatureRule) | ||
579 | // .strategy(new BestFirstStrategy().withSolutionLimit(222) | ||
580 | // .continueIfHardObjectivesFulfilled() | ||
581 | // )) | ||
582 | // .build(); | ||
583 | // | ||
584 | // var model = store.createEmptyModel(); | ||
585 | // var dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | ||
586 | // var queryEngine = model.getAdapter(ModelQueryAdapter.class); | ||
587 | // | ||
588 | // var modelElementInterpretation = model.getInterpretation(classModel); | ||
589 | // modelElementInterpretation.put(dseAdapter.createObject(), true); | ||
590 | // queryEngine.flushChanges(); | ||
591 | // | ||
592 | // var states = dseAdapter.explore(); | ||
593 | // assertEquals(222, states.size()); | ||
594 | // } | ||
595 | |||
596 | } | ||