Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial specimen #7

Open
mparigi opened this issue Jun 25, 2019 · 2 comments
Open

Add initial specimen #7

mparigi opened this issue Jun 25, 2019 · 2 comments

Comments

@mparigi
Copy link

mparigi commented Jun 25, 2019

Is there a way to include a few individuals (likely good solutions, starting points) to the initial population, while leaving the rest of them random?

@koritsky
Copy link

koritsky commented Aug 7, 2019

I would also like that

@rayliuca
Copy link

Until the pull request get merged, you can try something like

def create_individual(seed_data):
    """ Create a candidate solution representation
        e.g. for a bit array representation:
    """
    if len(seed_data['starting points']) > 0:
        print('Got individual from data')
        return seed_data['starting points'].pop(0)
    
    print('Gen new individual')
    return [random.randint(0, 1) for _ in range(len(seed_data['genes_num']))]

ga = pyeasyga.GeneticAlgorithm({'starting points':[[1, 0],[0, 0]], 
                                'genes_num': 2},  # Input seed data
                                #some other parameters 
                                )

ga.create_individual = create_individual

## the reset of the implementation

ga.run()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants