diff options
author | 2017-10-27 17:48:20 +0200 | |
---|---|---|
committer | 2017-10-27 17:48:20 +0200 | |
commit | dd52d1ddd7e85fb14c8f5ccf61a0bfd5496998e6 (patch) | |
tree | 4d4e8ee4e6cdb1d197396ec661661607cc57c595 /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood | |
parent | Representation included trace by accident (diff) | |
download | VIATRA-Generator-dd52d1ddd7e85fb14c8f5ccf61a0bfd5496998e6.tar.gz VIATRA-Generator-dd52d1ddd7e85fb14c8f5ccf61a0bfd5496998e6.tar.zst VIATRA-Generator-dd52d1ddd7e85fb14c8f5ccf61a0bfd5496998e6.zip |
neighbourhood calculated to fix range
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood')
1 files changed, 42 insertions, 2 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 df6fb6ae..936f2117 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 | |||
@@ -24,6 +24,7 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
24 | } | 24 | } |
25 | 25 | ||
26 | public static val FixPointRage = -1 | 26 | public static val FixPointRage = -1 |
27 | public static val GraphWidthRange = -2 | ||
27 | public static val FullParallels = Integer.MAX_VALUE | 28 | public static val FullParallels = Integer.MAX_VALUE |
28 | public static val MaxNumbers = Integer.MAX_VALUE | 29 | public static val MaxNumbers = Integer.MAX_VALUE |
29 | 30 | ||
@@ -67,6 +68,41 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
67 | return relevantRelations.contains(r) | 68 | return relevantRelations.contains(r) |
68 | } | 69 | } |
69 | } | 70 | } |
71 | /** | ||
72 | * Gets the largest | ||
73 | */ | ||
74 | def private getWidth(Map<DefinedElement, Set<String>> types, | ||
75 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, | ||
76 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations) | ||
77 | { | ||
78 | val elements = types.keySet | ||
79 | val Map<DefinedElement,Set<DefinedElement>> reachable = new HashMap | ||
80 | for(element : elements) { | ||
81 | val set = new HashSet | ||
82 | set.add(element) | ||
83 | reachable.put(element,set) | ||
84 | } | ||
85 | |||
86 | var int width = 0 | ||
87 | var boolean newAdded | ||
88 | do { | ||
89 | newAdded = false | ||
90 | for(element : elements) { | ||
91 | val elementNeigbours = element.lookup(reachable) | ||
92 | val size = elementNeigbours.size | ||
93 | for(incoming : element.lookup(IncomingRelations)) { | ||
94 | elementNeigbours.addAll(incoming.from.lookup(reachable)) | ||
95 | } | ||
96 | for(outgoing : element.lookup(OutgoingRelations)) { | ||
97 | elementNeigbours.addAll(outgoing.to.lookup(reachable)) | ||
98 | } | ||
99 | newAdded = newAdded || (elementNeigbours.size > size) | ||
100 | } | ||
101 | |||
102 | width +=1 | ||
103 | } while(newAdded) | ||
104 | return width | ||
105 | } | ||
70 | 106 | ||
71 | /** | 107 | /** |
72 | * Creates a neighbourhood representation with traces | 108 | * Creates a neighbourhood representation with traces |
@@ -107,6 +143,10 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
107 | } else return res | 143 | } else return res |
108 | } else if (range == FixPointRage) { | 144 | } else if (range == FixPointRage) { |
109 | return refineUntilFixpoint(model,types,IncomingRelations,OutgoingRelations,parallels,maxNumber) | 145 | return refineUntilFixpoint(model,types,IncomingRelations,OutgoingRelations,parallels,maxNumber) |
146 | } else if (range == GraphWidthRange) { | ||
147 | val width = this.getWidth(types,IncomingRelations,OutgoingRelations) | ||
148 | //println(width) | ||
149 | return doRecursiveNeighbourCalculation(model,types,IncomingRelations,OutgoingRelations,width,parallels,maxNumber) | ||
110 | } | 150 | } |
111 | } | 151 | } |
112 | 152 | ||
@@ -297,7 +337,7 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
297 | ) | 337 | ) |
298 | node2Representation.put(object,uniqueDescription.get(nodeDescriptor)) | 338 | node2Representation.put(object,uniqueDescription.get(nodeDescriptor)) |
299 | } else { | 339 | } else { |
300 | descriptor2Number.put(nodeDescriptor,1) | 340 | descriptor2Number.put(nodeDescriptor,if(1>maxNumber){Integer.MAX_VALUE}else{1}) |
301 | uniqueDescription.put(nodeDescriptor,nodeDescriptor) | 341 | uniqueDescription.put(nodeDescriptor,nodeDescriptor) |
302 | node2Representation.put(object,nodeDescriptor) | 342 | node2Representation.put(object,nodeDescriptor) |
303 | } | 343 | } |
@@ -333,7 +373,7 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
333 | } else { | 373 | } else { |
334 | uniqueRepresentation.put(newDescriptor,newDescriptor) | 374 | uniqueRepresentation.put(newDescriptor,newDescriptor) |
335 | node2Representation.put(element,newDescriptor) | 375 | node2Representation.put(element,newDescriptor) |
336 | representation2Amount.put(newDescriptor, 1) | 376 | representation2Amount.put(newDescriptor, if(1>maxNumber){Integer.MAX_VALUE}else{1}) |
337 | } | 377 | } |
338 | } else { | 378 | } else { |
339 | node2Representation.put(element,newDescriptor) | 379 | node2Representation.put(element,newDescriptor) |