diff options
author | 2018-07-15 20:27:36 +0200 | |
---|---|---|
committer | 2018-07-15 20:27:36 +0200 | |
commit | 564bbf59f15314320b7ebc5d7acced6cff01b649 (patch) | |
tree | 121172f3f82ba9125443f0c9f3c9735d8caccb97 | |
parent | Additional packages for standalone runtime environment (diff) | |
download | VIATRA-Generator-564bbf59f15314320b7ebc5d7acced6cff01b649.tar.gz VIATRA-Generator-564bbf59f15314320b7ebc5d7acced6cff01b649.tar.zst VIATRA-Generator-564bbf59f15314320b7ebc5d7acced6cff01b649.zip |
Added scope validation as a service of the solver interface
-rw-r--r-- | Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicSolver.xtend | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicSolver.xtend b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicSolver.xtend index b2a98570..073e550b 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicSolver.xtend +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/LogicSolver.xtend | |||
@@ -12,6 +12,7 @@ import java.util.Map | |||
12 | import java.util.SortedSet | 12 | import java.util.SortedSet |
13 | import java.util.TreeSet | 13 | import java.util.TreeSet |
14 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure0 | 14 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure0 |
15 | import java.util.LinkedList | ||
15 | 16 | ||
16 | abstract class LogicReasoner { | 17 | abstract class LogicReasoner { |
17 | def abstract LogicResult solve(LogicProblem problem, LogicSolverConfiguration configuration, | 18 | def abstract LogicResult solve(LogicProblem problem, LogicSolverConfiguration configuration, |
@@ -82,7 +83,7 @@ public enum DocumentationLevel { | |||
82 | * Defines the the size of the generated models. Constant <code>Unlimited</code> defines no upper limit to the type. | 83 | * Defines the the size of the generated models. Constant <code>Unlimited</code> defines no upper limit to the type. |
83 | */ | 84 | */ |
84 | public class TypeScopes { | 85 | public class TypeScopes { |
85 | public static val Unlimited = -1; | 86 | public static val Unlimited = Integer.MAX_VALUE; |
86 | 87 | ||
87 | /** | 88 | /** |
88 | * Sets the Integers that are already in the scope of the problem. | 89 | * Sets the Integers that are already in the scope of the problem. |
@@ -124,6 +125,31 @@ public class TypeScopes { | |||
124 | * | 125 | * |
125 | */ | 126 | */ |
126 | public var Map<Type,Integer> maxNewElementsByType = new HashMap | 127 | public var Map<Type,Integer> maxNewElementsByType = new HashMap |
128 | |||
129 | /** | ||
130 | * Checks if the scope contains negative elements | ||
131 | */ | ||
132 | def public validateTypeScopes(TypeScopes scopes) { | ||
133 | val res = new LinkedList<String> | ||
134 | if(scopes.maxNewElements < 0) { | ||
135 | res += '''Inconsistent scope: Maximal number of new elements is negative.''' | ||
136 | } | ||
137 | if(scopes.maxNewIntegers < 0) { | ||
138 | res += '''Inconsistent scope: Maximal number of new integer values is negative.''' | ||
139 | } | ||
140 | if(scopes.maxNewReals < 0) { | ||
141 | res += '''Inconsistent scope: Maximal number of new real values is negative.''' | ||
142 | } | ||
143 | if(scopes.maxNewStrings < 0) { | ||
144 | res += '''Inconsistent scope: Maximal number of new string values is negative.''' | ||
145 | } | ||
146 | for(x : scopes.minNewElementsByType.entrySet) { | ||
147 | if(x.value < 0) { | ||
148 | res += '''Inconsistent scope: Maximal number of new "«x.key.name»" elements is negative.''' | ||
149 | } | ||
150 | } | ||
151 | return res | ||
152 | } | ||
127 | } | 153 | } |
128 | 154 | ||
129 | /** | 155 | /** |
@@ -131,7 +157,7 @@ public class TypeScopes { | |||
131 | * Constant <code>All</code> defines that all solution for the problem is requested. | 157 | * Constant <code>All</code> defines that all solution for the problem is requested. |
132 | */ | 158 | */ |
133 | public class SolutionScope { | 159 | public class SolutionScope { |
134 | public static val All = -1; | 160 | public static val All = Integer.MAX_VALUE; |
135 | public var numberOfRequiredSolution = 1 | 161 | public var numberOfRequiredSolution = 1 |
136 | } | 162 | } |
137 | /** Progress monitor class for a solver to | 163 | /** Progress monitor class for a solver to |