Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are not allowed to use advanced data structures such as lists, Tuples, Sets, Dictionaries, Classes, etc. Use of these prohibited concepts earns zero points
You are not allowed to use advanced data structures such as lists, Tuples, Sets, Dictionaries, Classes,
etc. Use of these prohibited concepts earns zero points for the whole project. The goal of this project is to implement a simple genetic algorithm. We call it GeneticGuess Sentencer
GeneticGuess Sentencer utilizes a basic genetic algorithm to guess sentences! The user will enter a sentence,
a string composed of lowercaseletters and spaces. Then, it will use strategic randomization to get the users
sentence from several random strings. You will implement the basic genetic algorithm structure, including
several short but important functions. The basis of this project can be reused for other problems if you are
interested in it D Genetic Algorithm Basics
Genetic algorithms work similar to reallife genes and evolutionary principles. You begin by creating a
population. This population will crossover and mutate with one another by selecting individuals with high
fitness. The result of this process leads to a new population, or a new generation. The process works like this:
There are multiple ways to implement the population, fitness, selection, crossover, and mutation. We will focus
on one method of each.
Population
The population is a large number of individuals. We have set the population size in the variable
NUM POPULATION. The entire population will be stored in a string of length NUM POPULATION
times the length of each individual. The length of each individual will be the length of the target sentence,
provided by the user. As the program continues through several generations, the population will collect
individuals that look more and more similar to the target string. To create an individual, use
random. choice with a string of lowercase letters and a space defined as ALPHABET in the starter
code Do it in this order so your results match the testcases!
Do not separate the individuals by a space. You have the length of the target sentence, so you know where
to split the string for each individual.
For example, try this code:
import random
random. seed
"welcome"
print randomchoice to
print randomchoice x iw
Example
NUM POPULATION
Target "hello workl"
population "haskd als ajs foj oa j
each individual is highlighted
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started