コード例 #1
0
    def initDecode(self, ind):
        """
        """
        # decode tree chromosome
        room_list = parseTree.parseTree(ind.genome["tree"], self.params["plotSizeX"], self.params["plotSizeY"])

        tree, shape_list = self.getQuadTree(room_list["sizes"], room_list["desc"])
        ind.genome["tree"] = tree
        ind.shape_list = shape_list

        plan = self.newDecode(tree)

        ind.decoded_plan = plan
        ind.numRoom = plan[0]
        ind.roomarea = plan[1]
        ind.roomlist = plan[2]
        ind.roomDesc = plan[3]
        ind.roomSizes = plan[4]

        # 2nd chromosome
        # decode color chromosome
        chrom = ind.genome["color"]
        temp = 0
        len_chrom = len(chrom)
        for i in xrange(len_chrom):
            if chrom[i]:
                temp += 2 ** (len_chrom - i - 1)
        ind.color = self.colors[temp]
コード例 #2
0
    def initDecode(self, ind):
        '''
        '''
        # decode tree chromosome
        room_list = parseTree.parseTree(ind.genome['tree'], self.params['plotSizeX'], self.params['plotSizeY'])

        tree, shape_list = self.getQuadTree(room_list['sizes'], room_list['desc'])
        ind.genome['tree'] = tree
        ind.shape_list = shape_list

        plan = self.newDecode(tree)

        ind.decoded_plan = plan
        ind.numRoom = plan[0]
        ind.roomarea = plan[1]
        ind.roomlist = plan[2]
        ind.roomDesc = plan[3]
        ind.roomSizes = plan[4]

        # 2nd chromosome
        # decode color chromosome
        chrom = ind.genome['color']
        temp = 0
        len_chrom = len(chrom)
        for i in xrange(len_chrom):
            if chrom[i]:
                temp += 2**(len_chrom-i-1)
        ind.color = temp
コード例 #3
0
    def decodePlan(self, ind):
        room_list = parseTree.parseTree(ind, self.width, self.height)
        plan = decodePlan.decodePlan(room_list)

        ind.decoded_plan = plan
        ind.numRoom = plan[0]
        ind.roomarea = plan[1]
        ind.roomlist = plan[2]
        ind.roomDesc = plan[3]
        ind.roomSizes = plan[4]
コード例 #4
0
    def decodePlan(self):
        room_list = parseTree.parseTree(self, self.params["plotSizeX"], self.params["plotSizeY"])
        plan = decodePlan.decodePlan(room_list)

        self.decoded_plan = plan
        self.numRoom = plan[0]
        self.roomarea = plan[1]
        self.roomlist = plan[2]
        self.roomDesc = plan[3]
        self.roomSizes = plan[4]
コード例 #5
0
    def decodePlan(self, ind):
        room_list = parseTree.parseTree(ind, self.params["plotSizeX"], self.params["plotSizeY"])
        plan = decodePlan.decodePlan(room_list)

        ind.decoded_plan = plan
        ind.numRoom = plan[0]
        ind.roomarea = plan[1]
        ind.roomlist = plan[2]
        ind.roomDesc = plan[3]
        ind.roomSizes = plan[4]
コード例 #6
0
    def decodePlan(self, ind):
        room_list = parseTree.parseTree(ind, self.params['plotSizeX'],self.params['plotSizeY'])
        plan = decodePlan.decodePlan(room_list['desc'], room_list['sizes'])

        ind.decoded_plan = plan
        ind.numRoom = plan[0]
        ind.roomarea = plan[1]
        ind.roomlist = plan[2]
        ind.roomDesc = plan[3]
        ind.roomSizes = plan[4]
        ind.transf = room_list['transf']
コード例 #7
0
    def decodePlan(self, ind):
        '''
        '''
        # decode tree chromosome
        room_list = parseTree.parseTree(ind.genome['tree'], self.params['plotSizeX'], self.params['plotSizeY'])
        plan = decodePlan.decodePlan(room_list['desc'], room_list['sizes'])

        ind.decoded_plan = plan
        ind.numRoom = plan[0]
        ind.roomarea = plan[1]
        ind.roomlist = plan[2]
        ind.roomDesc = plan[3]
        ind.roomSizes = plan[4]

        # decode transformation chromosomes
        transf = room_list['transf']
        for i in xrange(len(transf)):
            xscale_chrom = transf[i][0]
            yscale_chrom = transf[i][1]
            len_scale = len(xscale_chrom)
            temp_x, temp_y = 0., 0.
            for j in xrange(len_scale):
                if xscale_chrom[j]:
                    temp_x += 2**(len_scale-j-1)
                if yscale_chrom[j]:
                    temp_y += 2**(len_scale-j-1)
            transf[i][0] = temp_x/(2**len_scale)
            transf[i][1] = temp_y/(2**len_scale)

        ind.transf = transf

        # 2nd chromosome
        # decode color chromosome
        chrom = ind.genome['color']
        temp = 0
        len_chrom = len(chrom)
        for i in xrange(len_chrom):
            if chrom[i]:
                temp += 2**(len_chrom-i-1)
        ind.color = temp
コード例 #8
0
ファイル: test.py プロジェクト: mam446/GraphEvo
import parseTree
import settings


s = settings.runSettings()


x = parseTree.parseTree(s)
x.createER()
print x.toDict()


print x.evaluate()
#print x.eval2()
x.makeProg()
x.report()
x.makeGraph()