aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/Alloy-Solver
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <marussy@mit.bme.hu>2020-06-25 19:55:10 +0200
committerLibravatar Kristóf Marussy <marussy@mit.bme.hu>2020-06-25 19:55:10 +0200
commitc3a6d4b9cf3657070d180aa65ddbf0459e880329 (patch)
tree780c4fc61578dcb309af53fb0c164c7627e51676 /Solvers/Alloy-Solver
parentNew configuration language parser WIP (diff)
parentScope unsat benchmarks (diff)
downloadVIATRA-Generator-c3a6d4b9cf3657070d180aa65ddbf0459e880329.tar.gz
VIATRA-Generator-c3a6d4b9cf3657070d180aa65ddbf0459e880329.tar.zst
VIATRA-Generator-c3a6d4b9cf3657070d180aa65ddbf0459e880329.zip
Merge branch 'kris'
Diffstat (limited to 'Solvers/Alloy-Solver')
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.classpath26
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/META-INF/MANIFEST.MF7
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloySolver.xtend2
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Alloy2LogicMapper.xtend2
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyHandler.xtend17
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/RunCommandMapper.xtend19
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.launch/Generate Language Infrastructure (hu.bme.mit.inf.dslreasoner.alloy.language).launch18
7 files changed, 41 insertions, 50 deletions
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 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<classpath> 2<classpath>
3 <classpathentry kind="src" path="xtend-gen"/> 3 <classpathentry kind="src" path="xtend-gen"/>
4 <classpathentry kind="src" path="queries"/> 4 <classpathentry kind="src" path="queries"/>
5 <classpathentry kind="src" path="vql-gen"/> 5 <classpathentry kind="src" path="vql-gen"/>
6 <classpathentry exported="true" kind="lib" path="lib/alloy4.2_2015-02-22.jar"/> 6 <classpathentry exported="true" kind="lib" path="lib/alloy4.2_2015-02-22.jar"/>
7 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> 7 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
8 <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> 8 <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
9 <classpathentry kind="src" path="src"/> 9 <classpathentry kind="src" path="src">
10 <classpathentry kind="output" path="bin"/> 10 <attributes>
11</classpath> 11 <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="hu.bme.mit.inf.dlsreasoner.alloy.reasoner/lib"/>
12 </attributes>
13 </classpathentry>
14 <classpathentry kind="output" path="bin"/>
15</classpath>
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,
20 org.eclipse.viatra.query.runtime.base.itc;bundle-version="1.3.0", 20 org.eclipse.viatra.query.runtime.base.itc;bundle-version="1.3.0",
21 hu.bme.mit.inf.dslreasoner.ecore2logic;bundle-version="1.0.0", 21 hu.bme.mit.inf.dslreasoner.ecore2logic;bundle-version="1.0.0",
22 org.eclipse.viatra.query.runtime;bundle-version="2.0.0" 22 org.eclipse.viatra.query.runtime;bundle-version="2.0.0"
23Import-Package: org.apache.log4j;version="1.2.15"
24Automatic-Module-Name: hu.bme.mit.inf.dlsreasoner.alloy.reasoner
25Bundle-ActivationPolicy: lazy
26Bundle-RequiredExecutionEnvironment: JavaSE-1.8 23Bundle-RequiredExecutionEnvironment: JavaSE-1.8
24Bundle-ActivationPolicy: lazy
25Bundle-NativeCode: libminisat.so;osname=Linux;processor=x86_64
26Automatic-Module-Name: hu.bme.mit.inf.dlsreasoner.alloy.reasoner
27Import-Package: org.apache.log4j;version="1.2.15"
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloySolver.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloySolver.xtend
index f6b0b4a5..1eb6442b 100644
--- a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloySolver.xtend
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloySolver.xtend
@@ -62,7 +62,7 @@ class AlloySolver extends LogicReasoner{
62 val result2 = handler.callSolver(alloyProblem,workspace,alloyConfig,alloyCode) 62 val result2 = handler.callSolver(alloyProblem,workspace,alloyConfig,alloyCode)
63 alloyConfig.progressMonitor.workedSearchFinished 63 alloyConfig.progressMonitor.workedSearchFinished
64 64
65 val logicResult = backwardMapper.transformOutput(problem,configuration.solutionScope.numberOfRequiredSolution,result2,forwardTrace,transformationTime) 65 val logicResult = backwardMapper.transformOutput(problem,configuration.solutionScope.numberOfRequiredSolutions,result2,forwardTrace,transformationTime)
66 alloyConfig.progressMonitor.workedBackwardTransformationFinished 66 alloyConfig.progressMonitor.workedBackwardTransformationFinished
67 //val solverFinish = System.currentTimeMillis-solverStart 67 //val solverFinish = System.currentTimeMillis-solverStart
68 // Finish: Solving Alloy problem 68 // Finish: Solving Alloy problem
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Alloy2LogicMapper.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Alloy2LogicMapper.xtend
index 2efd6b29..328ca176 100644
--- a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Alloy2LogicMapper.xtend
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Alloy2LogicMapper.xtend
@@ -9,7 +9,7 @@ class Alloy2LogicMapper {
9 public def transformOutput(LogicProblem problem, int requiredNumberOfSolution, MonitoredAlloySolution monitoredAlloySolution, Logic2AlloyLanguageMapperTrace trace, long transformationTime) { 9 public def transformOutput(LogicProblem problem, int requiredNumberOfSolution, MonitoredAlloySolution monitoredAlloySolution, Logic2AlloyLanguageMapperTrace trace, long transformationTime) {
10 val models = monitoredAlloySolution.aswers.map[it.key].toList 10 val models = monitoredAlloySolution.aswers.map[it.key].toList
11 11
12 if(!monitoredAlloySolution.finishedBeforeTimeout) { 12 if(models.empty || !monitoredAlloySolution.finishedBeforeTimeout) {
13 return createInsuficientResourcesResult => [ 13 return createInsuficientResourcesResult => [
14 it.problem = problem 14 it.problem = problem
15 it.representation += models 15 it.representation += models
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyHandler.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyHandler.xtend
index 9b4265b9..451aad6e 100644
--- a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyHandler.xtend
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyHandler.xtend
@@ -101,15 +101,8 @@ class AlloyHandler {
101 try{ 101 try{
102 answers = future.get(configuration.runtimeLimit,TimeUnit.SECONDS) 102 answers = future.get(configuration.runtimeLimit,TimeUnit.SECONDS)
103 finished = true 103 finished = true
104 } catch (TimeoutException ex) { 104 } catch (TimeoutException | InterruptedException | ExecutionException e) {
105 // handle the timeout 105 future.cancel(true)
106 } catch (InterruptedException e) {
107 // handle the interrupts
108 } catch (ExecutionException e) {
109 // handle other exceptions
110 } finally {
111 future.cancel(true);
112
113 answers = callable.partialAnswers 106 answers = callable.partialAnswers
114 finished = false 107 finished = false
115 } 108 }
@@ -195,7 +188,7 @@ class AlloyCallerWithTimeout implements Callable<List<Pair<A4Solution,Long>>>{
195 } else { 188 } else {
196 lastAnswer = lastAnswer.next 189 lastAnswer = lastAnswer.next
197 } 190 }
198 configuration.progressMonitor.workedBackwardTransformation(configuration.solutionScope.numberOfRequiredSolution) 191 configuration.progressMonitor.workedBackwardTransformation(configuration.solutionScope.numberOfRequiredSolutions)
199 192
200 val runtime = System.currentTimeMillis -startTime 193 val runtime = System.currentTimeMillis -startTime
201 synchronized(this) { 194 synchronized(this) {
@@ -212,8 +205,8 @@ class AlloyCallerWithTimeout implements Callable<List<Pair<A4Solution,Long>>>{
212 } 205 }
213 206
214 def hasEnoughSolution(List<?> answers) { 207 def hasEnoughSolution(List<?> answers) {
215 if(configuration.solutionScope.numberOfRequiredSolution < 0) return false 208 if(configuration.solutionScope.numberOfRequiredSolutions < 0) return false
216 else return answers.size() == configuration.solutionScope.numberOfRequiredSolution 209 else return answers.size() == configuration.solutionScope.numberOfRequiredSolutions
217 } 210 }
218 211
219 public def getPartialAnswers() { 212 public def getPartialAnswers() {
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/RunCommandMapper.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/RunCommandMapper.xtend
index 494197bc..b74017d8 100644
--- a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/RunCommandMapper.xtend
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/RunCommandMapper.xtend
@@ -9,8 +9,12 @@ import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSString
9import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSTerm 9import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSTerm
10import hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguageFactory 10import hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguageFactory
11import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicSolverConfiguration 11import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicSolverConfiguration
12import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
13import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition
12import java.util.List 14import java.util.List
13 15
16import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
17
14class RunCommandMapper { 18class RunCommandMapper {
15 val extension AlloyLanguageFactory factory = AlloyLanguageFactory.eINSTANCE 19 val extension AlloyLanguageFactory factory = AlloyLanguageFactory.eINSTANCE
16 val Logic2AlloyLanguageMapper_Support support = new Logic2AlloyLanguageMapper_Support; 20 val Logic2AlloyLanguageMapper_Support support = new Logic2AlloyLanguageMapper_Support;
@@ -89,16 +93,18 @@ class RunCommandMapper {
89 ] 93 ]
90 94
91 for(upperLimit : config.typeScopes.maxNewElementsByType.entrySet) { 95 for(upperLimit : config.typeScopes.maxNewElementsByType.entrySet) {
92 val limit = upperLimit.value 96 val type = upperLimit.key
97 val limit = upperLimit.value + getExistingCount(type)
93 if(limit != LogicSolverConfiguration::Unlimited) { 98 if(limit != LogicSolverConfiguration::Unlimited) {
94 this.typeScopeMapping.addUpperMultiplicity(specification,upperLimit.key,limit,mapper,trace) 99 this.typeScopeMapping.addUpperMultiplicity(specification,type,limit,mapper,trace)
95 } 100 }
96 } 101 }
97 102
98 for(lowerLimit : config.typeScopes.minNewElementsByType.entrySet) { 103 for(lowerLimit : config.typeScopes.minNewElementsByType.entrySet) {
99 val limit = lowerLimit.value 104 val type = lowerLimit.key
105 val limit = lowerLimit.value + getExistingCount(type)
100 if(limit != 0) { 106 if(limit != 0) {
101 this.typeScopeMapping.addLowerMultiplicity(specification,lowerLimit.key,limit,mapper,trace) 107 this.typeScopeMapping.addLowerMultiplicity(specification,type,limit,mapper,trace)
102 } 108 }
103 } 109 }
104 110
@@ -106,6 +112,11 @@ class RunCommandMapper {
106 setStringScope(specification,config,specification.runCommand) 112 setStringScope(specification,config,specification.runCommand)
107 } 113 }
108 114
115 private def getExistingCount(Type type) {
116 val existing = type.transitiveClosureStar[it.subtypes].filter(TypeDefinition).map[elements].flatten.toSet
117 existing.size
118 }
119
109 protected def Boolean setStringScope(ALSDocument specification, AlloySolverConfiguration config, ALSRunCommand it) { 120 protected def Boolean setStringScope(ALSDocument specification, AlloySolverConfiguration config, ALSRunCommand it) {
110 if(config.typeScopes.maxNewStrings === LogicSolverConfiguration::Unlimited) { 121 if(config.typeScopes.maxNewStrings === LogicSolverConfiguration::Unlimited) {
111 throw new UnsupportedOperationException('''A string scope have to be specified for Alloy!''') 122 throw new UnsupportedOperationException('''A string scope have to be specified for Alloy!''')
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.launch/Generate Language Infrastructure (hu.bme.mit.inf.dslreasoner.alloy.language).launch b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.launch/Generate Language Infrastructure (hu.bme.mit.inf.dslreasoner.alloy.language).launch
deleted file mode 100644
index 77031bf1..00000000
--- a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.launch/Generate Language Infrastructure (hu.bme.mit.inf.dslreasoner.alloy.language).launch
+++ /dev/null
@@ -1,18 +0,0 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<launchConfiguration type="org.eclipse.emf.mwe2.launch.Mwe2LaunchConfigurationType">
3<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; id=&quot;1299248699643_13&quot; label=&quot;working set&quot; name=&quot;working set&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/hu.bme.mit.inf.dslreasoner.alloy.language&quot; type=&quot;4&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/hu.bme.mit.inf.dslreasoner.alloy.language.generator&quot; type=&quot;4&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/hu.bme.mit.inf.dslreasoner.alloy.language.tests&quot; type=&quot;4&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/hu.bme.mit.inf.dslreasoner.alloy.language.ui&quot; type=&quot;4&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
4<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
5<listEntry value="/hu.bme.mit.inf.dslreasoner.alloy.language"/>
6</listAttribute>
7<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
8<listEntry value="4"/>
9</listAttribute>
10<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
11<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
12<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
13</listAttribute>
14<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
15<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/hu/bme/mit/inf/dslreasoner/GenerateAlloyLanguage.mwe2"/>
16<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="hu.bme.mit.inf.dslreasoner.alloy.language"/>
17<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m"/>
18</launchConfiguration>