aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend
blob: 5da202eb93436ab34cf78fedba2f5f525cb08cf0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood

import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
import java.util.Map
import org.eclipse.collections.api.factory.Maps

class PartialInterpretation2Hash extends PartialInterpretation2NeighbourhoodRepresentation<Integer, Integer>{
	
	new() {
		super(false, true)
	}
	
	override protected createLocalRepresentation(Map<DefinedElement, LocalNodeDescriptor> node2Representation, Map<LocalNodeDescriptor, Integer> representation2Amount) {
		return new NeighbourhoodWithTraces(
			representation2Amount.hashCode,node2Representation.hashValues,
			null)
	}
	
	override protected createFurtherRepresentation(Map<FurtherNodeDescriptor<Integer>, Integer> nodeDescriptors, Map<DefinedElement, FurtherNodeDescriptor<Integer>> node2Representation, NeighbourhoodWithTraces<Integer, Integer> previous, boolean deepRepresentation) {
		return new NeighbourhoodWithTraces(
			nodeDescriptors.hashCode,
			node2Representation.hashValues,
			if(deepRepresentation) {previous} else {null})
	}
	
	private def <T> hashValues(Map<DefinedElement, T> map) {
		val hashedMap = Maps.mutable.ofInitialCapacity(map.size)
		for (entry : map.entrySet) {
			hashedMap.put(entry.key, entry.value.hashCode)
		}
		hashedMap
	}
}