diff options
author | 2020-07-07 15:00:13 +0200 | |
---|---|---|
committer | 2020-07-07 15:00:13 +0200 | |
commit | a7b9a3eef14fc165909d00c65bb6fc1744a8ebd8 (patch) | |
tree | dd816939088926b3009432afa22be0e2a116436f /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend | |
parent | Add modified VIATRA-DSE version (diff) | |
download | VIATRA-Generator-a7b9a3eef14fc165909d00c65bb6fc1744a8ebd8.tar.gz VIATRA-Generator-a7b9a3eef14fc165909d00c65bb6fc1744a8ebd8.tar.zst VIATRA-Generator-a7b9a3eef14fc165909d00c65bb6fc1744a8ebd8.zip |
Trying to fix performance regressions
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend index 481f4ce1..27208cf4 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend | |||
@@ -9,13 +9,13 @@ import java.util.List | |||
9 | import org.eclipse.viatra.dse.base.ThreadContext | 9 | import org.eclipse.viatra.dse.base.ThreadContext |
10 | import org.eclipse.viatra.dse.objectives.Comparators | 10 | import org.eclipse.viatra.dse.objectives.Comparators |
11 | import org.eclipse.viatra.dse.objectives.IObjective | 11 | import org.eclipse.viatra.dse.objectives.IObjective |
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PrimitiveElement | ||
12 | 13 | ||
13 | class ModelGenerationCompositeObjective implements IThreeValuedObjective { | 14 | class ModelGenerationCompositeObjective implements IThreeValuedObjective { |
14 | val IObjective scopeObjective | 15 | val IObjective scopeObjective |
15 | val List<UnfinishedMultiplicityObjective> unfinishedMultiplicityObjectives | 16 | val List<UnfinishedMultiplicityObjective> unfinishedMultiplicityObjectives |
16 | val UnfinishedWFObjective unfinishedWFObjective | 17 | val UnfinishedWFObjective unfinishedWFObjective |
17 | var PartialInterpretation model = null | 18 | var PartialInterpretation model = null |
18 | val boolean punishSize | ||
19 | val int scopeWeight | 19 | val int scopeWeight |
20 | val int conaintmentWeight | 20 | val int conaintmentWeight |
21 | val int nonContainmentWeight | 21 | val int nonContainmentWeight |
@@ -28,7 +28,7 @@ class ModelGenerationCompositeObjective implements IThreeValuedObjective { | |||
28 | ViatraReasonerConfiguration configuration) | 28 | ViatraReasonerConfiguration configuration) |
29 | { | 29 | { |
30 | this( | 30 | this( |
31 | scopeObjective, unfinishedMultiplicityObjectives, unfinishedWFObjective, configuration.punishSize, | 31 | scopeObjective, unfinishedMultiplicityObjectives, unfinishedWFObjective, |
32 | configuration.scopeWeight, configuration.conaintmentWeight, configuration.nonContainmentWeight, | 32 | configuration.scopeWeight, configuration.conaintmentWeight, configuration.nonContainmentWeight, |
33 | configuration.unfinishedWFWeight | 33 | configuration.unfinishedWFWeight |
34 | ) | 34 | ) |
@@ -38,13 +38,12 @@ class ModelGenerationCompositeObjective implements IThreeValuedObjective { | |||
38 | IObjective scopeObjective, | 38 | IObjective scopeObjective, |
39 | List<UnfinishedMultiplicityObjective> unfinishedMultiplicityObjectives, | 39 | List<UnfinishedMultiplicityObjective> unfinishedMultiplicityObjectives, |
40 | UnfinishedWFObjective unfinishedWFObjective, | 40 | UnfinishedWFObjective unfinishedWFObjective, |
41 | boolean punishSize, int scopeWeight, int conaintmentWeight, int nonContainmentWeight, int unfinishedWFWeight) | 41 | int scopeWeight, int conaintmentWeight, int nonContainmentWeight, int unfinishedWFWeight) |
42 | { | 42 | { |
43 | this.scopeObjective = scopeObjective | 43 | this.scopeObjective = scopeObjective |
44 | this.unfinishedMultiplicityObjectives = unfinishedMultiplicityObjectives | 44 | this.unfinishedMultiplicityObjectives = unfinishedMultiplicityObjectives |
45 | this.unfinishedWFObjective = unfinishedWFObjective | 45 | this.unfinishedWFObjective = unfinishedWFObjective |
46 | 46 | ||
47 | this.punishSize = punishSize | ||
48 | this.scopeWeight = scopeWeight | 47 | this.scopeWeight = scopeWeight |
49 | this.conaintmentWeight = conaintmentWeight | 48 | this.conaintmentWeight = conaintmentWeight |
50 | this.nonContainmentWeight = nonContainmentWeight | 49 | this.nonContainmentWeight = nonContainmentWeight |
@@ -63,7 +62,7 @@ class ModelGenerationCompositeObjective implements IThreeValuedObjective { | |||
63 | scopeObjective.createNew, | 62 | scopeObjective.createNew, |
64 | ImmutableList.copyOf(unfinishedMultiplicityObjectives.map[createNew as UnfinishedMultiplicityObjective]), | 63 | ImmutableList.copyOf(unfinishedMultiplicityObjectives.map[createNew as UnfinishedMultiplicityObjective]), |
65 | unfinishedWFObjective.createNew as UnfinishedWFObjective, | 64 | unfinishedWFObjective.createNew as UnfinishedWFObjective, |
66 | punishSize, scopeWeight, conaintmentWeight, nonContainmentWeight, unfinishedWFWeight | 65 | scopeWeight, conaintmentWeight, nonContainmentWeight, unfinishedWFWeight |
67 | ) | 66 | ) |
68 | } | 67 | } |
69 | 68 | ||
@@ -77,16 +76,14 @@ class ModelGenerationCompositeObjective implements IThreeValuedObjective { | |||
77 | var containmentMultiplicity = 0.0 | 76 | var containmentMultiplicity = 0.0 |
78 | var nonContainmentMultiplicity = 0.0 | 77 | var nonContainmentMultiplicity = 0.0 |
79 | for(multiplicityObjective : unfinishedMultiplicityObjectives) { | 78 | for(multiplicityObjective : unfinishedMultiplicityObjectives) { |
79 | val multiplicity = multiplicityObjective.getFitness(context) | ||
80 | // println(multiplicityObjective.name + "=" + multiplicity) | ||
80 | if(multiplicityObjective.containment) { | 81 | if(multiplicityObjective.containment) { |
81 | containmentMultiplicity+=multiplicityObjective.getFitness(context) | 82 | containmentMultiplicity+=multiplicity |
82 | } else { | 83 | } else { |
83 | nonContainmentMultiplicity+=multiplicityObjective.getFitness(context) | 84 | nonContainmentMultiplicity+=multiplicity |
84 | } | 85 | } |
85 | } | 86 | |
86 | val size = if(punishSize) { | ||
87 | 0.9/model.newElements.size | ||
88 | } else { | ||
89 | 0 | ||
90 | } | 87 | } |
91 | 88 | ||
92 | var sum = 0.0 | 89 | var sum = 0.0 |
@@ -94,7 +91,9 @@ class ModelGenerationCompositeObjective implements IThreeValuedObjective { | |||
94 | sum += containmentMultiplicity*conaintmentWeight | 91 | sum += containmentMultiplicity*conaintmentWeight |
95 | sum += nonContainmentMultiplicity*nonContainmentWeight | 92 | sum += nonContainmentMultiplicity*nonContainmentWeight |
96 | sum += unfinishedWFsFitness*unfinishedWFWeight | 93 | sum += unfinishedWFsFitness*unfinishedWFWeight |
97 | sum+=size | 94 | |
95 | // println('''scope=«scopeFitnes», containment=«containmentMultiplicity», nonContainment=«nonContainmentMultiplicity», wf=«unfinishedWFsFitness», sum=«sum»''') | ||
96 | |||
98 | return sum | 97 | return sum |
99 | } | 98 | } |
100 | 99 | ||
@@ -112,7 +111,7 @@ class ModelGenerationCompositeObjective implements IThreeValuedObjective { | |||
112 | 111 | ||
113 | override isHardObjective() { true } | 112 | override isHardObjective() { true } |
114 | 113 | ||
115 | override satisifiesHardObjective(Double fitness) { fitness <= 0.9 } | 114 | override satisifiesHardObjective(Double fitness) { fitness < 0.01 } |
116 | 115 | ||
117 | override setComparator(Comparator<Double> comparator) { | 116 | override setComparator(Comparator<Double> comparator) { |
118 | throw new UnsupportedOperationException("Model generation objective comparator cannot be set.") | 117 | throw new UnsupportedOperationException("Model generation objective comparator cannot be set.") |