diff options
author | 2021-02-16 01:11:15 +0100 | |
---|---|---|
committer | 2021-02-16 01:11:15 +0100 | |
commit | acb8dedc9d03e1d17f570e07c9f75a571bd66cf8 (patch) | |
tree | 56d4f9899af7c70fa006395ffb0b93ff339fac7b /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver | |
parent | Minor adjsutments to CrossScen ad FamTree local case studies (diff) | |
download | VIATRA-Generator-acb8dedc9d03e1d17f570e07c9f75a571bd66cf8.tar.gz VIATRA-Generator-acb8dedc9d03e1d17f570e07c9f75a571bd66cf8.tar.zst VIATRA-Generator-acb8dedc9d03e1d17f570e07c9f75a571bd66cf8.zip |
Ready for strategies case study
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver')
3 files changed, 20 insertions, 3 deletions
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 5ad78506..a692e1e5 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 | |||
@@ -110,7 +110,7 @@ class ViatraReasoner extends LogicReasoner { | |||
110 | new SolutionStore(numberOfRequiredSolutions) | 110 | new SolutionStore(numberOfRequiredSolutions) |
111 | } | 111 | } |
112 | solutionStore.registerSolutionFoundHandler(new LoggerSolutionFoundHandler(viatraConfig)) | 112 | solutionStore.registerSolutionFoundHandler(new LoggerSolutionFoundHandler(viatraConfig)) |
113 | val numericSolver = new NumericSolver(method, viatraConfig, true)//was formerly hard-coded to false for caching | 113 | val numericSolver = new NumericSolver(method, viatraConfig, false)//was formerly hard-coded to false for caching |
114 | val solutionSaver = method.solutionSaver | 114 | val solutionSaver = method.solutionSaver |
115 | solutionSaver.numericSolver = numericSolver | 115 | solutionSaver.numericSolver = numericSolver |
116 | val solutionCopier = solutionSaver.solutionCopier | 116 | val solutionCopier = solutionSaver.solutionCopier |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/NumericSolver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/NumericSolver.xtend index 44964079..28edff41 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/NumericSolver.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/NumericSolver.xtend | |||
@@ -24,10 +24,12 @@ import java.util.List | |||
24 | import java.util.Map | 24 | import java.util.Map |
25 | import org.eclipse.emf.ecore.EObject | 25 | import org.eclipse.emf.ecore.EObject |
26 | import org.eclipse.viatra.dse.base.ThreadContext | 26 | import org.eclipse.viatra.dse.base.ThreadContext |
27 | import org.eclipse.viatra.dse.objectives.Fitness | ||
27 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | 28 | import org.eclipse.viatra.query.runtime.api.IPatternMatch |
28 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | 29 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher |
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint | 30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint |
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation | 31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation |
32 | import org.eclipse.viatra.dse.objectives.IObjective | ||
31 | 33 | ||
32 | class NumericSolver { | 34 | class NumericSolver { |
33 | val ModelGenerationMethod method | 35 | val ModelGenerationMethod method |
@@ -206,7 +208,6 @@ class NumericSolver { | |||
206 | } | 208 | } |
207 | } else { | 209 | } else { |
208 | if (needsFilling){ | 210 | if (needsFilling){ |
209 | //TODO ASSUME Always True | ||
210 | //GET LIST OF VARS TO FILL | 211 | //GET LIST OF VARS TO FILL |
211 | val fillMap = t.delegateGetSolution(dataObjects, propagatedConstraints, selectSolver(phase)) | 212 | val fillMap = t.delegateGetSolution(dataObjects, propagatedConstraints, selectSolver(phase)) |
212 | if (fillMap === null) finalResult = false | 213 | if (fillMap === null) finalResult = false |
@@ -225,7 +226,9 @@ class NumericSolver { | |||
225 | //STRATEGY | 226 | //STRATEGY |
226 | if (phase == 2) { | 227 | if (phase == 2) { |
227 | if (!finalResult) return finalResult | 228 | if (!finalResult) return finalResult |
228 | else finalResult = isSatisfiable(matches, 3) | 229 | else { |
230 | finalResult = isSatisfiable(matches, 3) | ||
231 | } | ||
229 | } | 232 | } |
230 | return finalResult | 233 | return finalResult |
231 | } | 234 | } |
@@ -243,6 +246,14 @@ class NumericSolver { | |||
243 | // -1 : take all numeric constraints | 246 | // -1 : take all numeric constraints |
244 | // -2 : SKIP (take no numeric constraints) | 247 | // -2 : SKIP (take no numeric constraints) |
245 | if (strategy == ExplorationStrategy.CrossingScenario) { | 248 | if (strategy == ExplorationStrategy.CrossingScenario) { |
249 | // //if has structural (non-WF) fitness issues, skip numeric handling | ||
250 | // val IObjective ob = threadContext.objectives.filter[it instanceof ModelGenerationCompositeObjective].get(0) | ||
251 | // val compo = ob as ModelGenerationCompositeObjective | ||
252 | // if (compo.getNonWFFitness(threadContext) > 0) { | ||
253 | // println("bootleg numeric-skip") | ||
254 | // return -2; | ||
255 | // } | ||
256 | |||
246 | //assumikng standard input, w/ visinBlocked and CollisionExists between pre-included actors | 257 | //assumikng standard input, w/ visinBlocked and CollisionExists between pre-included actors |
247 | val PartialInterpretation head = threadContext.getModel() as PartialInterpretation; | 258 | val PartialInterpretation head = threadContext.getModel() as PartialInterpretation; |
248 | val List<PartialRelationInterpretation> relations = head.getPartialrelationinterpretation(); | 259 | val List<PartialRelationInterpretation> relations = head.getPartialrelationinterpretation(); |
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 1b61ffa5..b5b44254 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 | |||
@@ -37,6 +37,12 @@ class UnfinishedWFObjective implements IObjective { | |||
37 | override getComparator() { Comparators.LOWER_IS_BETTER } | 37 | override getComparator() { Comparators.LOWER_IS_BETTER } |
38 | 38 | ||
39 | override getFitness(ThreadContext context) { | 39 | override getFitness(ThreadContext context) { |
40 | // //MEGA ASSUMPTION Below TODO | ||
41 | // //if has no unfilled variables, return 0 | ||
42 | // val model = context.getModel as PartialInterpretation | ||
43 | // val unfilledDataObjects = model.newElements.filter(PrimitiveElement).filter[!model.openWorldElements.contains(it)].filter[!it.isValueSet].toList | ||
44 | // if (unfilledDataObjects.isEmpty) return 0.0 | ||
45 | |||
40 | var sumOfMatches = 0 | 46 | var sumOfMatches = 0 |
41 | for (matcher : matchers) { | 47 | for (matcher : matchers) { |
42 | val number = matcher.countMatches | 48 | val number = matcher.countMatches |