diff options
author | 2019-04-07 13:46:36 +0200 | |
---|---|---|
committer | 2019-04-07 13:46:36 +0200 | |
commit | 3f9b1c92cc35fa4ed9672a2b8601f4c22af24921 (patch) | |
tree | 927c41492ff3b50b3d998a4fbe87861187d85912 /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend | |
parent | Add reliability probability and mtff objectives (diff) | |
download | VIATRA-Generator-3f9b1c92cc35fa4ed9672a2b8601f4c22af24921.tar.gz VIATRA-Generator-3f9b1c92cc35fa4ed9672a2b8601f4c22af24921.tar.zst VIATRA-Generator-3f9b1c92cc35fa4ed9672a2b8601f4c22af24921.zip |
Infrastructure for objective functions
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 | 77 |
1 files changed, 40 insertions, 37 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 2489c751..af6d1bbd 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 | |||
@@ -1,11 +1,12 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse |
2 | 2 | ||
3 | import com.google.common.collect.ImmutableList | ||
3 | import java.util.Comparator | 4 | import java.util.Comparator |
4 | import java.util.List | 5 | import java.util.List |
5 | import org.eclipse.viatra.dse.base.ThreadContext | 6 | import org.eclipse.viatra.dse.base.ThreadContext |
6 | import org.eclipse.viatra.dse.objectives.Comparators | 7 | import org.eclipse.viatra.dse.objectives.Comparators |
7 | import org.eclipse.viatra.dse.objectives.IObjective | 8 | import org.eclipse.viatra.dse.objectives.IObjective |
8 | import org.eclipse.viatra.dse.objectives.impl.BaseObjective | 9 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor |
9 | 10 | ||
10 | //class ViatraReasonerNumbers { | 11 | //class ViatraReasonerNumbers { |
11 | // public static val scopePriority = 2 | 12 | // public static val scopePriority = 2 |
@@ -22,64 +23,66 @@ import org.eclipse.viatra.dse.objectives.impl.BaseObjective | |||
22 | // public static val compositePriority = 2 | 23 | // public static val compositePriority = 2 |
23 | //} | 24 | //} |
24 | 25 | ||
25 | class ModelGenerationCompositeObjective implements IObjective{ | 26 | @FinalFieldsConstructor |
26 | val ScopeObjective scopeObjective | 27 | class ModelGenerationCompositeObjective implements IThreeValuedObjective { |
27 | val List<UnfinishedMultiplicityObjective> unfinishedMultiplicityObjectives | 28 | val IObjective scopeObjective |
28 | val UnfinishedWFObjective unfinishedWFObjective | 29 | val List<IObjective> unfinishedMultiplicityObjectives |
29 | 30 | val IObjective unfinishedWFObjective | |
30 | public new( | 31 | |
31 | ScopeObjective scopeObjective, | ||
32 | List<UnfinishedMultiplicityObjective> unfinishedMultiplicityObjectives, | ||
33 | UnfinishedWFObjective unfinishedWFObjective) | ||
34 | { | ||
35 | this.scopeObjective = scopeObjective | ||
36 | this.unfinishedMultiplicityObjectives = unfinishedMultiplicityObjectives | ||
37 | this.unfinishedWFObjective = unfinishedWFObjective | ||
38 | } | ||
39 | |||
40 | override init(ThreadContext context) { | 32 | override init(ThreadContext context) { |
41 | this.scopeObjective.init(context) | 33 | this.scopeObjective.init(context) |
42 | this.unfinishedMultiplicityObjectives.forEach[it.init(context)] | 34 | this.unfinishedMultiplicityObjectives.forEach[it.init(context)] |
43 | this.unfinishedWFObjective.init(context) | 35 | this.unfinishedWFObjective.init(context) |
44 | } | 36 | } |
45 | 37 | ||
46 | override createNew() { | 38 | override createNew() { |
47 | return new ModelGenerationCompositeObjective( | 39 | return new ModelGenerationCompositeObjective( |
48 | this.scopeObjective, this.unfinishedMultiplicityObjectives, this.unfinishedWFObjective) | 40 | scopeObjective.createNew, |
41 | ImmutableList.copyOf(unfinishedMultiplicityObjectives.map[createNew]), | ||
42 | unfinishedWFObjective.createNew | ||
43 | ) | ||
49 | } | 44 | } |
50 | 45 | ||
51 | override getComparator() { Comparators.LOWER_IS_BETTER } | 46 | override getComparator() { Comparators.LOWER_IS_BETTER } |
47 | |||
52 | override getFitness(ThreadContext context) { | 48 | override getFitness(ThreadContext context) { |
53 | var sum = 0.0 | 49 | var sum = 0.0 |
54 | val scopeFitnes = scopeObjective.getFitness(context) | 50 | val scopeFitnes = scopeObjective.getFitness(context) |
55 | //val unfinishedMultiplicitiesFitneses = unfinishedMultiplicityObjectives.map[x|x.getFitness(context)] | 51 | // val unfinishedMultiplicitiesFitneses = unfinishedMultiplicityObjectives.map[x|x.getFitness(context)] |
56 | val unfinishedWFsFitness = unfinishedWFObjective.getFitness(context) | 52 | val unfinishedWFsFitness = unfinishedWFObjective.getFitness(context) |
57 | 53 | ||
58 | sum+=scopeFitnes | 54 | sum += scopeFitnes |
59 | var multiplicity = 0.0 | 55 | var multiplicity = 0.0 |
60 | for(multiplicityObjective : unfinishedMultiplicityObjectives) { | 56 | for (multiplicityObjective : unfinishedMultiplicityObjectives) { |
61 | multiplicity+=multiplicityObjective.getFitness(context)//*0.5 | 57 | multiplicity += multiplicityObjective.getFitness(context) // *0.5 |
62 | } | 58 | } |
63 | sum+=multiplicity | 59 | sum += multiplicity |
64 | sum += unfinishedWFsFitness//*0.5 | 60 | sum += unfinishedWFsFitness // *0.5 |
65 | 61 | // println('''Sum=«sum»|Scope=«scopeFitnes»|Multiplicity=«multiplicity»|WFs=«unfinishedWFsFitness»''') | |
66 | //println('''Sum=«sum»|Scope=«scopeFitnes»|Multiplicity=«multiplicity»|WFs=«unfinishedWFsFitness»''') | ||
67 | |||
68 | return sum | 62 | return sum |
69 | } | 63 | } |
70 | 64 | ||
71 | override getLevel() { 2 } | 65 | override getWorstPossibleFitness(ThreadContext threadContext) { |
72 | override getName() { "CompositeUnfinishednessObjective"} | 66 | Double.POSITIVE_INFINITY |
67 | } | ||
73 | 68 | ||
69 | override getBestPossibleFitness(ThreadContext threadContext) { | ||
70 | 0.0 | ||
71 | } | ||
72 | |||
73 | override getLevel() { 2 } | ||
74 | |||
75 | override getName() { "CompositeUnfinishednessObjective" } | ||
76 | |||
74 | override isHardObjective() { true } | 77 | override isHardObjective() { true } |
78 | |||
75 | override satisifiesHardObjective(Double fitness) { fitness <= 0.001 } | 79 | override satisifiesHardObjective(Double fitness) { fitness <= 0.001 } |
76 | 80 | ||
77 | |||
78 | override setComparator(Comparator<Double> comparator) { | 81 | override setComparator(Comparator<Double> comparator) { |
79 | throw new UnsupportedOperationException("TODO: auto-generated method stub") | 82 | throw new UnsupportedOperationException("Model generation objective comparator cannot be set.") |
80 | } | 83 | } |
84 | |||
81 | override setLevel(int level) { | 85 | override setLevel(int level) { |
82 | throw new UnsupportedOperationException("TODO: auto-generated method stub") | 86 | throw new UnsupportedOperationException("Model generation objective level cannot be set.") |
83 | } | 87 | } |
84 | 88 | } | |
85 | } \ No newline at end of file | ||