Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use this code as a skeleton do not change this part: PROJECT HEADER GOES HERE import random #DO NOT
Use this code as a skeleton do not change this part:
PROJECT HEADER GOES HERE
import random
#DO NOT CHANGE THIS
random.seed
NUMGENERATIONS
NUMPOPULATION
PROBABILITYMUTATION
PROBABILITYCROSSOVER
ALPHABET 'abcdefghijklmnopqrstuvwxyz
BANNER
Welcome to GeneticGuess Sentencer!
This program will attempt to guess a sentence that you input.
Simply input a sentence and the program will attempt to guess it
INPUT
Would you like to continue? yn
Please input the sentence you would like the program to guess:
Incorrect input. Please try again.
GeneticGuess results:"
"Generation:
"I found the sentence early!"
Best Individual:
Thank you for using GeneticGuess Sentencer!"
def fitnesstarget individual:
DOCSTRING
pass
def fivetournamentselectionpopulation target:
DOCSTRING
pass
def makepopulationtarget:
DOCSTRING
pass
def mutationindividual:
DOCSTRING
pass
def singlepointcrossoverindividual individual:
DOCSTRING
pass
def findbestindividualpopulation target:
DOCSTRING
pass
def main:
pass
# These two lines allow this program to be imported into other codes
# such as our function tests code allowing other functions to be run
# and tested without 'main' running. However, when this program is
# run alone, 'main' will execute.
# DO NOT CHANGE THESE lines or Do NOT add code to them. Everything
# you add should be in the 'main' function above.
if namemain:
main Also, 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. and Assignment Notes and Other Requirements
To clarify the project specifications, sample output is appended to the end of this document.
Convert target to lowercase before calling functions.
Items of the Coding Standard will be enforced for this project.
We provide a Projectzip folder for you to start with. You need to download the folder, unzip
the file and open it in PyCharm. The zip file contains the function tests as well as the text files for the
inputoutput tests.
random is imported for you, and constant variables are provided.
You are not allowed to use advanced data structures such as lists, sets, dictionaries and classes.
A strings.txt file of strings used is provided to help with testing. The same strings are provided in
the starter code.
To print out that a string was found early only once, try setting a flag. a variable set to true or false
Do NOT change the random.seed NOW look at the image and follow all instructions thanks. Project Description
You pogram must met the following spocifications:
we the following:
a nakepopulation target : Randomly builds a population of size
packinge and criteria.
b Fitresa Earget isdividua : Takes two strings as parametes. Returns be amber
of digits int that match in eact striag, divided by the number of digits in the string. Both
strings are the same length. Check the "issignment bockground section for int exumple.
c five teurnasentselection population target: Takes two strings as
parameter. Randomly grabs beginting indeses of population individuals. The population
getting the inderes.
nutation individua : Takes a siagle strizg as parimeter. lerales over chanacters in
individual, genting a new assignement if that iteration has a probability less the
e singlepointetosabver individual individua Takes two strings as
parameter. Randomly finds a point wo cross explained above and crowses the two iedividuak at
that point. Two new individuals should be returned. Check the "insignement bockgound
for an example.
f findbestindividual population target : Takes wo strings as parameter.
Merates over the entire population wo fiad the individual with the beat fitness highest fitness
Page of
CSE I
Sprieg
Reoursis that indivilual. Remember that popalatice has sum poputarton individual. Check
the "asignment buckgousd Sor an example on how so find an individual in a population.
Ako, you should recall the algorithm to find maximue.
g Bain : Takes no input. Resurns nochieg. The main functice is a simple implementation of a
genetic algorithe used for evolving a popalatioe of individuals ow ards a target solutice.
i Print the barser.
ii Prompt the user if they want to coetinue.
ii If the user enters of do the sollowing:
Promps for target string. The program should be ease insensitive it accepts any
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