From 110268c8e8937df8d67075caebd6d31460d0f81a Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Thu, 15 Aug 2019 15:36:05 +0200 Subject: Measurements WIP --- .../mit/inf/dslreasoner/run/FileSystemHint.xtend | 32 +++++++++++++++++++ .../run/FileSystemInconsistencyDetector.xtend | 6 ++-- .../mit/inf/dslreasoner/run/MetamodelLoader.xtend | 15 +++++++-- .../mit/inf/dslreasoner/run/SatelliteHint.xtend | 37 ---------------------- .../dslreasoner/run/script/MeasurementScript.xtend | 2 +- .../run/script/MeasurementScriptRunner.xtend | 2 +- 6 files changed, 49 insertions(+), 45 deletions(-) create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemHint.xtend (limited to 'Tests/hu.bme.mit.inf.dslreasoner.run/src/hu') diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemHint.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemHint.xtend new file mode 100644 index 00000000..8d6523b1 --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemHint.xtend @@ -0,0 +1,32 @@ +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 FileSystemHint extends Ecore2LogicTraceBasedHint { + static val REMAINING_CONTENTS_ROOT = "hint_root" + + new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { + super(ecore2Logic, trace) + } + + override getAdditionalPatterns(PatternGenerator it) ''' + pattern «REMAINING_CONTENTS_ROOT»(problem:LogicProblem, interpretation:PartialInterpretation, remainingContents:java Integer) { + find interpretation(problem, interpretation); + remainingContents == sum find remainingContents_root_reference_Dir_helper(problem, interpretation, _, #_) + } + ''' + + override createConstraintUpdater(LinearTypeExpressionBuilderFactory it) { + val dirCount = createBuilder.add(1, "Dir".type).build + + val remainingContentsRootMatcher = createMatcher(REMAINING_CONTENTS_ROOT) + + return [ p | + dirCount.tightenLowerBound(remainingContentsRootMatcher.getCount(p)) + ] + } + +} diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemInconsistencyDetector.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemInconsistencyDetector.xtend index e79a6261..f4f36951 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemInconsistencyDetector.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemInconsistencyDetector.xtend @@ -35,11 +35,11 @@ class FileSystemInconsistencyDetector extends ModelGenerationMethodBasedGlobalCo override checkGlobalConstraint(ThreadContext context) { var requiredNewObjects = - filesystem.countMatches*2 + - root.countMatches + root.countMatches*2 + + filesystem.countMatches val availableNewObjects = partialInterpretation.maxNewElements val res = availableNewObjects >= requiredNewObjects - //println('''[«availableNewObjects» >= «requiredNewObjects»] = «res»''') + println('''[«availableNewObjects» >= «requiredNewObjects»] = «res»''') return res } 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 54724226..4b0791d4 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 @@ -195,8 +195,9 @@ class YakinduLoader extends MetamodelLoader { this.workspace.readModel(EObject, "Yakindu.xmi").eResource.allContents.toList } - override additionalConstraints() { // #[] - #[[method|new SGraphInconsistencyDetector(method)]] + override additionalConstraints() { + //#[[method|new SGraphInconsistencyDetector(method)]] + emptyList } override getTypeQuantiles() { @@ -260,9 +261,17 @@ class FileSystemLoader extends MetamodelLoader { } override additionalConstraints() { - #[[method|new FileSystemInconsistencyDetector(method)]] + //#[[method|new FileSystemInconsistencyDetector(method)]] + emptyList } + override getTypeQuantiles() { + #{ + "Filesystem" -> new TypeQuantiles(0, 0.05), + "Dir" -> new TypeQuantiles(0.15, 0.3), + "File" -> new TypeQuantiles(0.25, 0.85) + } + } } class EcoreLoader extends MetamodelLoader { 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 index e95c0c64..ef5b779e 100644 --- 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 @@ -9,8 +9,6 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGene 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) @@ -32,54 +30,19 @@ class SatelliteHint extends Ecore2LogicTraceBasedHint { 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/script/MeasurementScript.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend index 5abff962..56a65091 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 @@ -22,7 +22,7 @@ class MeasurementScript { ScopeHeuristic scopeHeuristic def toCsvHeader() { - '''«domain»,«scope»,«solver»,«scopePropagator ?: "NULL"»,«propagatedConstraints ?: "NULL"»,«polyhedronSolver ?: "NULL"»''' + '''«domain»,«scope»,«solver»,«scopePropagator ?: "NULL"»,«propagatedConstraints ?: "NULL"»,«polyhedronSolver ?: "NULL"»,«scopeHeuristic ?: "NULL"»''' } } 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 48e750cb..bfbbf329 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 @@ -68,7 +68,7 @@ class MeasurementScriptRunner { 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"»_''') + "/", '''«script.domain»_«script.solver»_«script.scope»_«script.scopePropagator ?: "na"»_«script.propagatedConstraints ?: "na"»_«script.polyhedronSolver ?: "na"»_«script.scopeHeuristic ?: "na"»_''') metamodelLoader = switch (script.domain) { case fs: new FileSystemLoader(inputWorkspace) case ecore: new EcoreLoader(inputWorkspace) -- cgit v1.2.3-54-g00ecf