Giter Club home page Giter Club logo

genetic-algorithm's Introduction

genetic-algorithm's People

Contributors

ezstoltz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

genetic-algorithm's Issues

wrong implemention in breed(parent1, parent2)

the implementation of "child = childP1 + childP2" is wrong here. If we use the example in the figure of "Illustration of ordered crossover (credit: Lee Jacobson)", the resulting offspring of your implementation is "954321678" which is wrong. The correct result should be "954326781".

The original JAVA implementation by Lee Jacobson is correct. See the "public static Tour crossover(Tour parent1, Tour parent2)" in the GA.java of the original post. Look at how it loops through parent2's city tour.

Just for reference, I put my modified breed(parent1, parent2) function below:

child = [None] * len(parent1)
childP1 = []

geneA = int(random.random() * len(parent1))
geneB = int(random.random() * len(parent1))

startGene = min(geneA, geneB)
endGene = max(geneA, geneB)

for i in range(startGene, endGene):
    childP1.append(parent1[i])
    child[i] = parent1[i]  # copy segment to the same position

ptr = 0
for item in parent2:
    if item not in childP1:
        while ptr < len(parent1) and child[ptr] != None: # find the next None element
            ptr += 1

        child[ptr] = item  # only copy the remaining gene to positions that are None
        ptr += 1

return child

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.