Genetic Algorithms w/ Java – Tutorial 01

///Genetic Algorithms w/ Java – Tutorial 01

Genetic Algorithms w/ Java – Tutorial 01

FavoriteLoadingAdd to favorites

00:01 quickly go over the various parts of this tutorial
00:32 demo a prebuilt version of the application
01:04 a chromosome is a potential solution
01:20 define fitness in this app. context
01:57 population of chromosomes evolves from one generation to the next using selection, crossover, mutation, and elitism
02:40 code the app.
03:01 go over various classes in this app.
04:05 start coding Chromosome class
04:35 start coding Population class
05:00 initialize chromosome with random 0s and 1s
06:05 initialize a population of chromosomes in Population class
07:40 calculate fitness functionality in Chromosome class
08:58 sort chromosomes by fitness in Population class
09:34 start coding selection, crossover, mutation, and elitism functionality in GeneticAlgorithm class
11:01 start coding application Driver class
12:52 quickly test run Generation 0 app. functionality
15:40 test run app. before adding mutation and crossover functionality (evolve method returns same population i.e. never ending loop)
16:28 elite chromosomes are not subjected to crossover or mutation from one generation to the next
16:46 start implementing population crossover and population mutate methods
17:54 crossoverChromosome method does random gene selection from each one of the parent chromosomes
19:10 in tournament selection a number of chromosomes is selected randomly and from those the one with the highest fitness is chosen
20:44 finish implementing crossoverPopulation method
21:46 mutateChromosome method applies randomness to passed in chromosome
22:11 mutation rate is the probability that a chromosome gene does random mutation
23:40 finish implementing mutatePopulation method
24:01 test run completed application

Java468x60

Website + download source code @ or or download directly @

source

By |2020-05-31T07:33:41+00:00May 31st, 2020|Java Video Tutorials|6 Comments

6 Comments

  1. zaneacademy May 31, 2020 at 7:33 am - Reply

    Genetic Algorithms w/ Python – Tutorial 01 @ https://youtu.be/zumC_C0C25c

    Genetic Algorithms w/ Scala – Tutorial 01 @ https://youtu.be/6ngju74tHbI
    Genetic Algorithms w/ JAVA + JavaFX – Tutorial 02 @ https://youtu.be/0VijcOA5ZAY

    TSP By Genetic Algorithms w/ JAVA @ https://youtu.be/Z3668A0zLCM

    Genetic Algorithms Tutorial 04 – Class Scheduling JAVA Application @ https://youtu.be/cn1JyZvV5YA

    Genetic Algorithms Tutorial 05 – Robotics JAVA Application @ https://youtu.be/mhtTOp8rWOU

    Genetic Algorithms Tutorial 06 – data mining + JAVA 8 + logical operators @ https://youtu.be/Ha9xddd7xTY

    Genetic Algorithms Tutorial 07 – data mining + arithmetic operators + JAVA @ https://youtu.be/azdlGExeXKc

    Class Scheduling w/ Genetic Algorithm + SQLite DB + JAVA @ https://youtu.be/PQPs-vJuHC0

    Genetic Algorithms w/ Python – Tutorial 01 @ https://youtu.be/zumC_C0C25c

    Genetic Algorithms Class Scheduling w/ Python Tutorial @ https://youtu.be/8NrNX_jCkjw

    Genetic Algorithm + SQLite DB + Python + Class Scheduling @ https://youtu.be/6SDQdx5VLO8

  2. Alex May 31, 2020 at 7:33 am - Reply

    Although your coding conventions are terrifying, this video is super helpful, thank you! 🙂

  3. Nsm May 31, 2020 at 7:33 am - Reply

    I have this error could you please help me?
    Generation +0| Fittest Chromosome fitness: 8
    Target Chorosome: [1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0]
    ————————————————-
    Chromosome#0:[1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0]| Fitness8
    Chromosome#1:[1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1]| Fitness8
    Exception in thread "main" java.lang.NullPointerException
    Chromosome#2:[0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0]| Fitness7
    Chromosome#3:[0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1]| Fitness6
    Chromosome#4:[0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0]| Fitness5
    Chromosome#5:[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]| Fitness5
    Chromosome#6:[0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1]| Fitness4
    at geneticalgorithsimplebyme.Population.lambda$sortChoromosomesByFitness$0(Population.java:38)
    Chromosome#7:[0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1]| Fitness4

    ————————————————-
    at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
    at java.util.TimSort.sort(TimSort.java:220)
    at java.util.Arrays.sort(Arrays.java:1438)
    at geneticalgorithsimplebyme.Population.sortChoromosomesByFitness(Population.java:36)
    at geneticalgorithsimplebyme.Main.main(Main.java:31)
    C:UsersscholAppDataLocalNetBeansCache8.2executor-snippetsrun.xml:53: Java returned: 1
    BUILD FAILED (total time: 0 seconds)

  4. Debashis Saha May 31, 2020 at 7:33 am - Reply

    Could you please tell me the random seed value for this code? Thanks.

  5. ginanjar mahardhika May 31, 2020 at 7:33 am - Reply

    in 9:20
    I have error on : Arrays.sort(chromosomes,(chromosome1, chromosome2) ->
    cannot find symbol chromosome1 and chromosome2

    pls help me 🙂

  6. Hong May 31, 2020 at 7:33 am - Reply

    Why is the isFitnessChanged flag needed?

Leave A Comment

*