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. ‹

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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 4 steps with 6 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education