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 --- .../bme/mit/inf/dslreasoner/run/CountMatches.xtend | 176 --------------------- 1 file changed, 176 deletions(-) delete mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/CountMatches.xtend (limited to 'Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/CountMatches.xtend') 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..