Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will be writing a program in Python that simulates a genetic algorithm inspired breeding program to produce giant rats for your use as a

You will be writing a program in Python that simulates a genetic algorithm inspired breeding program to produce giant rats for your use as a mad scientist. Mwah ha ha!

The Task:

Your program should not prompt the user for any input. It should make use of the following constants, as defined in the code:

  • GOAL_WEIGHT The goal weight for your rats to achieve. 50,000 is a good value for this.

  • NUM_FEMALES The number of female rats that you keep from generation to generation. Also the number

    of female rats you begin the simulation with. 20 is a good value for this.

  • NUM_MALES The number of male rats that you keep from generation to generation. Also the number of

    male rats you begin the simulation with. 20 is a good value for this.

  • INIT_MIN_WEIGHT The initial minimum weight of a starting rat. 200 is a good value for this.

  • INIT_MAX_WEIGHT The initial maximum weight of a starting rat. 600 is a good value for this.

  • INIT_MALE_AVERAGE The average weight of a male starting rat. 350 is a good value for this.

  • INIT_FEMALE_AVERAGE The average weight of a female starting rat. 250 is a good value for this.

  • MUTATE_PROB The probability that a child will mutate. 0.01 is a good value for this.

  • MUTATE_MIN The smallest possible weight multiplier that a mutation can cause. 0.5 is a good value for this.

  • MUTATE_MAX The largest possible weight multiplier that a mutation can cause. 1.2 is a good value for this.

  • LITTER_MAX The largest number of children that a breeding pair can produce in one breeding. 8 is a good

    value for this. The smallest number of children that a pair can produce is 1.

  • GENERATION_LIMIT The maximum number of generations that your program will simulate. 500 is a good

    value for this.

    The program should simulate the breeding of the rats using a genetic algorithm. Specifically, it should:

    • Create an initial population of males and females, randomly selecting their weights using the minimum,

      maximum, and average values.

    • Begin the generation simulation process:

      1. Cull all but the given number of males and females, keeping the largest possible rats.

      2. Print the weight of the largest male and female, along with the generation number.

      3. If the goal weight has been reached, finish the program. If the generation limit has been reached, finish

        the program.

      4. Have each female breed with a randomly selected male. This will create a litter of children, the number

        of which should be randomly determined. The weight of the child should be randomly distributed

        between the mothers and fathers weight.

      5. Possibly mutate the child if a mutation occurs, randomly determine the mutation multiplier using the

        min and max values given, and multiply the weight by the multiplier.

      6. Once the breeding is finished, integrate the newly created children with the original rats.

      7. Return to step 1.

      You can experiment and play around with the values of the constants to see what effect they have on the performance of the program.

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

Step: 3

blur-text-image

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

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

Distinguish between poor and good positive and neutral messages.

Answered: 1 week ago