diff options
author | 2017-06-10 19:05:05 +0200 | |
---|---|---|
committer | 2017-06-10 19:05:05 +0200 | |
commit | 60f01f46ba232ed6416054f0a6115cb2a9b70b4e (patch) | |
tree | 5edf8aeb07abc51f3fec63bbd15c926e1de09552 /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2ImmutableTypeLatticeWithEquivalenceCounter.xtend | |
parent | Initial commit, migrating from SVN (diff) | |
download | VIATRA-Generator-60f01f46ba232ed6416054f0a6115cb2a9b70b4e.tar.gz VIATRA-Generator-60f01f46ba232ed6416054f0a6115cb2a9b70b4e.tar.zst VIATRA-Generator-60f01f46ba232ed6416054f0a6115cb2a9b70b4e.zip |
Migrating Additional projects
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2ImmutableTypeLatticeWithEquivalenceCounter.xtend')
1 files changed, 56 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2ImmutableTypeLatticeWithEquivalenceCounter.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2ImmutableTypeLatticeWithEquivalenceCounter.xtend new file mode 100644 index 00000000..251a82f0 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2ImmutableTypeLatticeWithEquivalenceCounter.xtend | |||
@@ -0,0 +1,56 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement | ||
4 | import java.util.Map | ||
5 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | ||
6 | import java.util.HashMap | ||
7 | |||
8 | class PartialInterpretation2ImmutableTypeLatticeWithEquivalenceCounter extends | ||
9 | PartialInterpretation2NeighbourhoodRepresentation< | ||
10 | Map<? extends AbstractNodeDescriptor,Integer>, // <- Model Descriptor | ||
11 | AbstractNodeDescriptor> // <- Node Descriptor | ||
12 | { | ||
13 | |||
14 | protected new() { | ||
15 | super(true,false) | ||
16 | } | ||
17 | |||
18 | override protected createLocalRepresentation(Map<DefinedElement, LocalNodeDescriptor> node2Representation, Map<LocalNodeDescriptor, Integer> representation2Amount) { | ||
19 | return new NeighbourhoodWithTraces(node2Representation.immutableCopy,node2Representation.immutableCopy,null) | ||
20 | } | ||
21 | |||
22 | override protected createFurtherRepresentation( | ||
23 | Map<FurtherNodeDescriptor<AbstractNodeDescriptor>, Integer> nodeDescriptors, | ||
24 | Map<DefinedElement, FurtherNodeDescriptor<AbstractNodeDescriptor>> node2Representation, | ||
25 | NeighbourhoodWithTraces<Map<? extends AbstractNodeDescriptor, Integer>, AbstractNodeDescriptor> previous, | ||
26 | boolean deepRepresentation | ||
27 | ) { | ||
28 | if(deepRepresentation) { | ||
29 | return new NeighbourhoodWithTraces<Map<? extends AbstractNodeDescriptor, Integer>, AbstractNodeDescriptor>(nodeDescriptors,node2Representation,previous) | ||
30 | } else { | ||
31 | return new NeighbourhoodWithTraces<Map<? extends AbstractNodeDescriptor, Integer>, AbstractNodeDescriptor>(nodeDescriptors,node2Representation,null) | ||
32 | } | ||
33 | } | ||
34 | |||
35 | public def finalRepresentation(NeighbourhoodWithTraces<Map<? extends AbstractNodeDescriptor, Integer>,AbstractNodeDescriptor> representation) { | ||
36 | val node2Representation = representation.nodeRepresentations | ||
37 | val node2LocalRepresentation = new HashMap | ||
38 | //val localRepresentation2Node = new HashMap | ||
39 | for(entry: node2Representation.entrySet) { | ||
40 | val node = entry.key | ||
41 | val localNodeDescriptor = entry.value.toLocalDescriptor | ||
42 | node2LocalRepresentation.put(node,localNodeDescriptor) | ||
43 | } | ||
44 | |||
45 | } | ||
46 | |||
47 | public def LocalNodeDescriptor toLocalDescriptor(AbstractNodeDescriptor descriptor) { | ||
48 | if(descriptor instanceof LocalNodeDescriptor) { | ||
49 | return descriptor | ||
50 | } else if(descriptor instanceof FurtherNodeDescriptor<?>) { | ||
51 | (descriptor.previousRepresentation as AbstractNodeDescriptor).toLocalDescriptor | ||
52 | } else throw new IllegalArgumentException('''Unsupported descriptor type: «descriptor.class.simpleName»''') | ||
53 | } | ||
54 | |||
55 | |||
56 | } | ||