Exemple #1
0
    def __init__(self, gcode, config, **kwargs):
        self.code = gcode
        self.simtime = config.getint('default', 'simtime')
        prob = kwargs['problem']

        promfun = bindparams(config, buildpromlist)
        productsfun = bindparams(config, buildproducts)
        #TODO: add nout to the parameters file or bring the problem instance here?
        self.promlist,self.effectorproms = \
                        promfun(gcode,
                                productprom='11111111',
                                nout = prob.nout)
        self.proteins = productsfun(gcode, self.promlist)

        self.effectors = []
        if self.effectorproms:
            self.effectors = productsfun(gcode, self.effectorproms)

        self.receptors = build_customproducts()
        self.receptorproms = [r[0] for r in self.receptors]

        pbindfun = bindparams(config, getbindings)
        weightsfun = bindparams(config, _getweights)

        self.numtf = len(self.proteins)
        if prob.nout == 1:
            self.numeff = len(self.effectors)
        else:
            self.numeff = min(len(self.effectors), prob.nout)

        self.effectorproms = self.effectorproms[:self.numeff]
        self.effectors = self.effectors[:self.numeff]
        self.numrec = min(len(self.receptorproms), prob.ninp)
        self.receptorproms = self.receptorproms[:self.numrec]
        self.receptors = self.receptors[:self.numrec]
        self.ccs = []
        if self.promlist or self.effectorproms:
            self.ccs = nparray(
                [1.0 / (self.numtf + self.numeff + self.numrec)] *
                (self.numtf + self.numeff + self.numrec))
            self._initializehistory()
            self._initializebindings(pbindfun)
            self._initializeweights(weightsfun)
            for i in range(len(self.proteins)):
                self.proteins[i].append(self.ccs[i])

        self.simfun = bindparams(config, iterate)

        self.delta = config.getfloat('default', 'delta')
        log.debug(self.snapshot())
        self.output_idx = 0
Exemple #2
0
        def __init__(self, config, gcode = None, parentfit = 1e4):
                Agent.__init__(self, parentfit)
                generator = arn.bindparams(config, arn.generatechromo)
                if gcode == None:
                        gcode = generator()

                self.genotype = arn.ARNetwork(gcode,config)
                self.phenotype = []
                self.fitness = 1e4
Exemple #3
0
    def __init__(self, gcode, config, **kwargs):
        self.code = gcode
        self.simtime = config.getint('default', 'simtime')

        promfun = bindparams(config, buildpromlist)
        productsfun = bindparams(config, buildproducts)
        self.promlist = promfun(gcode)
        self.proteins = productsfun(gcode, self.promlist)

        self.effectors = []
        self.effectorproms = promfun(gcode, promoter='00000000')
        if self.effectorproms:
            #print 'EFFECTORS:', self.effectorproms
            self.effectors = productsfun(gcode, self.effectorproms)

        self.receptors = []
        self.receptorproms = promfun(gcode, promoter='11111111')
        if self.receptorproms:
            #print 'RECEPTORS:', self.receptorproms
            self.receptors = productsfun(gcode, self.receptorproms)

        pbindfun = bindparams(config, getbindings)
        weightsfun = bindparams(config, _getweights)

        prob = kwargs['problem']
        self.numtf = len(self.proteins)
        self.numeff = min(len(self.effectors), prob.nout)
        self.effectors = self.effectors[:self.numeff]
        self.numrec = min(len(self.receptors), prob.ninp)
        self.receptors = self.receptors[:self.numrec]
        self.ccs = []
        if self.promlist:
            self.ccs = nparray(
                [1.0 / (self.numtf + self.numeff + self.numrec)] *
                (self.numtf + self.numeff + self.numrec))
            self._initializehistory()
            self._initializebindings(pbindfun)
            self._initializeweights(weightsfun)
            for i in range(len(self.proteins)):
                self.proteins[i].append(self.ccs[i])

        self.simfun = bindparams(config, iterate)
        self.delta = config.getfloat('default', 'delta')
Exemple #4
0
    def __init__(self, gcode, config, **kwargs):
        self.code = gcode
        self.simtime = config.getint('default','simtime')

        promfun = bindparams(config, buildpromlist)
        productsfun = bindparams(config, buildproducts)
        self.promlist = promfun(gcode)
        self.proteins = productsfun( gcode, self.promlist)

        self.effectors=[]
        self.effectorproms = promfun(gcode, promoter='00000000')
        if self.effectorproms:
            #print 'EFFECTORS:', self.effectorproms
            self.effectors = productsfun(gcode,self.effectorproms)

        self.receptors=[]
        self.receptorproms = promfun(gcode, promoter='11111111')
        if self.receptorproms:
            #print 'RECEPTORS:', self.receptorproms
            self.receptors = productsfun(gcode,self.receptorproms)

        pbindfun = bindparams(config, getbindings)
        weightsfun = bindparams(config, _getweights)

        prob = kwargs['problem']
        self.numtf = len(self.proteins)
        self.numeff = min(len(self.effectors),prob.nout)
        self.effectors = self.effectors[:self.numeff]
        self.numrec = min(len(self.receptors),prob.ninp)
        self.receptors = self.receptors[:self.numrec]
        self.ccs = []
        if self.promlist:
            self.ccs = nparray([1.0/(self.numtf+self.numeff+self.numrec)]*
                               (self.numtf+self.numeff+self.numrec))
            self._initializehistory()
            self._initializebindings(pbindfun)
            self._initializeweights(weightsfun)
            for i in range(len(self.proteins)):
                self.proteins[i].append(self.ccs[i])

        self.simfun = bindparams(config,iterate)
        self.delta = config.getfloat('default','delta')
Exemple #5
0
        def __init__(self, config, problem, gcode = None, parent = None):
                Agent.__init__(self, parent)
                generator = arn.bindparams(config, self.generate)
                if gcode == None:
                        gcode = generator()

                arnet = arn.ARNetwork(gcode,config)
                self.genotype = arnet
                self.phenotype = P(arnet,buildcircuit(self,problem), problem)
                self.problem = problem
                self.fitness = 1e6
Exemple #6
0
    def __init__(self, config, problem, gcode=None, parent=None):
        Agent.__init__(self, parent)
        generator = arn.bindparams(config, self.generate)
        if gcode == None:
            gcode = generator()

        arnet = arn.ARNetwork(gcode, config)
        self.genotype = arnet
        self.phenotype = P(arnet, buildcircuit(self, problem), problem)
        self.problem = problem
        self.fitness = 1e6
Exemple #7
0
def getmapping(arncfg, fback = False):
	"""
	Returns the mapping (from genome and expression to circuit)
	"""
	return functools.partial( bindparams(arncfg,_buildcircuitfunctions),
				  feedback = fback)