Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The genes are always integers even if the gene_space attribute has float values. #27

Closed
Assignees
ahmedfgad
Labels
bugSomething isn't working
@ahmedfgad

Description

@ahmedfgad

In the next code, the initial_population parameter is used to feed an initial population that has 8 solutions with 2 genes each. Thegene_space parameter is used which has the half values starting from 0.5 to 15.5.

When the mutation is applied, it is expected that some genes have floating-point values like 3.5, 6.5, 0.5, 2.5, etc. But all genes are integers.

importpygadimportnumpyinit_pop= ((1,1), (3,3), (5,5), (7,7), (9,9), (11,11), (13,13), (15,15))deffitness_func(solution,solution_idx):fitness=numpy.sum(solution)returnfitnessgene_space=numpy.arange(0.5,15.5,1)ga_instance=pygad.GA(initial_population=init_pop,num_generations=4,num_parents_mating=8,fitness_func=fitness_func,gene_space=gene_space)ga_instance.run()

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp