-
Notifications
You must be signed in to change notification settings - Fork 65
/
SMarkDeltaBlue.class.st
100 lines (79 loc) · 2.65 KB
/
SMarkDeltaBlue.class.st
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
89
90
91
92
93
94
95
96
97
98
99
100
"
One-way constraint solver Benchmark. The main focus in DeltaBlue is on polymorphism and object-oriented programming
To run the benchmark, execute the expression 'SMarkDeltaBlue run: 10'.
"
Class {
#name : #SMarkDeltaBlue,
#superclass : #SMarkSuite,
#category : #'CogBenchmarks-DeltaBlue'
}
{ #category : #benchmarking }
SMarkDeltaBlue >> benchDeltaBlue [
"This the combined benchmark."
| n |
n := self problemSize.
DBStrength initialize.
self doChain: n.
self doProjection: n
]
{ #category : #defaults }
SMarkDeltaBlue >> defaultProblemSize [
^ 20000
]
{ #category : #benchmarking }
SMarkDeltaBlue >> doChain: n [
| vars editConstraint plan planner |
planner := DBPlanner new.
vars := (1 to: n+1) collect: [ :i | DBVariable new].
"thread a chain of equality constraints through the variables"
1 to: n do:
[ :i || v1 v2 |
v1 := vars at: i.
v2 := vars at: i + 1.
DBEqualityConstraint var: v1 var: v2 strength: #required].
DBStayConstraint var: vars last strength: #strongDefault.
editConstraint := DBEditConstraint var: (vars first) strength: #preferred.
plan := planner extractPlanFromConstraints: (Array with: editConstraint).
1 to: 100 do: [ :v |
vars first value: v.
plan execute.
vars last value ~= v ifTrue: [self error: 'Chain test failed!!']].
editConstraint destroyConstraint
]
{ #category : #benchmarking }
SMarkDeltaBlue >> doProjection: n [
"This test constructs a two sets of variables related to each other by
a simple linear transformation (scale and offset)."
| scale offset src dst planner dests |
planner := DBPlanner new.
dests := OrderedCollection new.
scale := DBVariable value: 10.
offset := DBVariable value: 1000.
1 to: n do:
[ :i |
src := DBVariable value: i.
dst := DBVariable value: i.
dests add: dst.
DBStayConstraint var: src strength: #default.
DBScaleConstraint var: src var: scale var: offset var: dst strength: #required].
planner changeVar: src newValue: 17.
dst value ~= 1170 ifTrue: [self error: 'Projection test 1 failed!!'].
planner changeVar: dst newValue: 1050.
src value ~= 5 ifTrue: [self error: 'Projection test 2 failed!!'].
planner changeVar: scale newValue: 5.
1 to: n - 1 do: [ :i |
(dests at: i) value ~= (i*5 + 1000)
ifTrue: [self error: 'Projection test 3 failed!!']].
planner changeVar: offset newValue: 2000.
1 to: n - 1 do: [ :i |
(dests at: i) value ~= (i*5 + 2000)
ifTrue: [self error: 'Projection test 4 failed!!']].
]
{ #category : #accessing }
SMarkDeltaBlue >> problemSize [
<omniUnenforced> "Hint for the OMOP that it is part of the meta infrastructure"
| ps |
ps := super problemSize.
ps isInteger ifFalse: [ ^ self defaultProblemSize].
^ ps
]