please use python language instruction- 1. Read the code from line 123 to line 137. This is the basically the selection.
Remember how we talk about there are certain things about controlling population?
Please explain how we make sure that the population, when going through a selection, does not shrink over generation. You may simply explain this as comments in a Python file as opposed to in a Word file:.
Note that the code from line 123 to line 137 is divided into two small blocks. Use that as 2. The code we've just examined has one functionality of selection. So, we really should wrap that into one function nanied 'select'. Note that in this file there is no class named
'Population'. So, you should make this function a static method that belongs to the class named 'Individual', or a simple function that resides outside the class named
'Individual'. Please think about what the inputs and output of this function are before you start coding. Once you have created the function/method, you should remove the block ot coae from line 123 to line 137. 3. There are two class methods (mutated_genes on line 25, create_gnome on line 35) that belong to the class named 'Individual'. In general, a class method does not apply to an instance but to a class. So, to be perfectly correct, so there should not be 'self in the inputs of any of the two methods just mentioned here. Please modify these two class methods so they confirm to the convention just highlighted. ‹

icon
Related questions
Question
please use python language instruction- 1. Read the code from line 123 to line 137. This is the basically the selection.
Remember how we talk about there are certain things about controlling population?
Please explain how we make sure that the population, when going through a selection, does not shrink over generation. You may simply explain this as comments in a Python file as opposed to in a Word file:.
Note that the code from line 123 to line 137 is divided into two small blocks. Use that as 2. The code we've just examined has one functionality of selection. So, we really should wrap that into one function nanied 'select'. Note that in this file there is no class named
'Population'. So, you should make this function a static method that belongs to the class named 'Individual', or a simple function that resides outside the class named
'Individual'. Please think about what the inputs and output of this function are before you start coding. Once you have created the function/method, you should remove the block ot coae from line 123 to line 137. 3. There are two class methods (mutated_genes on line 25, create_gnome on line 35) that belong to the class named 'Individual'. In general, a class method does not apply to an instance but to a class. So, to be perfectly correct, so there should not be 'self in the inputs of any of the two methods just mentioned here. Please modify these two class methods so they confirm to the convention just highlighted. ‹
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Otherwise generate new offsprings for new generation
new generation = []
#look over here
s = int((10*POPULATION_SIZE)/100)
new_generation.extend (population [:s])
#look over here
s = int((90*POPULATION_SIZE)/100)
for
in range(s):
parent1 = random.choice (population [:50])
parent2 = random.choice (population [:50])
child = parent1.mate (parent2)
new_generation.append(child)
population = new_generation
-
Transcribed Image Text:122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 # Otherwise generate new offsprings for new generation new generation = [] #look over here s = int((10*POPULATION_SIZE)/100) new_generation.extend (population [:s]) #look over here s = int((90*POPULATION_SIZE)/100) for in range(s): parent1 = random.choice (population [:50]) parent2 = random.choice (population [:50]) child = parent1.mate (parent2) new_generation.append(child) population = new_generation -
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def mutated genes (self):
I
create random genes for mutation
global GENES
#Return a random element from a list or a sequence.
gene= random. choice (GENES)
return gene
@classmethod
def create_gnome (self):
11
create chromosome or string of genes
11.
Transcribed Image Text:25 26 27 28 29 30 31 32 33 34 35 36 37 38 def mutated genes (self): I create random genes for mutation global GENES #Return a random element from a list or a sequence. gene= random. choice (GENES) return gene @classmethod def create_gnome (self): 11 create chromosome or string of genes 11.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer