def makeq(self):
     if self.t == 0:
         new = range(self.pop)
     else:
         new, self.q = sols.oldnew(self.archive, self.q, self.newgenes)
     print('Found ', len(new), 'new solutions. \n')
     for m in new:
         newsol = sols.process(self.idnum, self.t, self.newgenes[m],
                               self.bpp, self.items)
         self.q.append(newsol)
         self.archive.append(newsol)
         self.updateid()
     self.archive = sols.reduce(self.archive, self.p, self.q)
Exemple #2
0
 def testProcess(self):
     data = parse('1,9,10,3,2,3,11,0,99,30,40,50')
     self.assertEqual(process(data), (3500, 9, 10))
 def test7(self):
     test = parse_input('3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99')
     self.assertEqual(process(test, 7), 999)
     self.assertEqual(process(test, 8), 1000)
     self.assertEqual(process(test, 9), 1001)
 def test6(self):
     test = parse_input('3,3,1105,-1,9,1101,0,0,12,4,12,99,1')
     self.assertEqual(process(test, 0), 0)
     self.assertEqual(process(test, 1), 1)
     self.assertEqual(process(test, 2), 1)
 def test5(self):
     test = parse_input('3,12,6,12,15,1,13,14,13,4,13,99,-1,0,1,9')
     self.assertEqual(process(test, 0), 0)
     self.assertEqual(process(test, 1), 1)
     self.assertEqual(process(test, 2), 1)
 def test4(self):
     test = parse_input('3,3,1107,-1,8,3,4,3,99')
     self.assertEqual(process(test, 7), 1)
     self.assertEqual(process(test, 8), 0)
 def test2(self):
     test = parse_input('3,9,7,9,10,9,4,9,99,-1,8')
     self.assertEqual(process(test, 7), 1)
     self.assertEqual(process(test, 8), 0)