diff options
author | 2020-07-07 17:48:54 +0200 | |
---|---|---|
committer | 2020-07-07 17:48:54 +0200 | |
commit | b13b083b683d28365f4956bae1c6e3e7ac8fab1c (patch) | |
tree | 1701a775a2e18ac83be4b28146069382dd09ddae /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/PunishSizeObjective.xtend | |
parent | Trying to fix performance regressions (diff) | |
download | VIATRA-Generator-b13b083b683d28365f4956bae1c6e3e7ac8fab1c.tar.gz VIATRA-Generator-b13b083b683d28365f4956bae1c6e3e7ac8fab1c.tar.zst VIATRA-Generator-b13b083b683d28365f4956bae1c6e3e7ac8fab1c.zip |
Restore inverse punishSize
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/PunishSizeObjective.xtend')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/PunishSizeObjective.xtend | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/PunishSizeObjective.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/PunishSizeObjective.xtend index 8505661c..bad8e4d1 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/PunishSizeObjective.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/PunishSizeObjective.xtend | |||
@@ -2,28 +2,27 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse | |||
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PrimitiveElement | 4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PrimitiveElement |
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.IThreeValuedObjective | 5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.AbstractThreeValuedObjective |
6 | import java.util.Comparator | 6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind |
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold | ||
7 | import org.eclipse.viatra.dse.base.ThreadContext | 8 | import org.eclipse.viatra.dse.base.ThreadContext |
8 | import org.eclipse.viatra.dse.objectives.Comparators | ||
9 | import org.eclipse.xtend.lib.annotations.Accessors | ||
10 | 9 | ||
11 | class PunishSizeObjective implements IThreeValuedObjective { | 10 | class PunishSizeObjective extends AbstractThreeValuedObjective { |
12 | @Accessors int level = 3 | 11 | static val NAME = typeof(PunishSizeObjective).name |
12 | |||
13 | new(ObjectiveKind kind, int level) { | ||
14 | super(NAME, kind, ObjectiveThreshold.NO_THRESHOLD, level) | ||
15 | } | ||
13 | 16 | ||
14 | override createNew() { | 17 | override createNew() { |
15 | this | 18 | new PunishSizeObjective(kind, level) |
16 | } | 19 | } |
17 | 20 | ||
18 | override init(ThreadContext context) { | 21 | override init(ThreadContext context) { |
19 | // Nothing to initialize. | 22 | // Nothing to initialize. |
20 | } | 23 | } |
21 | 24 | ||
22 | override getComparator() { | 25 | override getRawFitness(ThreadContext threadContext) { |
23 | Comparators.LOWER_IS_BETTER | ||
24 | } | ||
25 | |||
26 | override getFitness(ThreadContext threadContext) { | ||
27 | val model = threadContext.model | 26 | val model = threadContext.model |
28 | if (model instanceof PartialInterpretation) { | 27 | if (model instanceof PartialInterpretation) { |
29 | val size = model.newObjectCount | 28 | val size = model.newObjectCount |
@@ -34,11 +33,11 @@ class PunishSizeObjective implements IThreeValuedObjective { | |||
34 | } | 33 | } |
35 | } | 34 | } |
36 | 35 | ||
37 | override getBestPossibleFitness(ThreadContext threadContext) { | 36 | override getLowestPossibleFitness(ThreadContext threadContext) { |
38 | getFitness(threadContext) | 37 | getRawFitness(threadContext) |
39 | } | 38 | } |
40 | 39 | ||
41 | override getWorstPossibleFitness(ThreadContext threadContext) { | 40 | override getHighestPossibleFitness(ThreadContext threadContext) { |
42 | val model = threadContext.model | 41 | val model = threadContext.model |
43 | if (model instanceof PartialInterpretation) { | 42 | if (model instanceof PartialInterpretation) { |
44 | (model.newObjectCount + model.maxNewElements) as double | 43 | (model.newObjectCount + model.maxNewElements) as double |
@@ -50,21 +49,4 @@ class PunishSizeObjective implements IThreeValuedObjective { | |||
50 | private def getNewObjectCount(PartialInterpretation interpretation) { | 49 | private def getNewObjectCount(PartialInterpretation interpretation) { |
51 | interpretation.newElements.reject[it instanceof PrimitiveElement].size | 50 | interpretation.newElements.reject[it instanceof PrimitiveElement].size |
52 | } | 51 | } |
53 | |||
54 | override getName() { | ||
55 | typeof(PunishSizeObjective).name | ||
56 | } | ||
57 | |||
58 | override isHardObjective() { | ||
59 | false | ||
60 | } | ||
61 | |||
62 | override satisifiesHardObjective(Double fitness) { | ||
63 | true | ||
64 | } | ||
65 | |||
66 | override setComparator(Comparator<Double> comparator) { | ||
67 | throw new UnsupportedOperationException("Model generation objective comparator cannot be set.") | ||
68 | } | ||
69 | |||
70 | } \ No newline at end of file | 52 | } \ No newline at end of file |