Answered step by step
Verified Expert Solution
Link Copied!

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(10)
NUM_GENERATIONS =200
NUM_POPULATION =100
PROBABILITY_MUTATION =0.2
PROBABILITY_CROSSOVER =0.8
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? (y/n)"
"
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 fitness(target, individual):
"""
DOCSTRING
"""
pass
def five_tournament_selection(population, target):
"""
DOCSTRING
"""
pass
def make_population(target):
"""
DOCSTRING
"""
pass
def mutation(individual):
"""
DOCSTRING
"""
pass
def single_point_crossover(individual1, individual2):
"""
DOCSTRING
"""
pass
def find_best_individual(population, 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 2 lines or Do NOT add code to them. Everything
# you add should be in the 'main' function above.
if __name__=='__main__':
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
1. To clarify the project specifications, sample output is appended to the end of this document.
2. Convert target to lowercase before calling functions.
3. Items 1-8 of the Coding Standard will be enforced for this project.
4. We provide a Project04.zip 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
input/output tests.
5. random is imported for you, and constant variables are provided.
6. You are not allowed to use advanced data structures such as lists, sets, dictionaries and classes.
7. A strings.txt file of strings used is provided to help with testing. The same strings are provided in
the starter code.
8. To print out that a string was found early only once, try setting a flag. (a variable set to true or false)
9. Do NOT change the random.seed(10) NOW look at the image and follow all instructions thanks. Project Description
You pogram must met the following spocifications:
we the following:
a. nake_population (target) : Randomly builds a population of size
packinge and criteria.
b. Fitresa (Earget, isdividua1] : 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 5.3" section for int exumple.
c. five teurnasent_selection (population, target): Takes two strings as
parameter. Randomly grabs beginting indeses of 5 population individuals. The population
getting the inderes.
nutation (individua1) : Takes a siagle strizg as parimeter. lerales over chanacters in
individual, genting a new assignement if that iteration has a probability less the
5.5foeanexample.
e. single_point_etosabver (individual1, individua12) 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 5.6"
for an example.
f. find_best_individual (population, target) : Takes wo strings as parameter.
Merates over the entire population wo fiad the individual with the beat fitness (highest fitness).
Page 5 of 9
CSE 23I
Sprieg 2024
Reoursis that indivilual. Remember that popalatice has sum poputarton individual. Check
the "asignment buckgousd 5.2" 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 "Y" of "", do the sollowing:
Promps for target string. The program should be ease insensitive (it accepts any
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

What are the four components of typical DBMS software?

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago