2""" @brief Definition of phenotype as non inheritable characters.
5#============================================================================#
6# EVOLIFE http://evolife.telecom-paris.fr Jean-Louis Dessalles
21if __name__ ==
'__main__': sys.path.append(
'../..')
31 """ class Phene: define a non-heritable characteristics
36 """ creates a zero-valued or a random characteristics, depending on FlagRandom
45 """ returns the Phene's value between 0 and 100
49 def value(self, Value=None, Levelling = False):
50 """ sets or merely reads the Phene's value, possibly by limiting it to MaxPheneValue
52 if Value
is None:
return self.
__value
53 if Value <= Phene.MaxPheneValue: self.
__value = Value
54 elif Levelling: self.
__value = Phene.MaxPheneValue
55 else:
error(
"Phenotype: ",
"Maximum value exceeded: %f" % Value)
59 return self.
Name +
'=' +
"%d" % self.
value()
62 """ class Phenome: set of non inheritable characteristics
64 def __init__(self, Scenario, FlagRandom = True):
65 """ creates a dictionary of Phenes as defined by Scenario.phenemap()
72 """ reads or sets the value of a phene
77 """ returns a Phene's value between 0 and 100
79 return self.
Phenes[name].relative_value()
82 """ returns phene values as a list of relative values
84 return [self.
Phenes[PN].relative_value()
for PN
in self.
Scenario.phenemap()]
87 return 'Phenotype:\n ' +
' <> '.join([Ph.__str__()
for Ph
in self.
Phenes.values()])
92if __name__ ==
"__main__":
94 from Evolife.Scenarii.MyScenario
import InstantiateScenario
95 InstantiateScenario(
'Signalling')
96 from Evolife.Scenarii.MyScenario
import MyScenario
102__author__ =
'Dessalles'
class Phene: define a non-heritable characteristics
def __init__(self, Name, FlagRandom=True)
creates a zero-valued or a random characteristics, depending on FlagRandom
def relative_value(self)
returns the Phene's value between 0 and 100
def value(self, Value=None, Levelling=False)
sets or merely reads the Phene's value, possibly by limiting it to MaxPheneValue
class Phenome: set of non inheritable characteristics
def __init__(self, Scenario, FlagRandom=True)
creates a dictionary of Phenes as defined by Scenario.phenemap()
def Phene_relative_value(self, name)
returns a Phene's value between 0 and 100
def signature(self)
returns phene values as a list of relative values
def Phene_value(self, name, Value=None, Levelling=False)
reads or sets the value of a phene
value
value += self.__dna[pos]* 2 ** (end - 1 - pos)