Skip to content

Commit 6a3b58b

Browse files
author
Ahmed Gad
committed
Apply constraints on gene space
1 parent c5d35dc commit 6a3b58b

28 files changed

+2214
-1121
lines changed

.DS_Store

8 KB
Binary file not shown.

example.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ def fitness_func(ga_instance, solution, solution_idx):
2323
random_mutation_min_val=1,
2424
random_mutation_max_val=100,
2525
mutation_by_replacement=True,
26-
gene_type=int,
26+
gene_type=[float, 1],
27+
save_solutions=True,
2728
allow_duplicate_genes=False,
28-
# mutation_probability=0.4,
29-
# gene_constraint=[lambda x: x[0]>=8,None,None,None,None,None],
29+
# gene_space=numpy.unique(numpy.random.uniform(1, 100, size=100)),
30+
gene_space=[range(10), {"low": 1, "high": 5}, 2.5891221, [1,2,3,4], None, numpy.unique(numpy.random.uniform(1, 100, size=4))],
3031
gene_constraint=[lambda x: x[0]>=98,lambda x: x[1]>=98,lambda x: x[2]<98,lambda x: x[3]<98,lambda x: x[4]<98,lambda x: x[5]<98],
3132
)
3233

33-
# ga_instance.run()
34+
ga_instance.run()
35+
36+
print(ga_instance.gene_space_unpacked)
37+
print(ga_instance.population)

pygad/.DS_Store

6 KB
Binary file not shown.

pygad/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from .pygad import * # Relative import.
22

3-
__version__ = "3.3.1"
3+
__version__ = "3.5.0"
-22 Bytes
Binary file not shown.
-21 Bytes
Binary file not shown.
-22 Bytes
Binary file not shown.
7.26 KB
Binary file not shown.
-20 Bytes
Binary file not shown.

pygad/helper/misc.py

Lines changed: 300 additions & 37 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)