blob: af6d1bbdc29793d5ab16ac2c3287764943799701 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse
import com.google.common.collect.ImmutableList
import java.util.Comparator
import java.util.List
import org.eclipse.viatra.dse.base.ThreadContext
import org.eclipse.viatra.dse.objectives.Comparators
import org.eclipse.viatra.dse.objectives.IObjective
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
//class ViatraReasonerNumbers {
// public static val scopePriority = 2
// public static val unfinishedMultiplicityPriority = 2
// public static val unifinshedWFPriority = 2
// //public static val complexityPriority = 4
//
// public static val scopeWeigth = 1.0
// public static val unfinishedMultiplicityWeigth = 1.5
// public static val unfinishedWFWeigth = 1.5
// //public static val complexityWeigth = 0.1
//
// public static val useCompositeObjective = true
// public static val compositePriority = 2
//}
@FinalFieldsConstructor
class ModelGenerationCompositeObjective implements IThreeValuedObjective {
val IObjective scopeObjective
val List<IObjective> unfinishedMultiplicityObjectives
val IObjective unfinishedWFObjective
override init(ThreadContext context) {
this.scopeObjective.init(context)
this.unfinishedMultiplicityObjectives.forEach[it.init(context)]
this.unfinishedWFObjective.init(context)
}
override createNew() {
return new ModelGenerationCompositeObjective(
scopeObjective.createNew,
ImmutableList.copyOf(unfinishedMultiplicityObjectives.map[createNew]),
unfinishedWFObjective.createNew
)
}
override getComparator() { Comparators.LOWER_IS_BETTER }
override getFitness(ThreadContext context) {
var sum = 0.0
val scopeFitnes = scopeObjective.getFitness(context)
// val unfinishedMultiplicitiesFitneses = unfinishedMultiplicityObjectives.map[x|x.getFitness(context)]
val unfinishedWFsFitness = unfinishedWFObjective.getFitness(context)
sum += scopeFitnes
var multiplicity = 0.0
for (multiplicityObjective : unfinishedMultiplicityObjectives) {
multiplicity += multiplicityObjective.getFitness(context) // *0.5
}
sum += multiplicity
sum += unfinishedWFsFitness // *0.5
// println('''Sum=«sum»|Scope=«scopeFitnes»|Multiplicity=«multiplicity»|WFs=«unfinishedWFsFitness»''')
return sum
}
override getWorstPossibleFitness(ThreadContext threadContext) {
Double.POSITIVE_INFINITY
}
override getBestPossibleFitness(ThreadContext threadContext) {
0.0
}
override getLevel() { 2 }
override getName() { "CompositeUnfinishednessObjective" }
override isHardObjective() { true }
override satisifiesHardObjective(Double fitness) { fitness <= 0.001 }
override setComparator(Comparator<Double> comparator) {
throw new UnsupportedOperationException("Model generation objective comparator cannot be set.")
}
override setLevel(int level) {
throw new UnsupportedOperationException("Model generation objective level cannot be set.")
}
}
|