Skip to content

Commit d3193c0

Browse files
authored
Merge pull request #333 from DurieuxPol/fix/redTests
Fixed remaining red tests
2 parents c9005cb + e666a48 commit d3193c0

25 files changed

Lines changed: 344 additions & 391 deletions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Extension { #name : #Collection }
1+
Extension { #name : 'Collection' }
22

3-
{ #category : #'*Math-FunctionFit' }
3+
{ #category : '*Math-FunctionFit' }
44
Collection >> norm [
55
^(self*self)sum sqrt
66
]

src/Math-FunctionFit/PMAnotherChromosomeManager.class.st

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ AnotherChromosomeManager implements more specific operations for Floats.
33
Is used by AnotherGeneticOptimizer
44
"
55
Class {
6-
#name : #PMAnotherChromosomeManager,
7-
#superclass : #PMVectorChromosomeManager,
6+
#name : 'PMAnotherChromosomeManager',
7+
#superclass : 'PMVectorChromosomeManager',
88
#instVars : [
99
'hammersley',
1010
'rateOfLC',
@@ -14,10 +14,11 @@ Class {
1414
#classVars : [
1515
'Primes'
1616
],
17-
#category : #'Math-FunctionFit'
17+
#category : 'Math-FunctionFit',
18+
#package : 'Math-FunctionFit'
1819
}
1920

20-
{ #category : #utilities }
21+
{ #category : 'utilities' }
2122
PMAnotherChromosomeManager class >> integerDigitsFor: anInteger base: aBase [
2223
| n integer next result |
2324
"n:=(anInteger ln / aBase ln) floor ." "does not always work because of floating point errors. next 2 lines are better"
@@ -33,7 +34,7 @@ PMAnotherChromosomeManager class >> integerDigitsFor: anInteger base: aBase [
3334
^result
3435
]
3536

36-
{ #category : #utilities }
37+
{ #category : 'utilities' }
3738
PMAnotherChromosomeManager class >> numberOfHamersleyPoints: n dimension: d randomGenerator: randomGenerator [
3839
"a bit randomized "
3940

@@ -59,12 +60,12 @@ PMAnotherChromosomeManager class >> numberOfHamersleyPoints: n dimension: d rand
5960
ifNil: [ sum ] ] ] ]
6061
]
6162

62-
{ #category : #'instance creation' }
63+
{ #category : 'instance creation' }
6364
PMAnotherChromosomeManager class >> origin: anArray range: anotherArray [
6465
^self new origin: anArray; range: anotherArray; yourself
6566
]
6667

67-
{ #category : #operation }
68+
{ #category : 'operation' }
6869
PMAnotherChromosomeManager >> crossover: aChromosome1 and: aChromosome2 [
6970
"the Discrete Recombination operator
7071
that does not prefer schemata of certain parameters based on their position"
@@ -86,7 +87,7 @@ that does not prefer schemata of certain parameters based on their position"
8687
^ Array with: new1 with: new2
8788
]
8889

89-
{ #category : #operation }
90+
{ #category : 'operation' }
9091
PMAnotherChromosomeManager >> eirCrossover: aChromosome1 and: aChromosome2 [
9192
"the Extended Intermediate Recombination 0.5 operator, slightly changed to make it more similar to linecrossover (distribution is more centered around Chromosome1, which is better than C2)"
9293
| randomNumbers new1 new2 dif |
@@ -108,7 +109,7 @@ PMAnotherChromosomeManager >> eirCrossover: aChromosome1 and: aChromosome2 [
108109
^ { new1 . new2 }
109110
]
110111

111-
{ #category : #initialization }
112+
{ #category : 'initialization' }
112113
PMAnotherChromosomeManager >> initialize [
113114

114115
super initialize.
@@ -121,13 +122,13 @@ PMAnotherChromosomeManager >> initialize [
121122
Primes ifNil: [ Primes := Integer primesUpTo: 500 ] "sufficient for up to 95 dimensions (parameters)"
122123
]
123124

124-
{ #category : #information }
125+
{ #category : 'information' }
125126
PMAnotherChromosomeManager >> isFullyPopulated [
126127
population ifNil: [^false].
127128
^super isFullyPopulated
128129
]
129130

130-
{ #category : #operation }
131+
{ #category : 'operation' }
131132
PMAnotherChromosomeManager >> lineCrossOver: aChromosome1 and: aChromosome2 [
132133
"BGA Line Recombination; expects C1 to be better than C2, which is not correct at the moment, need to change that!!! mhm i think i did that."
133134
| new1 new2 line norm|
@@ -140,7 +141,7 @@ PMAnotherChromosomeManager >> lineCrossOver: aChromosome1 and: aChromosome2 [
140141
^Array with: new1 with: new2
141142
]
142143

143-
{ #category : #operation }
144+
{ #category : 'operation' }
144145
PMAnotherChromosomeManager >> mutate: aVector [
145146
"BGA mutation"
146147
| isMutated threshold new index |
@@ -163,13 +164,13 @@ PMAnotherChromosomeManager >> mutate: aVector [
163164
^ new
164165
]
165166

166-
{ #category : #accessing }
167+
{ #category : 'accessing' }
167168
PMAnotherChromosomeManager >> populationSize [
168169
"AnotherGeneticOptimizer needs these data"
169170
^populationSize
170171
]
171172

172-
{ #category : #printing }
173+
{ #category : 'printing' }
173174
PMAnotherChromosomeManager >> printOn: aStream [
174175
aStream
175176
nextPutAll: self class name;
@@ -184,7 +185,7 @@ PMAnotherChromosomeManager >> printOn: aStream [
184185
nextPut: $)
185186
]
186187

187-
{ #category : #operation }
188+
{ #category : 'operation' }
188189
PMAnotherChromosomeManager >> process: aChromosome1 and: aChromosome2 [
189190
| roll |
190191
roll := randomNumberGenerator next.
@@ -208,78 +209,78 @@ PMAnotherChromosomeManager >> process: aChromosome1 and: aChromosome2 [
208209
add: (self clone: aChromosome2)]]]]
209210
]
210211

211-
{ #category : #accessing }
212+
{ #category : 'accessing' }
212213
PMAnotherChromosomeManager >> randomGenerator [
213214

214215
^ randomGenerator
215216
]
216217

217-
{ #category : #accessing }
218+
{ #category : 'accessing' }
218219
PMAnotherChromosomeManager >> randomGenerator: anObject [
219220

220221
randomGenerator := anObject
221222
]
222223

223-
{ #category : #private }
224+
{ #category : 'private' }
224225
PMAnotherChromosomeManager >> randomRangeAt: aPosition [
225226
^(range at: aPosition )*(self smallDistribution )
226227
]
227228

228-
{ #category : #operation }
229+
{ #category : 'operation' }
229230
PMAnotherChromosomeManager >> randomizePopulation [
230231

231232
hammersley ifFalse: [ ^ super randomizePopulation ].
232233
population := self class numberOfHamersleyPoints: populationSize dimension: origin size randomGenerator: (self randomGenerator ifNil: [ Random new ]).
233234
population := population collect: [ :aChr | aChr * range + origin ]
234235
]
235236

236-
{ #category : #accessing }
237+
{ #category : 'accessing' }
237238
PMAnotherChromosomeManager >> range [
238239
"AnotherGeneticOptimizer needs these data"
239240
^range
240241
]
241242

242-
{ #category : #initialization }
243+
{ #category : 'initialization' }
243244
PMAnotherChromosomeManager >> rateOfCrossover: aNumber [
244245

245246
self testRate: aNumber oldRate: rateOfCrossover name: 'rateOfCrossover'.
246247
rateOfCrossover := aNumber
247248
]
248249

249-
{ #category : #initialization }
250+
{ #category : 'initialization' }
250251
PMAnotherChromosomeManager >> rateOfEir: aNumber [
251252

252253
self testRate: aNumber oldRate: rateOfEir name: 'rateOfEir'.
253254
rateOfEir := aNumber
254255
]
255256

256-
{ #category : #initialization }
257+
{ #category : 'initialization' }
257258
PMAnotherChromosomeManager >> rateOfLC: aNumber [
258259

259260
self testRate: aNumber oldRate: rateOfLC name: 'rateOfLC'.
260261
rateOfLC := aNumber
261262
]
262263

263-
{ #category : #initialization }
264+
{ #category : 'initialization' }
264265
PMAnotherChromosomeManager >> rateOfMutation: aNumber [
265266
self testRate: aNumber oldRate: rateOfMutation name: 'rateOfMutation'.
266267
rateOfMutation := aNumber
267268
]
268269

269-
{ #category : #private }
270+
{ #category : 'private' }
270271
PMAnotherChromosomeManager >> smallDistribution [
271272
"an exponential distribution as used by H. Mühlenbein"
272273
^ 2 raisedTo: (16 * randomNumberGenerator next negated)
273274
]
274275

275-
{ #category : #private }
276+
{ #category : 'private' }
276277
PMAnotherChromosomeManager >> testRate:aFloat oldRate: asecondFloat name:aString [
277278
(aFloat between: 0 and: 1) ifFalse: [(DomainError new)from:0;to:1;messageText: 'Value outside [0 , 1]';signalIn: thisContext sender].
278279
(rateOfCrossover + rateOfMutation + rateOfLC + rateOfEir + aFloat - asecondFloat)>1.000000000000001 "for Float inaccuracies"
279280
ifTrue: [Warning signal:'All rates together are higher than 1, if ' , aString, ' is set to ',aFloat asString ]
280281
]
281282

282-
{ #category : #initialization }
283+
{ #category : 'initialization' }
283284
PMAnotherChromosomeManager >> useHammersley: aBoolean [
284285
"default is true"
285286
hammersley :=aBoolean

0 commit comments

Comments
 (0)