Beispiel #1
0
 def __init__(self, params={}):
     BaseChromo.__init__(
         self,
         size=2 * puzzle_size,
         #range=(0,puzzle_size-1), dtype=int )
         range=puz_ranges,
         dtype=int)
Beispiel #2
0
 def __init__(self, params={}):
     BaseChromo.__init__(
         self,
         size=8,
         #range=(0,8-1), dtype=int )
         range=(0, 7),
         dtype=int)
Beispiel #3
0
    def __init__(self):
        self.cpu = CPU(num_levels=num_levels,
                       nodes_per_level=nodes_per_level,
                       input_size=input_size)
        self.total_instrs = len(self.cpu.OPSinstrs)

        # ranges for each chromo ..
        rlist = []
        for ll in range(num_levels):
            lvl_start = ll * nodes_per_level + input_size
            for nn in range(nodes_per_level):
                rlist.append((0, self.total_instrs - 1))  # function-identifier
                rlist.append(
                    (0, lvl_start - 1))  # op1=node-num less than level-start
                rlist.append(
                    (0, lvl_start - 1))  # op2=node-num less than level-start
        # output node
        lvl_start = num_levels * nodes_per_level + input_size
        rlist.append((0, self.total_instrs - 1))  # function-identifier
        rlist.append((0, lvl_start - 1))  # op1=node-num less than level-start
        rlist.append((0, lvl_start - 1))  # op2=node-num less than level-start

        BaseChromo.__init__(self,
                            size=3 * num_levels * nodes_per_level + 3,
                            range=rlist,
                            dtype=int)
Beispiel #4
0
    def __init__(self):
        # cpuSimple:  self.cpu = CPU( data_memory_size=2, register_set_size=2, instruction_memory_size=2+2 )
        self.cpu = CPU(instruction_size=prog_size,
                       input_size=input_size,
                       rom_size=rom_size)
        self.total_instrs = len(self.cpu.OPSinstrs)

        # ranges for each chromo ..
        rlist = [(0, self.total_instrs - 1) for i in range(prog_size)]
        rlist.extend([(-5, 5) for i in range(rom_size)])
        # TODO: datatypes for each chromo ..

        BaseChromo.__init__(self,
                            size=prog_size + rom_size,
                            range=rlist,
                            dtype=int)
Beispiel #5
0
class TestChromo(unittest.TestCase):
	def setUp(self):
		self.chromo = BaseChromo( size=4, dtype=int )
		self.chromo2 = BaseChromo( size=4, dtype=[int,int,float,float] )

	def test_size(self):
		self.assertEqual( self.chromo.chromo_sz, 4 )
	def test_size2(self):
		self.assertEqual( self.chromo.chromo_sz, len(self.chromo.data) )

	def test_dtype(self):
		self.assertListEqual( self.chromo.dataType, [int,int,int,int] )
	def test_dtype2(self):
		self.assertListEqual( self.chromo2.dataType, [int,int,float,float] )

	def test_pack(self):
		newdata = [1,2,3,4]
		self.chromo.setInitData( newdata )
		x = self.chromo.packData()
		self.chromo.unpackData( x )
		self.assertListEqual( self.chromo.data, newdata )
Beispiel #6
0
 def __init__(self):
     BaseChromo.__init__(self, size=1, range=(-10, -1), dtype=int)
Beispiel #7
0
 def __init__(self):
     BaseChromo.__init__(self,
                         size=3 * num_sprayers,
                         range=dataRanges,
                         dtype=float)
Beispiel #8
0
 def __init__(self):
     BaseChromo.__init__(self,
                         size=2 * nnodes,
                         range=dataRanges,
                         dtype=float)
Beispiel #9
0
	def __init__( self, params={} ):
		BaseChromo.__init__( self, size=9+6,
			range=[ (1,maxnum),(1,maxnum-1),(1,maxnum-2),(1,maxnum-3),(1,maxnum-4),(1,maxnum-5),(1,maxnum-6),(1,maxnum-7),(1,maxnum-8),     # digits
					(1,4),(1,4),(1,4),(1,4),(1,4),(1,4) ],  # operators: +/-/=
			dtype=int )
Beispiel #10
0
 def __init__(self, params={}):
     BaseChromo.__init__(self, size=width * height, range=(0, 3), dtype=int)
Beispiel #11
0
	def __init__( self ):
		BaseChromo.__init__( self, size=5, dtype=float )
Beispiel #12
0
	def __init__( self ):
		BaseChromo.__init__( self, size=10,
			range=(-2.048,2.048), dtype=float )
Beispiel #13
0
 def __init__(self, params={}):
     BaseChromo.__init__(self,
                         size=maxnum,
                         range=(0, maxnum - 1),
                         dtype=int)
Beispiel #14
0
 def __init__(self):
     BaseChromo.__init__(self, size=3, dtype=float, dataRange=(-5, 5))
Beispiel #15
0
	def setUp(self):
		self.chromo = BaseChromo( size=4, dtype=int )
		self.chromo2 = BaseChromo( size=4, dtype=[int,int,float,float] )
Beispiel #16
0
	def __init__( self ):
		BaseChromo.__init__( self, size=4,
			range=(0,10), dtype=int )
Beispiel #17
0
	def __init__( self ):
		BaseChromo.__init__( self, size=MAX_PATH_LEN,
			range=(-1,1), dtype=int )
Beispiel #18
0
	def __init__( self, params={} ):
		BaseChromo.__init__( self, size=81,
			range=(0,8), dtype=int )
Beispiel #19
0
 def __init__(self):
     BaseChromo.__init__(self,
                         size=len(solution),
                         range=(0, len(letters) - 1),
                         dtype=int)
Beispiel #20
0
 def __init__(self):
     BaseChromo.__init__(self, size=20, range=(-5.12, 5.12), dtype=float)