From c0c5a1644cc221352b8b9b370eea6a87677ba948 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sat, 15 Jun 2019 20:56:47 -0400 Subject: Try fix statecode bug Modified graph width calculation to not depend on order of nodes --- .../neighbourhood/Descriptor.xtend | 188 +++++---- .../neighbourhood/NeighbourhoodOptions.xtend | 22 + ...nterpretation2NeighbourhoodRepresentation.xtend | 456 +++++++++++---------- ...ation2PairwiseNeighbourhoodRepresentation.xtend | 68 +++ ...bstractNeighborhoodBasedStateCoderFactory.xtend | 137 +++++++ .../IdentifierBasedStateCoderFactory.xtend | 4 +- .../NeighbourhoodBasedStateCoderFactory.xtend | 275 ++++--------- ...irwiseNeighbourhoodBasedStateCoderFactory.xtend | 75 ++++ 8 files changed, 730 insertions(+), 495 deletions(-) create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2PairwiseNeighbourhoodRepresentation.xtend create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/AbstractNeighborhoodBasedStateCoderFactory.xtend create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/PairwiseNeighbourhoodBasedStateCoderFactory.xtend (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme') diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend index 41482b28..c7c1ad77 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend @@ -4,10 +4,21 @@ import java.util.HashMap import java.util.Map import java.util.Set import org.eclipse.xtend.lib.annotations.Data +import org.eclipse.xtend2.lib.StringConcatenationClient @Data abstract class AbstractNodeDescriptor { long dataHash - + + protected def StringConcatenationClient prettyPrint() { + '''(«dataHash»)[«class.simpleName»]''' + } + + override toString() { + ''' + «prettyPrint» + ''' + } + // @Pure // @Override // override public boolean equals(Object obj) { @@ -24,34 +35,41 @@ import org.eclipse.xtend.lib.annotations.Data // } } -@Data class LocalNodeDescriptor extends AbstractNodeDescriptor{ +@Data class LocalNodeDescriptor extends AbstractNodeDescriptor { Set types String id; + new(String id, Set types) { - super(calcualteDataHash(id,types)) + super(calcualteDataHash(id, types)) this.types = types this.id = id } - + def private static calcualteDataHash(String id, Set types) { val int prime = 31; var result = 0 - if(id !== null) - result = id.hashCode(); - if(types !== null) { - result = prime * result + types.hashCode - } - return result + if (id !== null) + result = id.hashCode(); + if (types !== null) { + result = prime * result + types.hashCode + } + return result } - + override hashCode() { return this.dataHash.hashCode } - + + override protected prettyPrint() { + '''(«dataHash»)[«IF id !== null»id = "«id»"«IF types === null || !types.empty», «ENDIF»«ENDIF»«IF types === null»TYPES = null«ELSE»«FOR type : types SEPARATOR ", "»«type»«ENDFOR»«ENDIF»]''' + } + override toString() { - return class.name + this.dataHash + ''' + «prettyPrint» + ''' } - + // @Pure // @Override // override public boolean equals(Object obj) { @@ -66,7 +84,6 @@ import org.eclipse.xtend.lib.annotations.Data // return false; // return true; // } - // @Pure // override public boolean equals(Object obj) { // if (this === obj) @@ -97,49 +114,70 @@ import org.eclipse.xtend.lib.annotations.Data String type } -@Data class FurtherNodeDescriptor extends AbstractNodeDescriptor{ - - NodeRep previousRepresentation - Map,Integer> incomingEdges - Map,Integer> outgoingEdges - - new( - NodeRep previousRepresentation, - Map,Integer> incomingEdges, - Map,Integer> outgoingEdges) - { - super(calculateDataHash(previousRepresentation,incomingEdges,outgoingEdges)) - this.previousRepresentation = previousRepresentation - this.incomingEdges = new HashMap(incomingEdges) - this.outgoingEdges = new HashMap(outgoingEdges) - } - - static def private int calculateDataHash( - NodeRep previousRepresentation, - Map,Integer> incomingEdges, - Map,Integer> outgoingEdges) - { - val int prime = 31; - var int result = previousRepresentation.hashCode; - if(incomingEdges !== null) - result = prime * result + incomingEdges.hashCode(); - if(outgoingEdges !== null) - result = prime * result + outgoingEdges.hashCode(); - return result; - } - - override hashCode() { - return this.dataHash.hashCode +@Data class FurtherNodeDescriptor extends AbstractNodeDescriptor { + + NodeRep previousRepresentation + Map, Integer> incomingEdges + Map, Integer> outgoingEdges + + new(NodeRep previousRepresentation, Map, Integer> incomingEdges, + Map, Integer> outgoingEdges) { + super(calculateDataHash(previousRepresentation, incomingEdges, outgoingEdges)) + this.previousRepresentation = previousRepresentation + this.incomingEdges = new HashMap(incomingEdges) + this.outgoingEdges = new HashMap(outgoingEdges) } - + + static def private int calculateDataHash(NodeRep previousRepresentation, + Map, Integer> incomingEdges, Map, Integer> outgoingEdges) { + val int prime = 31; + var int result = previousRepresentation.hashCode; + if (incomingEdges !== null) + result = prime * result + incomingEdges.hashCode(); + if (outgoingEdges !== null) + result = prime * result + outgoingEdges.hashCode(); + return result; + } + + override hashCode() { + return this.dataHash.hashCode + } + + override prettyPrint() { + ''' + («dataHash»)[ + PREV = «previousRepresentation?.prettyPrint» + «IF incomingEdges === null» + IN null + «ELSE» + «FOR edge : incomingEdges.entrySet» + IN «edge.value» «edge.key.type» = «edge.key.from.prettyPrint» + «ENDFOR» + «ENDIF» + «IF outgoingEdges === null» + OUT null + «ELSE» + «FOR edge : outgoingEdges.entrySet» + OUT «edge.value» «edge.key.type» = «edge.key.to.prettyPrint» + «ENDFOR» + «ENDIF» + ]''' + } + + private def StringConcatenationClient prettyPrint(NodeRep rep) { + if (rep instanceof AbstractNodeDescriptor) { + rep.prettyPrint + } else { + '''«rep»''' + } + } + override toString() { - return class.name + dataHash -// return '''[«previousRepresentation»,(«FOR -// in: incomingEdges.entrySet»(«in.key.type.name»=«in.key.from»,«in.value»)«ENDFOR»),(«FOR -// out: outgoingEdges.entrySet»(«out.key.type.name»=«out.key.to»,«out.value»)«ENDFOR»),«FOR -// att: attributeValues»(«att.type.name»=«att.value»)«ENDFOR»]''' + ''' + «prettyPrint» + ''' } - + // @Pure // @Override // override public boolean equals(Object obj) { @@ -154,7 +192,6 @@ import org.eclipse.xtend.lib.annotations.Data // return false; // return true; // } - // @Pure // override public boolean equals(Object obj) { // if (this === obj) @@ -191,24 +228,23 @@ import org.eclipse.xtend.lib.annotations.Data // return true; // } } - /* -@Data -class ModelDescriptor { - int dataHash - int unknownElements - Map knownElements - - public new(Map knownElements, int unknownElements) { - this.dataHash = calculateDataHash(knownElements,unknownElements) - this.unknownElements = unknownElements - this.knownElements = knownElements - } - - def private static calculateDataHash(Map knownElements, int unknownElements) - { - val int prime = 31; - return knownElements.hashCode * prime + unknownElements.hashCode - } -} -*/ \ No newline at end of file + * @Data + * class ModelDescriptor { + * int dataHash + * int unknownElements + * Map knownElements + * + * public new(Map knownElements, int unknownElements) { + * this.dataHash = calculateDataHash(knownElements,unknownElements) + * this.unknownElements = unknownElements + * this.knownElements = knownElements + * } + * + * def private static calculateDataHash(Map knownElements, int unknownElements) + * { + * val int prime = 31; + * return knownElements.hashCode * prime + unknownElements.hashCode + * } + * } + */ diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend new file mode 100644 index 00000000..efc89803 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend @@ -0,0 +1,22 @@ +package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood + +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration +import java.util.Set +import org.eclipse.xtend.lib.annotations.Data + +@Data +class NeighbourhoodOptions { + public static val FixPointRage = -1 + public static val GraphWidthRange = -2 + public static val FullParallels = Integer.MAX_VALUE + public static val MaxNumbers = Integer.MAX_VALUE + + public static val DEFAULT = new NeighbourhoodOptions(GraphWidthRange, FullParallels, MaxNumbers, null, null) + + val int range + val int parallels + val int maxNumber + val Set relevantTypes + val Set relevantRelations +} 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..54b0f54a 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 @@ -4,32 +4,34 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation +import java.util.ArrayList import java.util.HashMap import java.util.HashSet -import java.util.LinkedList import java.util.List import java.util.Map import java.util.Set import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation -abstract class PartialInterpretation2NeighbourhoodRepresentation { - private val boolean deepRepresentation - private val boolean mergeSimilarNeighbourhood +abstract class PartialInterpretation2NeighbourhoodRepresentation { + val boolean deepRepresentation + val boolean mergeSimilarNeighbourhood protected new(boolean deeprepresentation, boolean mergeSimilarNeighbourhood) { this.deepRepresentation = deeprepresentation this.mergeSimilarNeighbourhood = mergeSimilarNeighbourhood } - - public static val FixPointRage = -1 - public static val GraphWidthRange = -2 - public static val FullParallels = Integer.MAX_VALUE - public static val MaxNumbers = Integer.MAX_VALUE - + + public static val FixPointRage = NeighbourhoodOptions.FixPointRage + public static val GraphWidthRange = NeighbourhoodOptions.GraphWidthRange + public static val FullParallels = NeighbourhoodOptions.FullParallels + public static val MaxNumbers = NeighbourhoodOptions.MaxNumbers + + static val FOCUSED_ELEMENT_NAME = "<>" + /** * Creates a neighbourhood representation with traces * @param model The model to be represented. @@ -37,10 +39,15 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation relevantTypes, Set relevantRelations) - { + def createRepresentation(PartialInterpretation model, int range, int parallels, int maxNumber, + Set relevantTypes, Set relevantRelations) { + createRepresentationWithFocus(model, range, parallels, maxNumber, relevantTypes, relevantRelations, null) + } + + def createRepresentationWithFocus(PartialInterpretation model, NeighbourhoodOptions options, + DefinedElement focusedElement) { + createRepresentationWithFocus(model, options.range, options.parallels, options.maxNumber, options.relevantTypes, + options.relevantRelations, focusedElement) + } + + def createRepresentationWithFocus(PartialInterpretation model, int range, int parallels, int maxNumber, + Set relevantTypes, Set relevantRelations, DefinedElement focusedElement) { val Map> types = new HashMap - fillTypes(model,types,relevantTypes) + fillTypes(model, types, relevantTypes) val Map>> IncomingRelations = new HashMap; val Map>> OutgoingRelations = new HashMap; - fillReferences(model,IncomingRelations,OutgoingRelations,relevantRelations) - - val res = doRecursiveNeighbourCalculation(model,types,IncomingRelations,OutgoingRelations,range,parallels,maxNumber); - + fillReferences(model, IncomingRelations, OutgoingRelations, relevantRelations) + + val res = doRecursiveNeighbourCalculation(model, types, IncomingRelations, OutgoingRelations, range, parallels, + maxNumber, focusedElement); + return res; } - + def private isRelevant(TypeDeclaration t, Set relevantTypes) { - if(relevantTypes === null) { + if (relevantTypes === null) { return true } else { return relevantTypes.contains(t) } } + def private isRelevant(RelationDeclaration r, Set relevantRelations) { - if(relevantRelations === null) { + if (relevantRelations === null) { return true } else { return relevantRelations.contains(r) } } + /** - * Gets the largest + * Gets the minimal neighbourhood size such that every reachable node appears in the shape of every other at least once. */ def private getWidth(Map> types, Map>> IncomingRelations, - Map>> OutgoingRelations) - { - val elements = types.keySet - val Map> reachable = new HashMap - for(element : elements) { + Map>> OutgoingRelations) { + val elements = types.keySet + var Map> reachable = new HashMap + var Map> newReachable = new HashMap + for (element : elements) { val set = new HashSet set.add(element) - reachable.put(element,set) + reachable.put(element, new HashSet) + newReachable.put(element, set) } - + var int width = 0 var boolean newAdded do { + var tmp = reachable + reachable = newReachable + newReachable = tmp newAdded = false - for(element : elements) { + for (element : elements) { val elementNeigbours = element.lookup(reachable) - val size = elementNeigbours.size - for(incoming : element.lookup(IncomingRelations)) { - elementNeigbours.addAll(incoming.from.lookup(reachable)) + val newElementNeigbours = element.lookup(newReachable) + newElementNeigbours.addAll(elementNeigbours) + for (incoming : element.lookup(IncomingRelations)) { + newElementNeigbours.addAll(incoming.from.lookup(reachable)) } - for(outgoing : element.lookup(OutgoingRelations)) { - elementNeigbours.addAll(outgoing.to.lookup(reachable)) + for (outgoing : element.lookup(OutgoingRelations)) { + newElementNeigbours.addAll(outgoing.to.lookup(reachable)) } - newAdded = newAdded || (elementNeigbours.size > size) + newAdded = newAdded || (newElementNeigbours.size > elementNeigbours.size) } - - width +=1 - } while(newAdded) + + width += 1 + } while (newAdded) return width } - + /** * Creates a neighbourhood representation with traces * @param model The model to be represented. @@ -122,68 +145,71 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation doRecursiveNeighbourCalculation( - PartialInterpretation model, - Map> types, + def private NeighbourhoodWithTraces doRecursiveNeighbourCalculation( + PartialInterpretation model, Map> types, Map>> IncomingRelations, - Map>> OutgoingRelations, - int range, int parallels, int maxNumber) - { - if(range == 0){ - val r = calculateLocalNodeDescriptors(model,types,maxNumber) - val res = this.createLocalRepresentation(r.value,r.key) - if(res.modelRepresentation === null) { + Map>> OutgoingRelations, int range, int parallels, + int maxNumber, DefinedElement focusedElement) { + if (range == 0) { + val r = calculateLocalNodeDescriptors(model, types, maxNumber, focusedElement) + val res = this.createLocalRepresentation(r.value, r.key) + if (res.modelRepresentation === null) { throw new IllegalArgumentException('''Model representation is null''') - } else if(res.nodeRepresentations === null || res.nodeRepresentations.empty) { + } else if (res.nodeRepresentations === null || res.nodeRepresentations.empty) { throw new IllegalArgumentException('''No node representation''') - } else if(res.previousRepresentation !== null) { + } else if (res.previousRepresentation !== null) { throw new IllegalArgumentException('''The previous representation of the first neighbourhood have to be null''') - } else return res - } else if(range > 0) { - val previous = doRecursiveNeighbourCalculation(model,types,IncomingRelations,OutgoingRelations,range-1,parallels,maxNumber) - val r = calculateFurtherNodeDescriptors(model,previous,IncomingRelations,OutgoingRelations,parallels,maxNumber) - //println('''Level «range» finished.''') - val res = createFurtherRepresentation(r.key,r.value,previous,deepRepresentation) - if(res.modelRepresentation === null) { + } else + return res + } else if (range > 0) { + val previous = doRecursiveNeighbourCalculation(model, types, IncomingRelations, OutgoingRelations, + range - 1, parallels, maxNumber, focusedElement) + val r = calculateFurtherNodeDescriptors(model, previous, IncomingRelations, OutgoingRelations, parallels, + maxNumber) + // println('''Level «range» finished.''') + val res = createFurtherRepresentation(r.key, r.value, previous, deepRepresentation) + if (res.modelRepresentation === null) { throw new IllegalArgumentException('''Model representation is null''') - } else if(res.nodeRepresentations === null || res.nodeRepresentations.empty) { + } else if (res.nodeRepresentations === null || res.nodeRepresentations.empty) { throw new IllegalArgumentException('''No node representation''') - } else if(res.previousRepresentation === null && deepRepresentation) { + } else if (res.previousRepresentation === null && deepRepresentation) { throw new IllegalArgumentException('''Need previous representations''') - } else return res + } else + return res } else if (range == FixPointRage) { - return refineUntilFixpoint(model,types,IncomingRelations,OutgoingRelations,parallels,maxNumber) + return refineUntilFixpoint(model, types, IncomingRelations, OutgoingRelations, parallels, maxNumber, + focusedElement) } else if (range == GraphWidthRange) { - val width = this.getWidth(types,IncomingRelations,OutgoingRelations) - //println(width) - return doRecursiveNeighbourCalculation(model,types,IncomingRelations,OutgoingRelations,width,parallels,maxNumber) + val width = this.getWidth(types, IncomingRelations, OutgoingRelations) + // println(width) + return doRecursiveNeighbourCalculation(model, types, IncomingRelations, OutgoingRelations, width, parallels, + maxNumber, focusedElement) } } - - def private refineUntilFixpoint( - PartialInterpretation model, - Map> types, + + def private refineUntilFixpoint(PartialInterpretation model, Map> types, Map>> IncomingRelations, - Map>> OutgoingRelations, - int parallels, int maxNumbers) - { + Map>> OutgoingRelations, int parallels, int maxNumbers, + DefinedElement focusedElement) { var lastRange = 0 - val last = calculateLocalNodeDescriptors(model,types,maxNumbers) - var lastRepresentation = this.createLocalRepresentation(last.value,last.key) - //println('''Level 0 finished.''') + val last = calculateLocalNodeDescriptors(model, types, maxNumbers, focusedElement) + var lastRepresentation = this.createLocalRepresentation(last.value, last.key) + // println('''Level 0 finished.''') var boolean hasRefined do { - val nextRange = lastRange+1 - val next = calculateFurtherNodeDescriptors(model,lastRepresentation,IncomingRelations,OutgoingRelations,parallels,maxNumbers) - val nextRepresentation = createFurtherRepresentation(next.key,next.value,lastRepresentation,deepRepresentation) - - val previousNumberOfTypes =lastRepresentation.nodeRepresentations.values.toSet.size + val nextRange = lastRange + 1 + val next = calculateFurtherNodeDescriptors(model, lastRepresentation, IncomingRelations, OutgoingRelations, + parallels, maxNumbers) + val nextRepresentation = createFurtherRepresentation(next.key, next.value, lastRepresentation, + deepRepresentation) + + val previousNumberOfTypes = lastRepresentation.nodeRepresentations.values.toSet.size val nextNumberOfTypes = nextRepresentation.nodeRepresentations.values.toSet.size - hasRefined = nextNumberOfTypes > previousNumberOfTypes - + hasRefined = nextNumberOfTypes > previousNumberOfTypes + lastRange = nextRange lastRepresentation = nextRepresentation - + // if(hasRefined) { // println('''Level «nextRange» is calculated, number of types is refined: «previousNumberOfTypes» -> «nextNumberOfTypes»''') // } else { @@ -192,211 +218,219 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation> node2Type, Set relevantTypes) { - for(element : model.elements) { + + def private fillTypes(PartialInterpretation model, Map> node2Type, + Set relevantTypes) { + for (element : model.elements) { node2Type.put(element, new HashSet) } - + // for(typeDefinition : model.problem.types.filter(TypeDefinition)) { // // Dont need // } - for(typeInterpretation : model.partialtypeinterpratation) { - if(typeInterpretation instanceof PartialPrimitiveInterpretation) { - - } else if(typeInterpretation instanceof PartialComplexTypeInterpretation) { + for (typeInterpretation : model.partialtypeinterpratation) { + if (typeInterpretation instanceof PartialPrimitiveInterpretation) { + } else if (typeInterpretation instanceof PartialComplexTypeInterpretation) { val type = typeInterpretation.interpretationOf - if(type.isRelevant(relevantTypes)) { - for(element : typeInterpretation.elements) { + if (type.isRelevant(relevantTypes)) { + for (element : typeInterpretation.elements) { element.lookup(node2Type).add(type.name) } } } } } - + /** * Indexes the references */ def private fillReferences(PartialInterpretation model, Map>> IncomingRelations, Map>> OutgoingRelations, - Set relevantRelations) - { - for(object : model.elements) { - IncomingRelations.put(object,new LinkedList) - OutgoingRelations.put(object,new LinkedList) + Set relevantRelations) { + for (object : model.elements) { + IncomingRelations.put(object, new ArrayList) + OutgoingRelations.put(object, new ArrayList) } - for(relationInterpretation : model.partialrelationinterpretation) { + for (relationInterpretation : model.partialrelationinterpretation) { val type = relationInterpretation.interpretationOf - if(type.isRelevant(relevantRelations)) { - for(link : relationInterpretation.relationlinks) { - if(link instanceof BinaryElementRelationLink) { - OutgoingRelations.get(link.param1) += new OutgoingRelation(link.param2,type.name) - IncomingRelations.get(link.param2) += new IncomingRelation(link.param1,type.name) - } else throw new UnsupportedOperationException + if (type.isRelevant(relevantRelations)) { + for (link : relationInterpretation.relationlinks) { + if (link instanceof BinaryElementRelationLink) { + OutgoingRelations.get(link.param1) += new OutgoingRelation(link.param2, type.name) + IncomingRelations.get(link.param2) += new IncomingRelation(link.param1, type.name) + } else + throw new UnsupportedOperationException } } } } - + /** * Creates a local representation of the objects (aka zero range neighbourhood) */ - def abstract protected NeighbourhoodWithTraces createLocalRepresentation( + def abstract protected NeighbourhoodWithTraces createLocalRepresentation( Map node2Representation, Map representation2Amount ) - + /** * Creates a */ - def abstract protected NeighbourhoodWithTraces createFurtherRepresentation( + def abstract protected NeighbourhoodWithTraces createFurtherRepresentation( Map, Integer> nodeDescriptors, Map> node2Representation, - NeighbourhoodWithTraces previous, + NeighbourhoodWithTraces previous, boolean deepRepresentation ) - + def private addOne(int original, int max) { if(original == Integer.MAX_VALUE) return Integer.MAX_VALUE - if(original +1 > max) return Integer.MAX_VALUE - else return original+1 + if(original + 1 > max) return Integer.MAX_VALUE else return original + 1 } - + private def calculateIncomingEdges(Map>> IncomingRelations, - DefinedElement object, Map previousNodeRepresentations, int parallel) - { + DefinedElement object, Map previousNodeRepresentations, + int parallel) { val Map, Integer> res = new HashMap for (incomingConcreteEdge : IncomingRelations.get(object)) { val IncomingRelation e = new IncomingRelation( previousNodeRepresentations.get(incomingConcreteEdge.from), incomingConcreteEdge.type) if (res.containsKey(e)) { - res.put(e, addOne(res.get(e),parallel)) + res.put(e, addOne(res.get(e), parallel)) } else { res.put(e, 1) } } return res } - - private def calcuateOutgoingEdges(Map>> OutgoingRelations, - DefinedElement object, Map previousNodeRepresentations, int parallel) - { - val Map,Integer> res= new HashMap - for(outgoingConcreteEdge : OutgoingRelations.get(object)) { - val OutgoingRelation e = - new OutgoingRelation( - previousNodeRepresentations.get(outgoingConcreteEdge.to), - outgoingConcreteEdge.type) - if(res.containsKey(e)) { - res.put(e,addOne(res.get(e),parallel)) + + private def calcuateOutgoingEdges(Map>> OutgoingRelations, + DefinedElement object, Map previousNodeRepresentations, + int parallel) { + val Map, Integer> res = new HashMap + for (outgoingConcreteEdge : OutgoingRelations.get(object)) { + val OutgoingRelation e = new OutgoingRelation( + previousNodeRepresentations.get(outgoingConcreteEdge.to), outgoingConcreteEdge.type) + if (res.containsKey(e)) { + res.put(e, addOne(res.get(e), parallel)) } else { - res.put(e,1) + res.put(e, 1) } } return res; } - + /*def private void addOrCreate_Set(Map> map, KEY key, VALUE value) { - var Set s; - if(map.containsKey(key)) { - s = map.get(key); - } else { - s = new HashSet - map.put(key,s) - } - s.add(value) - }*/ - - - private def calculateFurtherNodeDescriptors( - PartialInterpretation model, + * var Set s; + * if(map.containsKey(key)) { + * s = map.get(key); + * } else { + * s = new HashSet + * map.put(key,s) + * } + * s.add(value) + }*/ + private def calculateFurtherNodeDescriptors(PartialInterpretation model, NeighbourhoodWithTraces previous, Map>> IncomingRelations, - Map>> OutgoingRelations, - int parallels, int maxNumber) - { + Map>> OutgoingRelations, int parallels, int maxNumber) { val previousNodeRepresentations = previous.nodeRepresentations - val node2Representation = new HashMap> - val Map,Integer> descriptor2Number = - if(this.mergeSimilarNeighbourhood){ new HashMap } else { null } - val Map,FurtherNodeDescriptor> uniqueDescription = - if(this.mergeSimilarNeighbourhood){ new HashMap } else { null } - - for(object: model.elements) { - val incomingEdges = this.calculateIncomingEdges(IncomingRelations, object, previousNodeRepresentations,parallels) - val outgoingEdges = this.calcuateOutgoingEdges(OutgoingRelations,object, previousNodeRepresentations,parallels) - + val node2Representation = new HashMap> + val Map, Integer> descriptor2Number = if (this. + mergeSimilarNeighbourhood) { + new HashMap + } else { + null + } + val Map, FurtherNodeDescriptor> uniqueDescription = if (this. + mergeSimilarNeighbourhood) { + new HashMap + } else { + null + } + + for (object : model.elements) { + val incomingEdges = this.calculateIncomingEdges(IncomingRelations, object, previousNodeRepresentations, + parallels) + val outgoingEdges = this.calcuateOutgoingEdges(OutgoingRelations, object, previousNodeRepresentations, + parallels) + val previousType = previousNodeRepresentations.get(object) - - if(previousType === null) { + + if (previousType === null) { println("Error in state coder") } - - val nodeDescriptor = new FurtherNodeDescriptor( - previousType, - incomingEdges, - outgoingEdges) - - if(this.mergeSimilarNeighbourhood) { - if(descriptor2Number.containsKey(nodeDescriptor)) { + + val nodeDescriptor = new FurtherNodeDescriptor(previousType, incomingEdges, outgoingEdges) + + if (this.mergeSimilarNeighbourhood) { + if (descriptor2Number.containsKey(nodeDescriptor)) { descriptor2Number.put( nodeDescriptor, - addOne(descriptor2Number.get(nodeDescriptor),maxNumber) + addOne(descriptor2Number.get(nodeDescriptor), maxNumber) ) - node2Representation.put(object,uniqueDescription.get(nodeDescriptor)) + node2Representation.put(object, uniqueDescription.get(nodeDescriptor)) } else { - descriptor2Number.put(nodeDescriptor,if(1>maxNumber){Integer.MAX_VALUE}else{1}) - uniqueDescription.put(nodeDescriptor,nodeDescriptor) - node2Representation.put(object,nodeDescriptor) + descriptor2Number.put(nodeDescriptor, if (1 > maxNumber) { + Integer.MAX_VALUE + } else { + 1 + }) + uniqueDescription.put(nodeDescriptor, nodeDescriptor) + node2Representation.put(object, nodeDescriptor) } } else { - node2Representation.put(object,nodeDescriptor) + node2Representation.put(object, nodeDescriptor) } } - + return descriptor2Number -> node2Representation } - - private def calculateLocalNodeDescriptors( - PartialInterpretation model, - Map> types, - int maxNumber) - { + + private def calculateLocalNodeDescriptors(PartialInterpretation model, Map> types, + int maxNumber, DefinedElement focusedElement) { val Map node2Representation = new HashMap - val Map representation2Amount = - if(mergeSimilarNeighbourhood){ new HashMap } else { null } - val Map uniqueRepresentation = - if(this.mergeSimilarNeighbourhood){ new HashMap } else { null } - - for(element : model.elements) { - var newDescriptor = new LocalNodeDescriptor(element.name,element.lookup(types)) - if(this.mergeSimilarNeighbourhood){ - if(uniqueRepresentation.containsKey(newDescriptor)) { + val Map representation2Amount = if (mergeSimilarNeighbourhood) { + new HashMap + } else { + null + } + val Map uniqueRepresentation = if (this.mergeSimilarNeighbourhood) { + new HashMap + } else { + null + } + + for (element : model.elements) { + val name = if(element == focusedElement) FOCUSED_ELEMENT_NAME else element.name + var newDescriptor = new LocalNodeDescriptor(name, element.lookup(types)) + if (this.mergeSimilarNeighbourhood) { + if (uniqueRepresentation.containsKey(newDescriptor)) { newDescriptor = newDescriptor.lookup(uniqueRepresentation) - node2Representation.put(element,newDescriptor) + node2Representation.put(element, newDescriptor) representation2Amount.put( newDescriptor, - addOne(newDescriptor.lookup(representation2Amount),maxNumber) + addOne(newDescriptor.lookup(representation2Amount), maxNumber) ) } else { - uniqueRepresentation.put(newDescriptor,newDescriptor) - node2Representation.put(element,newDescriptor) - representation2Amount.put(newDescriptor, if(1>maxNumber){Integer.MAX_VALUE}else{1}) + uniqueRepresentation.put(newDescriptor, newDescriptor) + node2Representation.put(element, newDescriptor) + representation2Amount.put(newDescriptor, if (1 > maxNumber) { + Integer.MAX_VALUE + } else { + 1 + }) } } else { - node2Representation.put(element,newDescriptor) + node2Representation.put(element, newDescriptor) } } - + return representation2Amount -> node2Representation } -} \ No newline at end of file +} diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2PairwiseNeighbourhoodRepresentation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2PairwiseNeighbourhoodRepresentation.xtend new file mode 100644 index 00000000..c10457b0 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2PairwiseNeighbourhoodRepresentation.xtend @@ -0,0 +1,68 @@ +package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood + +import com.google.common.collect.Maps +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation +import java.util.HashMap +import java.util.Map +import org.eclipse.xtend.lib.annotations.Data +import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor + +@Data +class PairwiseNeighbourhoodRepresentation { + val Map modelRepresentation + val Map basicNodeRepresentations + val Map> pairwiseNodeRepresentations + + def getBasicRepresentation(DefinedElement a) { + basicNodeRepresentations.get(a) + } + + def getPairwiseRepresentation(DefinedElement a, DefinedElement b) { + pairwiseNodeRepresentations.get(a).get(b) + } +} + +@FinalFieldsConstructor +class PartialInterpretation2PairwiseNeighbourhoodRepresentation { + val PartialInterpretation2NeighbourhoodRepresentation, BasicNodeRepresentation> basicNeighbourhoodRepresenter + + def createRepresentation(PartialInterpretation model, NeighbourhoodOptions options) { + val basicRepresentation = basicNeighbourhoodRepresenter.createRepresentation(model, options) + val basicModelRepresentation = basicRepresentation.modelRepresentation + val basicNodeRepresentations = basicRepresentation.nodeRepresentations + val pairwiseNodeRepresentations = Maps.newHashMapWithExpectedSize(basicNodeRepresentations.size) + val modelRepresentation = new HashMap + for (nodeWithBasicRepresentation : basicNodeRepresentations.entrySet) { + val node = nodeWithBasicRepresentation.key + val basicNodeRepresentation = nodeWithBasicRepresentation.value + val count = basicModelRepresentation.get(basicNodeRepresentation) + if (count == 1) { + pairwiseNodeRepresentations.put(node, basicNodeRepresentations) + modelRepresentation.put(basicNodeRepresentation, count) + } else { + val neighbourhoodRepresentation = basicNeighbourhoodRepresenter. + createRepresentationWithFocus(model, options, node) + pairwiseNodeRepresentations.put(node, neighbourhoodRepresentation.nodeRepresentations) + modelRepresentation.compute(neighbourhoodRepresentation.modelRepresentation) [ key, value | + if (value === null) { + if (1 > options.maxNumber) { + Integer.MAX_VALUE + } else { + 1 + } + } else { + addOne(value, options.maxNumber) + } + ] + } + } + new PairwiseNeighbourhoodRepresentation(modelRepresentation, basicNodeRepresentations, + pairwiseNodeRepresentations) + } + + def private addOne(int original, int max) { + if(original == Integer.MAX_VALUE) return Integer.MAX_VALUE + if(original + 1 > max) return Integer.MAX_VALUE else return original + 1 + } +} diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/AbstractNeighborhoodBasedStateCoderFactory.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/AbstractNeighborhoodBasedStateCoderFactory.xtend new file mode 100644 index 00000000..089880b1 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/AbstractNeighborhoodBasedStateCoderFactory.xtend @@ -0,0 +1,137 @@ +package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder + +import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.NeighbourhoodOptions +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage +import java.util.LinkedList +import java.util.List +import org.eclipse.emf.common.notify.Notifier +import org.eclipse.emf.ecore.EClass +import org.eclipse.emf.ecore.EObject +import org.eclipse.emf.ecore.EStructuralFeature +import org.eclipse.viatra.dse.statecode.IStateCoder +import org.eclipse.viatra.dse.statecode.IStateCoderFactory +import org.eclipse.viatra.query.runtime.api.IPatternMatch +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine +import org.eclipse.viatra.query.runtime.base.api.FeatureListener +import org.eclipse.viatra.query.runtime.base.api.IndexingLevel +import org.eclipse.viatra.query.runtime.base.api.InstanceListener +import org.eclipse.viatra.query.runtime.emf.EMFBaseIndexWrapper +import org.eclipse.viatra.query.runtime.emf.EMFScope +import org.eclipse.xtend.lib.annotations.Accessors + +abstract class AbstractNeighbourhoodBasedStateCoderFactory implements IStateCoderFactory { + val List statecoders = new LinkedList + + val NeighbourhoodOptions options + + protected new() { + this(NeighbourhoodOptions.DEFAULT) + } + + protected new(NeighbourhoodOptions options) { + this.options = options + } + + synchronized override createStateCoder() { + val res = doCreateStateCoder(options) + statecoders += res + return res + } + + protected def AbstractNeighbourhoodBasedPartialInterpretationStateCoder doCreateStateCoder( + NeighbourhoodOptions options) + + def getSumStatecoderRuntime() { + statecoders.map[statecoderRuntime].reduce[p1, p2|p1 + p2] + } +} + +abstract class AbstractNeighbourhoodBasedPartialInterpretationStateCoder implements IStateCoder { + val NeighbourhoodOptions options + + var PartialInterpretation target + + protected new(NeighbourhoodOptions options) { + this.options = options + } + + @Accessors(PUBLIC_GETTER) var long statecoderRuntime = 0 + + synchronized private def refreshStateCodes() { + if (refreshNeeded) { + val startTime = System.nanoTime + doRefreshStateCodes(target, options) + statecoderRuntime += (System.nanoTime - startTime) + } + } + + protected def boolean isRefreshNeeded() + + protected def void doRefreshStateCodes(PartialInterpretation target, NeighbourhoodOptions options) + + synchronized override createActivationCode(IPatternMatch match) { + refreshStateCodes + val startTime = System.nanoTime + val code = doCreateActivationCode(match) + statecoderRuntime += (System.nanoTime - startTime) + code + } + + protected def Object doCreateActivationCode(IPatternMatch match) + + synchronized override createStateCode() { + refreshStateCodes + doCreateStateCode + } + + protected def Object doCreateStateCode() + + override init(Notifier notifier) { + this.target = notifier as PartialInterpretation + val queryEngine = ViatraQueryEngine.on(new EMFScope(notifier)) + val baseIndex = queryEngine.getBaseIndex() as EMFBaseIndexWrapper + val navigationHelper = baseIndex.getNavigationHelper(); + + val classes = PartialinterpretationPackage.eINSTANCE.EClassifiers.filter(EClass).toSet + val features = classes.map[it.EAllStructuralFeatures].flatten.toSet + navigationHelper.registerObservedTypes(classes, null, features, IndexingLevel.FULL); + + navigationHelper.addFeatureListener(features, new FeatureListener() { + override void featureInserted(EObject host, EStructuralFeature feature, Object value) { invalidate } + + override void featureDeleted(EObject host, EStructuralFeature feature, Object value) { invalidate } + }) + navigationHelper.addInstanceListener(classes, new InstanceListener() { + override void instanceInserted(EClass clazz, EObject instance) { invalidate } + + override void instanceDeleted(EClass clazz, EObject instance) { invalidate } + }) + } + + synchronized def invalidate() { + doInvalidate + } + + protected def void doInvalidate() + + def protected getFallbackCode(Object o) { + switch (o) { + PartialInterpretation, + LogicProblem: + null + PartialRelationInterpretation: + o.interpretationOf.name + PartialPrimitiveInterpretation: + o.class.simpleName.hashCode + PartialComplexTypeInterpretation: + o.interpretationOf.name.hashCode + default: + throw new UnsupportedOperationException('''Unsupported type: «o.class.simpleName»''') + } + } +} diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/IdentifierBasedStateCoderFactory.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/IdentifierBasedStateCoderFactory.xtend index f55a501a..c7b8ee37 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/IdentifierBasedStateCoderFactory.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/IdentifierBasedStateCoderFactory.xtend @@ -62,13 +62,13 @@ class IdentifierBasedStateCode { int numberOfNewElement SortedSet relationStatecoders - private static val comparator = new Comparator() { + static val comparator = new Comparator() { override compare(RelationStatecoder o1, RelationStatecoder o2) { o1.relationName.compareTo(o2.relationName) } } - public new(int numberOfNewElements) { + new(int numberOfNewElements) { this.numberOfNewElement = numberOfNewElements this.relationStatecoders = new TreeSet(comparator) } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/NeighbourhoodBasedStateCoderFactory.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/NeighbourhoodBasedStateCoderFactory.xtend index a86bcd1f..4ff39999 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/NeighbourhoodBasedStateCoderFactory.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/NeighbourhoodBasedStateCoderFactory.xtend @@ -1,223 +1,86 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.AbstractNodeDescriptor +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.NeighbourhoodOptions import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2ImmutableTypeLattice import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage import java.util.ArrayList -import java.util.LinkedList -import java.util.List import java.util.Map -import org.eclipse.emf.common.notify.Notifier -import org.eclipse.emf.ecore.EClass -import org.eclipse.emf.ecore.EObject -import org.eclipse.emf.ecore.EStructuralFeature -import org.eclipse.viatra.dse.statecode.IStateCoder -import org.eclipse.viatra.dse.statecode.IStateCoderFactory import org.eclipse.viatra.query.runtime.api.IPatternMatch -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine -import org.eclipse.viatra.query.runtime.base.api.FeatureListener -import org.eclipse.viatra.query.runtime.base.api.IndexingLevel -import org.eclipse.viatra.query.runtime.base.api.InstanceListener -import org.eclipse.viatra.query.runtime.emf.EMFBaseIndexWrapper -import org.eclipse.viatra.query.runtime.emf.EMFScope -import org.eclipse.xtend.lib.annotations.Accessors -import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement -import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation -import java.util.Set -import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration -import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2NeighbourhoodRepresentation -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation - -class NeighbourhoodBasedStateCoderFactory implements IStateCoderFactory { - val List statecoders = new LinkedList - - val int range - val int parallels - val int maxNumber - val Set relevantTypes - val Set relevantRelations - - public new() { - this.range = PartialInterpretation2NeighbourhoodRepresentation::GraphWidthRange - this.parallels = PartialInterpretation2NeighbourhoodRepresentation::FullParallels - this.maxNumber = PartialInterpretation2NeighbourhoodRepresentation::MaxNumbers - this.relevantTypes = null - this.relevantRelations = null + +class NeighbourhoodBasedStateCoderFactory extends AbstractNeighbourhoodBasedStateCoderFactory { + new() { } - - public new(int range, int parallels, int maxNumber, Set relevantTypes, Set relevantRelations) { - this.range = range - this.parallels = parallels - this.maxNumber = maxNumber - this.relevantTypes = relevantTypes - this.relevantRelations = relevantRelations + + new(NeighbourhoodOptions options) { + super(options) + } + + override protected doCreateStateCoder(NeighbourhoodOptions options) { + new NeighbourhoodBasedPartialInterpretationStateCoder(options) } - - synchronized override createStateCoder() { - val res = new NeighbourhoodBasedPartialInterpretationStateCoder(statecoders.size, - range,parallels,maxNumber,relevantTypes,relevantRelations) - statecoders += res - return res - } - def getSumStatecoderRuntime() { - statecoders.map[statecoderRuntime].reduce[p1, p2|p1+p2] - } + } -class NeighbourhoodBasedPartialInterpretationStateCoder implements IStateCoder{ - val int id; - val int range - val int parallels - val int maxNumber - val Set relevantTypes - val Set relevantRelations - - val calculator = - new PartialInterpretation2ImmutableTypeLattice - var PartialInterpretation target - - private var Map nodeRepresentations = null - private var Map modelRepresentation = null - - /*public new(int id) { - this.id = id - this.range = PartialInterpretation2NeighbourhoodRepresentation::FixPointRage - this.parallels = PartialInterpretation2NeighbourhoodRepresentation::FullParallels - this.maxNumber = maxNumber = PartialInterpretation2NeighbourhoodRepresentation::MaxNumbers - this.relevantTypes = relevantTypes - this.relevantRelations = relevantRelations - }*/ - - public new(int id, int range, int parallels, int maxNumber, Set relevantTypes, Set relevantRelations) { - this.id = id - this.range = range - this.parallels = parallels - this.maxNumber = maxNumber - this.relevantTypes = relevantTypes - this.relevantRelations = relevantRelations +class NeighbourhoodBasedPartialInterpretationStateCoder extends AbstractNeighbourhoodBasedPartialInterpretationStateCoder { + val calculator = new PartialInterpretation2ImmutableTypeLattice + + var Map nodeRepresentations = null + var Map modelRepresentation = null + + new(NeighbourhoodOptions options) { + super(options) } - - @Accessors(PUBLIC_GETTER) var long statecoderRuntime = 0 - -// val range = -1 -// val par = Integer.MAX_VALUE - //val deeprepresentation = false - - ///////// - // Caching version - ///////// - synchronized private def refreshStateCodes() { - if(this.nodeRepresentations === null || this.modelRepresentation === null) { - val startTime = System.nanoTime - //relevantObjects.forEach[println(it)] - val code = calculator.createRepresentation(target,range,parallels,maxNumber,relevantTypes,relevantRelations) - this.modelRepresentation = code.modelRepresentation - this.nodeRepresentations = code.nodeRepresentations - statecoderRuntime += (System.nanoTime - startTime) - } - } - synchronized override createActivationCode(IPatternMatch match) { - refreshStateCodes - - val startTime = System.nanoTime - val size = match.specification.parameters.size - val res = new ArrayList(size) - var int index = 0 - var int equivalenceHash = 0 - val prime = 31 - - while(index < size) { - res.add(getCode(match.get(index))) - index++ - for(var i = 0; i(res->equivalenceHash).hashCode - } - - - def private getCode(Object o) { - if(o instanceof DefinedElement) { - this.nodeRepresentations.get(o) - } else if(o instanceof PartialInterpretation || o instanceof LogicProblem) { - return null - } else if(o instanceof PartialRelationInterpretation) { - return o.interpretationOf.name - } else if(o instanceof PartialTypeInterpratation) { - if(o instanceof PartialPrimitiveInterpretation) { - o.class.simpleName.hashCode - } else if (o instanceof PartialComplexTypeInterpretation){ - return o.interpretationOf.name.hashCode - } else { - throw new UnsupportedOperationException('''Unsupported type: «o.class.simpleName»''') + + override protected isRefreshNeeded() { + nodeRepresentations === null || modelRepresentation === null + } + + override doRefreshStateCodes(PartialInterpretation target, NeighbourhoodOptions options) { + val code = calculator.createRepresentation(target, options) + modelRepresentation = code.modelRepresentation + nodeRepresentations = code.nodeRepresentations + } + + override doCreateActivationCode(IPatternMatch match) { + val size = match.specification.parameters.size + val res = new ArrayList(size) + var int index = 0 + var int equivalenceHash = 0 + val prime = 31 + + while (index < size) { + res.add(getCode(match.get(index))) + index++ + for (var i = 0; i < index; i++) { + val number = if (match.get(index) === match.get(i)) { + 1 + } else { + 0 + } + equivalenceHash = prime * equivalenceHash + number } - } else { - throw new UnsupportedOperationException('''Unsupported type: «o.class.simpleName»''') } - } - - synchronized override createStateCode() { - refreshStateCodes - return this.modelRepresentation.hashCode - } - ///////// - // Caching version - ///////// - - ///////// - // Recalculating version - ///////// -// synchronized override createActivationCode(IPatternMatch match) { -// val nodes = calculator.createRepresentation(getRelevantObjects().toList,range,par).nodeRepresentations -// val res = match.toArray.map[objectInMatch | -// nodes.get(objectInMatch) -// ] -// return res -// } -// -// override createStateCode() { -// return this.calculator.createRepresentation(getRelevantObjects().toList,range,par).modelRepresentation -// } - ///////// - // Recalculating version - ///////// - - override init(Notifier notifier) { - this.target = notifier as PartialInterpretation - val queryEngine = ViatraQueryEngine.on(new EMFScope(notifier)) - val baseIndex = queryEngine.getBaseIndex() as EMFBaseIndexWrapper - val navigationHelper = baseIndex.getNavigationHelper(); - - val classes = PartialinterpretationPackage.eINSTANCE.EClassifiers.filter(EClass).toSet - val features = classes.map[it.EAllStructuralFeatures].flatten.toSet - navigationHelper.registerObservedTypes( - classes, - null, - features, - IndexingLevel.FULL); - - - navigationHelper.addFeatureListener(features, new FeatureListener() { - override public void featureInserted(EObject host, EStructuralFeature feature, Object value) { invalidate } - override public void featureDeleted(EObject host, EStructuralFeature feature, Object value) { invalidate } - }); - navigationHelper.addInstanceListener(classes, new InstanceListener() { - override public void instanceInserted(EClass clazz, EObject instance) { invalidate } - override public void instanceDeleted(EClass clazz, EObject instance) { invalidate } - }); - } - - synchronized def public invalidate() { - this.nodeRepresentations = null - this.modelRepresentation = null + + match.specification.fullyQualifiedName -> (res -> equivalenceHash).hashCode + } + + def private getCode(Object o) { + switch (o) { + DefinedElement: + nodeRepresentations.get(o) + default: + getFallbackCode(o) + } + } + + override doCreateStateCode() { + modelRepresentation.hashCode + } + + override doInvalidate() { + nodeRepresentations = null + modelRepresentation = null } } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/PairwiseNeighbourhoodBasedStateCoderFactory.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/PairwiseNeighbourhoodBasedStateCoderFactory.xtend new file mode 100644 index 00000000..84e798f2 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/PairwiseNeighbourhoodBasedStateCoderFactory.xtend @@ -0,0 +1,75 @@ +package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder + +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.AbstractNodeDescriptor +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.NeighbourhoodOptions +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PairwiseNeighbourhoodRepresentation +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2ImmutableTypeLattice +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2PairwiseNeighbourhoodRepresentation +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation +import java.util.ArrayList +import org.eclipse.viatra.query.runtime.api.IPatternMatch + +class PairwiseNeighbourhoodBasedStateCoderFactory extends AbstractNeighbourhoodBasedStateCoderFactory { + new() { + } + + new(NeighbourhoodOptions options) { + super(options) + } + + override protected doCreateStateCoder(NeighbourhoodOptions options) { + new PairwiseNeighbourhoodBasedPartialInterpretationStateCoder(options) + } +} + +class PairwiseNeighbourhoodBasedPartialInterpretationStateCoder extends AbstractNeighbourhoodBasedPartialInterpretationStateCoder { + val calculator = new PartialInterpretation2PairwiseNeighbourhoodRepresentation( + new PartialInterpretation2ImmutableTypeLattice) + var PairwiseNeighbourhoodRepresentation representation + + new(NeighbourhoodOptions options) { + super(options) + } + + override protected isRefreshNeeded() { + representation === null + } + + override protected doRefreshStateCodes(PartialInterpretation target, NeighbourhoodOptions options) { + representation = calculator.createRepresentation(target, options) + } + + override protected doCreateActivationCode(IPatternMatch match) { + val size = match.specification.parameters.size + val res = new ArrayList(size * size) + for (var int i = 0; i < size; i++) { + val a = match.get(i) + for (var int j = 0; j < size; j++) { + val b = match.get(j) + res.add(getPairwiseRepresentation(a, b)) + } + } + match.specification.fullyQualifiedName -> res.hashCode + } + + private def getPairwiseRepresentation(Object a, Object b) { + if (b instanceof DefinedElement) { + if (a instanceof DefinedElement) { + representation.getPairwiseRepresentation(a, b) + } else { + representation.getBasicRepresentation(b) + } + } else { + getFallbackCode(b) + } + } + + override protected doCreateStateCode() { + representation.modelRepresentation.hashCode + } + + override protected doInvalidate() { + representation = null + } +} -- cgit v1.2.3-54-g00ecf From fc84d3fe670331bc89fb1e4c44104bc1fc811438 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Wed, 14 Aug 2019 18:26:33 +0200 Subject: Measurements WIP --- .../.ApplicationConfigurationIdeModule.xtendbin | Bin 1701 -> 1701 bytes .../ide/.ApplicationConfigurationIdeSetup.xtendbin | Bin 2570 -> 2570 bytes .../domains/transima/fam/FamPatterns.vql | 2 +- .../domains/cps/dse/RuleBasedCpsSolver.xtend | 6 +- .../.classpath | 7 +- .../.project | 1 + .../.settings/org.eclipse.core.resources.prefs | 3 - .../META-INF/MANIFEST.MF | 16 +- .../configs/generation.vsconfig | 2 +- .../ecore-gen/satellite/CommSubsystem.java | 20 +- .../ecore-gen/satellite/ConstellationMission.java | 2 +- .../ecore-gen/satellite/InterferometryMission.java | 28 -- .../ecore-gen/satellite/SatellitePackage.java | 88 +----- .../satellite/impl/CommSubsystemImpl.java | 115 +------ .../satellite/impl/InterferometryMissionImpl.java | 130 -------- .../satellite/impl/SatellitePackageImpl.java | 37 +-- .../inputs/SatelliteInstance.xmi | 9 +- .../model/satellite.ecore | 12 +- .../model/satellite.genmodel | 5 +- .../model/satellite.henshin | 61 ---- .../model/satellite.henshin_diagram | 131 -------- .../model/satellite_fixup.henshin | 61 ---- .../plugin.xml | 1 + .../representations.aird | 2 + .../domains/satellite/mdeo/CostObjective.xtend | 13 - .../satellite/mdeo/LocalSearchEngineManager.xtend | 31 -- .../mdeo/MetricBasedGuidanceFunction.xtend | 47 --- .../satellite/mdeo/PatternMatchConstraint.xtend | 29 -- .../satellite/mdeo/SatelliteMdeOptimiserMain.xtend | 51 --- .../domains/satellite/mdeo/satellite.mopt | 36 --- .../domains/satellite/queries/SatelliteQueries.vql | 11 +- .../META-INF/MANIFEST.MF | 3 +- .../plugin.xml | 74 +---- .../yakindu/mutated/mutated.vql | 270 ---------------- .../partialsnapshot_mavo/yakindu/patterns.vql | 64 ++-- .../ModelGenerationMethodProvider.xtend | 35 +- .../cardinality/LinearTypeConstraintHint.xtend | 30 ++ .../cardinality/PolyhedronScopePropagator.xtend | 106 +++++-- .../cardinality/PolyhedronSolver.xtend | 72 ++++- .../cardinality/RelationConstraintCalculator.xtend | 5 +- .../logic2viatra/cardinality/ScopePropagator.xtend | 25 +- .../cardinality/ScopePropagatorStrategy.xtend | 11 +- .../cardinality/TypeHierarchyScopePropagator.xtend | 20 +- .../cardinality/Z3PolyhedronSolver.xtend | 32 +- .../logic2viatra/patterns/PatternGenerator.xtend | 18 +- .../logic2viatra/patterns/PatternProvider.xtend | 6 +- .../patterns/RelationRefinementGenerator.xtend | 2 +- .../logic2viatra/patterns/UnfinishedIndexer.xtend | 26 +- .../rules/RefinementRuleProvider.xtend | 15 +- .../PartialInterpretation.java | 24 ++ .../PartialinterpretationPackage.java | 60 +++- .../partialinterpretation/Scope.java | 24 ++ .../impl/BinaryElementRelationLinkImpl.java | 4 + .../impl/BooleanElementImpl.java | 4 +- .../impl/IntegerElementImpl.java | 4 +- .../impl/NaryRelationLinkElementImpl.java | 6 +- .../impl/NaryRelationLinkImpl.java | 1 + .../impl/PartialComplexTypeInterpretationImpl.java | 3 + .../impl/PartialConstantInterpretationImpl.java | 2 + .../impl/PartialFunctionInterpretationImpl.java | 2 + .../impl/PartialInterpretationImpl.java | 73 ++++- .../impl/PartialRelationInterpretationImpl.java | 7 + .../impl/PartialTypeInterpratationImpl.java | 2 + .../impl/PartialinterpretationFactoryImpl.java | 19 ++ .../impl/PartialinterpretationPackageImpl.java | 88 +++++- .../impl/PrimitiveElementImpl.java | 4 +- .../impl/RealElementImpl.java | 4 +- .../partialinterpretation/impl/ScopeImpl.java | 64 +++- .../impl/StringElementImpl.java | 4 +- .../impl/UnaryElementRelationLinkImpl.java | 2 + .../model/PartialInterpretation.ecore | 6 + .../model/PartialInterpretation.genmodel | 14 +- .../neighbourhood/Descriptor.xtend | 8 + .../neighbourhood/NeighbourhoodOptions.xtend | 4 +- .../neighbourhood/PartialInterpretation2Hash.xtend | 2 +- ...nterpretation2NeighbourhoodRepresentation.xtend | 4 +- .../NeighbourhoodBasedStateCoderFactory.xtend | 29 +- .../viatrasolver/reasoner/ViatraReasoner.xtend | 25 +- .../reasoner/ViatraReasonerConfiguration.xtend | 3 + .../reasoner/dse/BasicScopeGlobalConstraint.xtend | 103 ++++++ .../dse/BestFirstStrategyForModelGeneration.java | 2 +- .../dse/ModelGenerationCompositeObjective.xtend | 2 +- .../viatrasolver/reasoner/dse/ScopeObjective.xtend | 4 +- .../reasoner/dse/UnfinishedWFObjective.xtend | 34 +- .../reasoner/dse/ViatraReasonerSolutionSaver.xtend | 11 +- .../META-INF/MANIFEST.MF | 8 +- ..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 13 + ..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 16 + ..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 15 + ..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 15 + ..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 17 + .../initialModels/satellite.xmi | 14 + .../bme/mit/inf/dslreasoner/run/CountMatches.xtend | 176 ----------- .../run/Ecore2LogicTraceBasedHint.xtend | 56 ++++ .../mit/inf/dslreasoner/run/MetamodelLoader.xtend | 302 +++++++++++++----- .../bme/mit/inf/dslreasoner/run/SGraphHint.xtend | 46 +++ .../mit/inf/dslreasoner/run/SatelliteHint.xtend | 86 +++++ .../run/TypeDistributionCalculator.xtend | 35 ++ .../dslreasoner/run/script/MeasurementScript.xtend | 70 ++++ .../run/script/MeasurementScriptRunner.xtend | 351 +++++++++++++++++++++ 100 files changed, 1976 insertions(+), 1667 deletions(-) delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.settings/org.eclipse.core.resources.prefs delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin_diagram delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite_fixup.henshin create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/representations.aird delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/CostObjective.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/LocalSearchEngineManager.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/mutated/mutated.vql create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/LinearTypeConstraintHint.xtend create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BasicScopeGlobalConstraint.xtend create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/FAM_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/fs_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/initialModels/satellite.xmi delete mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/CountMatches.xtend create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/Ecore2LogicTraceBasedHint.xtend create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphHint.xtend create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme') diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin index 069bd953..22db4093 100644 Binary files a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin and b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin differ diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin index 624846d6..3ad5d167 100644 Binary files a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin and b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin differ diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/src/hu/bme/mit/inf/dslreasoner/domains/transima/fam/FamPatterns.vql b/Domains/Examples/ModelGenExampleFAM_plugin/src/hu/bme/mit/inf/dslreasoner/domains/transima/fam/FamPatterns.vql index f0e48d42..1d9a6b6d 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/src/hu/bme/mit/inf/dslreasoner/domains/transima/fam/FamPatterns.vql +++ b/Domains/Examples/ModelGenExampleFAM_plugin/src/hu/bme/mit/inf/dslreasoner/domains/transima/fam/FamPatterns.vql @@ -10,7 +10,7 @@ pattern terminatorAndInformation(T : FAMTerminator, I : InformationLink) = { InformationLink.to(I,In); FunctionalInput.terminator(In,T); } - +/* @QueryBasedFeature pattern type(This : Function, Target : FunctionType) = { find rootElements(_Model, This); diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend index e4c758f0..503c06ea 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend @@ -35,18 +35,18 @@ class RuleBasedCpsSolver { val dse = new DesignSpaceExplorer dse.addMetaModelPackage(CpsPackage.eINSTANCE) dse.initialModel = problem.eResource.resourceSet - dse.addTransformationRule(createRule(RequirementNotSatisfied.instance).action [ + dse.addTransformationRule(createRule.precondition(RequirementNotSatisfied.instance).action [ val app = createApplicationInstance req.type.instances += app req.instances += app ].build) - dse.addTransformationRule(createRule(Allocate.instance).action [ + dse.addTransformationRule(createRule.precondition(Allocate.instance).action [ app.allocatedTo = host ].build) // dse.addTransformationRule(createRule(UnallocateAppInstance.instance).action [ // app.allocatedTo = null // ].build) - dse.addTransformationRule(createRule(CreateHostInstance.instance).action [ + dse.addTransformationRule(createRule.precondition(CreateHostInstance.instance).action [ hostType.instances += createHostInstance ].build) // dse.addTransformationRule(createRule(RemoveHostInstance.instance).action [ diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.classpath b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.classpath index e5e58475..6781ea8f 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.classpath +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.classpath @@ -3,9 +3,12 @@ - + + + + + - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.project b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.project index 16db5fc5..e594a173 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.project +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.project @@ -32,6 +32,7 @@ + org.eclipse.sirius.nature.modelingproject org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature org.eclipse.viatra.query.projectnature diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.settings/org.eclipse.core.resources.prefs b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 4a3e59e4..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -encoding//model/satellite.henshin=UTF-8 -encoding//model/satellite.henshin_diagram=UTF-8 diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/META-INF/MANIFEST.MF index 36d729b4..966fc660 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/META-INF/MANIFEST.MF +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/META-INF/MANIFEST.MF @@ -7,6 +7,7 @@ Bundle-ClassPath: . Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: hu.bme.mit.inf.dslreasoner.domains.satellite.queries, + hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal, satellite, satellite.impl, satellite.util @@ -22,20 +23,7 @@ Require-Bundle: org.eclipse.viatra.addon.querybasedfeatures.runtime, org.eclipse.viatra.dse.genetic, hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner;bundle-version="1.0.0", org.eclipse.emf.ecore.xmi;bundle-version="2.15.0", - uk.ac.kcl.inf.mdeoptimiser.libraries.core;bundle-version="1.0.0", - uk.ac.kcl.inf.mdeoptimiser.interfaces.cli;bundle-version="1.0.0", - org.eclipse.emf.henshin.interpreter;bundle-version="1.5.0", - uk.ac.kcl.inf.mdeoptimiser.libraries.rulegen;bundle-version="1.0.0", - org.sidiff.common;bundle-version="1.0.0", - org.sidiff.common.emf;bundle-version="1.0.0", - org.sidiff.common.emf.extensions;bundle-version="1.0.0", - org.moeaframework;bundle-version="2.13.0", - org.apache.commons.math3;bundle-version="3.6.1", - org.apache.commons.lang3;bundle-version="3.8.1", - com.google.inject;bundle-version="3.0.0", - org.sidiff.common.henshin;bundle-version="1.0.0", - org.sidiff.serge;bundle-version="1.0.0", - org.eclipse.viatra.query.runtime.rete;bundle-version="2.2.0" + org.eclipse.viatra.query.runtime.rete;bundle-version="2.0.0" Import-Package: org.apache.log4j Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.domains.satellite Bundle-ActivationPolicy: lazy diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/configs/generation.vsconfig b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/configs/generation.vsconfig index 66c468d0..2fb246c9 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/configs/generation.vsconfig +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/configs/generation.vsconfig @@ -2,7 +2,7 @@ import epackage "model/satellite.ecore" import viatra "src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql" generate { - metamodel = { package satellite excluding { InterferometryMission.observationTime } } + metamodel = { package satellite } constraints = { package hu.bme.mit.inf.dslreasoner.domains.satellite.queries } partial-model = { "inputs/SatelliteInstance.xmi"} solver = ViatraSolver diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/CommSubsystem.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/CommSubsystem.java index 90bca78c..3b9d7ecf 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/CommSubsystem.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/CommSubsystem.java @@ -2,7 +2,6 @@ */ package satellite; -import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; /** @@ -15,7 +14,6 @@ import org.eclipse.emf.ecore.EObject; *

*
    *
  • {@link satellite.CommSubsystem#getTarget Target}
  • - *
  • {@link satellite.CommSubsystem#getSource Source}
  • *
* * @see satellite.SatellitePackage#getCommSubsystem() @@ -26,14 +24,12 @@ public interface CommSubsystem extends EObject { /** * Returns the value of the 'Target' reference. - * It is bidirectional and its opposite is '{@link satellite.CommSubsystem#getSource Source}'. * * * @return the value of the 'Target' reference. * @see #setTarget(CommSubsystem) * @see satellite.SatellitePackage#getCommSubsystem_Target() - * @see satellite.CommSubsystem#getSource - * @model opposite="source" + * @model * @generated */ CommSubsystem getTarget(); @@ -48,18 +44,4 @@ public interface CommSubsystem extends EObject { */ void setTarget(CommSubsystem value); - /** - * Returns the value of the 'Source' reference list. - * The list contents are of type {@link satellite.CommSubsystem}. - * It is bidirectional and its opposite is '{@link satellite.CommSubsystem#getTarget Target}'. - * - * - * @return the value of the 'Source' reference list. - * @see satellite.SatellitePackage#getCommSubsystem_Source() - * @see satellite.CommSubsystem#getTarget - * @model opposite="target" - * @generated - */ - EList getSource(); - } // CommSubsystem diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/ConstellationMission.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/ConstellationMission.java index 6182d7ad..8ff69955 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/ConstellationMission.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/ConstellationMission.java @@ -53,7 +53,7 @@ public interface ConstellationMission extends EObject { * * @return the value of the 'Spacecraft' containment reference list. * @see satellite.SatellitePackage#getConstellationMission_Spacecraft() - * @model containment="true" lower="2" upper="50" + * @model containment="true" lower="2" * @generated */ EList getSpacecraft(); diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/InterferometryMission.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/InterferometryMission.java index eb4ea064..4e28df38 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/InterferometryMission.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/InterferometryMission.java @@ -7,39 +7,11 @@ package satellite; * A representation of the model object 'Interferometry Mission'. * * - *

- * The following features are supported: - *

- *
    - *
  • {@link satellite.InterferometryMission#getObservationTime Observation Time}
  • - *
* * @see satellite.SatellitePackage#getInterferometryMission() * @model * @generated */ public interface InterferometryMission extends ConstellationMission { - /** - * Returns the value of the 'Observation Time' attribute. - * The default value is "2.0". - * - * - * @return the value of the 'Observation Time' attribute. - * @see #setObservationTime(float) - * @see satellite.SatellitePackage#getInterferometryMission_ObservationTime() - * @model default="2.0" required="true" - * @generated - */ - float getObservationTime(); - - /** - * Sets the value of the '{@link satellite.InterferometryMission#getObservationTime Observation Time}' attribute. - * - * - * @param value the new value of the 'Observation Time' attribute. - * @see #getObservationTime() - * @generated - */ - void setObservationTime(float value); } // InterferometryMission diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/SatellitePackage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/SatellitePackage.java index 7be4ef84..9ca99311 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/SatellitePackage.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/SatellitePackage.java @@ -2,7 +2,6 @@ */ package satellite; -import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EReference; @@ -130,15 +129,6 @@ public interface SatellitePackage extends EPackage { */ int INTERFEROMETRY_MISSION__SPACECRAFT = CONSTELLATION_MISSION__SPACECRAFT; - /** - * The feature id for the 'Observation Time' attribute. - * - * - * @generated - * @ordered - */ - int INTERFEROMETRY_MISSION__OBSERVATION_TIME = CONSTELLATION_MISSION_FEATURE_COUNT + 0; - /** * The number of structural features of the 'Interferometry Mission' class. * @@ -146,7 +136,7 @@ public interface SatellitePackage extends EPackage { * @generated * @ordered */ - int INTERFEROMETRY_MISSION_FEATURE_COUNT = CONSTELLATION_MISSION_FEATURE_COUNT + 1; + int INTERFEROMETRY_MISSION_FEATURE_COUNT = CONSTELLATION_MISSION_FEATURE_COUNT + 0; /** * The number of operations of the 'Interferometry Mission' class. @@ -296,15 +286,6 @@ public interface SatellitePackage extends EPackage { */ int COMM_SUBSYSTEM__TARGET = 0; - /** - * The feature id for the 'Source' reference list. - * - * - * @generated - * @ordered - */ - int COMM_SUBSYSTEM__SOURCE = 1; - /** * The number of structural features of the 'Comm Subsystem' class. * @@ -312,7 +293,7 @@ public interface SatellitePackage extends EPackage { * @generated * @ordered */ - int COMM_SUBSYSTEM_FEATURE_COUNT = 2; + int COMM_SUBSYSTEM_FEATURE_COUNT = 1; /** * The number of operations of the 'Comm Subsystem' class. @@ -582,15 +563,6 @@ public interface SatellitePackage extends EPackage { */ int UHF_COMM_SUBSYSTEM__TARGET = COMM_SUBSYSTEM__TARGET; - /** - * The feature id for the 'Source' reference list. - * - * - * @generated - * @ordered - */ - int UHF_COMM_SUBSYSTEM__SOURCE = COMM_SUBSYSTEM__SOURCE; - /** * The number of structural features of the 'UHF Comm Subsystem' class. * @@ -628,15 +600,6 @@ public interface SatellitePackage extends EPackage { */ int XCOMM_SUBSYSTEM__TARGET = COMM_SUBSYSTEM__TARGET; - /** - * The feature id for the 'Source' reference list. - * - * - * @generated - * @ordered - */ - int XCOMM_SUBSYSTEM__SOURCE = COMM_SUBSYSTEM__SOURCE; - /** * The number of structural features of the 'XComm Subsystem' class. * @@ -674,15 +637,6 @@ public interface SatellitePackage extends EPackage { */ int KA_COMM_SUBSYSTEM__TARGET = COMM_SUBSYSTEM__TARGET; - /** - * The feature id for the 'Source' reference list. - * - * - * @generated - * @ordered - */ - int KA_COMM_SUBSYSTEM__SOURCE = COMM_SUBSYSTEM__SOURCE; - /** * The number of structural features of the 'Ka Comm Subsystem' class. * @@ -743,17 +697,6 @@ public interface SatellitePackage extends EPackage { */ EClass getInterferometryMission(); - /** - * Returns the meta object for the attribute '{@link satellite.InterferometryMission#getObservationTime Observation Time}'. - * - * - * @return the meta object for the attribute 'Observation Time'. - * @see satellite.InterferometryMission#getObservationTime() - * @see #getInterferometryMission() - * @generated - */ - EAttribute getInterferometryMission_ObservationTime(); - /** * Returns the meta object for class '{@link satellite.CommunicatingElement Communicating Element}'. * @@ -827,17 +770,6 @@ public interface SatellitePackage extends EPackage { */ EReference getCommSubsystem_Target(); - /** - * Returns the meta object for the reference list '{@link satellite.CommSubsystem#getSource Source}'. - * - * - * @return the meta object for the reference list 'Source'. - * @see satellite.CommSubsystem#getSource() - * @see #getCommSubsystem() - * @generated - */ - EReference getCommSubsystem_Source(); - /** * Returns the meta object for class '{@link satellite.Payload Payload}'. * @@ -988,14 +920,6 @@ public interface SatellitePackage extends EPackage { */ EClass INTERFEROMETRY_MISSION = eINSTANCE.getInterferometryMission(); - /** - * The meta object literal for the 'Observation Time' attribute feature. - * - * - * @generated - */ - EAttribute INTERFEROMETRY_MISSION__OBSERVATION_TIME = eINSTANCE.getInterferometryMission_ObservationTime(); - /** * The meta object literal for the '{@link satellite.impl.CommunicatingElementImpl Communicating Element}' class. * @@ -1060,14 +984,6 @@ public interface SatellitePackage extends EPackage { */ EReference COMM_SUBSYSTEM__TARGET = eINSTANCE.getCommSubsystem_Target(); - /** - * The meta object literal for the 'Source' reference list feature. - * - * - * @generated - */ - EReference COMM_SUBSYSTEM__SOURCE = eINSTANCE.getCommSubsystem_Source(); - /** * The meta object literal for the '{@link satellite.impl.PayloadImpl Payload}' class. * diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/CommSubsystemImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/CommSubsystemImpl.java index 21e385a8..d39abd4d 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/CommSubsystemImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/CommSubsystemImpl.java @@ -2,16 +2,11 @@ */ package satellite.impl; -import java.util.Collection; import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; -import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; -import org.eclipse.emf.ecore.util.InternalEList; import satellite.CommSubsystem; import satellite.SatellitePackage; @@ -24,7 +19,6 @@ import satellite.SatellitePackage; *

*
    *
  • {@link satellite.impl.CommSubsystemImpl#getTarget Target}
  • - *
  • {@link satellite.impl.CommSubsystemImpl#getSource Source}
  • *
* * @generated @@ -40,16 +34,6 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp */ protected CommSubsystem target; - /** - * The cached value of the '{@link #getSource() Source}' reference list. - * - * - * @see #getSource() - * @generated - * @ordered - */ - protected EList source; - /** * * @@ -97,25 +81,6 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp return target; } - /** - * - * - * @generated - */ - public NotificationChain basicSetTarget(CommSubsystem newTarget, NotificationChain msgs) { - CommSubsystem oldTarget = target; - target = newTarget; - if (eNotificationRequired()) { - ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, - SatellitePackage.COMM_SUBSYSTEM__TARGET, oldTarget, newTarget); - if (msgs == null) - msgs = notification; - else - msgs.add(notification); - } - return msgs; - } - /** * * @@ -123,70 +88,11 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp */ @Override public void setTarget(CommSubsystem newTarget) { - if (newTarget != target) { - NotificationChain msgs = null; - if (target != null) - msgs = ((InternalEObject) target).eInverseRemove(this, SatellitePackage.COMM_SUBSYSTEM__SOURCE, - CommSubsystem.class, msgs); - if (newTarget != null) - msgs = ((InternalEObject) newTarget).eInverseAdd(this, SatellitePackage.COMM_SUBSYSTEM__SOURCE, - CommSubsystem.class, msgs); - msgs = basicSetTarget(newTarget, msgs); - if (msgs != null) - msgs.dispatch(); - } else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, SatellitePackage.COMM_SUBSYSTEM__TARGET, newTarget, - newTarget)); - } - - /** - * - * - * @generated - */ - @Override - public EList getSource() { - if (source == null) { - source = new EObjectWithInverseResolvingEList(CommSubsystem.class, this, - SatellitePackage.COMM_SUBSYSTEM__SOURCE, SatellitePackage.COMM_SUBSYSTEM__TARGET); - } - return source; - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case SatellitePackage.COMM_SUBSYSTEM__TARGET: - if (target != null) - msgs = ((InternalEObject) target).eInverseRemove(this, SatellitePackage.COMM_SUBSYSTEM__SOURCE, - CommSubsystem.class, msgs); - return basicSetTarget((CommSubsystem) otherEnd, msgs); - case SatellitePackage.COMM_SUBSYSTEM__SOURCE: - return ((InternalEList) (InternalEList) getSource()).basicAdd(otherEnd, msgs); - } - return super.eInverseAdd(otherEnd, featureID, msgs); - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case SatellitePackage.COMM_SUBSYSTEM__TARGET: - return basicSetTarget(null, msgs); - case SatellitePackage.COMM_SUBSYSTEM__SOURCE: - return ((InternalEList) getSource()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); + CommSubsystem oldTarget = target; + target = newTarget; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SatellitePackage.COMM_SUBSYSTEM__TARGET, oldTarget, + target)); } /** @@ -201,8 +107,6 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp if (resolve) return getTarget(); return basicGetTarget(); - case SatellitePackage.COMM_SUBSYSTEM__SOURCE: - return getSource(); } return super.eGet(featureID, resolve, coreType); } @@ -219,10 +123,6 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp case SatellitePackage.COMM_SUBSYSTEM__TARGET: setTarget((CommSubsystem) newValue); return; - case SatellitePackage.COMM_SUBSYSTEM__SOURCE: - getSource().clear(); - getSource().addAll((Collection) newValue); - return; } super.eSet(featureID, newValue); } @@ -238,9 +138,6 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp case SatellitePackage.COMM_SUBSYSTEM__TARGET: setTarget((CommSubsystem) null); return; - case SatellitePackage.COMM_SUBSYSTEM__SOURCE: - getSource().clear(); - return; } super.eUnset(featureID); } @@ -255,8 +152,6 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp switch (featureID) { case SatellitePackage.COMM_SUBSYSTEM__TARGET: return target != null; - case SatellitePackage.COMM_SUBSYSTEM__SOURCE: - return source != null && !source.isEmpty(); } return super.eIsSet(featureID); } diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/InterferometryMissionImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/InterferometryMissionImpl.java index 3401ad51..450f8a9a 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/InterferometryMissionImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/InterferometryMissionImpl.java @@ -2,12 +2,7 @@ */ package satellite.impl; -import org.eclipse.emf.common.notify.Notification; - import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; - import satellite.InterferometryMission; import satellite.SatellitePackage; @@ -15,36 +10,10 @@ import satellite.SatellitePackage; * * An implementation of the model object 'Interferometry Mission'. * - *

- * The following features are implemented: - *

- *
    - *
  • {@link satellite.impl.InterferometryMissionImpl#getObservationTime Observation Time}
  • - *
* * @generated */ public class InterferometryMissionImpl extends ConstellationMissionImpl implements InterferometryMission { - /** - * The default value of the '{@link #getObservationTime() Observation Time}' attribute. - * - * - * @see #getObservationTime() - * @generated - * @ordered - */ - protected static final float OBSERVATION_TIME_EDEFAULT = 2.0F; - - /** - * The cached value of the '{@link #getObservationTime() Observation Time}' attribute. - * - * - * @see #getObservationTime() - * @generated - * @ordered - */ - protected float observationTime = OBSERVATION_TIME_EDEFAULT; - /** * * @@ -64,103 +33,4 @@ public class InterferometryMissionImpl extends ConstellationMissionImpl implemen return SatellitePackage.Literals.INTERFEROMETRY_MISSION; } - /** - * - * - * @generated - */ - @Override - public float getObservationTime() { - return observationTime; - } - - /** - * - * - * @generated - */ - @Override - public void setObservationTime(float newObservationTime) { - float oldObservationTime = observationTime; - observationTime = newObservationTime; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - SatellitePackage.INTERFEROMETRY_MISSION__OBSERVATION_TIME, oldObservationTime, observationTime)); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case SatellitePackage.INTERFEROMETRY_MISSION__OBSERVATION_TIME: - return getObservationTime(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * - * - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case SatellitePackage.INTERFEROMETRY_MISSION__OBSERVATION_TIME: - setObservationTime((Float) newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case SatellitePackage.INTERFEROMETRY_MISSION__OBSERVATION_TIME: - setObservationTime(OBSERVATION_TIME_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case SatellitePackage.INTERFEROMETRY_MISSION__OBSERVATION_TIME: - return observationTime != OBSERVATION_TIME_EDEFAULT; - } - return super.eIsSet(featureID); - } - - /** - * - * - * @generated - */ - @Override - public String toString() { - if (eIsProxy()) - return super.toString(); - - StringBuilder result = new StringBuilder(super.toString()); - result.append(" (observationTime: "); - result.append(observationTime); - result.append(')'); - return result.toString(); - } - } //InterferometryMissionImpl diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/SatellitePackageImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/SatellitePackageImpl.java index 17212a96..f6dc1e30 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/SatellitePackageImpl.java +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/SatellitePackageImpl.java @@ -2,7 +2,6 @@ */ package satellite.impl; -import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EReference; @@ -242,16 +241,6 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka return interferometryMissionEClass; } - /** - * - * - * @generated - */ - @Override - public EAttribute getInterferometryMission_ObservationTime() { - return (EAttribute) interferometryMissionEClass.getEStructuralFeatures().get(0); - } - /** * * @@ -322,16 +311,6 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka return (EReference) commSubsystemEClass.getEStructuralFeatures().get(0); } - /** - * - * - * @generated - */ - @Override - public EReference getCommSubsystem_Source() { - return (EReference) commSubsystemEClass.getEStructuralFeatures().get(1); - } - /** * * @@ -457,7 +436,6 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka createEReference(constellationMissionEClass, CONSTELLATION_MISSION__SPACECRAFT); interferometryMissionEClass = createEClass(INTERFEROMETRY_MISSION); - createEAttribute(interferometryMissionEClass, INTERFEROMETRY_MISSION__OBSERVATION_TIME); communicatingElementEClass = createEClass(COMMUNICATING_ELEMENT); createEReference(communicatingElementEClass, COMMUNICATING_ELEMENT__COMM_SUBSYSTEM); @@ -469,7 +447,6 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka commSubsystemEClass = createEClass(COMM_SUBSYSTEM); createEReference(commSubsystemEClass, COMM_SUBSYSTEM__TARGET); - createEReference(commSubsystemEClass, COMM_SUBSYSTEM__SOURCE); payloadEClass = createEClass(PAYLOAD); @@ -537,15 +514,12 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka initEReference(getConstellationMission_GroundStationNetwork(), this.getGroundStationNetwork(), null, "groundStationNetwork", null, 1, 1, ConstellationMission.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getConstellationMission_Spacecraft(), this.getSpacecraft(), null, "spacecraft", null, 2, 50, + initEReference(getConstellationMission_Spacecraft(), this.getSpacecraft(), null, "spacecraft", null, 2, -1, ConstellationMission.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(interferometryMissionEClass, InterferometryMission.class, "InterferometryMission", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getInterferometryMission_ObservationTime(), ecorePackage.getEFloat(), "observationTime", "2.0", - 1, 1, InterferometryMission.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, - IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(communicatingElementEClass, CommunicatingElement.class, "CommunicatingElement", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); @@ -564,12 +538,9 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka initEClass(commSubsystemEClass, CommSubsystem.class, "CommSubsystem", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getCommSubsystem_Target(), this.getCommSubsystem(), this.getCommSubsystem_Source(), "target", - null, 0, 1, CommSubsystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, - IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getCommSubsystem_Source(), this.getCommSubsystem(), this.getCommSubsystem_Target(), "source", - null, 0, -1, CommSubsystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, - IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getCommSubsystem_Target(), this.getCommSubsystem(), null, "target", null, 0, 1, + CommSubsystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, + !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(payloadEClass, Payload.class, "Payload", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/inputs/SatelliteInstance.xmi b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/inputs/SatelliteInstance.xmi index 7b8e355a..3d07a199 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/inputs/SatelliteInstance.xmi +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/inputs/SatelliteInstance.xmi @@ -4,11 +4,4 @@ xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:satellite="http://www.example.org/satellite" - xsi:schemaLocation="http://www.example.org/satellite ../model/satellite.ecore"> - - - - - + xsi:schemaLocation="http://www.example.org/satellite ../model/satellite.ecore"/> diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.ecore b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.ecore index 1685c756..9f17d43c 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.ecore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.ecore @@ -5,12 +5,9 @@ - - - + upperBound="-1" eType="#//Spacecraft" containment="true"/> + @@ -21,10 +18,7 @@ containment="true"/> - - + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.genmodel b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.genmodel index 09b5f64c..bc98abd6 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.genmodel +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.genmodel @@ -15,9 +15,7 @@ - - - + @@ -27,7 +25,6 @@ - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin deleted file mode 100644 index 33059424..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin_diagram b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin_diagram deleted file mode 100644 index a5c675d8..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin_diagram +++ /dev/null @@ -1,131 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite_fixup.henshin b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite_fixup.henshin deleted file mode 100644 index 224ced8f..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite_fixup.henshin +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml index a07867dc..b0b77996 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml @@ -8,6 +8,7 @@ + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/representations.aird b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/representations.aird new file mode 100644 index 00000000..efa8e366 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/representations.aird @@ -0,0 +1,2 @@ + + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/CostObjective.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/CostObjective.xtend deleted file mode 100644 index 43b2902f..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/CostObjective.xtend +++ /dev/null @@ -1,13 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo - -//import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric -// -//class CostObjective extends MetricBasedGuidanceFunction { -// new() { -// super(CostMetric.instance) -// } -// -// override getName() { -// "Cost" -// } -//} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/LocalSearchEngineManager.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/LocalSearchEngineManager.xtend deleted file mode 100644 index ee7f0060..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/LocalSearchEngineManager.xtend +++ /dev/null @@ -1,31 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo - -import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.SatelliteQueries -import java.util.WeakHashMap -import org.eclipse.emf.ecore.EObject -import org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions -import org.eclipse.viatra.query.runtime.emf.EMFScope -import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchHints - -class LocalSearchEngineManager { - public static val INSTANCE = new LocalSearchEngineManager - - val WeakHashMap engineMap = new WeakHashMap - - private new() { - } - - def getEngine(EObject eObject) { - engineMap.computeIfAbsent(eObject) [ - val scope = new EMFScope(it) - val localSearchHints = LocalSearchHints.^default.build - val options = ViatraQueryEngineOptions.defineOptions.withDefaultHint(localSearchHints).withDefaultBackend( - localSearchHints.queryBackendFactory).build - val engine = AdvancedViatraQueryEngine.on(scope, options) - SatelliteQueries.instance.prepare(engine) - engine - ] - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.xtend deleted file mode 100644 index 1529794f..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.xtend +++ /dev/null @@ -1,47 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo - -import org.eclipse.viatra.query.runtime.api.IPatternMatch -import org.eclipse.viatra.query.runtime.api.IQuerySpecification -import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution - -abstract class MetricBasedGuidanceFunction implements IGuidanceFunction { - val IQuerySpecification> querySpecification - - protected new(IQuerySpecification> querySpecification) { - this.querySpecification = querySpecification - if (querySpecification.parameters.size != 1) { - throw new IllegalArgumentException("Metric must have a single parameter") - } - } - - override computeFitness(Solution model) { - val value = getMetricValue(model) - computeFitness(value) - } - - protected def double computeFitness(double metricValue) { - metricValue - } - - private def getMetricValue(Solution solution) { - val model = solution.model - val queryEngine = LocalSearchEngineManager.INSTANCE.getEngine(model) - val matcher = querySpecification.getMatcher(queryEngine) - val iterator = matcher.allMatches.iterator - if (!iterator.hasNext) { - throw new IllegalStateException("Too few matches") - } - val objectValue = iterator.next.get(0) - if (objectValue instanceof Number) { - val doubleValue = objectValue.doubleValue - if (iterator.hasNext) { - throw new IllegalStateException("Too many matches") - } - doubleValue - } else { - throw new IllegalStateException("Metric value must be a number") - } - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend deleted file mode 100644 index b238e64f..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend +++ /dev/null @@ -1,29 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo - -import com.google.common.collect.ImmutableList -import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.SatelliteQueries -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction -import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution - -class PatternMatchConstraint implements IGuidanceFunction { - static val CONSTRAINT_ANNOTATION_NAME = "Constraint" - - val queries = ImmutableList.copyOf(SatelliteQueries.instance.specifications.filter [ - allAnnotations.exists[name == CONSTRAINT_ANNOTATION_NAME] - ]) - - override getName() { - "PatternMatch" - } - - override computeFitness(Solution solution) { - val model = solution.model - val queryEngine = LocalSearchEngineManager.INSTANCE.getEngine(model) - var int matchCount = 0 - for (query : queries) { - val matcher = query.getMatcher(queryEngine) - matchCount += matcher.countMatches - } - matchCount - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend deleted file mode 100644 index 58034c43..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend +++ /dev/null @@ -1,51 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo - -import java.io.BufferedReader -import java.io.BufferedWriter -import java.io.FileReader -import java.io.FileWriter -import java.util.Map -import org.eclipse.emf.ecore.EPackage -import org.eclipse.emf.ecore.resource.Resource -import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl -import satellite.SatellitePackage -import uk.ac.kcl.inf.mdeoptimiser.interfaces.cli.Run - -class SatelliteMdeOptimiserMain { - static val PROJECT_PATH = "." - static val MOPT_PATH = "src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt" - - private new() { - new IllegalStateException("This is a static utility class and should not be instantiated directly.") - } - - public static def void main(String[] args) { - Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION, - new XMIResourceFactoryImpl) - EPackage.Registry.INSTANCE.put(SatellitePackage.eNS_URI, SatellitePackage.eINSTANCE) - fixupHenshinModel("model/satellite.henshin", "model/satellite_fixup.henshin", - #{"satellite.ecore" -> SatellitePackage.eNS_URI}) - Run.main(#["-p", PROJECT_PATH, "-m", MOPT_PATH]) - } - - private def static void fixupHenshinModel(String originalPath, String outputPath, Map remapMap) { - val reader = new BufferedReader(new FileReader(originalPath)) - try { - val writer = new BufferedWriter(new FileWriter(outputPath)) - try { - var String line - while ((line = reader.readLine) !== null) { - for (entry : remapMap.entrySet) { - line = line.replace(entry.key, entry.value) - } - writer.write(line) - writer.write("\n") - } - } finally { - writer.close - } - } finally { - reader.close - } - } -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt deleted file mode 100644 index e9bd1a64..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt +++ /dev/null @@ -1,36 +0,0 @@ -problem { - basepath - metamodel - model <../inputs/SatelliteInstance.xmi> -} - -goal { - objective Cost minimise java { "hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo.CostObjective" } - constraint PatternMatch java { "hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo.PatternMatchConstraint" } -} - -search { -// mutate using unit "addCubeSat3U" - mutate { "CubeSat3U" } - mutate { "CubeSat6U" } - mutate { "SmallSat" } - mutate { "InterferometryPayload" } - mutate { "UHFCommSubsystem" } - mutate { "XCommSubsystem" } - mutate { "KaCommSubsystem" } -} - -solver { - optimisation provider moea algorithm NSGAII { - variation: mutation - population: 25 - mutation.step: 3 - mutation.strategy: random - } - - termination { - time: 120 - } - - batches 1 -} \ No newline at end of file diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql index c1d3f7d3..1f83a3b0 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql @@ -21,6 +21,13 @@ pattern transmittingGroundStationNetwork(Station : GroundStationNetwork) { find transmittingCommSubsystem(Station, _); } +@Constraint(severity = "error", key = {Station}, + message = "The ground station network may not have UHF communication subsystems.") +pattern roundStationNetworkUHF(Station : GroundStationNetwork) { + CommunicatingElement.commSubsystem(Station, Comm); + UHFCommSubsystem(Comm); +} + // At least two spacecraft must have the interferometry payload configured @Constraint(severity = "error", key = {Mission}, @@ -97,10 +104,6 @@ private pattern cubeSat3U(Sat : CubeSat3U) { CubeSat3U(Sat); } -private pattern cubeSat6U(Sat : CubeSat6U) { - CubeSat6U(Sat); -} - // No communication loops may exist // No spacecraft may directly communicate with itself diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF index 81ee8677..2666dc5e 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF @@ -9,8 +9,7 @@ Bundle-Localization: plugin Export-Package: hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm, hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl, hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.util, - hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu, - hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated + hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu Require-Bundle: org.eclipse.viatra.query.runtime, org.eclipse.core.runtime, org.eclipse.emf.ecore;visibility:=reexport, diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml index 993ec75d..7bf4a20b 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml @@ -9,6 +9,8 @@ + + @@ -21,10 +23,14 @@ + + + + @@ -32,72 +38,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/mutated/mutated.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/mutated/mutated.vql deleted file mode 100644 index 58f66fe2..00000000 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/mutated/mutated.vql +++ /dev/null @@ -1,270 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated - -import epackage "hu.bme.mit.inf.yakindumm" - -///////// -// Entry -///////// - -pattern entryInRegion_M0(r1 : Region, e1 : Entry) { - Region.vertices(r1, e1); -} -pattern entryInRegion_M1(r1 : Region, e1) { - Region.vertices(r1, e1); -} -pattern entryInRegion_M2(r1 : Region, e1: Entry) { - // For positive constraint - Region(r1);Entry(e1); -} - - -//@Constraint(severity="error", message="error", key = {r1}) -pattern noEntryInRegion_M0(r1 : Region) { - neg find entryInRegion_M0(r1, _); -} -pattern noEntryInRegion_M1(r1 : Region) { - neg find entryInRegion_M1(r1, _); -} -pattern noEntryInRegion_M2(r1 : Region) { - neg find entryInRegion_M2(r1, _); -} -pattern noEntryInRegion_M3(r1 : Region) { - find entryInRegion_M0(r1, _); -} -pattern noEntryInRegion_M4(r1 : Region) { - find entryInRegion_M1(r1, _); -} -pattern noEntryInRegion_M5(r1 : Region) { - find entryInRegion_M2(r1, _); -} - -//@Constraint(severity="error", message="error", key = {r}) -pattern multipleEntryInRegion_M0(r : Region) { - find entryInRegion_M0(r, e1); - find entryInRegion_M0(r, e2); - e1 != e2; -} -pattern multipleEntryInRegion_M1(r : Region) { - find entryInRegion_M1(r, e1); - find entryInRegion_M0(r, e2); - e1 != e2; -} -pattern multipleEntryInRegion_M2(r : Region) { - find entryInRegion_M2(r, e1); - find entryInRegion_M0(r, e2); - e1 != e2; -} -pattern multipleEntryInRegion_M3(r : Region) { - find entryInRegion_M0(r, e1); - find entryInRegion_M1(r, e2); - e1 != e2; -} -pattern multipleEntryInRegion_M4(r : Region) { - find entryInRegion_M2(r, e1); - find entryInRegion_M2(r, e2); - e1 != e2; -} -pattern multipleEntryInRegion_M5(r : Region) { - find entryInRegion_M0(r, e1); - find entryInRegion_M0(r, e2); -} - - -pattern transition_M0(t : Transition, src : Vertex, trg : Vertex) { - Transition.source(t, src); - Transition.target(t, trg); -} -pattern transition_M1(t : Transition, src : Vertex, trg : Vertex) { - Transition.source(t, src); - Vertex(trg); -} -pattern transition_M2(t : Transition, src : Vertex, trg : Vertex) { - Vertex(src); - Transition.target(t, trg); -} -pattern transition_M3(t : Transition, src : Vertex, trg : Vertex) { - Transition.source(t_x, src); - Transition.target(t, trg); -} -pattern transition_M4(t : Transition, src : Vertex, trg : Vertex) { - Transition.source(t, src); - Transition.target(t_x, trg); -} - -//@Constraint(severity="error", message="error", key = {e}) -pattern incomingToEntry_M0(t : Transition, e : Entry) { - find transition_M0(t, _, e); -} -pattern incomingToEntry_1(t : Transition, e) { - find transition_M0(t, _, e); -} -pattern incomingToEntry_2(t : Transition, e : Entry) { - find transition_M1(t, _, e); -} -pattern incomingToEntry_3(t : Transition, e : Entry) { - find transition_M2(t, _, e); -} -pattern incomingToEntry_4(t : Transition, e : Entry) { - find transition_M3(t, _, e); -} -pattern incomingToEntry_5(t : Transition, e : Entry) { - find transition_M4(t, _, e); -} - -pattern noOutgoingTransitionFromEntry_M0(e : Entry) { - neg find transition_M0(_, e, _); -} - -pattern noOutgoingTransitionFromEntry_M1(e) { - Vertex(e); - neg find transition_M0(_, e, _); -} -pattern noOutgoingTransitionFromEntry_M2(e : Entry) { - neg find transition_M1(_, e, _); -} -pattern noOutgoingTransitionFromEntry_M3(e : Entry) { - neg find transition_M2(_, e, _); -} -pattern noOutgoingTransitionFromEntry_M4(e : Entry) { - neg find transition_M3(_, e, _); -} -pattern noOutgoingTransitionFromEntry_M5(e : Entry) { - neg find transition_M4(_, e, _); -} - - -//@Constraint(severity="error", message="error", key = {e}) -pattern multipleTransitionFromEntry_M0(e : Entry, t1 : Transition, t2: Transition) { - Entry.outgoingTransitions(e,t1); - Entry.outgoingTransitions(e,t2); - t1!=t2; -} -pattern multipleTransitionFromEntry_M1(e, t1 : Transition, t2: Transition) { - Entry.outgoingTransitions(e,t1); - Entry.outgoingTransitions(e,t2); - t1!=t2; -} -pattern multipleTransitionFromEntry_M2(e : Entry, t1 : Transition, t2: Transition) { - Transition(t1); - Entry.outgoingTransitions(e,t2); - t1!=t2; -} -pattern multipleTransitionFromEntry_M3(e : Entry, t1 : Transition, t2: Transition) { - Entry.outgoingTransitions(e,t1); - Transition(t2); - t1!=t2; -} -pattern multipleTransitionFromEntry_M4(e : Entry, t1 : Transition, t2: Transition) { - Entry.outgoingTransitions(e,t1); - Entry.outgoingTransitions(e,t2); -} - -///////// -// Exit -///////// - -//@Constraint(severity="error", message="error", key = {e}) -pattern outgoingFromExit_M0(t : Transition, e : Exit) { - Exit.outgoingTransitions(e,t); -} -pattern outgoingFromExit_M1(t : Transition, e) { - Vertex.outgoingTransitions(e,t); -} -pattern outgoingFromExit_M2(t : Transition, e : Exit) { - Transition(t); - Exit(e); -} - -///////// -// Final -///////// - -//@Constraint(severity="error", message="error", key = {f}) -pattern outgoingFromFinal_M0(t : Transition, f : FinalState) { - FinalState.outgoingTransitions(f,t); -} -pattern outgoingFromFinal_M1(t : Transition, f) { - Vertex.outgoingTransitions(f,t); -} -pattern outgoingFromFinal_M2(t : Transition, f : FinalState) { - Transition(t); - FinalState(f); -} - -///////// -// State vs Region -///////// - -//@Constraint(severity="error", message="error", key = {region}) -pattern noStateInRegion_M0(region: Region) { - neg find StateInRegion_M0(region,_); -} -pattern noStateInRegion_M1(region: Region) { - neg find StateInRegion_M1(region,_); -} -pattern noStateInRegion_M2(region: Region) { - neg find StateInRegion_M2(region,_); -} -pattern noStateInRegion_M3(region: Region) { - find StateInRegion_M0(region,_); -} - -pattern StateInRegion_M0(region: Region, state: State) { - Region.vertices(region,state); -} -pattern StateInRegion_M1(region: Region, state) { - Region.vertices(region,state); -} -pattern StateInRegion_M2(region: Region, state:State) { - Region(region);State(state); -} - -///////// -// Choice -///////// - -@Constraint(severity="error", message="error", key = {c}) -pattern choiceHasNoOutgoing_M0(c : Choice) { - neg find transition_M0(_, c, _); -} -pattern choiceHasNoOutgoing_M1(c:Vertex) { - neg find transition_M0(_, c, _); -} -pattern choiceHasNoOutgoing_M2(c : Choice) { - neg find transition_M1(_, c, _); -} -pattern choiceHasNoOutgoing_M3(c : Choice) { - neg find transition_M2(_, c, _); -} -pattern choiceHasNoOutgoing_M4(c : Choice) { - neg find transition_M3(_, c, _); -} -pattern choiceHasNoOutgoing_M5(c : Choice) { - neg find transition_M4(_, c, _); -} -pattern choiceHasNoOutgoing_M6(c : Choice) { - find transition_M0(_, c, _); -} - -@Constraint(severity="error", message="error", key = {c}) -pattern choiceHasNoIncoming_M0(c: Choice) { - neg find transition_M0(_, _, c); -} -pattern choiceHasNoIncoming_M1(c:Vertex) { - neg find transition_M0(_, _, c); -} -pattern choiceHasNoIncoming_M2(c: Choice) { - neg find transition_M1(_, _, c); -} -pattern choiceHasNoIncoming_M3(c: Choice) { - neg find transition_M2(_, _, c); -} -pattern choiceHasNoIncoming_M4(c: Choice) { - neg find transition_M3(_, _, c); -} -pattern choiceHasNoIncoming_M5(c: Choice) { - neg find transition_M4(_, _, c); -} -pattern choiceHasNoIncoming_M6(c: Choice) { - find transition_M0(_, _, c); -} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql index f4bfa3c1..98a10cde 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql @@ -27,14 +27,22 @@ pattern transition(t : Transition, src : Vertex, trg : Vertex) { Transition.target(t, trg); } +pattern transitionFrom(t : Transition, src : Vertex) { + Transition.source(t, src); +} + +pattern transitionTo(t : Transition, trg : Vertex) { + Transition.target(t, trg); +} + @Constraint(severity="error", message="error", key = {e}) pattern incomingToEntry(t : Transition, e : Entry) { - find transition(t, _, e); + find transitionTo(t, e); } @Constraint(severity="error", message="error", key = {e}) pattern noOutgoingTransitionFromEntry(e : Entry) { - neg find transition(_, e, _); + neg find transitionFrom(_, e); } @Constraint(severity="error", message="error", key = {e}) @@ -80,12 +88,12 @@ pattern StateInRegion(region: Region, state: State) { @Constraint(severity="error", message="error", key = {c}) pattern choiceHasNoOutgoing(c : Choice) { - neg find transition(_, c, _); + neg find transitionFrom(_, c); } @Constraint(severity="error", message="error", key = {c}) pattern choiceHasNoIncoming(c: Choice) { - neg find transition(_, _, c); + neg find transitionTo(_, c); } ///////// @@ -94,27 +102,33 @@ pattern choiceHasNoIncoming(c: Choice) { @Constraint(severity="error", message="error", key = {s}) pattern synchHasNoOutgoing(s : Synchronization) { - neg find transition(_, s, _); + neg find transitionFrom(_, s); } @Constraint(severity="error", message="error", key = {s}) pattern synchHasNoIncoming(s : Synchronization) { - neg find transition(_, _, s); + neg find transitionTo(_, s); } @Constraint(severity="error", message="error", key = {s}) -pattern SynchronizedIncomingInSameRegion(s : Synchronization, v1 : Vertex, v2 : Vertex) { - find transition(t1, v1, s); - find transition(t2, v2, s); +pattern SynchronizedIncomingInSameRegion(s : Synchronization, t1 : Transition, t2 : Transition) { + find SynchronizedIncomingInSameRegionHelper1(r, s, t1); + find SynchronizedIncomingInSameRegionHelper1(r, s, t2); t1!=t2; - Region.vertices(r, v1); - Region.vertices(r, v2); } or { - find transition(t1, s, v1); - find transition(t2, s, v2); + find SynchronizedIncomingInSameRegionHelper2(r, s, t1); + find SynchronizedIncomingInSameRegionHelper2(r, s, t2); t1!=t2; +} + +pattern SynchronizedIncomingInSameRegionHelper1(r : Region, s : Synchronization, t1 : Transition) { + find transition(t1, v1, s); + Region.vertices(r, v1); +} + +pattern SynchronizedIncomingInSameRegionHelper2(r : Region, s : Synchronization, t1 : Transition) { + find transition(t1, s, v1); Region.vertices(r, v1); - Region.vertices(r, v2); } @Constraint(severity="error", message="error", key = {s}) @@ -136,18 +150,24 @@ pattern hasMultipleIncomingTrainsition(v : Synchronization) { } @Constraint(severity="error", message="error", key = {s}) -pattern SynchronizedRegionsAreNotSiblings(s : Synchronization, v1 : Vertex, v2 : Vertex) { - find transition(_, v1, s); - find transition(_, v2, s); - CompositeElement.regions.vertices(r1, v1); - CompositeElement.regions.vertices(r2, v2); +pattern SynchronizedRegionsAreNotSiblings(s : Synchronization, r1 : CompositeElement, r2 : CompositeElement) { + find SynchronizedRegionsAreNotSiblingsHelper1(s, r1); + find SynchronizedRegionsAreNotSiblingsHelper1(s, r2); r1 != r2; } or { + find SynchronizedRegionsAreNotSiblingsHelper2(s, r1); + find SynchronizedRegionsAreNotSiblingsHelper2(s, r2); + r1 != r2; +} + +pattern SynchronizedRegionsAreNotSiblingsHelper1(s : Synchronization, r1 : CompositeElement) { find transition(_, s, v1); - find transition(_, s, v2); CompositeElement.regions.vertices(r1, v1); - CompositeElement.regions.vertices(r2, v2); - r1 != r2; +} + +pattern SynchronizedRegionsAreNotSiblingsHelper2(s : Synchronization, r1 : CompositeElement) { + find transition(_, v1, s); + CompositeElement.regions.vertices(r1, v1); } /////////////////////////////// diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend index 23632d4d..e45ec1c8 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend @@ -5,6 +5,7 @@ import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.CbcPolyhedronSolver +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.MultiplicityGoalConstraintCalculator import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronScopePropagator import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraintCalculator @@ -46,16 +47,28 @@ class ModelGenerationStatistics { public var long preliminaryTypeAnalisisTime = 0 public var int decisionsTried = 0 - + synchronized def incrementDecisionCount() { decisionsTried++ } + + public var int transformationInvocations + synchronized def incrementTransformationCount() { + transformationInvocations++ + } + public var int scopePropagatorInvocations - + synchronized def incrementScopePropagationCount() { scopePropagatorInvocations++ } + + public var int scopePropagatorSolverInvocations + + synchronized def incrementScopePropagationSolverCount() { + scopePropagatorSolverInvocations++ + } } @Data class ModelGenerationMethod { @@ -93,6 +106,7 @@ class ModelGenerationMethodProvider { boolean nameNewElements, TypeInferenceMethod typeInferenceMethod, ScopePropagatorStrategy scopePropagatorStrategy, + Collection hints, DocumentationLevel debugLevel ) { val statistics = new ModelGenerationStatistics @@ -103,8 +117,8 @@ class ModelGenerationMethodProvider { val relationConstraints = relationConstraintCalculator.calculateRelationConstraints(logicProblem) val queries = patternProvider.generateQueries(logicProblem, emptySolution, statistics, existingQueries, - workspace, typeInferenceMethod, scopePropagatorStrategy, relationConstraints, writeFiles) - val scopePropagator = createScopePropagator(scopePropagatorStrategy, emptySolution, queries, statistics) + workspace, typeInferenceMethod, scopePropagatorStrategy, relationConstraints, hints, writeFiles) + val scopePropagator = createScopePropagator(scopePropagatorStrategy, emptySolution, hints, queries, statistics) scopePropagator.propagateAllScopeConstraints val objectRefinementRules = refinementRuleProvider.createObjectRefinementRules(queries, scopePropagator, nameNewElements, statistics) @@ -138,14 +152,20 @@ class ModelGenerationMethodProvider { } private def createScopePropagator(ScopePropagatorStrategy scopePropagatorStrategy, - PartialInterpretation emptySolution, GeneratedPatterns queries, ModelGenerationStatistics statistics) { + PartialInterpretation emptySolution, Collection hints, GeneratedPatterns queries, + ModelGenerationStatistics statistics) { + if (!hints.empty && !(scopePropagatorStrategy instanceof ScopePropagatorStrategy.Polyhedral)) { + throw new IllegalArgumentException("Only the Polyhedral scope propagator strategy can use hints.") + } switch (scopePropagatorStrategy) { - case ScopePropagatorStrategy.Count: + case ScopePropagatorStrategy.None, + case ScopePropagatorStrategy.Basic: new ScopePropagator(emptySolution, statistics) case ScopePropagatorStrategy.BasicTypeHierarchy: new TypeHierarchyScopePropagator(emptySolution, statistics) ScopePropagatorStrategy.Polyhedral: { val types = queries.refineObjectQueries.keySet.map[newType].toSet + val allPatternsByName = queries.allQueries.toMap[fullyQualifiedName] val solver = switch (scopePropagatorStrategy.solver) { case Z3Integer: new Z3PolyhedronSolver(false, scopePropagatorStrategy.timeoutSeconds) @@ -160,7 +180,8 @@ class ModelGenerationMethodProvider { scopePropagatorStrategy.solver) } new PolyhedronScopePropagator(emptySolution, statistics, types, queries.multiplicityConstraintQueries, - queries.hasElementInContainmentQuery, solver, scopePropagatorStrategy.requiresUpperBoundIndexing) + queries.hasElementInContainmentQuery, allPatternsByName, hints, solver, + scopePropagatorStrategy.requiresUpperBoundIndexing, scopePropagatorStrategy.updateHeuristic) } default: throw new IllegalArgumentException("Unknown scope propagator strategy: " + scopePropagatorStrategy) diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/LinearTypeConstraintHint.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/LinearTypeConstraintHint.xtend new file mode 100644 index 00000000..8c21ca1d --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/LinearTypeConstraintHint.xtend @@ -0,0 +1,30 @@ +package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality + +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation +import org.eclipse.viatra.query.runtime.api.IPatternMatch +import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher + +interface LinearTypeExpressionBuilderFactory { + def ViatraQueryMatcher createMatcher(String queryName) + + def LinearTypeExpressionBuilder createBuilder() +} + +interface LinearTypeExpressionBuilder { + def LinearTypeExpressionBuilder add(int scale, Type type) + + def LinearBoundedExpression build() +} + +@FunctionalInterface +interface RelationConstraintUpdater { + def void update(PartialInterpretation p) +} + +interface LinearTypeConstraintHint { + def CharSequence getAdditionalPatterns(PatternGenerator patternGenerator) + + def RelationConstraintUpdater createConstraintUpdater(LinearTypeExpressionBuilderFactory builderFactory) +} diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagator.xtend index 7c05e818..51dba244 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagator.xtend @@ -1,5 +1,7 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality +import com.google.common.cache.Cache +import com.google.common.cache.CacheBuilder import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableMap import com.google.common.collect.ImmutableSet @@ -15,6 +17,7 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.par import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope import java.util.ArrayDeque import java.util.ArrayList +import java.util.Collection import java.util.HashMap import java.util.HashSet import java.util.List @@ -29,26 +32,33 @@ import org.eclipse.viatra.query.runtime.emf.EMFScope import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { + static val CACHE_SIZE = 10000 + + val boolean updateHeuristic val Map scopeBounds val LinearBoundedExpression topLevelBounds val Polyhedron polyhedron val PolyhedronSaturationOperator operator val Set relevantRelations + val Cache cache = CacheBuilder.newBuilder.maximumSize(CACHE_SIZE).build List updaters = emptyList new(PartialInterpretation p, ModelGenerationStatistics statistics, Set possibleNewDynamicTypes, Map unfinishedMultiplicityQueries, IQuerySpecification> hasElementInContainmentQuery, - PolyhedronSolver solver, boolean propagateRelations) { + Map>> allPatternsByName, + Collection hints, PolyhedronSolver solver, boolean propagateRelations, + boolean updateHeuristic) { super(p, statistics) + this.updateHeuristic = updateHeuristic val builder = new PolyhedronBuilder(p) builder.buildPolyhedron(possibleNewDynamicTypes) scopeBounds = builder.scopeBounds topLevelBounds = builder.topLevelBounds polyhedron = builder.polyhedron operator = solver.createSaturationOperator(polyhedron) + propagateAllScopeConstraints() if (propagateRelations) { - propagateAllScopeConstraints() val maximumNumberOfNewNodes = topLevelBounds.upperBound if (maximumNumberOfNewNodes === null) { throw new IllegalStateException("Could not determine maximum number of new nodes, it may be unbounded") @@ -57,7 +67,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { throw new IllegalStateException("Maximum number of new nodes is not positive") } builder.buildMultiplicityConstraints(unfinishedMultiplicityQueries, hasElementInContainmentQuery, - maximumNumberOfNewNodes) + allPatternsByName, hints, maximumNumberOfNewNodes) relevantRelations = builder.relevantRelations updaters = builder.updaters } else { @@ -66,21 +76,40 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { } override void doPropagateAllScopeConstraints() { + super.doPropagateAllScopeConstraints() resetBounds() populatePolyhedronFromScope() // println(polyhedron) - val result = operator.saturate() -// println(polyhedron) - if (result == PolyhedronSaturationResult.EMPTY) { - setScopesInvalid() - } else { - populateScopesFromPolyhedron() - if (result != PolyhedronSaturationResult.SATURATED) { - super.propagateAllScopeConstraints() + val signature = polyhedron.createSignature + val cachedSignature = cache.getIfPresent(signature) + switch (cachedSignature) { + case null: { + statistics.incrementScopePropagationSolverCount + val result = operator.saturate() + if (result == PolyhedronSaturationResult.EMPTY) { + cache.put(signature, PolyhedronSignature.EMPTY) + setScopesInvalid() + } else { + val resultSignature = polyhedron.createSignature + cache.put(signature, resultSignature) + populateScopesFromPolyhedron() + } } + case PolyhedronSignature.EMPTY: + setScopesInvalid() + PolyhedronSignature.Bounds: { + polyhedron.applySignature(signature) + populateScopesFromPolyhedron() + } + default: + throw new IllegalStateException("Unknown polyhedron signature: " + signature) + } +// println(polyhedron) + if (updateHeuristic) { + copyScopeBoundsToHeuristic() } } - + override propagateAdditionToRelation(Relation r) { super.propagateAdditionToRelation(r) if (relevantRelations.contains(r)) { @@ -186,7 +215,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { } @FinalFieldsConstructor - private static class PolyhedronBuilder { + private static class PolyhedronBuilder implements LinearTypeExpressionBuilderFactory { static val INFINITY_SCALE = 10 val PartialInterpretation p @@ -197,6 +226,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { Map typeBounds int infinity ViatraQueryEngine queryEngine + Map>> allPatternsByName ImmutableList.Builder updatersBuilder Map scopeBounds @@ -222,9 +252,11 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { def buildMultiplicityConstraints( Map constraints, IQuerySpecification> hasElementInContainmentQuery, - int maximumNuberOfNewNodes) { + Map>> allPatternsByName, + Collection hints, int maximumNuberOfNewNodes) { infinity = maximumNuberOfNewNodes * INFINITY_SCALE queryEngine = ViatraQueryEngine.on(new EMFScope(p)) + this.allPatternsByName = allPatternsByName updatersBuilder = ImmutableList.builder val containmentConstraints = constraints.entrySet.filter[key.containment].groupBy[key.targetType] for (pair : containmentConstraints.entrySet) { @@ -238,10 +270,13 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { } } buildRelevantRelations(constraints.keySet) + for (hint : hints) { + updatersBuilder.add(hint.createConstraintUpdater(this)) + } updaters = updatersBuilder.build addCachedConstraintsToPolyhedron() } - + private def buildRelevantRelations(Set constraints) { val builder = ImmutableSet.builder for (constraint : constraints) { @@ -345,7 +380,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { } } - private def addCoefficients(Map accumulator, int scale, Map a) { + private static def addCoefficients(Map accumulator, int scale, Map a) { for (pair : a.entrySet) { val dimension = pair.key val currentValue = accumulator.get(pair.key) ?: 0 @@ -411,14 +446,41 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { } scopeBoundsBuilder.build } + + override createMatcher(String queryName) { + val querySpecification = allPatternsByName.get(queryName) + if (querySpecification === null) { + throw new IllegalArgumentException("Unknown pattern: " + queryName) + } + querySpecification.getMatcher(queryEngine) + } + + override createBuilder() { + new PolyhedronBuilderLinearTypeExpressionBuilder(this) + } } - private static interface RelationConstraintUpdater { - def void update(PartialInterpretation p) + @FinalFieldsConstructor + private static class PolyhedronBuilderLinearTypeExpressionBuilder implements LinearTypeExpressionBuilder { + val PolyhedronBuilder polyhedronBuilder + val Map coefficients = new HashMap + + override add(int scale, Type type) { + val typeCoefficients = polyhedronBuilder.subtypeDimensions.get(type) + if (typeCoefficients === null) { + throw new IllegalArgumentException("Unknown type: " + type) + } + PolyhedronBuilder.addCoefficients(coefficients, scale, typeCoefficients) + this + } + + override build() { + polyhedronBuilder.toExpression(coefficients) + } } @FinalFieldsConstructor - static class ContainmentConstraintUpdater implements RelationConstraintUpdater { + private static class ContainmentConstraintUpdater implements RelationConstraintUpdater { val String name val LinearBoundedExpression orphansLowerBound val LinearBoundedExpression orphansUpperBound @@ -460,7 +522,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { } @FinalFieldsConstructor - static class ContainmentRootConstraintUpdater implements RelationConstraintUpdater { + private static class ContainmentRootConstraintUpdater implements RelationConstraintUpdater { val LinearBoundedExpression typeCardinality val ViatraQueryMatcher hasElementInContainmentMatcher @@ -479,7 +541,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { } @FinalFieldsConstructor - static class UnfinishedMultiplicityConstraintUpdater implements RelationConstraintUpdater { + private static class UnfinishedMultiplicityConstraintUpdater implements RelationConstraintUpdater { val String name val LinearBoundedExpression availableMultiplicityExpression val ViatraQueryMatcher unfinishedMultiplicityMatcher @@ -500,7 +562,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { } @FinalFieldsConstructor - static class UnrepairableMultiplicityConstraintUpdater implements RelationConstraintUpdater { + private static class UnrepairableMultiplicityConstraintUpdater implements RelationConstraintUpdater { val String name val LinearBoundedExpression targetCardinalityExpression val ViatraQueryMatcher unrepairableMultiplicityMatcher diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend index 9c6cb82e..4e046190 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend @@ -3,6 +3,7 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality import java.util.List import java.util.Map import org.eclipse.xtend.lib.annotations.Accessors +import org.eclipse.xtend.lib.annotations.Data import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor interface PolyhedronSolver { @@ -52,16 +53,66 @@ class Polyhedron { val List expressionsToSaturate override toString() ''' - Dimensions: - «FOR dimension : dimensions» - «dimension» - «ENDFOR» - Constraints: - «FOR constraint : constraints» - «constraint» - «ENDFOR» + Dimensions: + «FOR dimension : dimensions» + «dimension» + «ENDFOR» + Constraints: + «FOR constraint : constraints» + «constraint» + «ENDFOR» ''' + def createSignature() { + val size = dimensions.size + constraints.size + val lowerBounds = newArrayOfSize(size) + val upperBounds = newArrayOfSize(size) + var int i = 0 + for (dimension : dimensions) { + lowerBounds.set(i, dimension.lowerBound) + upperBounds.set(i, dimension.upperBound) + i++ + } + for (constraint : constraints) { + lowerBounds.set(i, constraint.lowerBound) + upperBounds.set(i, constraint.upperBound) + i++ + } + new PolyhedronSignature.Bounds(lowerBounds, upperBounds) + } + + def applySignature(PolyhedronSignature.Bounds signature) { + val lowerBounds = signature.lowerBounds + val upperBounds = signature.upperBounds + var int i = 0 + for (dimension : dimensions) { + dimension.lowerBound = lowerBounds.get(i) + dimension.upperBound = upperBounds.get(i) + i++ + } + for (constraint : constraints) { + constraint.lowerBound = lowerBounds.get(i) + constraint.upperBound = upperBounds.get(i) + i++ + } + } +} + +abstract class PolyhedronSignature { + public static val EMPTY = new PolyhedronSignature { + override toString() { + "PolyhedronSignature.EMPTY" + } + } + + private new() { + } + + @Data + static class Bounds extends PolyhedronSignature { + val Integer[] lowerBounds + val Integer[] upperBounds + } } @Accessors @@ -80,6 +131,11 @@ abstract class LinearBoundedExpression { upperBound = tighterBound } } + + def void assertEqualsTo(int bound) { + tightenLowerBound(bound) + tightenUpperBound(bound) + } } @Accessors diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend index 52a390a8..013e53e1 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend @@ -117,9 +117,12 @@ class RelationConstraintCalculator { var inverseUpperMultiplicity = -1 val inverseRelation = inverseRelations.get(relation) if (inverseRelation !== null) { - inverseUpperMultiplicity = upperMultiplicities.get(relation) + inverseUpperMultiplicity = upperMultiplicities.get(inverseRelation) container = containmentRelations.contains(inverseRelation) } + if (containment) { + inverseUpperMultiplicity = 1 + } val constraint = new RelationMultiplicityConstraint(relation, inverseRelation, containment, container, lowerMultiplicity, upperMultiplicity, inverseUpperMultiplicity) if (constraint.isActive) { diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend index 0bdb202e..2376fb38 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend @@ -14,7 +14,7 @@ import org.eclipse.xtend.lib.annotations.Accessors class ScopePropagator { @Accessors(PROTECTED_GETTER) val PartialInterpretation partialInterpretation - val ModelGenerationStatistics statistics + @Accessors(PROTECTED_GETTER) val ModelGenerationStatistics statistics val Map type2Scope @Accessors(PROTECTED_GETTER) val Map> superScopes @Accessors(PROTECTED_GETTER) val Map> subScopes @@ -59,12 +59,21 @@ class ScopePropagator { } } } while (changed) + + copyScopeBoundsToHeuristic() } def propagateAllScopeConstraints() { statistics.incrementScopePropagationCount() doPropagateAllScopeConstraints() } + + protected def copyScopeBoundsToHeuristic() { + partialInterpretation.minNewElementsHeuristic = partialInterpretation.minNewElements + for (scope : partialInterpretation.scopes) { + scope.minNewElementsHeuristic = scope.minNewElements + } + } protected def void doPropagateAllScopeConstraints() { // Nothing to propagate. @@ -73,12 +82,17 @@ class ScopePropagator { def propagateAdditionToType(PartialTypeInterpratation t) { // println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') val targetScope = type2Scope.get(t) - targetScope.removeOne - val sups = superScopes.get(targetScope) - sups.forEach[removeOne] + if (targetScope !== null) { + targetScope.removeOne + val sups = superScopes.get(targetScope) + sups.forEach[removeOne] + } if (this.partialInterpretation.minNewElements > 0) { this.partialInterpretation.minNewElements = this.partialInterpretation.minNewElements - 1 } + if (this.partialInterpretation.minNewElementsHeuristic > 0) { + this.partialInterpretation.minNewElementsHeuristic = this.partialInterpretation.minNewElementsHeuristic - 1 + } if (this.partialInterpretation.maxNewElements > 0) { this.partialInterpretation.maxNewElements = this.partialInterpretation.maxNewElements - 1 } else if (this.partialInterpretation.maxNewElements === 0) { @@ -105,5 +119,8 @@ class ScopePropagator { if (scope.minNewElements > 0) { scope.minNewElements = scope.minNewElements - 1 } + if (scope.minNewElementsHeuristic > 0) { + scope.minNewElementsHeuristic = scope.minNewElementsHeuristic - 1 + } } } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.xtend index b0ed75cb..3165917a 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.xtend @@ -16,7 +16,9 @@ enum PolyhedralScopePropagatorSolver { } abstract class ScopePropagatorStrategy { - public static val Count = new Simple("Count") + public static val None = new Simple("None") + + public static val Basic = new Simple("Basic") public static val BasicTypeHierarchy = new Simple("BasicTypeHierarchy") @@ -47,14 +49,19 @@ abstract class ScopePropagatorStrategy { val PolyhedralScopePropagatorConstraints constraints val PolyhedralScopePropagatorSolver solver + val boolean updateHeuristic val double timeoutSeconds @FinalFieldsConstructor new() { } + new(PolyhedralScopePropagatorConstraints constraints, PolyhedralScopePropagatorSolver solver, boolean updateHeuristic) { + this(constraints, solver, updateHeuristic, UNLIMITED_TIME) + } + new(PolyhedralScopePropagatorConstraints constraints, PolyhedralScopePropagatorSolver solver) { - this(constraints, solver, UNLIMITED_TIME) + this(constraints, solver, true) } override requiresUpperBoundIndexing() { diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/TypeHierarchyScopePropagator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/TypeHierarchyScopePropagator.xtend index be8ef00a..d1704b39 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/TypeHierarchyScopePropagator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/TypeHierarchyScopePropagator.xtend @@ -27,12 +27,16 @@ class TypeHierarchyScopePropagator extends ScopePropagator { } private def propagateLowerLimitUp(Scope subScope, Scope superScope) { + var changed = false if (subScope.minNewElements > superScope.minNewElements) { superScope.minNewElements = subScope.minNewElements - return true - } else { - return false + changed = true + } + if (subScope.minNewElementsHeuristic > superScope.minNewElementsHeuristic) { + superScope.minNewElementsHeuristic = subScope.minNewElementsHeuristic + changed = true } + changed } private def propagateUpperLimitDown(Scope subScope, Scope superScope) { @@ -50,16 +54,20 @@ class TypeHierarchyScopePropagator extends ScopePropagator { } private def propagateLowerLimitUp(Scope subScope, PartialInterpretation p) { + var changed = false if (subScope.minNewElements > p.minNewElements) { // println(''' // «(subScope.targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf.name» -> nodes // p.minNewElements «p.minNewElements» = subScope.minNewElements «subScope.minNewElements» // ''') p.minNewElements = subScope.minNewElements - return true - } else { - return false + changed = true + } + if (subScope.minNewElementsHeuristic > p.minNewElementsHeuristic) { + p.minNewElementsHeuristic = subScope.minNewElementsHeuristic + changed = true } + changed } private def propagateUpperLimitDown(Scope subScope, PartialInterpretation p) { diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/Z3PolyhedronSolver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/Z3PolyhedronSolver.xtend index 23444956..3b831433 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/Z3PolyhedronSolver.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/Z3PolyhedronSolver.xtend @@ -13,6 +13,7 @@ import java.math.BigDecimal import java.math.MathContext import java.math.RoundingMode import java.util.Map +import org.eclipse.xtend.lib.annotations.Accessors import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor class Z3PolyhedronSolver implements PolyhedronSolver { @@ -28,10 +29,33 @@ class Z3PolyhedronSolver implements PolyhedronSolver { } override createSaturationOperator(Polyhedron polyhedron) { + new DisposingZ3SaturationOperator(this, polyhedron) + } + + def createPersistentSaturationOperator(Polyhedron polyhedron) { new Z3SaturationOperator(polyhedron, lpRelaxation, timeoutSeconds) } } +@FinalFieldsConstructor +class DisposingZ3SaturationOperator implements PolyhedronSaturationOperator { + val Z3PolyhedronSolver solver + @Accessors val Polyhedron polyhedron + + override saturate() { + val persistentOperator = solver.createPersistentSaturationOperator(polyhedron) + try { + persistentOperator.saturate + } finally { + persistentOperator.close + } + } + + override close() throws Exception { + // Nothing to close. + } +} + class Z3SaturationOperator extends AbstractPolyhedronSaturationOperator { static val INFINITY_SYMBOL_NAME = "oo" static val MULT_SYMBOL_NAME = "*" @@ -106,9 +130,9 @@ class Z3SaturationOperator extends AbstractPolyhedronSaturationOperator { IntNum: resultExpr.getInt() RatNum: - floor(resultExpr) + ceil(resultExpr) AlgebraicNum: - floor(resultExpr.toLower(ALGEBRAIC_NUMBER_ROUNDING)) + ceil(resultExpr.toUpper(ALGEBRAIC_NUMBER_ROUNDING)) default: if (isNegativeInfinity(resultExpr)) { null @@ -136,9 +160,9 @@ class Z3SaturationOperator extends AbstractPolyhedronSaturationOperator { IntNum: resultExpr.getInt() RatNum: - ceil(resultExpr) + floor(resultExpr) AlgebraicNum: - ceil(resultExpr.toUpper(ALGEBRAIC_NUMBER_ROUNDING)) + floor(resultExpr.toLower(ALGEBRAIC_NUMBER_ROUNDING)) default: if (isPositiveInfinity(resultExpr)) { null diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend index 1b0db90e..5c35fb54 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend @@ -16,8 +16,11 @@ import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.Transform import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysisResult import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraints +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation +import java.util.Collection import java.util.HashMap import java.util.Map import org.eclipse.emf.ecore.EAttribute @@ -26,7 +29,6 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery import org.eclipse.xtend.lib.annotations.Accessors import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* -import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy class PatternGenerator { @Accessors(PUBLIC_GETTER) val TypeIndexer typeIndexer // = new TypeIndexer(this) @@ -104,7 +106,9 @@ class PatternGenerator { } def isRepresentative(Relation relation, Relation inverse) { - if (inverse === null) { + if (relation === null) { + return false + } else if (inverse === null) { return true } else { relation.name.compareTo(inverse.name) < 1 @@ -144,7 +148,8 @@ class PatternGenerator { PartialInterpretation emptySolution, Map fqn2PQuery, TypeAnalysisResult typeAnalysisResult, - RelationConstraints constraints + RelationConstraints constraints, + Collection hints ) { return ''' @@ -294,6 +299,13 @@ class PatternGenerator { // 4.3 Relation refinement ////////// «relationRefinementGenerator.generateRefineReference(problem)» + + ////////// + // 5 Hints + ////////// + «FOR hint : hints» + «hint.getAdditionalPatterns(this)» + «ENDFOR» ''' } } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend index eadf0ae0..f5c85524 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend @@ -26,6 +26,7 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery import org.eclipse.xtend.lib.annotations.Data import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint @Data class GeneratedPatterns { @@ -62,7 +63,8 @@ class PatternProvider { def generateQueries(LogicProblem problem, PartialInterpretation emptySolution, ModelGenerationStatistics statistics, Set existingQueries, ReasonerWorkspace workspace, TypeInferenceMethod typeInferenceMethod, - ScopePropagatorStrategy scopePropagatorStrategy, RelationConstraints relationConstraints, boolean writeToFile) { + ScopePropagatorStrategy scopePropagatorStrategy, RelationConstraints relationConstraints, + Collection hints, boolean writeToFile) { val fqn2Query = existingQueries.toMap[it.fullyQualifiedName] val PatternGenerator patternGenerator = new PatternGenerator(typeInferenceMethod, scopePropagatorStrategy) val typeAnalysisResult = if (patternGenerator.requiresTypeAnalysis) { @@ -75,7 +77,7 @@ class PatternProvider { null } val baseIndexerFile = patternGenerator.transformBaseProperties(problem, emptySolution, fqn2Query, - typeAnalysisResult, relationConstraints) + typeAnalysisResult, relationConstraints, hints) if (writeToFile) { workspace.writeText('''generated3valued.vql_deactivated''', baseIndexerFile) } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend index fa73c861..d915d47e 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend @@ -44,7 +44,7 @@ class RelationRefinementGenerator { def referRefinementQuery(RelationDeclaration relation, Relation inverseRelation, String relInterpretationName, String inverseInterpretationName, String sourceName, - String targetName) '''find «this.relationRefinementQueryName(relation,inverseRelation)»(problem, interpretation, «relInterpretationName», «IF inverseRelation !== null»inverseInterpretationName, «ENDIF»«sourceName», «targetName»);''' + String targetName) '''find «this.relationRefinementQueryName(relation,inverseRelation)»(problem, interpretation, «relInterpretationName», «IF inverseRelation !== null»«inverseInterpretationName», «ENDIF»«sourceName», «targetName»);''' def getRefineRelationQueries(LogicProblem p) { // val containmentRelations = p.containmentHierarchies.map[containmentRelations].flatten.toSet diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/UnfinishedIndexer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/UnfinishedIndexer.xtend index 15b5a047..a8a07756 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/UnfinishedIndexer.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/UnfinishedIndexer.xtend @@ -1,5 +1,6 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationMultiplicityConstraint @@ -76,21 +77,26 @@ class UnfinishedIndexer { «IF indexUpperMultiplicities» «IF constraint.constrainsUnrepairable || constraint.constrainsRemainingInverse» private pattern «repairMatchName(constraint)»(problem:LogicProblem, interpretation:PartialInterpretation, source:DefinedElement, target:DefinedElement) { - find interpretation(problem,interpretation); - find mustExist(problem,interpretation,source); - «base.typeIndexer.referInstanceOf(constraint.sourceType,Modality::MUST,"source")» - find mustExist(problem,interpretation,target); - «base.typeIndexer.referInstanceOf(constraint.targetType,Modality::MUST,"target")» - neg «base.referRelation(constraint.relation,"source","target",Modality.MUST,fqn2PQuery)» - «base.referRelation(constraint.relation,"source","target",Modality.MAY,fqn2PQuery)» + «IF base.isRepresentative(constraint.relation, constraint.inverseRelation) && constraint.relation instanceof RelationDeclaration» + «base.relationRefinementGenerator.referRefinementQuery(constraint.relation as RelationDeclaration, constraint.inverseRelation, "_", "_", "source", "target")» + «ELSE» + «IF base.isRepresentative(constraint.inverseRelation, constraint.relation) && constraint.inverseRelation instanceof RelationDeclaration» + «base.relationRefinementGenerator.referRefinementQuery(constraint.inverseRelation as RelationDeclaration, constraint.relation, "_", "_", "target", "source")» + «ELSE» + find interpretation(problem,interpretation); + find mustExist(problem,interpretation,source); + «base.typeIndexer.referInstanceOf(constraint.sourceType,Modality::MUST,"source")» + find mustExist(problem,interpretation,target); + «base.typeIndexer.referInstanceOf(constraint.targetType,Modality::MUST,"target")» + neg «base.referRelation(constraint.relation,"source","target",Modality.MUST,fqn2PQuery)» + «base.referRelation(constraint.relation,"source","target",Modality.MAY,fqn2PQuery)» + «ENDIF» + «ENDIF» } «ENDIF» «IF constraint.constrainsUnrepairable» private pattern «unrepairableMultiplicityName(constraint)»_helper(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement, unrepairableMultiplicity:java Integer) { - find interpretation(problem,interpretation); - find mustExist(problem,interpretation,object); - «base.typeIndexer.referInstanceOf(constraint.sourceType,Modality::MUST,"object")» find «unfinishedMultiplicityName(constraint)»_helper(problem, interpretation, object, missingMultiplicity); numberOfRepairMatches == count find «repairMatchName(constraint)»(problem, interpretation, object, _); check(numberOfRepairMatches < missingMultiplicity); diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend index bf816de9..7891ebd8 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend @@ -67,7 +67,8 @@ class RefinementRuleProvider { if(containmentRelation != null) { if(inverseRelation!= null) { ruleBuilder.action[match | - //println(name) + statistics.incrementTransformationCount +// println(name) val startTime = System.nanoTime //val problem = match.get(0) as LogicProblem val interpretation = match.get(1) as PartialInterpretation @@ -107,7 +108,8 @@ class RefinementRuleProvider { ] } else { ruleBuilder.action[match | - //println(name) + statistics.incrementTransformationCount +// println(name) val startTime = System.nanoTime //val problem = match.get(0) as LogicProblem val interpretation = match.get(1) as PartialInterpretation @@ -144,6 +146,9 @@ class RefinementRuleProvider { } } else { ruleBuilder.action[match | + statistics.incrementTransformationCount +// println(name) + val startTime = System.nanoTime //val problem = match.get(0) as LogicProblem val interpretation = match.get(1) as PartialInterpretation @@ -198,8 +203,9 @@ class RefinementRuleProvider { .precondition(lhs) if (inverseRelation == null) { ruleBuilder.action [ match | + statistics.incrementTransformationCount val startTime = System.nanoTime - //println(name) +// println(name) // val problem = match.get(0) as LogicProblem // val interpretation = match.get(1) as PartialInterpretation val relationInterpretation = match.get(2) as PartialRelationInterpretation @@ -217,8 +223,9 @@ class RefinementRuleProvider { ] } else { ruleBuilder.action [ match | + statistics.incrementTransformationCount val startTime = System.nanoTime - //println(name) +// println(name) // val problem = match.get(0) as LogicProblem // val interpretation = match.get(1) as PartialInterpretation val relationInterpretation = match.get(2) as PartialRelationInterpretation diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialInterpretation.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialInterpretation.java index 098cc15b..9d0c3fea 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialInterpretation.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialInterpretation.java @@ -30,6 +30,7 @@ import org.eclipse.emf.ecore.EObject; *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getScopes Scopes}
  • *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getMinNewElements Min New Elements}
  • *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getMaxNewElements Max New Elements}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getMinNewElementsHeuristic Min New Elements Heuristic}
  • * * * @see hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage#getPartialInterpretation() @@ -255,4 +256,27 @@ public interface PartialInterpretation extends EObject { */ void setMaxNewElements(int value); + /** + * Returns the value of the 'Min New Elements Heuristic' attribute. + * The default value is "0". + * + * + * @return the value of the 'Min New Elements Heuristic' attribute. + * @see #setMinNewElementsHeuristic(int) + * @see hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage#getPartialInterpretation_MinNewElementsHeuristic() + * @model default="0" required="true" + * @generated + */ + int getMinNewElementsHeuristic(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getMinNewElementsHeuristic Min New Elements Heuristic}' attribute. + * + * + * @param value the new value of the 'Min New Elements Heuristic' attribute. + * @see #getMinNewElementsHeuristic() + * @generated + */ + void setMinNewElementsHeuristic(int value); + } // PartialInterpretation diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialinterpretationPackage.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialinterpretationPackage.java index 4f34b9b7..f462ebe4 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialinterpretationPackage.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialinterpretationPackage.java @@ -166,6 +166,15 @@ public interface PartialinterpretationPackage extends EPackage { */ int PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS = 10; + /** + * The feature id for the 'Min New Elements Heuristic' attribute. + * + * + * @generated + * @ordered + */ + int PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC = 11; + /** * The number of structural features of the 'Partial Interpretation' class. * @@ -173,7 +182,7 @@ public interface PartialinterpretationPackage extends EPackage { * @generated * @ordered */ - int PARTIAL_INTERPRETATION_FEATURE_COUNT = 11; + int PARTIAL_INTERPRETATION_FEATURE_COUNT = 12; /** * The number of operations of the 'Partial Interpretation' class. @@ -912,6 +921,15 @@ public interface PartialinterpretationPackage extends EPackage { */ int SCOPE__TARGET_TYPE_INTERPRETATION = 2; + /** + * The feature id for the 'Min New Elements Heuristic' attribute. + * + * + * @generated + * @ordered + */ + int SCOPE__MIN_NEW_ELEMENTS_HEURISTIC = 3; + /** * The number of structural features of the 'Scope' class. * @@ -919,7 +937,7 @@ public interface PartialinterpretationPackage extends EPackage { * @generated * @ordered */ - int SCOPE_FEATURE_COUNT = 3; + int SCOPE_FEATURE_COUNT = 4; /** * The number of operations of the 'Scope' class. @@ -1357,6 +1375,17 @@ public interface PartialinterpretationPackage extends EPackage { */ EAttribute getPartialInterpretation_MaxNewElements(); + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getMinNewElementsHeuristic Min New Elements Heuristic}'. + * + * + * @return the meta object for the attribute 'Min New Elements Heuristic'. + * @see hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getMinNewElementsHeuristic() + * @see #getPartialInterpretation() + * @generated + */ + EAttribute getPartialInterpretation_MinNewElementsHeuristic(); + /** * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialConstantInterpretation Partial Constant Interpretation}'. * @@ -1749,6 +1778,17 @@ public interface PartialinterpretationPackage extends EPackage { */ EReference getScope_TargetTypeInterpretation(); + /** + * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getMinNewElementsHeuristic Min New Elements Heuristic}'. + * + * + * @return the meta object for the attribute 'Min New Elements Heuristic'. + * @see hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getMinNewElementsHeuristic() + * @see #getScope() + * @generated + */ + EAttribute getScope_MinNewElementsHeuristic(); + /** * Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation Partial Primitive Interpretation}'. * @@ -1952,6 +1992,14 @@ public interface PartialinterpretationPackage extends EPackage { */ EAttribute PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS = eINSTANCE.getPartialInterpretation_MaxNewElements(); + /** + * The meta object literal for the 'Min New Elements Heuristic' attribute feature. + * + * + * @generated + */ + EAttribute PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC = eINSTANCE.getPartialInterpretation_MinNewElementsHeuristic(); + /** * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialConstantInterpretationImpl Partial Constant Interpretation}' class. * @@ -2278,6 +2326,14 @@ public interface PartialinterpretationPackage extends EPackage { */ EReference SCOPE__TARGET_TYPE_INTERPRETATION = eINSTANCE.getScope_TargetTypeInterpretation(); + /** + * The meta object literal for the 'Min New Elements Heuristic' attribute feature. + * + * + * @generated + */ + EAttribute SCOPE__MIN_NEW_ELEMENTS_HEURISTIC = eINSTANCE.getScope_MinNewElementsHeuristic(); + /** * The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialPrimitiveInterpretationImpl Partial Primitive Interpretation}' class. * diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/Scope.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/Scope.java index 155b9f00..a0b58615 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/Scope.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/Scope.java @@ -16,6 +16,7 @@ import org.eclipse.emf.ecore.EObject; *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getMinNewElements Min New Elements}
  • *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getMaxNewElements Max New Elements}
  • *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getTargetTypeInterpretation Target Type Interpretation}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getMinNewElementsHeuristic Min New Elements Heuristic}
  • * * * @see hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage#getScope() @@ -105,4 +106,27 @@ public interface Scope extends EObject { */ void setTargetTypeInterpretation(PartialTypeInterpratation value); + /** + * Returns the value of the 'Min New Elements Heuristic' attribute. + * The default value is "0". + * + * + * @return the value of the 'Min New Elements Heuristic' attribute. + * @see #setMinNewElementsHeuristic(int) + * @see hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage#getScope_MinNewElementsHeuristic() + * @model default="0" required="true" + * @generated + */ + int getMinNewElementsHeuristic(); + + /** + * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getMinNewElementsHeuristic Min New Elements Heuristic}' attribute. + * + * + * @param value the new value of the 'Min New Elements Heuristic' attribute. + * @see #getMinNewElementsHeuristic() + * @generated + */ + void setMinNewElementsHeuristic(int value); + } // Scope diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BinaryElementRelationLinkImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BinaryElementRelationLinkImpl.java index f5efe02a..ca33dd65 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BinaryElementRelationLinkImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BinaryElementRelationLinkImpl.java @@ -73,6 +73,7 @@ public class BinaryElementRelationLinkImpl extends RelationLinkImpl implements B * * @generated */ + @Override public DefinedElement getParam1() { if (param1 != null && param1.eIsProxy()) { InternalEObject oldParam1 = (InternalEObject)param1; @@ -99,6 +100,7 @@ public class BinaryElementRelationLinkImpl extends RelationLinkImpl implements B * * @generated */ + @Override public void setParam1(DefinedElement newParam1) { DefinedElement oldParam1 = param1; param1 = newParam1; @@ -111,6 +113,7 @@ public class BinaryElementRelationLinkImpl extends RelationLinkImpl implements B * * @generated */ + @Override public DefinedElement getParam2() { if (param2 != null && param2.eIsProxy()) { InternalEObject oldParam2 = (InternalEObject)param2; @@ -137,6 +140,7 @@ public class BinaryElementRelationLinkImpl extends RelationLinkImpl implements B * * @generated */ + @Override public void setParam2(DefinedElement newParam2) { DefinedElement oldParam2 = param2; param2 = newParam2; diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BooleanElementImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BooleanElementImpl.java index e906e07d..5f12d9e4 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BooleanElementImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BooleanElementImpl.java @@ -69,6 +69,7 @@ public class BooleanElementImpl extends PrimitiveElementImpl implements BooleanE * * @generated */ + @Override public boolean isValue() { return value; } @@ -78,6 +79,7 @@ public class BooleanElementImpl extends PrimitiveElementImpl implements BooleanE * * @generated */ + @Override public void setValue(boolean newValue) { boolean oldValue = value; value = newValue; @@ -152,7 +154,7 @@ public class BooleanElementImpl extends PrimitiveElementImpl implements BooleanE public String toString() { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (value: "); result.append(value); result.append(')'); diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/IntegerElementImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/IntegerElementImpl.java index ef1a4b96..c8fbe1dd 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/IntegerElementImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/IntegerElementImpl.java @@ -69,6 +69,7 @@ public class IntegerElementImpl extends PrimitiveElementImpl implements IntegerE * * @generated */ + @Override public int getValue() { return value; } @@ -78,6 +79,7 @@ public class IntegerElementImpl extends PrimitiveElementImpl implements IntegerE * * @generated */ + @Override public void setValue(int newValue) { int oldValue = value; value = newValue; @@ -152,7 +154,7 @@ public class IntegerElementImpl extends PrimitiveElementImpl implements IntegerE public String toString() { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (value: "); result.append(value); result.append(')'); diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkElementImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkElementImpl.java index 749a03c5..c319a3f4 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkElementImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkElementImpl.java @@ -83,6 +83,7 @@ public class NaryRelationLinkElementImpl extends MinimalEObjectImpl.Container im * * @generated */ + @Override public int getIndex() { return index; } @@ -92,6 +93,7 @@ public class NaryRelationLinkElementImpl extends MinimalEObjectImpl.Container im * * @generated */ + @Override public void setIndex(int newIndex) { int oldIndex = index; index = newIndex; @@ -104,6 +106,7 @@ public class NaryRelationLinkElementImpl extends MinimalEObjectImpl.Container im * * @generated */ + @Override public DefinedElement getParam() { if (param != null && param.eIsProxy()) { InternalEObject oldParam = (InternalEObject)param; @@ -130,6 +133,7 @@ public class NaryRelationLinkElementImpl extends MinimalEObjectImpl.Container im * * @generated */ + @Override public void setParam(DefinedElement newParam) { DefinedElement oldParam = param; param = newParam; @@ -215,7 +219,7 @@ public class NaryRelationLinkElementImpl extends MinimalEObjectImpl.Container im public String toString() { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (index: "); result.append(index); result.append(')'); diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkImpl.java index f387ee06..9f7628cf 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkImpl.java @@ -66,6 +66,7 @@ public class NaryRelationLinkImpl extends RelationLinkImpl implements NaryRelati * * @generated */ + @Override public EList getElements() { if (elements == null) { elements = new EObjectContainmentEList(NaryRelationLinkElement.class, this, PartialinterpretationPackage.NARY_RELATION_LINK__ELEMENTS); diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialComplexTypeInterpretationImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialComplexTypeInterpretationImpl.java index 07ee282d..c00b4278 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialComplexTypeInterpretationImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialComplexTypeInterpretationImpl.java @@ -79,6 +79,7 @@ public class PartialComplexTypeInterpretationImpl extends PartialTypeInterpratat * * @generated */ + @Override public EList getSupertypeInterpretation() { if (supertypeInterpretation == null) { supertypeInterpretation = new EObjectResolvingEList(PartialComplexTypeInterpretation.class, this, PartialinterpretationPackage.PARTIAL_COMPLEX_TYPE_INTERPRETATION__SUPERTYPE_INTERPRETATION); @@ -91,6 +92,7 @@ public class PartialComplexTypeInterpretationImpl extends PartialTypeInterpratat * * @generated */ + @Override public TypeDeclaration getInterpretationOf() { if (interpretationOf != null && interpretationOf.eIsProxy()) { InternalEObject oldInterpretationOf = (InternalEObject)interpretationOf; @@ -117,6 +119,7 @@ public class PartialComplexTypeInterpretationImpl extends PartialTypeInterpratat * * @generated */ + @Override public void setInterpretationOf(TypeDeclaration newInterpretationOf) { TypeDeclaration oldInterpretationOf = interpretationOf; interpretationOf = newInterpretationOf; diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialConstantInterpretationImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialConstantInterpretationImpl.java index 81b2ce8d..6d51f0db 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialConstantInterpretationImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialConstantInterpretationImpl.java @@ -63,6 +63,7 @@ public class PartialConstantInterpretationImpl extends MinimalEObjectImpl.Contai * * @generated */ + @Override public ConstantDeclaration getInterpretationOf() { if (interpretationOf != null && interpretationOf.eIsProxy()) { InternalEObject oldInterpretationOf = (InternalEObject)interpretationOf; @@ -89,6 +90,7 @@ public class PartialConstantInterpretationImpl extends MinimalEObjectImpl.Contai * * @generated */ + @Override public void setInterpretationOf(ConstantDeclaration newInterpretationOf) { ConstantDeclaration oldInterpretationOf = interpretationOf; interpretationOf = newInterpretationOf; diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialFunctionInterpretationImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialFunctionInterpretationImpl.java index 2d361e8e..855c4abc 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialFunctionInterpretationImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialFunctionInterpretationImpl.java @@ -63,6 +63,7 @@ public class PartialFunctionInterpretationImpl extends MinimalEObjectImpl.Contai * * @generated */ + @Override public FunctionDeclaration getInterpretationOf() { if (interpretationOf != null && interpretationOf.eIsProxy()) { InternalEObject oldInterpretationOf = (InternalEObject)interpretationOf; @@ -89,6 +90,7 @@ public class PartialFunctionInterpretationImpl extends MinimalEObjectImpl.Contai * * @generated */ + @Override public void setInterpretationOf(FunctionDeclaration newInterpretationOf) { FunctionDeclaration oldInterpretationOf = interpretationOf; interpretationOf = newInterpretationOf; diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialInterpretationImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialInterpretationImpl.java index bce3e2e0..9afdd8d2 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialInterpretationImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialInterpretationImpl.java @@ -47,6 +47,7 @@ import org.eclipse.emf.ecore.util.InternalEList; *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialInterpretationImpl#getScopes Scopes}
  • *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialInterpretationImpl#getMinNewElements Min New Elements}
  • *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialInterpretationImpl#getMaxNewElements Max New Elements}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialInterpretationImpl#getMinNewElementsHeuristic Min New Elements Heuristic}
  • * * * @generated @@ -182,6 +183,26 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl */ protected int maxNewElements = MAX_NEW_ELEMENTS_EDEFAULT; + /** + * The default value of the '{@link #getMinNewElementsHeuristic() Min New Elements Heuristic}' attribute. + * + * + * @see #getMinNewElementsHeuristic() + * @generated + * @ordered + */ + protected static final int MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getMinNewElementsHeuristic() Min New Elements Heuristic}' attribute. + * + * + * @see #getMinNewElementsHeuristic() + * @generated + * @ordered + */ + protected int minNewElementsHeuristic = MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT; + /** * * @@ -206,6 +227,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public LogicProblem getProblem() { if (problem != null && problem.eIsProxy()) { InternalEObject oldProblem = (InternalEObject)problem; @@ -232,6 +254,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public void setProblem(LogicProblem newProblem) { LogicProblem oldProblem = problem; problem = newProblem; @@ -244,6 +267,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public EList getPartialconstantinterpretation() { if (partialconstantinterpretation == null) { partialconstantinterpretation = new EObjectContainmentEList(PartialConstantInterpretation.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__PARTIALCONSTANTINTERPRETATION); @@ -256,6 +280,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public EList getPartialrelationinterpretation() { if (partialrelationinterpretation == null) { partialrelationinterpretation = new EObjectContainmentEList(PartialRelationInterpretation.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__PARTIALRELATIONINTERPRETATION); @@ -268,6 +293,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public EList getPartialfunctioninterpretation() { if (partialfunctioninterpretation == null) { partialfunctioninterpretation = new EObjectContainmentEList(PartialFunctionInterpretation.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__PARTIALFUNCTIONINTERPRETATION); @@ -280,6 +306,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public EList getNewElements() { if (newElements == null) { newElements = new EObjectContainmentEList(DefinedElement.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__NEW_ELEMENTS); @@ -292,6 +319,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public EList getPartialtypeinterpratation() { if (partialtypeinterpratation == null) { partialtypeinterpratation = new EObjectContainmentEList(PartialTypeInterpratation.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__PARTIALTYPEINTERPRATATION); @@ -304,6 +332,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public EList getOpenWorldElements() { if (openWorldElements == null) { openWorldElements = new EObjectContainmentEList(DefinedElement.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__OPEN_WORLD_ELEMENTS); @@ -316,6 +345,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public LogicProblem getProblemConainer() { return problemConainer; } @@ -340,6 +370,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public void setProblemConainer(LogicProblem newProblemConainer) { if (newProblemConainer != problemConainer) { NotificationChain msgs = null; @@ -359,6 +390,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public EList getScopes() { if (scopes == null) { scopes = new EObjectContainmentEList(Scope.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__SCOPES); @@ -371,6 +403,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public int getMinNewElements() { return minNewElements; } @@ -380,6 +413,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public void setMinNewElements(int newMinNewElements) { int oldMinNewElements = minNewElements; minNewElements = newMinNewElements; @@ -392,6 +426,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public int getMaxNewElements() { return maxNewElements; } @@ -401,6 +436,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl * * @generated */ + @Override public void setMaxNewElements(int newMaxNewElements) { int oldMaxNewElements = maxNewElements; maxNewElements = newMaxNewElements; @@ -408,6 +444,29 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl eNotify(new ENotificationImpl(this, Notification.SET, PartialinterpretationPackage.PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS, oldMaxNewElements, maxNewElements)); } + /** + * + * + * @generated + */ + @Override + public int getMinNewElementsHeuristic() { + return minNewElementsHeuristic; + } + + /** + * + * + * @generated + */ + @Override + public void setMinNewElementsHeuristic(int newMinNewElementsHeuristic) { + int oldMinNewElementsHeuristic = minNewElementsHeuristic; + minNewElementsHeuristic = newMinNewElementsHeuristic; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PartialinterpretationPackage.PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC, oldMinNewElementsHeuristic, minNewElementsHeuristic)); + } + /** * * @@ -467,6 +526,8 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl return getMinNewElements(); case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS: return getMaxNewElements(); + case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC: + return getMinNewElementsHeuristic(); } return super.eGet(featureID, resolve, coreType); } @@ -520,6 +581,9 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS: setMaxNewElements((Integer)newValue); return; + case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC: + setMinNewElementsHeuristic((Integer)newValue); + return; } super.eSet(featureID, newValue); } @@ -565,6 +629,9 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS: setMaxNewElements(MAX_NEW_ELEMENTS_EDEFAULT); return; + case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC: + setMinNewElementsHeuristic(MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT); + return; } super.eUnset(featureID); } @@ -599,6 +666,8 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl return minNewElements != MIN_NEW_ELEMENTS_EDEFAULT; case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS: return maxNewElements != MAX_NEW_ELEMENTS_EDEFAULT; + case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC: + return minNewElementsHeuristic != MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT; } return super.eIsSet(featureID); } @@ -612,11 +681,13 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl public String toString() { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (minNewElements: "); result.append(minNewElements); result.append(", maxNewElements: "); result.append(maxNewElements); + result.append(", minNewElementsHeuristic: "); + result.append(minNewElementsHeuristic); result.append(')'); return result.toString(); } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialRelationInterpretationImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialRelationInterpretationImpl.java index 71aef9af..7ad06504 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialRelationInterpretationImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialRelationInterpretationImpl.java @@ -106,6 +106,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai * * @generated */ + @Override public RelationDeclaration getInterpretationOf() { if (interpretationOf != null && interpretationOf.eIsProxy()) { InternalEObject oldInterpretationOf = (InternalEObject)interpretationOf; @@ -132,6 +133,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai * * @generated */ + @Override public void setInterpretationOf(RelationDeclaration newInterpretationOf) { RelationDeclaration oldInterpretationOf = interpretationOf; interpretationOf = newInterpretationOf; @@ -144,6 +146,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai * * @generated */ + @Override public EList getRelationlinks() { if (relationlinks == null) { relationlinks = new EObjectContainmentEList(RelationLink.class, this, PartialinterpretationPackage.PARTIAL_RELATION_INTERPRETATION__RELATIONLINKS); @@ -156,6 +159,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai * * @generated */ + @Override public TypeReference getParam1() { if (param1 != null && param1.eIsProxy()) { InternalEObject oldParam1 = (InternalEObject)param1; @@ -182,6 +186,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai * * @generated */ + @Override public void setParam1(TypeReference newParam1) { TypeReference oldParam1 = param1; param1 = newParam1; @@ -194,6 +199,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai * * @generated */ + @Override public TypeReference getParam2() { if (param2 != null && param2.eIsProxy()) { InternalEObject oldParam2 = (InternalEObject)param2; @@ -220,6 +226,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai * * @generated */ + @Override public void setParam2(TypeReference newParam2) { TypeReference oldParam2 = param2; param2 = newParam2; diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialTypeInterpratationImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialTypeInterpratationImpl.java index da9b1472..51eabd2c 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialTypeInterpratationImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialTypeInterpratationImpl.java @@ -76,6 +76,7 @@ public abstract class PartialTypeInterpratationImpl extends MinimalEObjectImpl.C * * @generated */ + @Override public EList getElements() { if (elements == null) { elements = new EObjectResolvingEList(DefinedElement.class, this, PartialinterpretationPackage.PARTIAL_TYPE_INTERPRATATION__ELEMENTS); @@ -88,6 +89,7 @@ public abstract class PartialTypeInterpratationImpl extends MinimalEObjectImpl.C * * @generated */ + @Override public EList getScopes() { if (scopes == null) { scopes = new EObjectWithInverseResolvingEList(Scope.class, this, PartialinterpretationPackage.PARTIAL_TYPE_INTERPRATATION__SCOPES, PartialinterpretationPackage.SCOPE__TARGET_TYPE_INTERPRETATION); diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationFactoryImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationFactoryImpl.java index af1db8a1..06ca4e37 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationFactoryImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationFactoryImpl.java @@ -84,6 +84,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public PartialInterpretation createPartialInterpretation() { PartialInterpretationImpl partialInterpretation = new PartialInterpretationImpl(); return partialInterpretation; @@ -94,6 +95,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public PartialConstantInterpretation createPartialConstantInterpretation() { PartialConstantInterpretationImpl partialConstantInterpretation = new PartialConstantInterpretationImpl(); return partialConstantInterpretation; @@ -104,6 +106,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public PartialRelationInterpretation createPartialRelationInterpretation() { PartialRelationInterpretationImpl partialRelationInterpretation = new PartialRelationInterpretationImpl(); return partialRelationInterpretation; @@ -114,6 +117,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public PartialFunctionInterpretation createPartialFunctionInterpretation() { PartialFunctionInterpretationImpl partialFunctionInterpretation = new PartialFunctionInterpretationImpl(); return partialFunctionInterpretation; @@ -124,6 +128,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public UnaryElementRelationLink createUnaryElementRelationLink() { UnaryElementRelationLinkImpl unaryElementRelationLink = new UnaryElementRelationLinkImpl(); return unaryElementRelationLink; @@ -134,6 +139,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public BinaryElementRelationLink createBinaryElementRelationLink() { BinaryElementRelationLinkImpl binaryElementRelationLink = new BinaryElementRelationLinkImpl(); return binaryElementRelationLink; @@ -144,6 +150,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public NaryRelationLink createNaryRelationLink() { NaryRelationLinkImpl naryRelationLink = new NaryRelationLinkImpl(); return naryRelationLink; @@ -154,6 +161,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public NaryRelationLinkElement createNaryRelationLinkElement() { NaryRelationLinkElementImpl naryRelationLinkElement = new NaryRelationLinkElementImpl(); return naryRelationLinkElement; @@ -164,6 +172,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public BooleanElement createBooleanElement() { BooleanElementImpl booleanElement = new BooleanElementImpl(); return booleanElement; @@ -174,6 +183,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public IntegerElement createIntegerElement() { IntegerElementImpl integerElement = new IntegerElementImpl(); return integerElement; @@ -184,6 +194,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public RealElement createRealElement() { RealElementImpl realElement = new RealElementImpl(); return realElement; @@ -194,6 +205,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public StringElement createStringElement() { StringElementImpl stringElement = new StringElementImpl(); return stringElement; @@ -204,6 +216,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public Scope createScope() { ScopeImpl scope = new ScopeImpl(); return scope; @@ -214,6 +227,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public PartialBooleanInterpretation createPartialBooleanInterpretation() { PartialBooleanInterpretationImpl partialBooleanInterpretation = new PartialBooleanInterpretationImpl(); return partialBooleanInterpretation; @@ -224,6 +238,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public PartialIntegerInterpretation createPartialIntegerInterpretation() { PartialIntegerInterpretationImpl partialIntegerInterpretation = new PartialIntegerInterpretationImpl(); return partialIntegerInterpretation; @@ -234,6 +249,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public PartialRealInterpretation createPartialRealInterpretation() { PartialRealInterpretationImpl partialRealInterpretation = new PartialRealInterpretationImpl(); return partialRealInterpretation; @@ -244,6 +260,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public PartialStringInterpretation createPartialStringInterpretation() { PartialStringInterpretationImpl partialStringInterpretation = new PartialStringInterpretationImpl(); return partialStringInterpretation; @@ -254,6 +271,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public PartialComplexTypeInterpretation createPartialComplexTypeInterpretation() { PartialComplexTypeInterpretationImpl partialComplexTypeInterpretation = new PartialComplexTypeInterpretationImpl(); return partialComplexTypeInterpretation; @@ -264,6 +282,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa * * @generated */ + @Override public PartialinterpretationPackage getPartialinterpretationPackage() { return (PartialinterpretationPackage)getEPackage(); } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationPackageImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationPackageImpl.java index a21dc306..1ea3a11d 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationPackageImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationPackageImpl.java @@ -227,7 +227,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa /** * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. - * + * *

    This method is used to initialize {@link PartialinterpretationPackage#eINSTANCE} when that field is accessed. * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. * @@ -241,7 +241,8 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa if (isInited) return (PartialinterpretationPackage)EPackage.Registry.INSTANCE.getEPackage(PartialinterpretationPackage.eNS_URI); // Obtain or create and register package - PartialinterpretationPackageImpl thePartialinterpretationPackage = (PartialinterpretationPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof PartialinterpretationPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new PartialinterpretationPackageImpl()); + Object registeredPartialinterpretationPackage = EPackage.Registry.INSTANCE.get(eNS_URI); + PartialinterpretationPackageImpl thePartialinterpretationPackage = registeredPartialinterpretationPackage instanceof PartialinterpretationPackageImpl ? (PartialinterpretationPackageImpl)registeredPartialinterpretationPackage : new PartialinterpretationPackageImpl(); isInited = true; @@ -258,7 +259,6 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa // Mark meta-data to indicate it can't be changed thePartialinterpretationPackage.freeze(); - // Update the registry and return the package EPackage.Registry.INSTANCE.put(PartialinterpretationPackage.eNS_URI, thePartialinterpretationPackage); return thePartialinterpretationPackage; @@ -269,6 +269,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getPartialInterpretation() { return partialInterpretationEClass; } @@ -278,6 +279,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialInterpretation_Problem() { return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(0); } @@ -287,6 +289,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialInterpretation_Partialconstantinterpretation() { return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(1); } @@ -296,6 +299,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialInterpretation_Partialrelationinterpretation() { return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(2); } @@ -305,6 +309,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialInterpretation_Partialfunctioninterpretation() { return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(3); } @@ -314,6 +319,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialInterpretation_NewElements() { return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(4); } @@ -323,6 +329,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialInterpretation_Partialtypeinterpratation() { return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(5); } @@ -332,6 +339,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialInterpretation_OpenWorldElements() { return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(6); } @@ -341,6 +349,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialInterpretation_ProblemConainer() { return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(7); } @@ -350,6 +359,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialInterpretation_Scopes() { return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(8); } @@ -359,6 +369,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EAttribute getPartialInterpretation_MinNewElements() { return (EAttribute)partialInterpretationEClass.getEStructuralFeatures().get(9); } @@ -368,6 +379,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EAttribute getPartialInterpretation_MaxNewElements() { return (EAttribute)partialInterpretationEClass.getEStructuralFeatures().get(10); } @@ -377,6 +389,17 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override + public EAttribute getPartialInterpretation_MinNewElementsHeuristic() { + return (EAttribute)partialInterpretationEClass.getEStructuralFeatures().get(11); + } + + /** + * + * + * @generated + */ + @Override public EClass getPartialConstantInterpretation() { return partialConstantInterpretationEClass; } @@ -386,6 +409,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialConstantInterpretation_InterpretationOf() { return (EReference)partialConstantInterpretationEClass.getEStructuralFeatures().get(0); } @@ -395,6 +419,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getPartialRelationInterpretation() { return partialRelationInterpretationEClass; } @@ -404,6 +429,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialRelationInterpretation_InterpretationOf() { return (EReference)partialRelationInterpretationEClass.getEStructuralFeatures().get(0); } @@ -413,6 +439,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialRelationInterpretation_Relationlinks() { return (EReference)partialRelationInterpretationEClass.getEStructuralFeatures().get(1); } @@ -422,6 +449,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialRelationInterpretation_Param1() { return (EReference)partialRelationInterpretationEClass.getEStructuralFeatures().get(2); } @@ -431,6 +459,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialRelationInterpretation_Param2() { return (EReference)partialRelationInterpretationEClass.getEStructuralFeatures().get(3); } @@ -440,6 +469,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getPartialFunctionInterpretation() { return partialFunctionInterpretationEClass; } @@ -449,6 +479,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialFunctionInterpretation_InterpretationOf() { return (EReference)partialFunctionInterpretationEClass.getEStructuralFeatures().get(0); } @@ -458,6 +489,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getPartialTypeInterpratation() { return partialTypeInterpratationEClass; } @@ -467,6 +499,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialTypeInterpratation_Elements() { return (EReference)partialTypeInterpratationEClass.getEStructuralFeatures().get(0); } @@ -476,6 +509,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialTypeInterpratation_Scopes() { return (EReference)partialTypeInterpratationEClass.getEStructuralFeatures().get(1); } @@ -485,6 +519,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getRelationLink() { return relationLinkEClass; } @@ -494,6 +529,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getUnaryElementRelationLink() { return unaryElementRelationLinkEClass; } @@ -503,6 +539,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getUnaryElementRelationLink_Param1() { return (EReference)unaryElementRelationLinkEClass.getEStructuralFeatures().get(0); } @@ -512,6 +549,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getBinaryElementRelationLink() { return binaryElementRelationLinkEClass; } @@ -521,6 +559,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getBinaryElementRelationLink_Param1() { return (EReference)binaryElementRelationLinkEClass.getEStructuralFeatures().get(0); } @@ -530,6 +569,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getBinaryElementRelationLink_Param2() { return (EReference)binaryElementRelationLinkEClass.getEStructuralFeatures().get(1); } @@ -539,6 +579,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getNaryRelationLink() { return naryRelationLinkEClass; } @@ -548,6 +589,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getNaryRelationLink_Elements() { return (EReference)naryRelationLinkEClass.getEStructuralFeatures().get(0); } @@ -557,6 +599,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getNaryRelationLinkElement() { return naryRelationLinkElementEClass; } @@ -566,6 +609,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EAttribute getNaryRelationLinkElement_Index() { return (EAttribute)naryRelationLinkElementEClass.getEStructuralFeatures().get(0); } @@ -575,6 +619,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getNaryRelationLinkElement_Param() { return (EReference)naryRelationLinkElementEClass.getEStructuralFeatures().get(1); } @@ -584,6 +629,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getPrimitiveElement() { return primitiveElementEClass; } @@ -593,6 +639,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EAttribute getPrimitiveElement_ValueSet() { return (EAttribute)primitiveElementEClass.getEStructuralFeatures().get(0); } @@ -602,6 +649,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getBooleanElement() { return booleanElementEClass; } @@ -611,6 +659,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EAttribute getBooleanElement_Value() { return (EAttribute)booleanElementEClass.getEStructuralFeatures().get(0); } @@ -620,6 +669,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getIntegerElement() { return integerElementEClass; } @@ -629,6 +679,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EAttribute getIntegerElement_Value() { return (EAttribute)integerElementEClass.getEStructuralFeatures().get(0); } @@ -638,6 +689,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getRealElement() { return realElementEClass; } @@ -647,6 +699,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EAttribute getRealElement_Value() { return (EAttribute)realElementEClass.getEStructuralFeatures().get(0); } @@ -656,6 +709,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getStringElement() { return stringElementEClass; } @@ -665,6 +719,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EAttribute getStringElement_Value() { return (EAttribute)stringElementEClass.getEStructuralFeatures().get(0); } @@ -674,6 +729,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getScope() { return scopeEClass; } @@ -683,6 +739,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EAttribute getScope_MinNewElements() { return (EAttribute)scopeEClass.getEStructuralFeatures().get(0); } @@ -692,6 +749,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EAttribute getScope_MaxNewElements() { return (EAttribute)scopeEClass.getEStructuralFeatures().get(1); } @@ -701,6 +759,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getScope_TargetTypeInterpretation() { return (EReference)scopeEClass.getEStructuralFeatures().get(2); } @@ -710,6 +769,17 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override + public EAttribute getScope_MinNewElementsHeuristic() { + return (EAttribute)scopeEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + @Override public EClass getPartialPrimitiveInterpretation() { return partialPrimitiveInterpretationEClass; } @@ -719,6 +789,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getPartialBooleanInterpretation() { return partialBooleanInterpretationEClass; } @@ -728,6 +799,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getPartialIntegerInterpretation() { return partialIntegerInterpretationEClass; } @@ -737,6 +809,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getPartialRealInterpretation() { return partialRealInterpretationEClass; } @@ -746,6 +819,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getPartialStringInterpretation() { return partialStringInterpretationEClass; } @@ -755,6 +829,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EClass getPartialComplexTypeInterpretation() { return partialComplexTypeInterpretationEClass; } @@ -764,6 +839,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialComplexTypeInterpretation_SupertypeInterpretation() { return (EReference)partialComplexTypeInterpretationEClass.getEStructuralFeatures().get(0); } @@ -773,6 +849,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public EReference getPartialComplexTypeInterpretation_InterpretationOf() { return (EReference)partialComplexTypeInterpretationEClass.getEStructuralFeatures().get(1); } @@ -782,6 +859,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa * * @generated */ + @Override public PartialinterpretationFactory getPartialinterpretationFactory() { return (PartialinterpretationFactory)getEFactoryInstance(); } @@ -817,6 +895,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa createEReference(partialInterpretationEClass, PARTIAL_INTERPRETATION__SCOPES); createEAttribute(partialInterpretationEClass, PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS); createEAttribute(partialInterpretationEClass, PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS); + createEAttribute(partialInterpretationEClass, PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC); partialConstantInterpretationEClass = createEClass(PARTIAL_CONSTANT_INTERPRETATION); createEReference(partialConstantInterpretationEClass, PARTIAL_CONSTANT_INTERPRETATION__INTERPRETATION_OF); @@ -869,6 +948,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa createEAttribute(scopeEClass, SCOPE__MIN_NEW_ELEMENTS); createEAttribute(scopeEClass, SCOPE__MAX_NEW_ELEMENTS); createEReference(scopeEClass, SCOPE__TARGET_TYPE_INTERPRETATION); + createEAttribute(scopeEClass, SCOPE__MIN_NEW_ELEMENTS_HEURISTIC); partialPrimitiveInterpretationEClass = createEClass(PARTIAL_PRIMITIVE_INTERPRETATION); @@ -945,6 +1025,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa initEReference(getPartialInterpretation_Scopes(), this.getScope(), null, "scopes", null, 0, -1, PartialInterpretation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getPartialInterpretation_MinNewElements(), ecorePackage.getEInt(), "minNewElements", "0", 1, 1, PartialInterpretation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getPartialInterpretation_MaxNewElements(), ecorePackage.getEInt(), "maxNewElements", "-1", 1, 1, PartialInterpretation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getPartialInterpretation_MinNewElementsHeuristic(), ecorePackage.getEInt(), "minNewElementsHeuristic", "0", 1, 1, PartialInterpretation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(partialConstantInterpretationEClass, PartialConstantInterpretation.class, "PartialConstantInterpretation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEReference(getPartialConstantInterpretation_InterpretationOf(), theLogiclanguagePackage.getConstantDeclaration(), null, "interpretationOf", null, 1, 1, PartialConstantInterpretation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); @@ -997,6 +1078,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa initEAttribute(getScope_MinNewElements(), ecorePackage.getEInt(), "minNewElements", "0", 1, 1, Scope.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getScope_MaxNewElements(), ecorePackage.getEInt(), "maxNewElements", "-1", 1, 1, Scope.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getScope_TargetTypeInterpretation(), this.getPartialTypeInterpratation(), this.getPartialTypeInterpratation_Scopes(), "targetTypeInterpretation", null, 1, 1, Scope.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getScope_MinNewElementsHeuristic(), ecorePackage.getEInt(), "minNewElementsHeuristic", "0", 1, 1, Scope.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(partialPrimitiveInterpretationEClass, PartialPrimitiveInterpretation.class, "PartialPrimitiveInterpretation", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PrimitiveElementImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PrimitiveElementImpl.java index 29a1e1be..a8ef81b0 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PrimitiveElementImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PrimitiveElementImpl.java @@ -71,6 +71,7 @@ public abstract class PrimitiveElementImpl extends DefinedElementImpl implements * * @generated */ + @Override public boolean isValueSet() { return valueSet; } @@ -80,6 +81,7 @@ public abstract class PrimitiveElementImpl extends DefinedElementImpl implements * * @generated */ + @Override public void setValueSet(boolean newValueSet) { boolean oldValueSet = valueSet; valueSet = newValueSet; @@ -154,7 +156,7 @@ public abstract class PrimitiveElementImpl extends DefinedElementImpl implements public String toString() { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (valueSet: "); result.append(valueSet); result.append(')'); diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/RealElementImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/RealElementImpl.java index 0361a3e9..67cff5a2 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/RealElementImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/RealElementImpl.java @@ -71,6 +71,7 @@ public class RealElementImpl extends PrimitiveElementImpl implements RealElement * * @generated */ + @Override public BigDecimal getValue() { return value; } @@ -80,6 +81,7 @@ public class RealElementImpl extends PrimitiveElementImpl implements RealElement * * @generated */ + @Override public void setValue(BigDecimal newValue) { BigDecimal oldValue = value; value = newValue; @@ -154,7 +156,7 @@ public class RealElementImpl extends PrimitiveElementImpl implements RealElement public String toString() { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (value: "); result.append(value); result.append(')'); diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/ScopeImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/ScopeImpl.java index d8ade871..a1b6de35 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/ScopeImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/ScopeImpl.java @@ -26,6 +26,7 @@ import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; *

  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.ScopeImpl#getMinNewElements Min New Elements}
  • *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.ScopeImpl#getMaxNewElements Max New Elements}
  • *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.ScopeImpl#getTargetTypeInterpretation Target Type Interpretation}
  • + *
  • {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.ScopeImpl#getMinNewElementsHeuristic Min New Elements Heuristic}
  • * * * @generated @@ -81,6 +82,26 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { */ protected PartialTypeInterpratation targetTypeInterpretation; + /** + * The default value of the '{@link #getMinNewElementsHeuristic() Min New Elements Heuristic}' attribute. + * + * + * @see #getMinNewElementsHeuristic() + * @generated + * @ordered + */ + protected static final int MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getMinNewElementsHeuristic() Min New Elements Heuristic}' attribute. + * + * + * @see #getMinNewElementsHeuristic() + * @generated + * @ordered + */ + protected int minNewElementsHeuristic = MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT; + /** * * @@ -105,6 +126,7 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { * * @generated */ + @Override public int getMinNewElements() { return minNewElements; } @@ -114,6 +136,7 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { * * @generated */ + @Override public void setMinNewElements(int newMinNewElements) { int oldMinNewElements = minNewElements; minNewElements = newMinNewElements; @@ -126,6 +149,7 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { * * @generated */ + @Override public int getMaxNewElements() { return maxNewElements; } @@ -135,6 +159,7 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { * * @generated */ + @Override public void setMaxNewElements(int newMaxNewElements) { int oldMaxNewElements = maxNewElements; maxNewElements = newMaxNewElements; @@ -147,6 +172,7 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { * * @generated */ + @Override public PartialTypeInterpratation getTargetTypeInterpretation() { if (targetTypeInterpretation != null && targetTypeInterpretation.eIsProxy()) { InternalEObject oldTargetTypeInterpretation = (InternalEObject)targetTypeInterpretation; @@ -188,6 +214,7 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { * * @generated */ + @Override public void setTargetTypeInterpretation(PartialTypeInterpratation newTargetTypeInterpretation) { if (newTargetTypeInterpretation != targetTypeInterpretation) { NotificationChain msgs = null; @@ -202,6 +229,29 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { eNotify(new ENotificationImpl(this, Notification.SET, PartialinterpretationPackage.SCOPE__TARGET_TYPE_INTERPRETATION, newTargetTypeInterpretation, newTargetTypeInterpretation)); } + /** + * + * + * @generated + */ + @Override + public int getMinNewElementsHeuristic() { + return minNewElementsHeuristic; + } + + /** + * + * + * @generated + */ + @Override + public void setMinNewElementsHeuristic(int newMinNewElementsHeuristic) { + int oldMinNewElementsHeuristic = minNewElementsHeuristic; + minNewElementsHeuristic = newMinNewElementsHeuristic; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PartialinterpretationPackage.SCOPE__MIN_NEW_ELEMENTS_HEURISTIC, oldMinNewElementsHeuristic, minNewElementsHeuristic)); + } + /** * * @@ -247,6 +297,8 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { case PartialinterpretationPackage.SCOPE__TARGET_TYPE_INTERPRETATION: if (resolve) return getTargetTypeInterpretation(); return basicGetTargetTypeInterpretation(); + case PartialinterpretationPackage.SCOPE__MIN_NEW_ELEMENTS_HEURISTIC: + return getMinNewElementsHeuristic(); } return super.eGet(featureID, resolve, coreType); } @@ -268,6 +320,9 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { case PartialinterpretationPackage.SCOPE__TARGET_TYPE_INTERPRETATION: setTargetTypeInterpretation((PartialTypeInterpratation)newValue); return; + case PartialinterpretationPackage.SCOPE__MIN_NEW_ELEMENTS_HEURISTIC: + setMinNewElementsHeuristic((Integer)newValue); + return; } super.eSet(featureID, newValue); } @@ -289,6 +344,9 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { case PartialinterpretationPackage.SCOPE__TARGET_TYPE_INTERPRETATION: setTargetTypeInterpretation((PartialTypeInterpratation)null); return; + case PartialinterpretationPackage.SCOPE__MIN_NEW_ELEMENTS_HEURISTIC: + setMinNewElementsHeuristic(MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT); + return; } super.eUnset(featureID); } @@ -307,6 +365,8 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { return maxNewElements != MAX_NEW_ELEMENTS_EDEFAULT; case PartialinterpretationPackage.SCOPE__TARGET_TYPE_INTERPRETATION: return targetTypeInterpretation != null; + case PartialinterpretationPackage.SCOPE__MIN_NEW_ELEMENTS_HEURISTIC: + return minNewElementsHeuristic != MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT; } return super.eIsSet(featureID); } @@ -320,11 +380,13 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope { public String toString() { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (minNewElements: "); result.append(minNewElements); result.append(", maxNewElements: "); result.append(maxNewElements); + result.append(", minNewElementsHeuristic: "); + result.append(minNewElementsHeuristic); result.append(')'); return result.toString(); } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/StringElementImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/StringElementImpl.java index f207401d..0242c9b2 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/StringElementImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/StringElementImpl.java @@ -69,6 +69,7 @@ public class StringElementImpl extends PrimitiveElementImpl implements StringEle * * @generated */ + @Override public String getValue() { return value; } @@ -78,6 +79,7 @@ public class StringElementImpl extends PrimitiveElementImpl implements StringEle * * @generated */ + @Override public void setValue(String newValue) { String oldValue = value; value = newValue; @@ -152,7 +154,7 @@ public class StringElementImpl extends PrimitiveElementImpl implements StringEle public String toString() { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (value: "); result.append(value); result.append(')'); diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/UnaryElementRelationLinkImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/UnaryElementRelationLinkImpl.java index 2cb56323..e76a89b7 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/UnaryElementRelationLinkImpl.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/UnaryElementRelationLinkImpl.java @@ -62,6 +62,7 @@ public class UnaryElementRelationLinkImpl extends RelationLinkImpl implements Un * * @generated */ + @Override public DefinedElement getParam1() { if (param1 != null && param1.eIsProxy()) { InternalEObject oldParam1 = (InternalEObject)param1; @@ -88,6 +89,7 @@ public class UnaryElementRelationLinkImpl extends RelationLinkImpl implements Un * * @generated */ + @Override public void setParam1(DefinedElement newParam1) { DefinedElement oldParam1 = param1; param1 = newParam1; diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.ecore b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.ecore index acf82a3f..47d54258 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.ecore +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.ecore @@ -27,6 +27,9 @@ eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt" defaultValueLiteral="0"/> + + diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.genmodel b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.genmodel index 2ac0a4f3..daeaf594 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.genmodel +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.genmodel @@ -18,7 +18,10 @@ - + + + + @@ -33,9 +36,8 @@ - - + @@ -50,6 +52,7 @@ + @@ -70,11 +73,16 @@ + + + + + diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend index c7c1ad77..e4bdb086 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend @@ -60,6 +60,10 @@ import org.eclipse.xtend2.lib.StringConcatenationClient return this.dataHash.hashCode } + override equals(Object other) { + other.class == LocalNodeDescriptor && (other as AbstractNodeDescriptor).hashCode == hashCode + } + override protected prettyPrint() { '''(«dataHash»)[«IF id !== null»id = "«id»"«IF types === null || !types.empty», «ENDIF»«ENDIF»«IF types === null»TYPES = null«ELSE»«FOR type : types SEPARATOR ", "»«type»«ENDFOR»«ENDIF»]''' } @@ -143,6 +147,10 @@ import org.eclipse.xtend2.lib.StringConcatenationClient return this.dataHash.hashCode } + override equals(Object other) { + other.class == FurtherNodeDescriptor && (other as AbstractNodeDescriptor).hashCode == hashCode + } + override prettyPrint() { ''' («dataHash»)[ diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend index efc89803..c6e03f75 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend @@ -7,12 +7,12 @@ import org.eclipse.xtend.lib.annotations.Data @Data class NeighbourhoodOptions { - public static val FixPointRage = -1 + public static val FixPointRange = -1 public static val GraphWidthRange = -2 public static val FullParallels = Integer.MAX_VALUE public static val MaxNumbers = Integer.MAX_VALUE - public static val DEFAULT = new NeighbourhoodOptions(GraphWidthRange, FullParallels, MaxNumbers, null, null) + public static val DEFAULT = new NeighbourhoodOptions(FixPointRange, FullParallels, MaxNumbers, null, null) val int range val int parallels diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend index d474877d..ddf7d712 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend @@ -5,7 +5,7 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement class PartialInterpretation2Hash extends PartialInterpretation2NeighbourhoodRepresentation{ - protected new() { + new() { super(false, true) } 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 a0382e8e..3048167e 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 @@ -25,7 +25,7 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation nodeRepresentations = null - var Map modelRepresentation = null +class NeighbourhoodBasedHashStateCoderFactory extends AbstractNeighbourhoodBasedStateCoderFactory { + new() { + } new(NeighbourhoodOptions options) { super(options) } + override protected doCreateStateCoder(NeighbourhoodOptions options) { + new NeighbourhoodBasedPartialInterpretationStateCoder(new PartialInterpretation2Hash, options) + } +} + +class NeighbourhoodBasedPartialInterpretationStateCoder extends AbstractNeighbourhoodBasedPartialInterpretationStateCoder { + val PartialInterpretation2NeighbourhoodRepresentation calculator + var Map nodeRepresentations = null + var ModelRep modelRepresentation = null + + new(PartialInterpretation2NeighbourhoodRepresentation calculator, NeighbourhoodOptions options) { + super(options) + this.calculator = calculator + } + override protected isRefreshNeeded() { nodeRepresentations === null || modelRepresentation === null } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend index 1abde0a8..aa02cd30 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend @@ -12,12 +12,15 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicresultFactory import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethodProvider +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.PartialInterpretationInitialiser import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.AbstractNeighbourhoodBasedStateCoderFactory import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.IdentifierBasedStateCoderFactory +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.NeighbourhoodBasedHashStateCoderFactory import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.PairwiseNeighbourhoodBasedStateCoderFactory +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.BasicScopeGlobalConstraint import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.BestFirstStrategyForModelGeneration import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.DiversityChecker import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.InconsistentScopeGlobalConstraint @@ -39,7 +42,6 @@ import org.eclipse.viatra.dse.api.DesignSpaceExplorer import org.eclipse.viatra.dse.api.DesignSpaceExplorer.DseLoggingLevel import org.eclipse.viatra.dse.solutionstore.SolutionStore import org.eclipse.viatra.dse.statecode.IStateCoderFactory -import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.NeighbourhoodBasedStateCoderFactory class ViatraReasoner extends LogicReasoner { val PartialInterpretationInitialiser initialiser = new PartialInterpretationInitialiser() @@ -71,6 +73,11 @@ class ViatraReasoner extends LogicReasoner { workspace.writeModel(emptySolution, "init.partialmodel") } emptySolution.problemConainer = problem + var BasicScopeGlobalConstraint basicScopeGlobalConstraint = null + if (viatraConfig.scopePropagatorStrategy == ScopePropagatorStrategy.None) { + basicScopeGlobalConstraint = new BasicScopeGlobalConstraint(emptySolution) + emptySolution.scopes.clear + } val method = modelGenerationMethodProvider.createModelGenerationMethod( problem, @@ -79,11 +86,12 @@ class ViatraReasoner extends LogicReasoner { viatraConfig.nameNewElements, viatraConfig.typeInferenceMethod, viatraConfig.scopePropagatorStrategy, + viatraConfig.hints, viatraConfig.documentationLevel ) dse.addObjective(new ModelGenerationCompositeObjective( - new ScopeObjective, + basicScopeGlobalConstraint ?: new ScopeObjective, method.unfinishedMultiplicities.map[new UnfinishedMultiplicityObjective(it)], wf2ObjectiveConverter.createCompletenessObjective(method.unfinishedWF) )) @@ -132,6 +140,9 @@ class ViatraReasoner extends LogicReasoner { dse.addGlobalConstraint(wf2ObjectiveConverter.createInvalidationGlobalConstraint(method.invalidWF)) dse.addGlobalConstraint(new SurelyViolatedObjectiveGlobalConstraint(solutionSaver)) dse.addGlobalConstraint(new InconsistentScopeGlobalConstraint) + if (basicScopeGlobalConstraint !== null) { + dse.addGlobalConstraint(basicScopeGlobalConstraint) + } for (additionalConstraint : viatraConfig.searchSpaceConstraints.additionalGlobalConstraints) { dse.addGlobalConstraint(additionalConstraint.apply(method)) } @@ -140,7 +151,7 @@ class ViatraReasoner extends LogicReasoner { val IStateCoderFactory statecoder = switch (viatraConfig.stateCoderStrategy) { case Neighbourhood: - new NeighbourhoodBasedStateCoderFactory + new NeighbourhoodBasedHashStateCoderFactory case PairwiseNeighbourhood: new PairwiseNeighbourhoodBasedStateCoderFactory default: @@ -215,10 +226,18 @@ class ViatraReasoner extends LogicReasoner { it.name = "Decisions" it.value = method.statistics.decisionsTried ] + it.entries += createIntStatisticEntry => [ + it.name = "Transformations" + it.value = method.statistics.transformationInvocations + ] it.entries += createIntStatisticEntry => [ it.name = "ScopePropagations" it.value = method.statistics.scopePropagatorInvocations ] + it.entries += createIntStatisticEntry => [ + it.name = "ScopePropagationsSolverCalls" + it.value = method.statistics.scopePropagatorSolverInvocations + ] if (diversityChecker.isActive) { it.entries += createIntStatisticEntry => [ it.name = "SolutionDiversityCheckTime" diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend index a5f42a5f..6f38d261 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend @@ -16,6 +16,7 @@ import java.util.LinkedList import java.util.List import java.util.Set import org.eclipse.xtext.xbase.lib.Functions.Function1 +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint enum StateCoderStrategy { Neighbourhood, @@ -56,6 +57,8 @@ class ViatraReasonerConfiguration extends LogicSolverConfiguration { public var ScopePropagatorStrategy scopePropagatorStrategy = new ScopePropagatorStrategy.Polyhedral( PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp) + + public var List hints = newArrayList public var List costObjectives = newArrayList } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BasicScopeGlobalConstraint.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BasicScopeGlobalConstraint.xtend new file mode 100644 index 00000000..67f447ed --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BasicScopeGlobalConstraint.xtend @@ -0,0 +1,103 @@ +package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse + +import com.google.common.collect.ImmutableList +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation +import java.util.Comparator +import java.util.List +import org.eclipse.viatra.dse.base.ThreadContext +import org.eclipse.viatra.dse.objectives.Comparators +import org.eclipse.viatra.dse.objectives.IGlobalConstraint +import org.eclipse.viatra.dse.objectives.IObjective +import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor + +class BasicScopeGlobalConstraint implements IGlobalConstraint, IObjective { + val PartialInterpretation p + val List assertions + + new(PartialInterpretation p) { + this.p = p + assertions = ImmutableList.copyOf(p.scopes.map [ + val currentSize = targetTypeInterpretation.elements.size + val minElements = minNewElements + currentSize + val maxElements = if (maxNewElements < 0) { + -1 + } else { + maxNewElements + currentSize + } + new ScopeAssertion(minElements, maxElements, targetTypeInterpretation) + ]) + } + + override init(ThreadContext context) { + if (context.model != p) { + throw new IllegalArgumentException( + "Partial model must be passed to the constructor of BasicScopeGlobalConstraint") + } + } + + override checkGlobalConstraint(ThreadContext context) { + assertions.forall[upperBoundSatisfied] + } + + override getFitness(ThreadContext context) { + var double fitness = p.minNewElements + for (assertion : assertions) { + if (!assertion.lowerBoundSatisfied) { + fitness += 1 + } + } + fitness + } + + override satisifiesHardObjective(Double fitness) { + fitness <= 0.01 + } + + override BasicScopeGlobalConstraint createNew() { + this + } + + override getName() { + class.name + } + + override getComparator() { + Comparators.LOWER_IS_BETTER + } + + override getLevel() { + 2 + } + + override isHardObjective() { + true + } + + override setComparator(Comparator comparator) { + throw new UnsupportedOperationException + } + + override setLevel(int level) { + throw new UnsupportedOperationException + } + + @FinalFieldsConstructor + private static class ScopeAssertion { + val int lowerBound + val int upperBound + val PartialTypeInterpratation typeDefinitions + + private def getCount() { + typeDefinitions.elements.size + } + + private def isLowerBoundSatisfied() { + count >= lowerBound + } + + private def isUpperBoundSatisfied() { + upperBound < 0 || count <= upperBound + } + } +} diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java index 5af7fc69..081e48fa 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java @@ -255,7 +255,7 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { activationIds = new ArrayList(context.getUntraversedActivationIds()); Collections.shuffle(activationIds); } catch (NullPointerException e) { - logger.warn("Unexpected state code: " + context.getDesignSpaceManager().getCurrentState()); +// logger.warn("Unexpected state code: " + context.getDesignSpaceManager().getCurrentState()); numberOfStatecoderFail++; activationIds = Collections.emptyList(); } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend index 9a33753c..2976bebe 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend @@ -59,7 +59,7 @@ class ModelGenerationCompositeObjective implements IThreeValuedObjective { } sum += multiplicity sum += unfinishedWFsFitness // *0.5 - // println('''Sum=«sum»|Scope=«scopeFitnes»|Multiplicity=«multiplicity»|WFs=«unfinishedWFsFitness»''') +// println('''Sum=«sum»|Scope=«scopeFitnes»|Multiplicity=«multiplicity»|WFs=«unfinishedWFsFitness»''') return sum } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ScopeObjective.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ScopeObjective.xtend index 69efe0d7..e7967b00 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ScopeObjective.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ScopeObjective.xtend @@ -23,9 +23,9 @@ class ScopeObjective implements IObjective{ override getFitness(ThreadContext context) { val interpretation = context.model as PartialInterpretation - var res = interpretation.minNewElements.doubleValue + var res = interpretation.minNewElementsHeuristic.doubleValue for(scope : interpretation.scopes) { - res += scope.minNewElements*2 + res += scope.minNewElementsHeuristic*2 } return res } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/UnfinishedWFObjective.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/UnfinishedWFObjective.xtend index bf34aeeb..1b61ffa5 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/UnfinishedWFObjective.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/UnfinishedWFObjective.xtend @@ -14,41 +14,51 @@ import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher class UnfinishedWFObjective implements IObjective { Collection>> unfinishedWFs val List> matchers - - new(Collection>> unfinishedWFs) { + + new( + Collection>> unfinishedWFs) { this.unfinishedWFs = unfinishedWFs matchers = new ArrayList(unfinishedWFs.size) } + override getName() '''unfinishedWFs''' + override createNew() { return new UnfinishedWFObjective(unfinishedWFs) } + override init(ThreadContext context) { - val engine = context.queryEngine//ViatraQueryEngine.on(new EMFScope(context.model)) - for(unfinishedWF : unfinishedWFs) { + val engine = context.queryEngine // ViatraQueryEngine.on(new EMFScope(context.model)) + for (unfinishedWF : unfinishedWFs) { matchers += unfinishedWF.getMatcher(engine) } } - + override getComparator() { Comparators.LOWER_IS_BETTER } + override getFitness(ThreadContext context) { var sumOfMatches = 0 - for(matcher : matchers) { + for (matcher : matchers) { val number = matcher.countMatches - //println('''«matcher.patternName» = «number»''') - sumOfMatches+=number +// if (number > 0) { +// println('''«matcher.patternName» = «number»''') +// } + sumOfMatches += number } return sumOfMatches.doubleValue } - + override getLevel() { 2 } + override isHardObjective() { true } - override satisifiesHardObjective(Double fitness) { return fitness <=0.01 } - + + override satisifiesHardObjective(Double fitness) { return fitness <= 0.01 } + override setComparator(Comparator comparator) { throw new UnsupportedOperationException() } + override setLevel(int level) { throw new UnsupportedOperationException() } -} \ No newline at end of file +} diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ViatraReasonerSolutionSaver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ViatraReasonerSolutionSaver.xtend index 6bffeb59..74500cc2 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ViatraReasonerSolutionSaver.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ViatraReasonerSolutionSaver.xtend @@ -42,7 +42,7 @@ class ViatraReasonerSolutionSaver implements ISolutionSaver { private def saveBestSolutionOnly(ThreadContext context, Object id, SolutionTrajectory solutionTrajectory) { val fitness = context.lastFitness - if (!fitness.satisifiesHardObjectives) { + if (!shouldSaveSolution(fitness, context)) { return false } val dominatedTrajectories = newArrayList @@ -83,7 +83,7 @@ class ViatraReasonerSolutionSaver implements ISolutionSaver { private def saveAnyDiverseSolution(ThreadContext context, Object id, SolutionTrajectory solutionTrajectory) { val fitness = context.lastFitness - if (!fitness.satisifiesHardObjectives) { + if (!shouldSaveSolution(fitness, context)) { return false } if (!diversityChecker.newSolution(context, id, emptyList)) { @@ -92,7 +92,12 @@ class ViatraReasonerSolutionSaver implements ISolutionSaver { basicSaveSolution(context, id, solutionTrajectory, fitness) } - private def basicSaveSolution(ThreadContext context, Object id, SolutionTrajectory solutionTrajectory, Fitness fitness) { + private def shouldSaveSolution(Fitness fitness, ThreadContext context) { + return fitness.satisifiesHardObjectives + } + + private def basicSaveSolution(ThreadContext context, Object id, SolutionTrajectory solutionTrajectory, + Fitness fitness) { var boolean solutionSaved = false var dseSolution = solutionsCollection.get(id) if (dseSolution === null) { diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/META-INF/MANIFEST.MF b/Tests/hu.bme.mit.inf.dslreasoner.run/META-INF/MANIFEST.MF index cc274c7c..fe223d4a 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/META-INF/MANIFEST.MF +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/META-INF/MANIFEST.MF @@ -28,8 +28,10 @@ Require-Bundle: hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlan hu.bme.mit.inf.dslreasoner.visualisation;bundle-version="1.0.0", hu.bme.mit.inf.dslreasoner.domains.alloyexamples;bundle-version="1.0.0", org.eclipse.collections;bundle-version="9.2.0", - org.eclipse.viatra.query.patternlanguage.emf;bundle-version="2.2.0", - org.eclipse.viatra.query.runtime.rete;bundle-version="2.2.0", - org.objectweb.asm;bundle-version="7.0.0" + org.eclipse.viatra.query.patternlanguage.emf;bundle-version="2.0.0", + org.eclipse.viatra.query.runtime.rete;bundle-version="2.0.0", + org.objectweb.asm;bundle-version="7.0.0", + com.google.gson;bundle-version="2.8.2", + hu.bme.mit.inf.dslreasoner.domains.satellite;bundle-version="0.1.0" Import-Package: org.apache.log4j Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/FAM_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/FAM_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json new file mode 100644 index 00000000..26df3c74 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/FAM_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json @@ -0,0 +1,13 @@ +{ + "inputPath": "initialModels", + "outputPath": "outputModels", + "timeout": 1200, + "saveModels": true, + "warmupIterations": 0, + "iterations": 1, + "domain": "FAM", + "scope": "none", + "sizes": [500], + "solver": "ViatraSolver", + "scopePropagator": "basic" +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json new file mode 100644 index 00000000..5f8a01b1 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json @@ -0,0 +1,16 @@ +{ + "inputPath": "initialModels", + "outputPath": "outputModels", + "timeout": 1200, + "saveModels": false, + "warmupIterations": 0, + "iterations": 5, + "domain": "Yakindu", + "scope": "quantiles", + "sizes": [100], + "solver": "ViatraSolver", + "scopePropagator": "polyhedral", + "propagatedConstraints": "hints", + "polyhedronSolver": "Clp", + "scopeHeuristic": "basic" +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json new file mode 100644 index 00000000..42073422 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json @@ -0,0 +1,15 @@ +{ + "inputPath": "initialModels", + "outputPath": "outputModels", + "timeout": 1200, + "saveModels": true, + "warmupIterations": 0, + "iterations": 5, + "domain": "ecore", + "scope": "quantiles", + "sizes": [100], + "solver": "ViatraSolver", + "scopePropagator": "polyhedral", + "propagatedConstraints": "relations", + "polyhedronSolver": "Clp" +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/fs_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/fs_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json new file mode 100644 index 00000000..d7955ddd --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/fs_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json @@ -0,0 +1,15 @@ +{ + "inputPath": "initialModels", + "outputPath": "outputModels", + "timeout": 1200, + "saveModels": true, + "warmupIterations": 1, + "iterations": 1, + "domain": "fs", + "scope": "useful", + "sizes": [50, 100, 150, 200, 250, 300, 350, 400, 450, 500], + "solver": "ViatraSolver", + "scopePropagator": "polyhedral", + "propagatedConstraints": "relations", + "polyhedronSolver": "Clp" +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json new file mode 100644 index 00000000..474962e7 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json @@ -0,0 +1,17 @@ +{ + "inputPath": "initialModels", + "outputPath": "outputModels", + "timeout": 1200, + "saveModels": true, + "saveTemporaryFiles": true, + "warmupIterations": 0, + "iterations": 1, + "domain": "satellite", + "scope": "quantiles", + "sizes": [50], + "solver": "ViatraSolver", + "scopePropagator": "polyhedral", + "propagatedConstraints": "hints", + "polyhedronSolver": "Clp", + "scopeHeuristic": "polyhedral" +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/initialModels/satellite.xmi b/Tests/hu.bme.mit.inf.dslreasoner.run/initialModels/satellite.xmi new file mode 100644 index 00000000..77f6ecfd --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/initialModels/satellite.xmi @@ -0,0 +1,14 @@ + + + + + + + diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/CountMatches.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/CountMatches.xtend deleted file mode 100644 index 02caf9dd..00000000 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/CountMatches.xtend +++ /dev/null @@ -1,176 +0,0 @@ -package hu.bme.mit.inf.dslreasoner.run - -import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage -import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated -import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace -import java.io.File -import java.util.ArrayList -import java.util.Collection -import java.util.Comparator -import java.util.HashMap -import java.util.List -import java.util.Map -import java.util.TreeSet -import org.eclipse.emf.ecore.EObject -import org.eclipse.emf.ecore.resource.Resource -import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl -import org.eclipse.viatra.query.runtime.api.IPatternMatch -import org.eclipse.viatra.query.runtime.api.IQuerySpecification -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine -import org.eclipse.viatra.query.runtime.emf.EMFScope - -class QueryComparator implements Comparator>{ - - override compare(IQuerySpecification arg0, IQuerySpecification arg1) { - arg0.fullyQualifiedName.compareTo(arg1.fullyQualifiedName) - } -} - -class CountMatches { - var static List> wfPatterns; - var static Map,IQuerySpecification> query2Reference - - def static void main(String[] args) { - YakindummPackage.eINSTANCE.eClass - Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("*",new XMIResourceFactoryImpl) - - wfPatterns = Mutated.instance.specifications.toList; - //wfPatterns = wfPatterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toList - wfPatterns.sort(new QueryComparator) - - val groupName2Representant = new HashMap - query2Reference = new HashMap - for(wfPattern : wfPatterns) { - val groupName = wfPattern.groupName - if(groupName2Representant.containsKey(groupName)) { - val representant = groupName2Representant.get(groupName) - query2Reference.put(wfPattern,representant) - } else { - groupName2Representant.put(groupName,wfPattern) - } - } - - - println('''modelpath;run;model;« - FOR wfPattern:wfPatterns SEPARATOR ";"»#(« - wfPattern.fullyQualifiedName.split("\\.").last»);hash(« - wfPattern.fullyQualifiedName.split("\\.").last»)«ENDFOR»;« - FOR mutant : wfPatterns.filter[query2Reference.keySet.contains(it)] SEPARATOR ';'»diff(« - mutant.fullyQualifiedName.split("\\.").last»)«ENDFOR»''' - ) - countMatches('''D:/FASE18Meas/RemoHF''') - } - - def private static simpleName(IQuerySpecification wfPattern) { - wfPattern.fullyQualifiedName.split("\\.").last - } - def private static groupName(IQuerySpecification wfPattern) { - wfPattern.simpleName.split('_').head - } - - def static void countMatches(String path) { - val file = new File(path) - if(file.isDirectory) { - for(subFileName : file.list) { - (path + "/" + subFileName).countMatches - } - } else if(file.isFile) { - if(path.endsWith("xmi")) { - countMatches(file,path) - } - } - } - - def static void countMatches(File file, String path) { - - - val pathSegments = path.split("/") - val groupName = pathSegments.get(pathSegments.size-2).split("\\.").last.split("_").get(0) - print(groupName +";") - val nameExtension = pathSegments.get(pathSegments.size-1).split("\\.").get(0).split("_") - try{ - val runNumber = nameExtension.get(1) - val modelNumber = nameExtension.get(2) - print('''«runNumber»;«modelNumber»''') - } catch(Exception e) { - print('''«file.name»;0''') - } - - val parent = file.parent - val workspace = new FileSystemWorkspace(parent,"") - val model = workspace.readModel(EObject,file.name) - - val engine = ViatraQueryEngine.on(new EMFScope(model)) - val objectCode = model.eResource.calculateObjectCode - - val pattern2Hash = new HashMap - for(pattern : wfPatterns) { - val matcher = pattern.getMatcher(engine) - val matches = matcher.allMatches - val hash = matches.getMatchSetDescriptor(objectCode) - pattern2Hash.put(pattern,hash) - print(''';«matcher.countMatches»;«hash»''') - } - var mutantsKilled = 0 - for(mutant : wfPatterns.filter[query2Reference.keySet.contains(it)]) { - val equals = pattern2Hash.get(mutant) == pattern2Hash.get(query2Reference.get(mutant)) - print(''';''') - if(equals) { - print('0') - } else { - print('1') - mutantsKilled++ - } - } - //print(''';«mutantsKilled»''') - println() - } - - def static Map calculateObjectCode(Resource resource) { - val res = new HashMap - val iterator = resource.allContents - var index = 1 - while(iterator.hasNext) { - res.put(iterator.next,index++) - } - return res - } - - def static getMatchSetDescriptor(Collection matchSet, Map objectCode) { - val set = new TreeSet(new ArrayComparator) - for(match: matchSet) { - val size = match.parameterNames.size - val idArray = new ArrayList(size) - for(i:0..> { - - override compare(List arg0, List arg1) { - if(arg0.size === arg1.size) { - for(i : 0.. nameToType + val Map> nameToRelation + + protected new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { + nameToType = ImmutableMap.copyOf(ecore2Logic.allClassesInScope(trace).toMap[name].mapValues [ eClass | + ecore2Logic.TypeofEClass(trace, eClass) + ]) + nameToRelation = ImmutableMap.copyOf(ecore2Logic.allReferencesInScope(trace).groupBy[EContainingClass.name]. + mapValues [ references | + ImmutableMap.copyOf(references.toMap[name].mapValues [ reference | + ecore2Logic.relationOfReference(trace, reference) + ]) + ]) + } + + protected def getType(String name) { + nameToType.get(name) + } + + protected def relation(String typeName, String relationName) { + nameToRelation.get(typeName).get(relationName) + } + + protected static def int countMatches(ViatraQueryMatcher matcher, PartialInterpretation p) { + val match = matcher.newEmptyMatch + match.set(0, p.problem) + match.set(1, p) + matcher.countMatches(match) + } + + protected static def int getCount(ViatraQueryMatcher matcher, PartialInterpretation p) { + val match = matcher.newEmptyMatch + match.set(0, p.problem) + match.set(1, p) + val realMatch = matcher.getOneArbitraryMatch(match) + if (realMatch.present) { + realMatch.get.get(2) as Integer + } else { + 0 + } + } +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend index 34f3c267..54724226 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend @@ -4,18 +4,23 @@ import functionalarchitecture.FunctionalarchitecturePackage import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Ecore import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.FileSystem import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FilesystemPackage +import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SatelliteQueriesAll import hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethodBasedGlobalConstraint import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace import java.util.Collection import java.util.HashMap import java.util.LinkedHashMap import java.util.List +import java.util.Map import java.util.Set import org.eclipse.emf.ecore.EAttribute import org.eclipse.emf.ecore.EClass @@ -24,60 +29,83 @@ import org.eclipse.emf.ecore.EEnumLiteral import org.eclipse.emf.ecore.EObject import org.eclipse.emf.ecore.EReference import org.eclipse.emf.ecore.EcorePackage +import org.eclipse.xtend.lib.annotations.Data import org.eclipse.xtext.xbase.lib.Functions.Function1 -import hu.bme.mit.inf.dslreasoner.domains.transima.fam.Type -import hu.bme.mit.inf.dslreasoner.domains.transima.fam.Model +import satellite.SatellitePackage + +@Data +class TypeQuantiles { + double low + double high +} abstract class MetamodelLoader { protected val ReasonerWorkspace workspace + new(ReasonerWorkspace workspace) { this.workspace = workspace - } + } + def EcoreMetamodelDescriptor loadMetamodel() + def Set getRelevantTypes(EcoreMetamodelDescriptor descriptor) + def Set getRelevantReferences(EcoreMetamodelDescriptor descriptor) + def ViatraQuerySetDescriptor loadQueries(EcoreMetamodelDescriptor metamodel) + def List loadPartialModel() - - def List> additionalConstraints() - - def filterByNames(Iterable collection, Function1 nameExtractor, Collection requiredNames) { + + def List> additionalConstraints() + + def Map getTypeQuantiles() { + emptyMap + } + + def List getHints(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { + emptyList + } + + def filterByNames(Iterable collection, Function1 nameExtractor, + Collection requiredNames) { val res = collection.filter[requiredNames.contains(nameExtractor.apply(it))] if(res.size != requiredNames.size) throw new IllegalArgumentException return res.toSet } } -class FAMLoader extends MetamodelLoader{ - +class FAMLoader extends MetamodelLoader { + new(ReasonerWorkspace workspace) { super(workspace) } - + override loadMetamodel() { val package = FunctionalarchitecturePackage.eINSTANCE val List classes = package.EClassifiers.filter(EClass).toList val List enums = package.EClassifiers.filter(EEnum).toList val List literals = enums.map[ELiterals].flatten.toList - val List references = classes.map[EReferences].flatten.toList + val List references = classes.map[EReferences].flatten.filter[name != "type" && name != "model"]. + toList val List attributes = classes.map[EAttributes].flatten.toList - return new EcoreMetamodelDescriptor(classes,#{},false,enums,literals,references,attributes) + return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes) } - - override getRelevantTypes(EcoreMetamodelDescriptor descriptor) { - return descriptor.classes.filterByNames([it.name],#["FunctionalElement"]) + + override getRelevantTypes(EcoreMetamodelDescriptor descriptor) { + return descriptor.classes.filterByNames([it.name], #["FunctionalElement"]) } + override getRelevantReferences(EcoreMetamodelDescriptor descriptor) { - return descriptor.references.filterByNames([it.name],#["subElements"]) + return descriptor.references.filterByNames([it.name], #["subElements"]) } - + override loadQueries(EcoreMetamodelDescriptor metamodel) { val i = FamPatterns.instance val patterns = i.specifications.toList - val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name== "Constraint"]].toSet + val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet val derivedFeatures = new LinkedHashMap - derivedFeatures.put(Type.instance,metamodel.attributes.filter[it.name == "type"].head) - derivedFeatures.put(Model.instance,metamodel.references.filter[it.name == "model"].head) +// derivedFeatures.put(Type.instance,metamodel.attributes.filter[it.name == "type"].head) +// derivedFeatures.put(Model.instance,metamodel.references.filter[it.name == "model"].head) val res = new ViatraQuerySetDescriptor( patterns, wfPatterns, @@ -85,65 +113,67 @@ class FAMLoader extends MetamodelLoader{ ) return res } + override loadPartialModel() { - this.workspace.readModel(EObject,"FAM.xmi").eResource.allContents.toList + this.workspace.readModel(EObject, "FAM.xmi").eResource.allContents.toList } - + override additionalConstraints() { #[] } } -class YakinduLoader extends MetamodelLoader{ - +class YakinduLoader extends MetamodelLoader { + var useSynchronization = true; - var useComplexStates = false; - public static val patternsWithSynchronization = #[ - "synchHasNoOutgoing", "synchHasNoIncoming", "SynchronizedIncomingInSameRegion", "notSynchronizingStates", - "hasMultipleOutgoingTrainsition", "hasMultipleIncomingTrainsition", "SynchronizedRegionsAreNotSiblings", - "SynchronizedRegionDoesNotHaveMultipleRegions", "synchThree", "twoSynch","noSynch2","synch","noSynch4","noSynch3","noSynch"] - public static val patternsWithComplexStates =#["outgoingFromExit","outgoingFromFinal","choiceHasNoOutgoing","choiceHasNoIncoming"] + var useComplexStates = false; + public static val patternsWithSynchronization = #["synchHasNoOutgoing", "synchHasNoIncoming", + "SynchronizedIncomingInSameRegion", "SynchronizedIncomingInSameRegionHelper1", + "SynchronizedIncomingInSameRegionHelper2", "notSynchronizingStates", "hasMultipleOutgoingTrainsition", + "hasMultipleIncomingTrainsition", "SynchronizedRegionsAreNotSiblings", + "SynchronizedRegionsAreNotSiblingsHelper1", "SynchronizedRegionsAreNotSiblingsHelper2", + "SynchronizedRegionDoesNotHaveMultipleRegions", "synchThree", "twoSynch", "noSynch2", "synch", "noSynch4", + "noSynch3", "noSynch"] + public static val patternsWithComplexStates = #["outgoingFromExit", "outgoingFromFinal", "choiceHasNoOutgoing", + "choiceHasNoIncoming"] + new(ReasonerWorkspace workspace) { super(workspace) YakindummPackage.eINSTANCE.eClass } - + def setUseSynchronization(boolean useSynchronization) { this.useSynchronization = useSynchronization } + def setUseComplexStates(boolean useComplexStates) { this.useComplexStates = useComplexStates } - + override loadMetamodel() { val useSynchInThisLoad = this.useSynchronization val useComplexStates = this.useComplexStates - + val package = YakindummPackage.eINSTANCE - val List classes = package.EClassifiers.filter(EClass) - .filter[useSynchInThisLoad || (it.name != "Synchronization")] - .filter[useComplexStates || (it.name != "Choice" && it.name != "Exit" && it.name != "FinalState")] - .toList + val List classes = package.EClassifiers.filter(EClass).filter [ + useSynchInThisLoad || (it.name != "Synchronization") + ].filter[useComplexStates || (it.name != "Choice" && it.name != "Exit" && it.name != "FinalState")].toList val List enums = package.EClassifiers.filter(EEnum).toList val List literals = enums.map[ELiterals].flatten.toList val List references = classes.map[EReferences].flatten.toList val List attributes = classes.map[EAttributes].flatten.toList - return new EcoreMetamodelDescriptor(classes,#{},false,enums,literals,references,attributes) + return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes) } + override loadQueries(EcoreMetamodelDescriptor metamodel) { val useSynchInThisLoad = this.useSynchronization - + val i = Patterns.instance - val patterns = i.specifications - .filter[spec | - useSynchInThisLoad || - !patternsWithSynchronization.exists[spec.fullyQualifiedName.endsWith(it)] - ] - .filter[spec | - useComplexStates || - !patternsWithComplexStates.exists[spec.fullyQualifiedName.endsWith(it)] - ] - .toList - val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name== "Constraint"]].toSet + val patterns = i.specifications.filter [ spec | + useSynchInThisLoad || !patternsWithSynchronization.exists[spec.fullyQualifiedName.endsWith(it)] + ].filter [ spec | + useComplexStates || !patternsWithComplexStates.exists[spec.fullyQualifiedName.endsWith(it)] + ].toList + val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet val derivedFeatures = new LinkedHashMap val res = new ViatraQuerySetDescriptor( patterns, @@ -152,53 +182,71 @@ class YakinduLoader extends MetamodelLoader{ ) return res } + override getRelevantTypes(EcoreMetamodelDescriptor descriptor) { - descriptor.classes.filterByNames([it.name],#["Vertex","Transition","Synchronization"]) + descriptor.classes.filterByNames([it.name], #["Vertex", "Transition", "Synchronization"]) } - + override getRelevantReferences(EcoreMetamodelDescriptor descriptor) { - descriptor.references.filterByNames([it.name],#["source","target"]) + descriptor.references.filterByNames([it.name], #["source", "target"]) } - + override loadPartialModel() { - this.workspace.readModel(EObject,"Yakindu.xmi").eResource.allContents.toList + this.workspace.readModel(EObject, "Yakindu.xmi").eResource.allContents.toList } - - override additionalConstraints() { //#[] - #[[method | new SGraphInconsistencyDetector(method)]] + + override additionalConstraints() { // #[] + #[[method|new SGraphInconsistencyDetector(method)]] + } + + override getTypeQuantiles() { + #{ + "Choice" -> new TypeQuantiles(0.118279569892473, 0.154020979020979), + "Entry" -> new TypeQuantiles(0.0283018867924528, 0.0620167525773196), + "Exit" -> new TypeQuantiles(0, 0), + "FinalState" -> new TypeQuantiles(0, 0), + "Region" -> new TypeQuantiles(0.0294117647058824, 0.0633258678611422), + "State" -> new TypeQuantiles(0.132023636740618, 0.175925925925926), +// "Statechart" -> new TypeQuantiles(0.00961538461538462, 0.010752688172043), + "Transition" -> new TypeQuantiles(0.581632653061224, 0.645161290322581) + } + } + + override getHints(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { + #[new SGraphHint(ecore2Logic, trace)] } } -class FileSystemLoader extends MetamodelLoader{ - +class FileSystemLoader extends MetamodelLoader { + new(ReasonerWorkspace workspace) { super(workspace) } - + override loadMetamodel() { val package = FilesystemPackage.eINSTANCE val List classes = package.EClassifiers.filter(EClass).toList val List enums = package.EClassifiers.filter(EEnum).toList val List literals = enums.map[ELiterals].flatten.toList - val List references = classes.map[EReferences].flatten.toList + val List references = classes.map[EReferences].flatten.filter[name != "live"].toList val List attributes = classes.map[EAttributes].flatten.toList - return new EcoreMetamodelDescriptor(classes,#{},false,enums,literals,references,attributes) + return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes) } - + override getRelevantTypes(EcoreMetamodelDescriptor descriptor) { return null } - + override getRelevantReferences(EcoreMetamodelDescriptor descriptor) { null } - + override loadQueries(EcoreMetamodelDescriptor metamodel) { val patternGroup = FileSystem.instance val patterns = patternGroup.specifications.toList val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet val derivedFeatures = new HashMap - derivedFeatures.put(patternGroup.live,metamodel.references.filter[it.name == "live"].head) +// derivedFeatures.put(patternGroup.live,metamodel.references.filter[it.name == "live"].head) return new ViatraQuerySetDescriptor( patterns, wfPatterns, @@ -206,41 +254,46 @@ class FileSystemLoader extends MetamodelLoader{ ) } - + override loadPartialModel() { - this.workspace.readModel(EObject,"fs.xmi").eResource.allContents.toList + this.workspace.readModel(EObject, "fs.xmi").eResource.allContents.toList } - + override additionalConstraints() { - #[[method | new FileSystemInconsistencyDetector(method)]] + #[[method|new FileSystemInconsistencyDetector(method)]] } - + } class EcoreLoader extends MetamodelLoader { - + new(ReasonerWorkspace workspace) { super(workspace) } - + override loadMetamodel() { val package = EcorePackage.eINSTANCE - val List classes = package.EClassifiers.filter(EClass).filter[it.name!="EFactory"].toList + val List classes = package.EClassifiers.filter(EClass).filter [ + it.name != "EFactory" && it.name != "EObject" && it.name != "EResource" + ].toList val List enums = package.EClassifiers.filter(EEnum).toList val List literals = enums.map[ELiterals].flatten.toList - val List references = classes.map[EReferences].flatten.filter[it.name!="eFactoryInstance"].filter[!it.derived].toList - val List attributes = #[] //classes.map[EAttributes].flatten.toList - return new EcoreMetamodelDescriptor(classes,#{},false,enums,literals,references,attributes) + val List references = classes.map[EReferences].flatten.filter [ + it.name != "eFactoryInstance" && it.name != "contents" && it.name != "references" && + it.name != "eGenericType" && it.name != "eGenericSuperTypes" + ].filter[!it.derived].toList + val List attributes = #[] // classes.map[EAttributes].flatten.toList + return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes) } - + override getRelevantTypes(EcoreMetamodelDescriptor descriptor) { return null } - + override getRelevantReferences(EcoreMetamodelDescriptor descriptor) { null } - + override loadQueries(EcoreMetamodelDescriptor metamodel) { val patternGroup = Ecore.instance val patterns = patternGroup.specifications.toList @@ -253,13 +306,92 @@ class EcoreLoader extends MetamodelLoader { ) } - + override loadPartialModel() { - this.workspace.readModel(EObject,"ecore.xmi").eResource.allContents.toList + this.workspace.readModel(EObject, "ecore.xmi").eResource.allContents.toList } - + override additionalConstraints() { #[] } + + override getTypeQuantiles() { + #{ + "EAnnotation" -> new TypeQuantiles(0, 0), + "EAttribute" -> new TypeQuantiles(0.14, 0.300943396226415), + "EClass" -> new TypeQuantiles(0.224014336917563, 0.372881355932203), + "EDataType" -> new TypeQuantiles(0, 0), + "EEnum" -> new TypeQuantiles(0, 0.0275208638045255), + "EEnumLiteral" -> new TypeQuantiles(0, 0.105204907665065), + "EGenericType" -> new TypeQuantiles(0, 0), + "EOperation" -> new TypeQuantiles(0, 0), + "EPackage" -> new TypeQuantiles(0.0119047619047619, 0.0192307692307692), + "EParameter" -> new TypeQuantiles(0, 0), + "EReference" -> new TypeQuantiles(0.217599234815878, 0.406779661016949), + "EStringToStringMapEntry" -> new TypeQuantiles(0, 0), + "ETypeParameter" -> new TypeQuantiles(0, 0) + } + } + +} + +class SatelliteLoader extends MetamodelLoader { + + new(ReasonerWorkspace workspace) { + super(workspace) + } + + override loadMetamodel() { + val package = SatellitePackage.eINSTANCE + val List classes = package.EClassifiers.filter(EClass).toList + val List enums = package.EClassifiers.filter(EEnum).toList + val List literals = enums.map[ELiterals].flatten.toList + val List references = classes.map[EReferences].flatten.toList + val List attributes = classes.map[EAttributes].flatten.toList + return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes) + } + + override getRelevantTypes(EcoreMetamodelDescriptor descriptor) { + null + } + + override getRelevantReferences(EcoreMetamodelDescriptor descriptor) { + null + } + + override loadQueries(EcoreMetamodelDescriptor metamodel) { + val i = SatelliteQueriesAll.instance + val patterns = i.specifications.toList + val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet + val derivedFeatures = new LinkedHashMap + val res = new ViatraQuerySetDescriptor( + patterns, + wfPatterns, + derivedFeatures + ) + return res + } + + override loadPartialModel() { + this.workspace.readModel(EObject, "satellite.xmi").eResource.allContents.toList + } + + override additionalConstraints() { #[] } + + override getHints(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { + #[new SatelliteHint(ecore2Logic, trace)] + } + + override getTypeQuantiles() { + #{ + "CubeSat3U" -> new TypeQuantiles(0.1, 0.25), + "CubeSat6U" -> new TypeQuantiles(0, 0.25), + "SmallSat" -> new TypeQuantiles(0, 0.15), + "UHFCommSubsystem" -> new TypeQuantiles(0.08, 0.25), + "XCommSubsystem" -> new TypeQuantiles(0.08, 0.25), + "KaCommSubsystem" -> new TypeQuantiles(0, 0.1), + "InterferometryPayload" -> new TypeQuantiles(0.15, 0.25) + } + } -} \ No newline at end of file +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphHint.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphHint.xtend new file mode 100644 index 00000000..97ce4ee6 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphHint.xtend @@ -0,0 +1,46 @@ +package hu.bme.mit.inf.dslreasoner.run + +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator + +class SGraphHint extends Ecore2LogicTraceBasedHint { + new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { + super(ecore2Logic, trace) + } + + override getAdditionalPatterns(extension PatternGenerator patternGenerator) { + "" + } + + override createConstraintUpdater(LinearTypeExpressionBuilderFactory it) { + val newEntriesWithoutRegionCount = createBuilder.add(1, "Entry".type).add(-1, "Region".type).build + val newStatesWithoutRegionCount = createBuilder.add(1, "State".type).add(-1, "Region".type).build + val newTransitionWithoutNeedsOutgoingCount = createBuilder.add(1, "Transition".type).add(-1, "Entry".type). + add(-1, "Choice".type).build + val newTransitionWithoutNeedsIncomingCount = createBuilder.add(1, "Transition".type).add(-1, "Choice".type). + build + + val regionsWithoutEntryMatcher = createMatcher( + "unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_noEntryInRegion") + val regionsWithoutStateMatcher = createMatcher( + "unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_noStateInRegion") + val entryHasNoOutgoingMatcher = createMatcher( + "unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_noOutgoingTransitionFromEntry") + val choiceHasNoOutgoingMatcher = createMatcher( + "unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_choiceHasNoOutgoing") + val choiceHasNoIncomingMatcher = createMatcher( + "unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_choiceHasNoIncoming") + val transitionWithoutTargetMatcher = createMatcher("unfinishedLowerMultiplicity_target_reference_Transition") + + return [ p | + newEntriesWithoutRegionCount.assertEqualsTo(regionsWithoutEntryMatcher.countMatches(p)) + newStatesWithoutRegionCount.tightenLowerBound(regionsWithoutStateMatcher.countMatches(p)) + newTransitionWithoutNeedsOutgoingCount.tightenLowerBound( + entryHasNoOutgoingMatcher.countMatches(p) + choiceHasNoOutgoingMatcher.countMatches(p)) + newTransitionWithoutNeedsIncomingCount.tightenLowerBound( + choiceHasNoIncomingMatcher.countMatches(p) - transitionWithoutTargetMatcher.getCount(p)) + ] + } +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend new file mode 100644 index 00000000..e95c0c64 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend @@ -0,0 +1,86 @@ +package hu.bme.mit.inf.dslreasoner.run + +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator + +class SatelliteHint extends Ecore2LogicTraceBasedHint { + static val INTERFEROMETY_PAYLOAD = "hint_interferometryPayload" + static val REMAINING_CONTENTS_KA_COMM_SUBSYSTEM = "hint_kaCommSubsystem" + static val HINT_SPACECRAFT_UHF_POSSIBLE_LINK = "hint_spacecraftWithUhfPossibleLink" + static val HINT_SPACECRAFT_UHF_ONLY_NO_LINK = "hint_spacecraftUhfOnlyNoLink" + + new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { + super(ecore2Logic, trace) + } + + override getAdditionalPatterns(PatternGenerator it) ''' + pattern «INTERFEROMETY_PAYLOAD»(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement) { + find interpretation(problem, interpretation); + find mustExist(problem, interpretation, object); + «typeIndexer.referInstanceOf("InterferometryPayload".type, Modality.MUST, "object")» + } + + private pattern «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»_helper(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement, remainingContents:java Integer) { + find remainingContents_commSubsystem_reference_CommunicatingElement_helper(problem, interpretation, object, remainingContents); + «typeIndexer.referInstanceOf("SmallSat".type, Modality.MUST, "object")» + } + + pattern «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»(problem:LogicProblem, interpretation:PartialInterpretation, remainingContents:java Integer) { + find interpretation(problem, interpretation); + remainingContents == sum find «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»_helper(problem, interpretation, _, #_); + } + + private pattern hint_spacecraftNotUhfOnly(problem:LogicProblem, interpretation:PartialInterpretation, spacecraft:DefinedElement) { + find interpretation(problem, interpretation); + find mustExist(problem, interpretation, spacecraft); + «typeIndexer.referInstanceOf("Spacecraft".type, Modality.MUST, "spacecraft")» + «relationDeclarationIndexer.referRelation("CommunicatingElement".relation("commSubsystem"), "spacecraft", "comm", Modality.MAY)» + neg «typeIndexer.referInstanceOf("UHFCommSubsystem".type, Modality.MUST, "comm")» + } + + private pattern hint_spacecraftWithUhf(problem:LogicProblem, interpretation:PartialInterpretation, spacecraft:DefinedElement) { + find interpretation(problem, interpretation); + find mustExist(problem, interpretation, spacecraft); + «typeIndexer.referInstanceOf("Spacecraft".type, Modality.MUST, "spacecraft")» + «relationDeclarationIndexer.referRelation("CommunicatingElement".relation("commSubsystem"), "spacecraft", "comm", Modality.MUST)» + «typeIndexer.referInstanceOf("UHFCommSubsystem".type, Modality.MUST, "comm")» + } + + pattern «HINT_SPACECRAFT_UHF_POSSIBLE_LINK»(problem:LogicProblem, interpretation:PartialInterpretation) { + find hint_spacecraftWithUhf(problem, interpretation, spacecraft); + find hint_spacecraftNotUhfOnly(problem, interpretation, spacecraft); + } + + pattern «HINT_SPACECRAFT_UHF_ONLY_NO_LINK»(problem:LogicProblem, interpretation:PartialInterpretation) { + find interpretation(problem, interpretation); + find mustExist(problem, interpretation, spacecraft); + «typeIndexer.referInstanceOf("Spacecraft".type, Modality.MUST, "spacecraft")» + neg find hint_spacecraftNotUhfOnly(problem, interpretation, spacecraft); + find currentInRelation_pattern_hu_bme_mit_inf_dslreasoner_domains_satellite_queries_noLinkToGroundStation(problem, interpretation, spacecraft); + } + ''' + + override createConstraintUpdater(LinearTypeExpressionBuilderFactory it) { + val interferometryPayloadCount = createBuilder.add(1, "InterferometryPayload".type).build + val kaCommSubsystemWithoutSmallSatCount = createBuilder.add(1, "KaCommSubsystem".type).add(-2, "SmallSat".type). + build + val uhfCommSubsystemCount = createBuilder.add(1, "UHFCommSubsystem".type).build + + val interferometryPayloadMatcher = createMatcher(INTERFEROMETY_PAYLOAD) + val kaCommSubsystemRemainingContentsMatcher = createMatcher(REMAINING_CONTENTS_KA_COMM_SUBSYSTEM) + val uhfPossibleLinkMatcher = createMatcher(HINT_SPACECRAFT_UHF_POSSIBLE_LINK) + val uhfNoLinkMatcher = createMatcher(HINT_SPACECRAFT_UHF_ONLY_NO_LINK) + + return [ p | + interferometryPayloadCount.tightenLowerBound(2 - interferometryPayloadMatcher.countMatches(p)) + kaCommSubsystemWithoutSmallSatCount.tightenUpperBound(kaCommSubsystemRemainingContentsMatcher.getCount(p)) + if (uhfPossibleLinkMatcher.countMatches(p) == 0 && uhfNoLinkMatcher.countMatches(p) >= 1) { + uhfCommSubsystemCount.tightenLowerBound(1) + } + ] + } + +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend new file mode 100644 index 00000000..e2d6e6ca --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend @@ -0,0 +1,35 @@ +package hu.bme.mit.inf.dslreasoner.run + +import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage +import java.io.File +import org.eclipse.emf.common.util.URI +import org.eclipse.emf.ecore.EPackage +import org.eclipse.emf.ecore.EcorePackage +import org.eclipse.emf.ecore.resource.Resource +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl + +class TypeDistributionCalculator { + public static def void main(String[] args) { + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl) + EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE) + EPackage.Registry.INSTANCE.put(YakindummPackage.eNS_URI, YakindummPackage.eINSTANCE) + + println("model,className,count") + val directory = new File(args.get(0)) + for (file : directory.listFiles) { + val modelName = file.name + val resourceSet = new ResourceSetImpl + val resource = resourceSet.getResource(URI.createFileURI(file.absolutePath), true) + val objectsByTypeName = resource.allContents.filter [ obj | + val featureName = obj.eContainingFeature?.name + // Filter out "derived containment" references in Ecore. + // See https://stackoverflow.com/a/46340165 + featureName != "eGenericType" && featureName != "eGenericSuperTypes" + ].groupBy[eClass.name] + for (pair : objectsByTypeName.entrySet) { + println('''«modelName»,«pair.key»,«pair.value.size»''') + } + } + } +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend new file mode 100644 index 00000000..5abff962 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend @@ -0,0 +1,70 @@ +package hu.bme.mit.inf.dslreasoner.run.script + +import java.util.List +import org.eclipse.xtend.lib.annotations.Accessors + +@Accessors +class MeasurementScript { + String inputPath + String outputPath + int timeout + boolean saveModels + boolean saveTemporaryFiles + int warmupIterations + int iterations + Domain domain + Scope scope + List sizes + Solver solver + ScopePropagator scopePropagator + ScopeConstraints propagatedConstraints + PolyhedronSolver polyhedronSolver + ScopeHeuristic scopeHeuristic + + def toCsvHeader() { + '''«domain»,«scope»,«solver»,«scopePropagator ?: "NULL"»,«propagatedConstraints ?: "NULL"»,«polyhedronSolver ?: "NULL"»''' + } +} + +enum Domain { + fs, + ecore, + Yakindu, + FAM, + satellite +} + +enum Scope { + none, + quantiles +} + +enum Solver { + ViatraSolver, + AlloySolver +} + +enum ScopePropagator { + none, + basic, + polyhedral +} + +enum ScopeConstraints { + none, + typeHierarchy, + relations, + hints +} + +enum PolyhedronSolver { + Z3Integer, + Z3Real, + Cbc, + Clp +} + +enum ScopeHeuristic { + basic, + polyhedral +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend new file mode 100644 index 00000000..48e750cb --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend @@ -0,0 +1,351 @@ +package hu.bme.mit.inf.dslreasoner.run.script + +import com.google.gson.Gson +import hu.bme.mit.inf.dslreasoner.ecore2logic.EClassMapper +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace +import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel +import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntLiteral +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealLiteral +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.StringLiteral +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition +import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem +import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.IntStatisticEntry +import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicresultFactory +import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult +import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.RealStatisticEntry +import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.Statistics +import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.StringStatisticEntry +import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore +import hu.bme.mit.inf.dslreasoner.run.EcoreLoader +import hu.bme.mit.inf.dslreasoner.run.FAMLoader +import hu.bme.mit.inf.dslreasoner.run.FileSystemLoader +import hu.bme.mit.inf.dslreasoner.run.MetamodelLoader +import hu.bme.mit.inf.dslreasoner.run.SatelliteLoader +import hu.bme.mit.inf.dslreasoner.run.YakinduLoader +import hu.bme.mit.inf.dslreasoner.util.CollectionsUtil +import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic +import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partial2logicannotations.PartialModelRelation2Assertion +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration +import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace +import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace +import java.io.FileReader +import java.util.HashMap +import java.util.HashSet +import java.util.Map +import java.util.Set +import org.eclipse.emf.ecore.EObject +import org.eclipse.emf.ecore.resource.Resource +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl +import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions +import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory +import org.eclipse.xtend.lib.annotations.Data + +class MeasurementScriptRunner { + static val MODEL_SIZE_GAP = 0 + static val SCOPE_PROPAGATOR_TIMEOUT = 10 + static val USEC_TO_MSEC = 1000000 + + static extension val LogicresultFactory = LogicresultFactory.eINSTANCE + + val MeasurementScript script + val ReasonerWorkspace inputWorkspace + val ReasonerWorkspace outputWorkspace + val MetamodelLoader metamodelLoader + + new(MeasurementScript script) { + this.script = script + inputWorkspace = new FileSystemWorkspace(script.inputPath + "/", "") + outputWorkspace = new FileSystemWorkspace(script.outputPath + + "/", '''«script.domain»_«script.solver»_«script.scope»_«script.scopePropagator ?: "na"»_«script.propagatedConstraints ?: "na"»_«script.polyhedronSolver ?: "na"»_''') + metamodelLoader = switch (script.domain) { + case fs: new FileSystemLoader(inputWorkspace) + case ecore: new EcoreLoader(inputWorkspace) + case Yakindu: new YakinduLoader(inputWorkspace) => [useSynchronization = false; useComplexStates = true] + case FAM: new FAMLoader(inputWorkspace) + case satellite: new SatelliteLoader(inputWorkspace) + default: throw new IllegalArgumentException("Unsupported domain: " + script.domain) + } + } + + def run() { + if (script.sizes.empty) { + return + } + val start = System.currentTimeMillis + val warmupSize = script.sizes.head + for (var int i = 0; i < script.warmupIterations; i++) { + System.err.println('''Warmup «i + 1»/«script.warmupIterations»...''') + runExperiment(warmupSize) + } + val warmupEnd = System.currentTimeMillis + System.err.println('''Warmup completed in «(warmupEnd - start) / 1000» seconds''') + for (size : script.sizes) { + var int failures = 0 + for (var int i = 0; i < script.iterations; i++) { + System.err.println("Running GC...") + runGc() + System.err.println('''Iteration «i + 1»/«script.iterations» of size «size»...''') + val startTime = System.currentTimeMillis + val result = runExperiment(size) + val headerPrefix = '''«script.toCsvHeader»,«size»,«i + 1»,«result.resultName»''' + println('''«headerPrefix»,startTime,«startTime»''') + println('''«headerPrefix»,logic2SolverTransformationTime,«result.statistics.transformationTime»''') + println('''«headerPrefix»,solverTime,«result.statistics.solverTime»''') + for (statistic : result.statistics.entries) { + val valueString = switch (statistic) { + IntStatisticEntry: statistic.value.toString + RealStatisticEntry: statistic.value.toString + StringStatisticEntry: statistic.value.toString + default: statistic.toString + } + println('''«headerPrefix»,«statistic.name»,«valueString»''') + } + if (script.saveModels && result.model !== null) { + outputWorkspace.writeModel(result.model, '''«size»_«i + 1».xmi''') + } + if (result.resultName === "InsuficientResourcesResultImpl") { + failures++ + } + System.out.flush + } + if (failures == script.iterations) { + System.err.println("All measurements failed") + return + } + } + val end = System.currentTimeMillis + System.err.println('''Measurement completed in «(end - start) / 1000» seconds''') + } + + private static def void runGc() { + System.gc + Thread.sleep(100) + System.gc + Thread.sleep(100) + System.gc + Thread.sleep(800) + } + + private def runExperiment(int modelSize) { + if (script.solver != Solver.ViatraSolver) { + throw new IllegalArgumentException("Only VIATRA-Generator is supported") + } + val config = new ViatraReasonerConfiguration + config.solutionScope.numberOfRequiredSolutions = 1 + config.scopePropagatorStrategy = switch (script.scopePropagator) { + case none: + ScopePropagatorStrategy.None + case basic: + switch (script.propagatedConstraints) { + case none: + ScopePropagatorStrategy.Basic + case typeHierarchy: + ScopePropagatorStrategy.BasicTypeHierarchy + case relations, + case hints: + throw new IllegalArgumentException( + "Basic scope propagator does not support relational and hint constraints") + default: + throw new IllegalArgumentException("Unknown scope constraints: " + script.propagatedConstraints) + } + case polyhedral: { + val constraints = switch (script.propagatedConstraints) { + case none: + throw new IllegalArgumentException( + "Polyhedral scope propagator needs at least type hierarchy constraints") + case typeHierarchy: + PolyhedralScopePropagatorConstraints.TypeHierarchy + case relations, + case hints: + PolyhedralScopePropagatorConstraints.Relational + default: + throw new IllegalArgumentException("Unknown scope constraints: " + script.propagatedConstraints) + } + val polyhedronSolver = switch (script.polyhedronSolver) { + case Z3Integer: PolyhedralScopePropagatorSolver.Z3Integer + case Z3Real: PolyhedralScopePropagatorSolver.Z3Real + case Cbc: PolyhedralScopePropagatorSolver.Cbc + case Clp: PolyhedralScopePropagatorSolver.Clp + default: throw new IllegalArgumentException("Unknown polyhedron solver: " + script.polyhedronSolver) + } + val updateHeuristic = script.scopeHeuristic != ScopeHeuristic.basic + new ScopePropagatorStrategy.Polyhedral(constraints, polyhedronSolver, updateHeuristic, + SCOPE_PROPAGATOR_TIMEOUT) + } + default: + throw new IllegalArgumentException("Unknown scope propagator: " + script.scopePropagator) + } + config.runtimeLimit = script.timeout + config.documentationLevel = if(script.saveTemporaryFiles) DocumentationLevel.NORMAL else DocumentationLevel.NONE + config.debugConfiguration.partialInterpretatioVisualiser = null + config.searchSpaceConstraints.additionalGlobalConstraints += metamodelLoader.additionalConstraints + + val modelLoadingStart = System.nanoTime + val metamodelDescriptor = metamodelLoader.loadMetamodel + val partialModelDescriptor = metamodelLoader.loadPartialModel + val queryDescriptor = metamodelLoader.loadQueries(metamodelDescriptor) + val modelLoadingTime = System.nanoTime - modelLoadingStart + + val domain2LogicTransformationStart = System.nanoTime + val Ecore2Logic ecore2Logic = new Ecore2Logic + val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) + val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic + var modelGeneration = ecore2Logic.transformMetamodel(metamodelDescriptor, new Ecore2LogicConfiguration()) + var problem = modelGeneration.output + problem = instanceModel2Logic.transform( + modelGeneration, + partialModelDescriptor + ).output + problem = viatra2Logic.transformQueries( + queryDescriptor, + modelGeneration, + new Viatra2LogicConfiguration + ).output + initializeScope(config, modelSize, problem, ecore2Logic, modelGeneration.trace) + if (script.propagatedConstraints == ScopeConstraints.hints) { + config.hints = metamodelLoader.getHints(ecore2Logic, modelGeneration.trace) + } + val domain2LogicTransformationTime = System.nanoTime - domain2LogicTransformationStart + + if (config.documentationLevel != DocumentationLevel.NONE) { + outputWorkspace.writeModel(problem, "initial.logicproblem") + } + + val solver = new ViatraReasoner + val result = solver.solve(problem, config, outputWorkspace) + val statistics = result.statistics + statistics.entries += createIntStatisticEntry => [ + name = "modelLoadingTime" + value = (modelLoadingTime / USEC_TO_MSEC) as int + ] + statistics.entries += createIntStatisticEntry => [ + name = "domain2LogicTransformationTime" + value = (domain2LogicTransformationTime / USEC_TO_MSEC) as int + ] + var EObject modelResult = null + if (result instanceof ModelResult) { + val intepretations = solver.getInterpretations(result) + if (intepretations.size != 1) { + throw new IllegalStateException("Expected 1 interpretation, got " + intepretations.size) + } + var resultTransformationStart = System.nanoTime + val logic2Ecore = new Logic2Ecore(ecore2Logic) + modelResult = logic2Ecore.transformInterpretation(intepretations.head, modelGeneration.trace) + val resultTransformationTime = System.nanoTime - resultTransformationStart + statistics.entries += createIntStatisticEntry => [ + name = "ecore2LogicTransformationTime" + value = (resultTransformationTime / USEC_TO_MSEC) as int + ] + } + + new ExperimentResult(result.class.simpleName, statistics, modelResult) + } + + private def initializeScope(ViatraReasonerConfiguration config, int modelSize, LogicProblem problem, + EClassMapper eClassMapper, Ecore2Logic_Trace trace) { + val knownElements = initializeKnownElements(problem, config.typeScopes) + if (modelSize < 0) { + config.typeScopes.minNewElements = 0 + config.typeScopes.maxNewElements = TypeScopes.Unlimited + } else { + val numberOfKnownElements = knownElements.values.flatten.toSet.size + val newElementCount = modelSize - numberOfKnownElements + config.typeScopes.minNewElements = newElementCount + config.typeScopes.maxNewElements = newElementCount + MODEL_SIZE_GAP + } + switch (script.scope) { + case none: + return + case quantiles: { + val quantiles = metamodelLoader.typeQuantiles + for (eClassInScope : eClassMapper.allClassesInScope(trace)) { + val quantile = quantiles.get(eClassInScope.name) + if (quantile !== null) { + val type = eClassMapper.TypeofEClass(trace, eClassInScope) + val knownInstances = knownElements.get(type) + val currentCount = if(knownInstances === null) 0 else knownInstances.size + val lowCount = Math.floor(modelSize * quantile.low) as int + val highCount = Math.ceil((modelSize + MODEL_SIZE_GAP) * quantile.high) as int + config.typeScopes.minNewElementsByType.put(type, lowCount - currentCount) + config.typeScopes.maxNewElementsByType.put(type, highCount - currentCount) + } + } + } + default: + throw new IllegalArgumentException("Unknown scope: " + script.scope) + } + } + + /* + * Copied from hu.bme.mit.inf.dslreasoner.application.execution.ScopeLoader.initialiseknownElements(LogicProblem, TypeScopes) + */ + private static def initializeKnownElements(LogicProblem p, TypeScopes s) { + val Map> res = new HashMap + + // 1. fill map with every types + for (t : p.types) { + res.put(t, new HashSet) + } + + // 2. fill map with every objects + for (definedType : p.types.filter(TypeDefinition)) { + val supertypes = CollectionsUtil.transitiveClosureStar(definedType)[supertypes] + for (supertype : supertypes) { + for (element : definedType.elements) { + res.get(supertype).add(element) + } + } + } + val partialModelContents = p.annotations.filter(PartialModelRelation2Assertion).map[target].toList.map [ + eAllContents.toIterable + ].flatten.toList + s.knownIntegers += partialModelContents.filter(IntLiteral).map[it.value] + s.knownReals += partialModelContents.filter(RealLiteral).map[it.value] + s.knownStrings += partialModelContents.filter(StringLiteral).map[it.value] + + res + } + + public static def void main(String[] args) { + if (args.length != 1) { + System.err.println("Missing measurement script name.") + System.exit(-1) + } + EMFPatternLanguageStandaloneSetup.doSetup + ViatraQueryEngineOptions.setSystemDefaultBackends(ReteBackendFactory.INSTANCE, ReteBackendFactory.INSTANCE, + ReteBackendFactory.INSTANCE) + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl) + val config = readConfig(args.get(0)) + val runnner = new MeasurementScriptRunner(config) + runnner.run() + } + + static def readConfig(String scriptPath) { + val gson = new Gson + val reader = new FileReader(scriptPath) + try { + gson.fromJson(reader, MeasurementScript) + } finally { + reader.close + } + } + + @Data + private static class ExperimentResult { + String resultName + Statistics statistics + EObject model + } +} -- cgit v1.2.3-54-g00ecf From 6dca5681757fef7d65ffa051ff59ba8332c74a83 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Tue, 29 Oct 2019 17:33:15 +0100 Subject: Polyhedron solver SAT fix and initial scope filtering --- .../cardinality/CbcPolyhedronSolver.xtend | 6 +++++- .../cardinality/RelationConstraintCalculator.xtend | 2 ++ .../InstanceModel2PartialInterpretation.xtend | 23 +++++++++++++++++----- 3 files changed, 25 insertions(+), 6 deletions(-) (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme') diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/CbcPolyhedronSolver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/CbcPolyhedronSolver.xtend index 75c396b4..708f93dc 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/CbcPolyhedronSolver.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/CbcPolyhedronSolver.xtend @@ -193,7 +193,11 @@ class CbcSaturationOperator extends AbstractPolyhedronSaturationOperator { setBound(expressionToSaturate, constraints, Double.POSITIVE_INFINITY, columnUpperBounds, rowUpperBounds) } case CbcResult.UNSAT: - throw new RuntimeException("Minimization was SAT, but maximization is UNSAT") + if (lpRelaxation) { + return PolyhedronSaturationResult.EMPTY + } else { + throw new RuntimeException("Minimization was SAT, but maximization is UNSAT") + } case CbcResult.ABANDONED, case CbcResult.TIMEOUT: return PolyhedronSaturationResult.UNKNOWN diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend index c92260ea..3e4fea8a 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend @@ -44,6 +44,8 @@ class RelationMultiplicityConstraint { } def constrainsUnrepairable() { + // TODO Optimize the unrepairable matches computation, + // or come up with a heuristic when does computing unrepairables worth the overhead. constrainsUnfinished && canHaveMultipleSourcesPerTarget && false } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend index 8aaaacb5..cb5b587f 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend @@ -1,5 +1,6 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic +import com.google.common.collect.ImmutableList import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput @@ -12,18 +13,18 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.Par import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.Problem2PartialInterpretationTrace import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationFactory +import java.math.BigDecimal import java.util.HashMap +import java.util.HashSet import java.util.List import java.util.Map +import java.util.Set import org.eclipse.emf.common.util.Enumerator +import org.eclipse.emf.ecore.EAttribute import org.eclipse.emf.ecore.EObject import org.eclipse.emf.ecore.resource.Resource import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* -import java.util.HashSet -import java.util.Set -import java.math.BigDecimal -import org.eclipse.emf.ecore.EAttribute class InstanceModel2PartialInterpretation { val extension LogiclanguageFactory factory = LogiclanguageFactory.eINSTANCE @@ -36,7 +37,19 @@ class InstanceModel2PartialInterpretation { Resource resource, boolean withID) { - val objects = resource.allContents.toList + val objectsBuilder = ImmutableList.builder + val treeIterator = resource.allContents + val referencesUsed = ecore2Logic.allReferencesInScope(metamodelTranslationResult.trace).toSet + while (treeIterator.hasNext) { + val object = treeIterator.next + val containingReference = object.eContainmentFeature + if (containingReference === null || referencesUsed.contains(containingReference)) { + objectsBuilder.add(object) + } else { + treeIterator.prune + } + } + val objects = objectsBuilder.build return transform(metamodelTranslationResult,objects,withID) } -- cgit v1.2.3-54-g00ecf From 6a3ff9bb588bf47242a56b91e35479dbba38eb19 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Thu, 7 May 2020 17:26:07 +0200 Subject: Scope unsat benchmarks --- .../.ApplicationConfigurationIdeModule.xtendbin | Bin 1701 -> 1701 bytes .../ide/.ApplicationConfigurationIdeSetup.xtendbin | Bin 2570 -> 2526 bytes .../Examples/ModelGenExampleFAM_plugin/.project | 6 + .../Examples/ModelGenExampleFAM_plugin/plugin.xml | 18 +- .../dslreasoner/domains/alloyexamples/Ecore.vql | 10 + .../plugin.xml | 2 + .../dslreasoner/domains/alloyexamples/.gitignore | 5 + .../alloyexamples/Unsat_loopInInheritance.java | 566 +++++++++++++++++ .../domains/alloyexamples/Unsat_subpackage.java | 704 +++++++++++++++++++++ .../domains/alloyexamples/internal/.gitignore | 4 + .../plugin.xml | 12 +- .../domains/satellite/queries/SatelliteQueries.vql | 13 + .../plugin.xml | 1 + .../partialsnapshot_mavo/yakindu/patterns.vql | 11 + .../.classpath | 26 +- .../META-INF/MANIFEST.MF | 7 +- .../NeighbourhoodBasedStateCoderFactory.xtend | 9 +- .../reasoner/ViatraReasonerConfiguration.xtend | 2 +- ..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 16 - .../configs/Yakindu.json | 13 + ..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 17 - .../configs/ecore.json | 17 + ..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 16 - ..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 16 - .../configs/satellite.json | 17 + ..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 17 - .../mit/inf/dslreasoner/run/MetamodelLoader.xtend | 63 +- .../dslreasoner/run/script/MeasurementScript.xtend | 13 +- .../run/script/MeasurementScriptRunner.xtend | 46 +- 29 files changed, 1511 insertions(+), 136 deletions(-) create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_loopInInheritance.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_subpackage.java create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/internal/.gitignore delete mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/FAM_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu.json delete mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore.json delete mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json delete mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/fs_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite.json delete mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme') diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin index 83195553..c8086733 100644 Binary files a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin and b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin differ diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin index f5085470..1a907776 100644 Binary files a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin and b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin differ diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/.project b/Domains/Examples/ModelGenExampleFAM_plugin/.project index 6e1b3a06..570f8a60 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/.project +++ b/Domains/Examples/ModelGenExampleFAM_plugin/.project @@ -5,6 +5,11 @@ + + org.eclipse.xtext.ui.shared.xtextBuilder + + + org.eclipse.viatra.query.tooling.ui.projectbuilder @@ -30,5 +35,6 @@ org.eclipse.jdt.core.javanature org.eclipse.viatra.query.projectnature org.eclipse.pde.PluginNature + org.eclipse.xtext.ui.shared.xtextNature diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/plugin.xml b/Domains/Examples/ModelGenExampleFAM_plugin/plugin.xml index c117a28e..8d99d401 100644 --- a/Domains/Examples/ModelGenExampleFAM_plugin/plugin.xml +++ b/Domains/Examples/ModelGenExampleFAM_plugin/plugin.xml @@ -5,23 +5,13 @@ - - - - + + + + - - - - - - - diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql index 78525a35..16c24d05 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql @@ -11,6 +11,16 @@ pattern loopInInheritence(a: EClass) { find directSupertype+(a,a); } +pattern unsat_subpackage(a: EPackage, b: EPackage) { + EPackage.eSubpackages(a, b); +} + +@Constraint(key={p}, severity="error", message="error") +pattern unsat_loopInInheritance(p: EPackage) { + neg find unsat_subpackage(_, p); + neg find loopInInheritence(_); +} + pattern opposite(a:EReference, b: EReference) { EReference.eOpposite(a,b); } diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/plugin.xml index 6eae8535..eddd482c 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/plugin.xml +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/plugin.xml @@ -11,6 +11,8 @@ + + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/.gitignore index 0f8c77a1..70eab455 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/.gitignore +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/.gitignore @@ -54,3 +54,8 @@ /.RootIsNotDir.java._trace /Dir.java /RootIsNotDir.java +/.Unsat_loopInInheritance.java._trace +/.Subpackage.java._trace +/.Unsat_subpackage.java._trace +/.Unsat_subpackageOrSelf.java._trace +/.Unsat_topLevelPackageWithLoop.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_loopInInheritance.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_loopInInheritance.java new file mode 100644 index 00000000..83bd0f66 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_loopInInheritance.java @@ -0,0 +1,566 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; + +import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.LoopInInheritence; +import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Unsat_subpackage; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; +import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

    Original source: + *

    + *         {@literal @}Constraint(key={p}, severity="error", message="error")
    + *         pattern unsat_loopInInheritance(p: EPackage) {
    + *         	neg find unsat_subpackage(_, p);
    + *         	neg find loopInInheritence(_);
    + *         }
    + * 
    + * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class Unsat_loopInInheritance extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_loopInInheritance pattern, + * to be used in conjunction with {@link Matcher}. + * + *

    Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private EPackage fP; + + private static List parameterNames = makeImmutableList("p"); + + private Match(final EPackage pP) { + this.fP = pP; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "p": return this.fP; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fP; + default: return null; + } + } + + public EPackage getP() { + return this.fP; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("p".equals(parameterName) ) { + this.fP = (EPackage) newValue; + return true; + } + return false; + } + + public void setP(final EPackage pP) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fP = pP; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_loopInInheritance"; + } + + @Override + public List parameterNames() { + return Unsat_loopInInheritance.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fP}; + } + + @Override + public Unsat_loopInInheritance.Match toImmutable() { + return isMutable() ? newMatch(fP) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"p\"=" + prettyPrintValue(fP)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fP); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof Unsat_loopInInheritance.Match)) { + Unsat_loopInInheritance.Match other = (Unsat_loopInInheritance.Match) obj; + return Objects.equals(fP, other.fP); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public Unsat_loopInInheritance specification() { + return Unsat_loopInInheritance.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static Unsat_loopInInheritance.Match newEmptyMatch() { + return new Mutable(null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pP the fixed value of pattern parameter p, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static Unsat_loopInInheritance.Match newMutableMatch(final EPackage pP) { + return new Mutable(pP); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

    The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pP the fixed value of pattern parameter p, or null if not bound. + * @return the (partial) match object. + * + */ + public static Unsat_loopInInheritance.Match newMatch(final EPackage pP) { + return new Immutable(pP); + } + + private static final class Mutable extends Unsat_loopInInheritance.Match { + Mutable(final EPackage pP) { + super(pP); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends Unsat_loopInInheritance.Match { + Immutable(final EPackage pP) { + super(pP); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_loopInInheritance pattern, + * providing pattern-specific query methods. + * + *

    Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

    Matches of the pattern will be represented as {@link Match}. + * + *

    Original source: + *

    +   * {@literal @}Constraint(key={p}, severity="error", message="error")
    +   * pattern unsat_loopInInheritance(p: EPackage) {
    +   * 	neg find unsat_subpackage(_, p);
    +   * 	neg find loopInInheritence(_);
    +   * }
    +   * 
    + * + * @see Match + * @see Unsat_loopInInheritance + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static Unsat_loopInInheritance.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static Unsat_loopInInheritance.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_P = 0; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Unsat_loopInInheritance.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pP the fixed value of pattern parameter p, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final EPackage pP) { + return rawStreamAllMatches(new Object[]{pP}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

    + * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pP the fixed value of pattern parameter p, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final EPackage pP) { + return rawStreamAllMatches(new Object[]{pP}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pP the fixed value of pattern parameter p, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final EPackage pP) { + return rawGetOneArbitraryMatch(new Object[]{pP}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pP the fixed value of pattern parameter p, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final EPackage pP) { + return rawHasMatch(new Object[]{pP}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pP the fixed value of pattern parameter p, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final EPackage pP) { + return rawCountMatches(new Object[]{pP}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pP the fixed value of pattern parameter p, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final EPackage pP, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pP}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

    The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pP the fixed value of pattern parameter p, or null if not bound. + * @return the (partial) match object. + * + */ + public Unsat_loopInInheritance.Match newMatch(final EPackage pP) { + return Unsat_loopInInheritance.Match.newMatch(pP); + } + + /** + * Retrieve the set of values that occur in matches for p. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfp(final Object[] parameters) { + return rawStreamAllValues(POSITION_P, parameters).map(EPackage.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for p. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfp() { + return rawStreamAllValuesOfp(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for p. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfp() { + return rawStreamAllValuesOfp(emptyArray()); + } + + @Override + protected Unsat_loopInInheritance.Match tupleToMatch(final Tuple t) { + try { + return Unsat_loopInInheritance.Match.newMatch((EPackage) t.get(POSITION_P)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected Unsat_loopInInheritance.Match arrayToMatch(final Object[] match) { + try { + return Unsat_loopInInheritance.Match.newMatch((EPackage) match[POSITION_P]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected Unsat_loopInInheritance.Match arrayToMatchMutable(final Object[] match) { + try { + return Unsat_loopInInheritance.Match.newMutableMatch((EPackage) match[POSITION_P]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return Unsat_loopInInheritance.instance(); + } + } + + private Unsat_loopInInheritance() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static Unsat_loopInInheritance instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected Unsat_loopInInheritance.Matcher instantiate(final ViatraQueryEngine engine) { + return Unsat_loopInInheritance.Matcher.on(engine); + } + + @Override + public Unsat_loopInInheritance.Matcher instantiate() { + return Unsat_loopInInheritance.Matcher.create(); + } + + @Override + public Unsat_loopInInheritance.Match newEmptyMatch() { + return Unsat_loopInInheritance.Match.newEmptyMatch(); + } + + @Override + public Unsat_loopInInheritance.Match newMatch(final Object... parameters) { + return Unsat_loopInInheritance.Match.newMatch((org.eclipse.emf.ecore.EPackage) parameters[0]); + } + + /** + * Inner class allowing the singleton instance of {@link Unsat_loopInInheritance} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link Unsat_loopInInheritance#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final Unsat_loopInInheritance INSTANCE = new Unsat_loopInInheritance(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final Unsat_loopInInheritance.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_p = new PParameter("p", "org.eclipse.emf.ecore.EPackage", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EPackage")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_p); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_loopInInheritance"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("p"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_p = body.getOrCreateVariableByName("p"); + PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); + PVariable var___1_ = body.getOrCreateVariableByName("_<1>"); + new TypeConstraint(body, Tuples.flatTupleOf(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_p, parameter_p) + )); + // neg find unsat_subpackage(_, p) + new NegativePatternCall(body, Tuples.flatTupleOf(var___0_, var_p), Unsat_subpackage.instance().getInternalQueryRepresentation()); + // neg find loopInInheritence(_) + new NegativePatternCall(body, Tuples.flatTupleOf(var___1_), LoopInInheritence.instance().getInternalQueryRepresentation()); + bodies.add(body); + } + { + PAnnotation annotation = new PAnnotation("Constraint"); + annotation.addAttribute("key", Arrays.asList(new Object[] { + new ParameterReference("p") + })); + annotation.addAttribute("severity", "error"); + annotation.addAttribute("message", "error"); + addAnnotation(annotation); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_subpackage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_subpackage.java new file mode 100644 index 00000000..a9c8aed8 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Unsat_subpackage.java @@ -0,0 +1,704 @@ +/** + * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/patterns/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/Ecore.vql + */ +package hu.bme.mit.inf.dslreasoner.domains.alloyexamples; + +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.viatra.query.runtime.api.IQuerySpecification; +import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; +import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; +import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; +import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; +import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; +import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; +import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; +import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; +import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; +import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; +import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; +import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; + +/** + * A pattern-specific query specification that can instantiate Matcher in a type-safe way. + * + *

    Original source: + *

    + *         pattern unsat_subpackage(a: EPackage, b: EPackage) {
    + *         	EPackage.eSubpackages(a, b);
    + *         }
    + * 
    + * + * @see Matcher + * @see Match + * + */ +@SuppressWarnings("all") +public final class Unsat_subpackage extends BaseGeneratedEMFQuerySpecification { + /** + * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_subpackage pattern, + * to be used in conjunction with {@link Matcher}. + * + *

    Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. + * Each instance is a (possibly partial) substitution of pattern parameters, + * usable to represent a match of the pattern in the result of a query, + * or to specify the bound (fixed) input parameters when issuing a query. + * + * @see Matcher + * + */ + public static abstract class Match extends BasePatternMatch { + private EPackage fA; + + private EPackage fB; + + private static List parameterNames = makeImmutableList("a", "b"); + + private Match(final EPackage pA, final EPackage pB) { + this.fA = pA; + this.fB = pB; + } + + @Override + public Object get(final String parameterName) { + switch(parameterName) { + case "a": return this.fA; + case "b": return this.fB; + default: return null; + } + } + + @Override + public Object get(final int index) { + switch(index) { + case 0: return this.fA; + case 1: return this.fB; + default: return null; + } + } + + public EPackage getA() { + return this.fA; + } + + public EPackage getB() { + return this.fB; + } + + @Override + public boolean set(final String parameterName, final Object newValue) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + if ("a".equals(parameterName) ) { + this.fA = (EPackage) newValue; + return true; + } + if ("b".equals(parameterName) ) { + this.fB = (EPackage) newValue; + return true; + } + return false; + } + + public void setA(final EPackage pA) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fA = pA; + } + + public void setB(final EPackage pB) { + if (!isMutable()) throw new java.lang.UnsupportedOperationException(); + this.fB = pB; + } + + @Override + public String patternName() { + return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_subpackage"; + } + + @Override + public List parameterNames() { + return Unsat_subpackage.Match.parameterNames; + } + + @Override + public Object[] toArray() { + return new Object[]{fA, fB}; + } + + @Override + public Unsat_subpackage.Match toImmutable() { + return isMutable() ? newMatch(fA, fB) : this; + } + + @Override + public String prettyPrint() { + StringBuilder result = new StringBuilder(); + result.append("\"a\"=" + prettyPrintValue(fA) + ", "); + result.append("\"b\"=" + prettyPrintValue(fB)); + return result.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(fA, fB); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) { + return false; + } + if ((obj instanceof Unsat_subpackage.Match)) { + Unsat_subpackage.Match other = (Unsat_subpackage.Match) obj; + return Objects.equals(fA, other.fA) && Objects.equals(fB, other.fB); + } else { + // this should be infrequent + if (!(obj instanceof IPatternMatch)) { + return false; + } + IPatternMatch otherSig = (IPatternMatch) obj; + return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); + } + } + + @Override + public Unsat_subpackage specification() { + return Unsat_subpackage.instance(); + } + + /** + * Returns an empty, mutable match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @return the empty match. + * + */ + public static Unsat_subpackage.Match newEmptyMatch() { + return new Mutable(null, null); + } + + /** + * Returns a mutable (partial) match. + * Fields of the mutable match can be filled to create a partial match, usable as matcher input. + * + * @param pA the fixed value of pattern parameter a, or null if not bound. + * @param pB the fixed value of pattern parameter b, or null if not bound. + * @return the new, mutable (partial) match object. + * + */ + public static Unsat_subpackage.Match newMutableMatch(final EPackage pA, final EPackage pB) { + return new Mutable(pA, pB); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

    The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pA the fixed value of pattern parameter a, or null if not bound. + * @param pB the fixed value of pattern parameter b, or null if not bound. + * @return the (partial) match object. + * + */ + public static Unsat_subpackage.Match newMatch(final EPackage pA, final EPackage pB) { + return new Immutable(pA, pB); + } + + private static final class Mutable extends Unsat_subpackage.Match { + Mutable(final EPackage pA, final EPackage pB) { + super(pA, pB); + } + + @Override + public boolean isMutable() { + return true; + } + } + + private static final class Immutable extends Unsat_subpackage.Match { + Immutable(final EPackage pA, final EPackage pB) { + super(pA, pB); + } + + @Override + public boolean isMutable() { + return false; + } + } + } + + /** + * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_subpackage pattern, + * providing pattern-specific query methods. + * + *

    Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, + * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. + * + *

    Matches of the pattern will be represented as {@link Match}. + * + *

    Original source: + *

    +   * pattern unsat_subpackage(a: EPackage, b: EPackage) {
    +   * 	EPackage.eSubpackages(a, b);
    +   * }
    +   * 
    + * + * @see Match + * @see Unsat_subpackage + * + */ + public static class Matcher extends BaseMatcher { + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + public static Unsat_subpackage.Matcher on(final ViatraQueryEngine engine) { + // check if matcher already exists + Matcher matcher = engine.getExistingMatcher(querySpecification()); + if (matcher == null) { + matcher = (Matcher)engine.getMatcher(querySpecification()); + } + return matcher; + } + + /** + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * @return an initialized matcher + * @noreference This method is for internal matcher initialization by the framework, do not call it manually. + * + */ + public static Unsat_subpackage.Matcher create() { + return new Matcher(); + } + + private static final int POSITION_A = 0; + + private static final int POSITION_B = 1; + + private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Unsat_subpackage.Matcher.class); + + /** + * Initializes the pattern matcher within an existing VIATRA Query engine. + * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. + * + * @param engine the existing VIATRA Query engine in which this matcher will be created. + * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation + * + */ + private Matcher() { + super(querySpecification()); + } + + /** + * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pA the fixed value of pattern parameter a, or null if not bound. + * @param pB the fixed value of pattern parameter b, or null if not bound. + * @return matches represented as a Match object. + * + */ + public Collection getAllMatches(final EPackage pA, final EPackage pB) { + return rawStreamAllMatches(new Object[]{pA, pB}).collect(Collectors.toSet()); + } + + /** + * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. + *

    + * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * @param pA the fixed value of pattern parameter a, or null if not bound. + * @param pB the fixed value of pattern parameter b, or null if not bound. + * @return a stream of matches represented as a Match object. + * + */ + public Stream streamAllMatches(final EPackage pA, final EPackage pB) { + return rawStreamAllMatches(new Object[]{pA, pB}); + } + + /** + * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pA the fixed value of pattern parameter a, or null if not bound. + * @param pB the fixed value of pattern parameter b, or null if not bound. + * @return a match represented as a Match object, or null if no match is found. + * + */ + public Optional getOneArbitraryMatch(final EPackage pA, final EPackage pB) { + return rawGetOneArbitraryMatch(new Object[]{pA, pB}); + } + + /** + * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, + * under any possible substitution of the unspecified parameters (if any). + * @param pA the fixed value of pattern parameter a, or null if not bound. + * @param pB the fixed value of pattern parameter b, or null if not bound. + * @return true if the input is a valid (partial) match of the pattern. + * + */ + public boolean hasMatch(final EPackage pA, final EPackage pB) { + return rawHasMatch(new Object[]{pA, pB}); + } + + /** + * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. + * @param pA the fixed value of pattern parameter a, or null if not bound. + * @param pB the fixed value of pattern parameter b, or null if not bound. + * @return the number of pattern matches found. + * + */ + public int countMatches(final EPackage pA, final EPackage pB) { + return rawCountMatches(new Object[]{pA, pB}); + } + + /** + * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. + * Neither determinism nor randomness of selection is guaranteed. + * @param pA the fixed value of pattern parameter a, or null if not bound. + * @param pB the fixed value of pattern parameter b, or null if not bound. + * @param processor the action that will process the selected match. + * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked + * + */ + public boolean forOneArbitraryMatch(final EPackage pA, final EPackage pB, final Consumer processor) { + return rawForOneArbitraryMatch(new Object[]{pA, pB}, processor); + } + + /** + * Returns a new (partial) match. + * This can be used e.g. to call the matcher with a partial match. + *

    The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. + * @param pA the fixed value of pattern parameter a, or null if not bound. + * @param pB the fixed value of pattern parameter b, or null if not bound. + * @return the (partial) match object. + * + */ + public Unsat_subpackage.Match newMatch(final EPackage pA, final EPackage pB) { + return Unsat_subpackage.Match.newMatch(pA, pB); + } + + /** + * Retrieve the set of values that occur in matches for a. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfa(final Object[] parameters) { + return rawStreamAllValues(POSITION_A, parameters).map(EPackage.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for a. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfa() { + return rawStreamAllValuesOfa(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for a. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfa() { + return rawStreamAllValuesOfa(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for a. + *

    + * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfa(final Unsat_subpackage.Match partialMatch) { + return rawStreamAllValuesOfa(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for a. + *

    + * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfa(final EPackage pB) { + return rawStreamAllValuesOfa(new Object[]{null, pB}); + } + + /** + * Retrieve the set of values that occur in matches for a. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfa(final Unsat_subpackage.Match partialMatch) { + return rawStreamAllValuesOfa(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for a. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfa(final EPackage pB) { + return rawStreamAllValuesOfa(new Object[]{null, pB}).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for b. + * @return the Set of all values or empty set if there are no matches + * + */ + protected Stream rawStreamAllValuesOfb(final Object[] parameters) { + return rawStreamAllValues(POSITION_B, parameters).map(EPackage.class::cast); + } + + /** + * Retrieve the set of values that occur in matches for b. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfb() { + return rawStreamAllValuesOfb(emptyArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for b. + * @return the Set of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfb() { + return rawStreamAllValuesOfb(emptyArray()); + } + + /** + * Retrieve the set of values that occur in matches for b. + *

    + * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfb(final Unsat_subpackage.Match partialMatch) { + return rawStreamAllValuesOfb(partialMatch.toArray()); + } + + /** + * Retrieve the set of values that occur in matches for b. + *

    + * NOTE: It is important not to modify the source model while the stream is being processed. + * If the match set of the pattern changes during processing, the contents of the stream is undefined. + * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. + * + * @return the Stream of all values or empty set if there are no matches + * + */ + public Stream streamAllValuesOfb(final EPackage pA) { + return rawStreamAllValuesOfb(new Object[]{pA, null}); + } + + /** + * Retrieve the set of values that occur in matches for b. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfb(final Unsat_subpackage.Match partialMatch) { + return rawStreamAllValuesOfb(partialMatch.toArray()).collect(Collectors.toSet()); + } + + /** + * Retrieve the set of values that occur in matches for b. + * @return the Set of all values or empty set if there are no matches + * + */ + public Set getAllValuesOfb(final EPackage pA) { + return rawStreamAllValuesOfb(new Object[]{pA, null}).collect(Collectors.toSet()); + } + + @Override + protected Unsat_subpackage.Match tupleToMatch(final Tuple t) { + try { + return Unsat_subpackage.Match.newMatch((EPackage) t.get(POSITION_A), (EPackage) t.get(POSITION_B)); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in tuple not properly typed!",e); + return null; + } + } + + @Override + protected Unsat_subpackage.Match arrayToMatch(final Object[] match) { + try { + return Unsat_subpackage.Match.newMatch((EPackage) match[POSITION_A], (EPackage) match[POSITION_B]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + @Override + protected Unsat_subpackage.Match arrayToMatchMutable(final Object[] match) { + try { + return Unsat_subpackage.Match.newMutableMatch((EPackage) match[POSITION_A], (EPackage) match[POSITION_B]); + } catch(ClassCastException e) { + LOGGER.error("Element(s) in array not properly typed!",e); + return null; + } + } + + /** + * @return the singleton instance of the query specification of this pattern + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static IQuerySpecification querySpecification() { + return Unsat_subpackage.instance(); + } + } + + private Unsat_subpackage() { + super(GeneratedPQuery.INSTANCE); + } + + /** + * @return the singleton instance of the query specification + * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded + * + */ + public static Unsat_subpackage instance() { + try{ + return LazyHolder.INSTANCE; + } catch (ExceptionInInitializerError err) { + throw processInitializerError(err); + } + } + + @Override + protected Unsat_subpackage.Matcher instantiate(final ViatraQueryEngine engine) { + return Unsat_subpackage.Matcher.on(engine); + } + + @Override + public Unsat_subpackage.Matcher instantiate() { + return Unsat_subpackage.Matcher.create(); + } + + @Override + public Unsat_subpackage.Match newEmptyMatch() { + return Unsat_subpackage.Match.newEmptyMatch(); + } + + @Override + public Unsat_subpackage.Match newMatch(final Object... parameters) { + return Unsat_subpackage.Match.newMatch((org.eclipse.emf.ecore.EPackage) parameters[0], (org.eclipse.emf.ecore.EPackage) parameters[1]); + } + + /** + * Inner class allowing the singleton instance of {@link Unsat_subpackage} to be created + * not at the class load time of the outer class, + * but rather at the first call to {@link Unsat_subpackage#instance()}. + * + *

    This workaround is required e.g. to support recursion. + * + */ + private static class LazyHolder { + private static final Unsat_subpackage INSTANCE = new Unsat_subpackage(); + + /** + * Statically initializes the query specification after the field {@link #INSTANCE} is assigned. + * This initialization order is required to support indirect recursion. + * + *

    The static initializer is defined using a helper field to work around limitations of the code generator. + * + */ + private static final Object STATIC_INITIALIZER = ensureInitialized(); + + public static Object ensureInitialized() { + INSTANCE.ensureInitializedInternal(); + return null; + } + } + + private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { + private static final Unsat_subpackage.GeneratedPQuery INSTANCE = new GeneratedPQuery(); + + private final PParameter parameter_a = new PParameter("a", "org.eclipse.emf.ecore.EPackage", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EPackage")), PParameterDirection.INOUT); + + private final PParameter parameter_b = new PParameter("b", "org.eclipse.emf.ecore.EPackage", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EPackage")), PParameterDirection.INOUT); + + private final List parameters = Arrays.asList(parameter_a, parameter_b); + + private GeneratedPQuery() { + super(PVisibility.PUBLIC); + } + + @Override + public String getFullyQualifiedName() { + return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.unsat_subpackage"; + } + + @Override + public List getParameterNames() { + return Arrays.asList("a","b"); + } + + @Override + public List getParameters() { + return parameters; + } + + @Override + public Set doGetContainedBodies() { + setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); + Set bodies = new LinkedHashSet<>(); + { + PBody body = new PBody(this); + PVariable var_a = body.getOrCreateVariableByName("a"); + PVariable var_b = body.getOrCreateVariableByName("b"); + new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); + new TypeConstraint(body, Tuples.flatTupleOf(var_b), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); + body.setSymbolicParameters(Arrays.asList( + new ExportedParameter(body, var_a, parameter_a), + new ExportedParameter(body, var_b, parameter_b) + )); + // EPackage.eSubpackages(a, b) + new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); + PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); + new TypeConstraint(body, Tuples.flatTupleOf(var_a, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage", "eSubpackages"))); + new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); + new Equality(body, var__virtual_0_, var_b); + bodies.add(body); + } + return bodies; + } + } +} diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/internal/.gitignore b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/internal/.gitignore new file mode 100644 index 00000000..995169ff --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/internal/.gitignore @@ -0,0 +1,4 @@ +/.EcoreAll.java._trace +/.SubpackageOrSelf.java._trace +/.Subpackage.java._trace +/.TopLevelPackageWithLoop.java._trace diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml index b0b77996..fe1af62e 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml @@ -1,9 +1,12 @@ - - - - + + + + @@ -11,6 +14,7 @@ + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql index 1f83a3b0..ba12bbda 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql @@ -59,6 +59,19 @@ pattern noLinkToGroundStation(Spacecraft : Spacecraft) { neg find indirectCommunicationLink(Spacecraft, GroundStation); } +//@Constraint(severity = "error", key = {Spacecraft}, message = "UNSAT") +//pattern unsat_linkToGroundStation(Spacecraft : Spacecraft) { +// ConstellationMission.groundStationNetwork(Mission, GroundStation); +// ConstellationMission.spacecraft(Mission, Spacecraft); +// find indirectCommunicationLink(Spacecraft, GroundStation); +//} + +@Constraint(severity = "error", key = {Mission}, message = "UNSAT") +pattern unsat_linkToGroundStation(Mission : InterferometryMission) { + InterferometryMission(Mission); + neg find noLinkToGroundStation(_); +} + @Constraint(severity = "error", key = {Spacecraft}, message = "Spacecraft has no potential communication path to the ground station.") pattern noPotentialLinkToGroundStation(Spacecraft : Spacecraft) { diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml index 7bf4a20b..d4ab204e 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml @@ -8,6 +8,7 @@ + diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql index 98a10cde..49fb5b2f 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql @@ -22,6 +22,12 @@ pattern multipleEntryInRegion(r : Region) { e1 != e2; } +@Constraint(severity="error", message="error", key = {sct}) +pattern unsat_multipleEntryInRegion(sct : Statechart) { + Statechart(sct); + neg find multipleEntryInRegion(_); +} + pattern transition(t : Transition, src : Vertex, trg : Vertex) { Transition.source(t, src); Transition.target(t, trg); @@ -197,6 +203,11 @@ pattern SynchronizedRegionDoesNotHaveMultipleRegions(s : Synchronization, v : Ve neg find hasMultipleRegions(c); } +//@Constraint(severity="error", message="error", key = {sct}) +//pattern unsat_SynchronizedRegionDoesNotHaveMultipleRegions(sct : Statechart) { +// Statechart(sct); +// neg find SynchronizedRegionDoesNotHaveMultipleRegions(_, _); +//} pattern hasMultipleRegions(composite: CompositeElement) { CompositeElement.regions(composite,region1); diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.classpath b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.classpath index de68b5f7..25b7f16f 100644 --- a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.classpath +++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.classpath @@ -1,11 +1,15 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/META-INF/MANIFEST.MF b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/META-INF/MANIFEST.MF index b944302b..75581def 100644 --- a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/META-INF/MANIFEST.MF +++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/META-INF/MANIFEST.MF @@ -20,7 +20,8 @@ Require-Bundle: com.google.guava, org.eclipse.viatra.query.runtime.base.itc;bundle-version="1.3.0", hu.bme.mit.inf.dslreasoner.ecore2logic;bundle-version="1.0.0", org.eclipse.viatra.query.runtime;bundle-version="2.0.0" -Import-Package: org.apache.log4j;version="1.2.15" -Automatic-Module-Name: hu.bme.mit.inf.dlsreasoner.alloy.reasoner -Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Bundle-NativeCode: libminisat.so;osname=Linux;processor=x86_64 +Automatic-Module-Name: hu.bme.mit.inf.dlsreasoner.alloy.reasoner +Import-Package: org.apache.log4j;version="1.2.15" diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/NeighbourhoodBasedStateCoderFactory.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/NeighbourhoodBasedStateCoderFactory.xtend index 5e442ca7..f19ac30f 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/NeighbourhoodBasedStateCoderFactory.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/NeighbourhoodBasedStateCoderFactory.xtend @@ -59,15 +59,14 @@ class NeighbourhoodBasedPartialInterpretationStateCoder exten override doCreateActivationCode(IPatternMatch match) { val size = match.specification.parameters.size val res = new ArrayList(size) - var int index = 0 var int equivalenceHash = 0 val prime = 31 - while (index < size) { - res.add(getCode(match.get(index))) - index++ + for (var int index = 0; index < size; index++) { + val matchArgument = match.get(index) + res.add(getCode(matchArgument)) for (var i = 0; i < index; i++) { - val number = if (match.get(index) === match.get(i)) { + val number = if (matchArgument === match.get(i)) { 1 } else { 0 diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend index 6f38d261..c0a71c85 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend @@ -55,7 +55,7 @@ class ViatraReasonerConfiguration extends LogicSolverConfiguration { */ public var SearchSpaceConstraint searchSpaceConstraints = new SearchSpaceConstraint - public var ScopePropagatorStrategy scopePropagatorStrategy = new ScopePropagatorStrategy.Polyhedral( + public var ScopePropagatorStrategy scopePropagatorStrategy = ScopePropagatorStrategy.Polyhedral( PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp) public var List hints = newArrayList diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/FAM_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/FAM_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json deleted file mode 100644 index 1e2d4dd4..00000000 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/FAM_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "inputPath": "initialModels", - "outputPath": "outputModels", - "timeout": 1200, - "saveModels": true, - "warmupIterations": 0, - "iterations": 5, - "domain": "FAM", - "scope": "none", - "sizes": [500], - "solver": "ViatraSolver", - "scopePropagator": "polyhedral", - "propagatedConstraints": "hints", - "polyhedronSolver": "Clp", - "scopeHeuristics": "polyhedral" -} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu.json new file mode 100644 index 00000000..b602f2fe --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu.json @@ -0,0 +1,13 @@ +{ + "inputPath": "initialModels", + "outputPath": "outputModels", + "timeout": 300, + "saveModels": true, + "saveTemporaryFiles": false, + "warmupIterations": 0, + "iterations": 30, + "domain": "Yakindu", + "scope": "unsat", + "sizes": [20], + "solver": "AlloySolver" +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json deleted file mode 100644 index b4d51684..00000000 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "inputPath": "initialModels", - "outputPath": "outputModels", - "timeout": 1200, - "saveModels": false, - "saveTemporaryFiles": true, - "warmupIterations": 0, - "iterations": 5, - "domain": "Yakindu", - "scope": "none", - "sizes": [100], - "solver": "ViatraSolver", - "scopePropagator": "polyhedral", - "propagatedConstraints": "hints", - "polyhedronSolver": "Clp", - "scopeHeuristic": "polyhedral" -} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore.json new file mode 100644 index 00000000..36fb0ea2 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore.json @@ -0,0 +1,17 @@ +{ + "inputPath": "initialModels", + "outputPath": "outputModels", + "timeout": 300, + "saveModels": true, + "saveTemporaryFiles": false, + "warmupIterations": 0, + "iterations": 1, + "domain": "ecoreUnsat", + "scope": "none", + "sizes": [5, 10, 20, 30, 40, 50], + "solver": "ViatraSolver", + "scopePropagator": "polyhedral", + "propagatedConstraints": "hints", + "polyhedronSolver": "Clp", + "scopeHeuristic": "polyhedral" +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json deleted file mode 100644 index 72e97957..00000000 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "inputPath": "initialModels", - "outputPath": "outputModels", - "timeout": 1200, - "saveModels": true, - "warmupIterations": 0, - "iterations": 5, - "domain": "ecore", - "scope": "quantiles", - "sizes": [50], - "solver": "ViatraSolver", - "scopePropagator": "polyhedral", - "propagatedConstraints": "hints", - "polyhedronSolver": "Clp", - "scopeHeuristic": "polyhedral" -} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/fs_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/fs_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json deleted file mode 100644 index a7e29a22..00000000 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/fs_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "inputPath": "initialModels", - "outputPath": "outputModels", - "timeout": 1200, - "saveModels": true, - "warmupIterations": 1, - "iterations": 1, - "domain": "fs", - "scope": "none", - "sizes": [50, 100, 150, 200, 250, 300, 350, 400, 450, 500], - "solver": "ViatraSolver", - "scopePropagator": "polyhedral", - "propagatedConstraints": "hints", - "polyhedronSolver": "Clp", - "scopeHeuristic": "polyhedral" -} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite.json new file mode 100644 index 00000000..16abb5d0 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite.json @@ -0,0 +1,17 @@ +{ + "inputPath": "initialModels", + "outputPath": "outputModels", + "timeout": 300, + "saveModels": true, + "saveTemporaryFiles": false, + "warmupIterations": 0, + "iterations": 30, + "domain": "satelliteUnsat", + "scope": "none", + "sizes": [10], + "solver": "ViatraSolver", + "scopePropagator": "polyhedral", + "propagatedConstraints": "hints", + "polyhedronSolver": "Clp", + "scopeHeuristic": "polyhedral" +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json deleted file mode 100644 index d5469948..00000000 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "inputPath": "initialModels", - "outputPath": "outputModels", - "timeout": 120, - "saveModels": true, - "saveTemporaryFiles": true, - "warmupIterations": 0, - "iterations": 1, - "domain": "Yakindu", - "scope": "quantiles", - "sizes": [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], - "solver": "ViatraSolver", - "scopePropagator": "polyhedral", - "propagatedConstraints": "hints", - "polyhedronSolver": "Clp", - "scopeHeuristic": "polyhedral" -} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend index 1be03eed..bf9ca274 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend @@ -40,6 +40,8 @@ class TypeQuantiles { } abstract class MetamodelLoader { + public static val UNSAT_PREFIX = "unsat_" + protected val ReasonerWorkspace workspace new(ReasonerWorkspace workspace) { @@ -61,6 +63,10 @@ abstract class MetamodelLoader { def Map getTypeQuantiles() { emptyMap } + + def Map getUnsatTypeQuantiles() { + throw new UnsupportedOperationException("This domain has no type quantiles for unsatisfiable problems") + } def List getHints(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { emptyList @@ -136,9 +142,15 @@ class YakinduLoader extends MetamodelLoader { public static val patternsWithComplexStates = #["outgoingFromExit", "outgoingFromFinal", "choiceHasNoOutgoing", "choiceHasNoIncoming"] + val boolean satisfiable + new(ReasonerWorkspace workspace) { + this(workspace, true) + } + + new(ReasonerWorkspace workspace, boolean satisfiable) { super(workspace) - YakindummPackage.eINSTANCE.eClass + this.satisfiable = satisfiable } def setUseSynchronization(boolean useSynchronization) { @@ -173,6 +185,8 @@ class YakinduLoader extends MetamodelLoader { useSynchInThisLoad || !patternsWithSynchronization.exists[spec.fullyQualifiedName.endsWith(it)] ].filter [ spec | useComplexStates || !patternsWithComplexStates.exists[spec.fullyQualifiedName.endsWith(it)] + ].filter [ + !satisfiable || !it.simpleName.startsWith(UNSAT_PREFIX) ].toList val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet val derivedFeatures = new LinkedHashMap @@ -213,6 +227,19 @@ class YakinduLoader extends MetamodelLoader { "Transition" -> new TypeQuantiles(0.581632653061224, 0.645161290322581) } } + + override getUnsatTypeQuantiles() { + #{ + "Choice" -> new TypeQuantiles(0.118279569892473, 0.154020979020979), + "Entry" -> new TypeQuantiles(0.2, 0.4), + "Exit" -> new TypeQuantiles(0, 0), + "FinalState" -> new TypeQuantiles(0, 0), + "Region" -> new TypeQuantiles(0.0294117647058824, 0.0633258678611422), + "State" -> new TypeQuantiles(0.132023636740618, 0.175925925925926), +// "Statechart" -> new TypeQuantiles(0.00961538461538462, 0.010752688172043), + "Transition" -> new TypeQuantiles(0.581632653061224, 0.645161290322581) + } + } override getHints(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { #[new SGraphHint(ecore2Logic, trace)] @@ -276,9 +303,15 @@ class FileSystemLoader extends MetamodelLoader { } class EcoreLoader extends MetamodelLoader { + val boolean satisfiable new(ReasonerWorkspace workspace) { + this(workspace, true) + } + + new(ReasonerWorkspace workspace, boolean satisfiable) { super(workspace) + this.satisfiable = satisfiable } override loadMetamodel() { @@ -307,7 +340,12 @@ class EcoreLoader extends MetamodelLoader { override loadQueries(EcoreMetamodelDescriptor metamodel) { val patternGroup = Ecore.instance val patterns = patternGroup.specifications.toList - val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet + val allWfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet + val wfPatterns = if (satisfiable) { + allWfPatterns.filter[!it.simpleName.startsWith(UNSAT_PREFIX)].toSet + } else { + allWfPatterns + } val derivedFeatures = new HashMap return new ViatraQuerySetDescriptor( patterns, @@ -346,9 +384,15 @@ class EcoreLoader extends MetamodelLoader { } class SatelliteLoader extends MetamodelLoader { + val boolean satisfiable new(ReasonerWorkspace workspace) { + this(workspace, true) + } + + new(ReasonerWorkspace workspace, boolean satisfiable) { super(workspace) + this.satisfiable = satisfiable } override loadMetamodel() { @@ -371,7 +415,9 @@ class SatelliteLoader extends MetamodelLoader { override loadQueries(EcoreMetamodelDescriptor metamodel) { val i = SatelliteQueriesAll.instance - val patterns = i.specifications.toList + val patterns = i.specifications.filter [ + !satisfiable || !it.simpleName.startsWith(UNSAT_PREFIX) + ].toList val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet val derivedFeatures = new LinkedHashMap val res = new ViatraQuerySetDescriptor( @@ -404,4 +450,15 @@ class SatelliteLoader extends MetamodelLoader { } } + override getUnsatTypeQuantiles() { + #{ + "CubeSat3U" -> new TypeQuantiles(0.1, 0.25), + "CubeSat6U" -> new TypeQuantiles(0.1, 0.25), + "SmallSat" -> new TypeQuantiles(0.1, 0.25), + "UHFCommSubsystem" -> new TypeQuantiles(0.08, 0.1), + "XCommSubsystem" -> new TypeQuantiles(0, 0.1), + "KaCommSubsystem" -> new TypeQuantiles(0, 0.05), + "InterferometryPayload" -> new TypeQuantiles(0.15, 0.25) + } + } } diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend index 56a65091..f842afb5 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend @@ -29,19 +29,26 @@ class MeasurementScript { enum Domain { fs, ecore, + ecoreUnsat, Yakindu, + YakinduUnsat, FAM, - satellite + satellite, + satelliteUnsat } enum Scope { none, - quantiles + quantiles, + upperOnly, + unsat, + exactly } enum Solver { ViatraSolver, - AlloySolver + AlloySolver, + AlloyMiniSat } enum ScopePropagator { diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend index 1127f01a..973c3d13 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend @@ -54,6 +54,7 @@ import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandalone import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory import org.eclipse.xtend.lib.annotations.Data +import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloyBackendSolver class MeasurementScriptRunner { static val MODEL_SIZE_GAP = 0 @@ -75,9 +76,12 @@ class MeasurementScriptRunner { metamodelLoader = switch (script.domain) { case fs: new FileSystemLoader(inputWorkspace) case ecore: new EcoreLoader(inputWorkspace) + case ecoreUnsat: new EcoreLoader(inputWorkspace, false) case Yakindu: new YakinduLoader(inputWorkspace) => [useSynchronization = false; useComplexStates = true] + case YakinduUnsat: new YakinduLoader(inputWorkspace, false) => [useSynchronization = false; useComplexStates = true] case FAM: new FAMLoader(inputWorkspace) case satellite: new SatelliteLoader(inputWorkspace) + case satelliteUnsat: new SatelliteLoader(inputWorkspace, false) default: throw new IllegalArgumentException("Unsupported domain: " + script.domain) } } @@ -191,15 +195,17 @@ class MeasurementScriptRunner { config } - private def createAlloyConfig() { + private def createAlloyConfig(AlloyBackendSolver backendSolver) { val config = new AlloySolverConfiguration + config.solver = backendSolver config } private def createConfig(int modelSize) { val config = switch (solver : script.solver) { case ViatraSolver: createViatraConfig() - case AlloySolver: createAlloyConfig() + case AlloySolver: createAlloyConfig(AlloyBackendSolver.SAT4J) + case AlloyMiniSat: createAlloyConfig(AlloyBackendSolver.MiniSatJNI) default: throw new IllegalArgumentException("Unknown solver: " + solver) } config.solutionScope.numberOfRequiredSolutions = 1 @@ -243,7 +249,8 @@ class MeasurementScriptRunner { val solver = switch (solver : script.solver) { case ViatraSolver: new ViatraReasoner - case AlloySolver: new AlloySolver + case AlloySolver, + case AlloyMiniSat: new AlloySolver default: throw new IllegalArgumentException("Unknown solver: " + solver) } val result = solver.solve(problem, config, outputWorkspace) @@ -284,14 +291,31 @@ class MeasurementScriptRunner { } else { val numberOfKnownElements = knownElements.values.flatten.toSet.size val newElementCount = modelSize - numberOfKnownElements - config.typeScopes.minNewElements = newElementCount - config.typeScopes.maxNewElements = newElementCount + MODEL_SIZE_GAP + switch (script.scope) { + case upperOnly: + config.typeScopes.maxNewElements = newElementCount + MODEL_SIZE_GAP + case exactly: { + config.typeScopes.minNewElements = newElementCount + config.typeScopes.maxNewElements = newElementCount + } + default: { + config.typeScopes.minNewElements = newElementCount + config.typeScopes.maxNewElements = newElementCount + MODEL_SIZE_GAP + } + } } - switch (script.scope) { - case none: + switch (scope : script.scope) { + case none, + case exactly: return - case quantiles: { - val quantiles = metamodelLoader.typeQuantiles + case quantiles, + case unsat, + case upperOnly: { + val quantiles = if (scope == Scope.unsat) { + metamodelLoader.unsatTypeQuantiles + } else { + metamodelLoader.typeQuantiles + } for (eClassInScope : eClassMapper.allClassesInScope(trace)) { val quantile = quantiles.get(eClassInScope.name) if (quantile !== null) { @@ -301,7 +325,9 @@ class MeasurementScriptRunner { val lowCount = Math.floor(modelSize * quantile.low) as int val highCount = Math.ceil((modelSize + MODEL_SIZE_GAP) * quantile.high) as int // println('''«type.name» «lowCount» «highCount»''') - config.typeScopes.minNewElementsByType.put(type, Math.max(lowCount - currentCount, 0)) + if (script.scope != Scope.upperOnly) { + config.typeScopes.minNewElementsByType.put(type, Math.max(lowCount - currentCount, 0)) + } config.typeScopes.maxNewElementsByType.put(type, highCount - currentCount) } } -- cgit v1.2.3-54-g00ecf