diff options
Diffstat (limited to 'Solvers/VIATRA-Solver')
1 files changed, 27 insertions, 18 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2NeighbourhoodRepresentation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2NeighbourhoodRepresentation.xtend index 6dc40705..d1bf0348 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2NeighbourhoodRepresentation.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2NeighbourhoodRepresentation.xtend | |||
@@ -81,39 +81,48 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
81 | /** | 81 | /** |
82 | * Gets the largest | 82 | * Gets the largest |
83 | */ | 83 | */ |
84 | /** | ||
85 | |||
86 | * Gets the minimal neighbourhood size such that every reachable node appears in the shape of every other at least once. | ||
87 | |||
88 | */ | ||
89 | |||
84 | def private getWidth(Map<DefinedElement, Set<String>> types, | 90 | def private getWidth(Map<DefinedElement, Set<String>> types, |
85 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, | 91 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, |
86 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations) | 92 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations) { |
87 | { | 93 | val elements = types.keySet |
88 | val elements = types.keySet | 94 | var Map<DefinedElement, Set<DefinedElement>> reachable = new HashMap |
89 | val Map<DefinedElement,Set<DefinedElement>> reachable = new HashMap | 95 | var Map<DefinedElement, Set<DefinedElement>> newReachable = new HashMap |
90 | for(element : elements) { | 96 | for (element : elements) { |
91 | val set = new HashSet | 97 | val set = new HashSet |
92 | set.add(element) | 98 | set.add(element) |
93 | reachable.put(element,set) | 99 | reachable.put(element, new HashSet) |
100 | newReachable.put(element, set) | ||
94 | } | 101 | } |
95 | |||
96 | var int width = 0 | 102 | var int width = 0 |
97 | var boolean newAdded | 103 | var boolean newAdded |
98 | do { | 104 | do { |
105 | var tmp = reachable | ||
106 | reachable = newReachable | ||
107 | newReachable = tmp | ||
99 | newAdded = false | 108 | newAdded = false |
100 | for(element : elements) { | 109 | for (element : elements) { |
101 | val elementNeigbours = element.lookup(reachable) | 110 | val elementNeigbours = element.lookup(reachable) |
102 | val size = elementNeigbours.size | 111 | val newElementNeigbours = element.lookup(newReachable) |
103 | for(incoming : element.lookup(IncomingRelations)) { | 112 | newElementNeigbours.addAll(elementNeigbours) |
104 | elementNeigbours.addAll(incoming.from.lookup(reachable)) | 113 | for (incoming : element.lookup(IncomingRelations)) { |
114 | newElementNeigbours.addAll(incoming.from.lookup(reachable)) | ||
105 | } | 115 | } |
106 | for(outgoing : element.lookup(OutgoingRelations)) { | 116 | for (outgoing : element.lookup(OutgoingRelations)) { |
107 | elementNeigbours.addAll(outgoing.to.lookup(reachable)) | 117 | newElementNeigbours.addAll(outgoing.to.lookup(reachable)) |
108 | } | 118 | } |
109 | newAdded = newAdded || (elementNeigbours.size > size) | 119 | newAdded = newAdded || (newElementNeigbours.size > elementNeigbours.size) |
110 | } | 120 | } |
111 | 121 | width += 1 | |
112 | width +=1 | 122 | } while (newAdded) |
113 | } while(newAdded) | ||
114 | return width | 123 | return width |
115 | } | 124 | } |
116 | 125 | ||
117 | /** | 126 | /** |
118 | * Creates a neighbourhood representation with traces | 127 | * Creates a neighbourhood representation with traces |
119 | * @param model The model to be represented. | 128 | * @param model The model to be represented. |