@@ -102,44 +102,44 @@ def test_add_individual(self):
102102 self .assertEqual (mlc_repo .count_individual (), 0 )
103103
104104 # add the first individual
105- indiv_id , exists = mlc_repo .add_individual (Individual ("1+1 " ))
105+ indiv_id , exists = mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
106106 self .assertEqual (indiv_id , 1 )
107107 self .assertFalse (exists )
108108 self .assertEqual (mlc_repo .count_individual (), 1 )
109109
110110 # trying to add an Individual with the same value
111- indiv_id , exists = mlc_repo .add_individual (Individual ("1+1 " ))
111+ indiv_id , exists = mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
112112 self .assertEqual (indiv_id , 1 )
113113 self .assertTrue (exists )
114114 self .assertEqual (mlc_repo .count_individual (), 1 )
115115
116116 # adds another individual
117- indiv_id , exists = mlc_repo .add_individual (Individual ("2+2 " ))
117+ indiv_id , exists = mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
118118 self .assertEqual (indiv_id , 2 )
119119 self .assertFalse (exists )
120120 self .assertEqual (mlc_repo .count_individual (), 2 )
121121
122122 def test_get_individuals (self ):
123123 mlc_repo = self .__get_new_repo ()
124- mlc_repo .add_individual (Individual ("1+1 " ))
125- mlc_repo .add_individual (Individual ("2+2 " ))
124+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
125+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
126126
127127 # get individuals
128128 individual = mlc_repo .get_individual (1 )
129- self .assertEqual (individual .get_value (), "1+1 " )
129+ self .assertEqual (individual .get_value (), "(root (+ 1 1)) " )
130130
131131 individual = mlc_repo .get_individual (2 )
132- self .assertEqual (individual .get_value (), "2+2 " )
132+ self .assertEqual (individual .get_value (), "(root (+ 2 2)) " )
133133
134134 # get individual data
135135 data = mlc_repo .get_individual_data (1 )
136136 self .assertEqual (data .get_appearances (), 0 )
137- self .assertEqual (data .get_value (), "1+1 " )
137+ self .assertEqual (data .get_value (), "(root (+ 1 1)) " )
138138 self .assertEqual (data .get_cost_history (), {})
139139
140140 data = mlc_repo .get_individual_data (2 )
141141 self .assertEqual (data .get_appearances (), 0 )
142- self .assertEqual (data .get_value (), "2+2 " )
142+ self .assertEqual (data .get_value (), "(root (+ 2 2)) " )
143143 self .assertEqual (data .get_cost_history (), {})
144144
145145 # invalid id
@@ -152,9 +152,9 @@ def test_get_individuals(self):
152152 def test_add_population (self ):
153153 mlc_repo = self .__get_new_repo ()
154154
155- mlc_repo .add_individual (Individual ("1+1 " ))
156- mlc_repo .add_individual (Individual ("2+2 " ))
157- mlc_repo .add_individual (Individual ("3+3 " ))
155+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
156+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
157+ mlc_repo .add_individual (Individual ("(root (+ 3 3)) " ))
158158 self .assertEqual (mlc_repo .count_individual (), 3 )
159159
160160 p = Population (3 , 0 , Config .get_instance (), mlc_repo )
@@ -194,10 +194,10 @@ def test_get_individual_data(self):
194194 mlc_repo = self .__get_new_repo ()
195195
196196 # add individuals
197- mlc_repo .add_individual (Individual ("1+1 " ))
198- mlc_repo .add_individual (Individual ("2+2 " ))
199- mlc_repo .add_individual (Individual ("3+3 " ))
200- mlc_repo .add_individual (Individual ("4+4 " ))
197+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
198+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
199+ mlc_repo .add_individual (Individual ("(root (+ 3 3)) " ))
200+ mlc_repo .add_individual (Individual ("(root (+ 4 4)) " ))
201201
202202 # first population
203203 p = Population (3 , 0 , Config .get_instance (), mlc_repo )
@@ -219,25 +219,25 @@ def test_get_individual_data(self):
219219
220220 # Individual 1 have two appearances in the first generation
221221 data = mlc_repo .get_individual_data (1 )
222- self .assertEqual (data .get_value (), "1+1 " )
222+ self .assertEqual (data .get_value (), "(root (+ 1 1)) " )
223223 self .assertEqual (data .get_appearances (), 2 )
224224 self .assertEqual (data .get_cost_history (), {1 : [(4.0 , 5 ), (6.0 , 7 )]})
225225
226226 # Individual 2 have two appearances
227227 data = mlc_repo .get_individual_data (2 )
228- self .assertEqual (data .get_value (), "2+2 " )
228+ self .assertEqual (data .get_value (), "(root (+ 2 2)) " )
229229 self .assertEqual (data .get_appearances (), 2 )
230230 self .assertEqual (data .get_cost_history (), {1 : [(5.0 , 6 )], 2 : [(9.0 , 10 )]})
231231
232232 # Individual 3 have one appearances
233233 data = mlc_repo .get_individual_data (3 )
234- self .assertEqual (data .get_value (), "3+3 " )
234+ self .assertEqual (data .get_value (), "(root (+ 3 3)) " )
235235 self .assertEqual (data .get_appearances (), 1 )
236236 self .assertEqual (data .get_cost_history (), {2 : [(7.0 , 8 )]})
237237
238238 # Individual 4 have one appearances
239239 data = mlc_repo .get_individual_data (4 )
240- self .assertEqual (data .get_value (), "4+4 " )
240+ self .assertEqual (data .get_value (), "(root (+ 4 4)) " )
241241 self .assertEqual (data .get_appearances (), 1 )
242242 self .assertEqual (data .get_cost_history (), {2 : [(4.0 , 5 )]})
243243
@@ -252,8 +252,8 @@ def test_update_individual_cost(self):
252252 mlc_repo = self .__get_new_repo ()
253253
254254 # add individuals
255- mlc_repo .add_individual (Individual ("1+1 " ))
256- mlc_repo .add_individual (Individual ("2+2 " ))
255+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
256+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
257257
258258 # add first population
259259 p = Population (3 , 0 , Config .get_instance (), mlc_repo )
@@ -288,8 +288,8 @@ def test_update_individual_cost_in_generation(self):
288288 mlc_repo = self .__get_new_repo ()
289289
290290 # add individuals
291- mlc_repo .add_individual (Individual ("1+1 " ))
292- mlc_repo .add_individual (Individual ("2+2 " ))
291+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
292+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
293293
294294 # add first population
295295 p = Population (3 , 0 , Config .get_instance (), mlc_repo )
@@ -324,8 +324,8 @@ def test_reload_individuals_in_memory_loss_data(self):
324324 mlc_repo = self .__get_new_repo ()
325325
326326 # add individuals
327- mlc_repo .add_individual (Individual ("1+1 " ))
328- mlc_repo .add_individual (Individual ("2+2 " ))
327+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
328+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
329329
330330 # add population
331331 p = Population (3 , 0 , Config .get_instance (), mlc_repo )
@@ -347,8 +347,8 @@ def test_reload_individuals_from_file(self):
347347 mlc_repo = self .__get_new_repo ()
348348
349349 # add individuals
350- mlc_repo .add_individual (Individual ("1+1 " ))
351- mlc_repo .add_individual (Individual ("2+2 " ))
350+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
351+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
352352
353353 # add population
354354 p = Population (3 , 0 , Config .get_instance (), mlc_repo )
@@ -368,10 +368,10 @@ def test_remove_from_population(self):
368368 mlc_repo = self .__get_new_repo ()
369369
370370 # add individuals
371- mlc_repo .add_individual (Individual ("1+1 " ))
372- mlc_repo .add_individual (Individual ("2+2 " ))
373- mlc_repo .add_individual (Individual ("3+3 " ))
374- mlc_repo .add_individual (Individual ("4+4 " ))
371+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
372+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
373+ mlc_repo .add_individual (Individual ("(root (+ 3 3)) " ))
374+ mlc_repo .add_individual (Individual ("(root (+ 4 4)) " ))
375375
376376 # add first population
377377 p = Population (3 , 0 , Config .get_instance (), mlc_repo )
@@ -407,10 +407,10 @@ def test_remove_from_population(self):
407407 self .assertEqual (mlc_repo .count_individual (), 2 )
408408
409409 individual = mlc_repo .get_individual (1 )
410- self .assertEqual (individual .get_value (), "1+1 " )
410+ self .assertEqual (individual .get_value (), "(root (+ 1 1)) " )
411411
412412 individual = mlc_repo .get_individual (2 )
413- self .assertEqual (individual .get_value (), "2+2 " )
413+ self .assertEqual (individual .get_value (), "(root (+ 2 2)) " )
414414
415415 try :
416416 individual = mlc_repo .get_individual (3 )
@@ -422,11 +422,11 @@ def test_remove_population_to(self):
422422 mlc_repo = self .__get_new_repo ()
423423
424424 # add individuals
425- mlc_repo .add_individual (Individual ("1+1 " ))
426- mlc_repo .add_individual (Individual ("2+2 " ))
427- mlc_repo .add_individual (Individual ("3+3 " ))
428- mlc_repo .add_individual (Individual ("4+4 " ))
429- mlc_repo .add_individual (Individual ("5+5 " ))
425+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
426+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
427+ mlc_repo .add_individual (Individual ("(root (+ 3 3)) " ))
428+ mlc_repo .add_individual (Individual ("(root (+ 4 4)) " ))
429+ mlc_repo .add_individual (Individual ("(root (+ 5 5)) " ))
430430
431431 # add population
432432 p = Population (3 , 0 , Config .get_instance (), mlc_repo )
@@ -480,11 +480,11 @@ def test_remove_population_to_clear_generations(self):
480480 mlc_repo = self .__get_new_repo ()
481481
482482 # add individuals
483- mlc_repo .add_individual (Individual ("1+1 " ))
484- mlc_repo .add_individual (Individual ("2+2 " ))
485- mlc_repo .add_individual (Individual ("3+3 " ))
486- mlc_repo .add_individual (Individual ("4+4 " ))
487- mlc_repo .add_individual (Individual ("5+5 " ))
483+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
484+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
485+ mlc_repo .add_individual (Individual ("(root (+ 3 3)) " ))
486+ mlc_repo .add_individual (Individual ("(root (+ 4 4)) " ))
487+ mlc_repo .add_individual (Individual ("(root (+ 5 5)) " ))
488488
489489 # add population
490490 p = Population (3 , 0 , Config .get_instance (), mlc_repo )
@@ -541,11 +541,11 @@ def test_cut_generation(self):
541541 mlc_repo = self .__get_new_repo ()
542542
543543 # add individuals
544- mlc_repo .add_individual (Individual ("1+1 " ))
545- mlc_repo .add_individual (Individual ("2+2 " ))
546- mlc_repo .add_individual (Individual ("3+3 " ))
547- mlc_repo .add_individual (Individual ("4+4 " ))
548- mlc_repo .add_individual (Individual ("5+5 " ))
544+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
545+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
546+ mlc_repo .add_individual (Individual ("(root (+ 3 3)) " ))
547+ mlc_repo .add_individual (Individual ("(root (+ 4 4)) " ))
548+ mlc_repo .add_individual (Individual ("(root (+ 5 5)) " ))
549549
550550 # add population
551551 p = Population (3 , 0 , Config .get_instance (), mlc_repo )
@@ -588,7 +588,7 @@ def test_cut_generation(self):
588588 self .assertEqual (p ._individuals , [4 , 4 , 4 ])
589589
590590 individual = mlc_repo .get_individual (4 )
591- self .assertEqual (individual .get_value (), "4+4 " )
591+ self .assertEqual (individual .get_value (), "(root (+ 4 4)) " )
592592
593593
594594 def test_cut_generations_more_than_once (self ):
@@ -599,14 +599,14 @@ def test_cut_generations_more_than_once(self):
599599 mlc_repo = self .__get_new_repo ()
600600
601601 # add individuals
602- mlc_repo .add_individual (Individual ("1+1 " ))
603- mlc_repo .add_individual (Individual ("2+2 " ))
604- mlc_repo .add_individual (Individual ("3+3 " ))
605- mlc_repo .add_individual (Individual ("4+4 " ))
606- mlc_repo .add_individual (Individual ("5+5 " ))
607- mlc_repo .add_individual (Individual ("6+6 " ))
608- mlc_repo .add_individual (Individual ("7+7 " ))
609- mlc_repo .add_individual (Individual ("8+8 " ))
602+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
603+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
604+ mlc_repo .add_individual (Individual ("(root (+ 3 3)) " ))
605+ mlc_repo .add_individual (Individual ("(root (+ 4 4)) " ))
606+ mlc_repo .add_individual (Individual ("(root (+ 5 5)) " ))
607+ mlc_repo .add_individual (Individual ("(root (+ 6 6)) " ))
608+ mlc_repo .add_individual (Individual ("(root (+ 7 7)) " ))
609+ mlc_repo .add_individual (Individual ("(root (+ 8 8)) " ))
610610
611611 # add population
612612 p = Population (3 , 0 , Config .get_instance (), mlc_repo )
@@ -671,18 +671,18 @@ def test_cut_generations_more_than_once(self):
671671 self .assertEqual (p ._individuals , [7 , 7 , 7 ])
672672
673673 individual = mlc_repo .get_individual (7 )
674- self .assertEqual (individual .get_value (), "7+7 " )
674+ self .assertEqual (individual .get_value (), "(root (+ 7 7)) " )
675675
676676
677677 def test_remove_population_to_from_bad_values (self ):
678678 mlc_repo = self .__get_new_repo ()
679679
680680 # add individuals
681- mlc_repo .add_individual (Individual ("1+1 " ))
682- mlc_repo .add_individual (Individual ("2+2 " ))
683- mlc_repo .add_individual (Individual ("3+3 " ))
684- mlc_repo .add_individual (Individual ("4+4 " ))
685- mlc_repo .add_individual (Individual ("5+5 " ))
681+ mlc_repo .add_individual (Individual ("(root (+ 1 1)) " ))
682+ mlc_repo .add_individual (Individual ("(root (+ 2 2)) " ))
683+ mlc_repo .add_individual (Individual ("(root (+ 3 3)) " ))
684+ mlc_repo .add_individual (Individual ("(root (+ 4 4)) " ))
685+ mlc_repo .add_individual (Individual ("(root (+ 5 5)) " ))
686686
687687 # add population
688688 p = Population (3 , 0 , Config .get_instance (), mlc_repo )
0 commit comments