You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e0ac111
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/source/benchmarks.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
# Benchmark Problems
2
2
3
-
PyGAD ships a small collection of standard benchmark problems under `pygad.benchmarks`. Each problem is a class that can be called with the PyGAD fitness signature `(ga, solution, sol_idx)` and returns a fitness value in PyGAD's maximization format (the original minimization values are negated for you).
3
+
PyGAD bundles common benchmark problems under `pygad.benchmarks`. Each problem is a class callable with `(ga, solution, sol_idx)` and returns a fitness in PyGAD's maximisation format. Minimisation values are negated.
4
4
5
-
Each class also exposes the attributes you usually need to set up the GA:
5
+
Class attributes for setting up the GA:
6
6
7
7
-`num_genes`: number of decision variables.
8
-
-`num_objectives`: number of objectives. `1` for single-objective problems.
8
+
-`num_objectives`: number of objectives (`1` for single-objective).
9
9
-`bounds`: `(low, high)` tuple of variable bounds.
10
10
11
-
For ZDT problems and ZDT4 / ZDT6, the class also has a `pareto_front(num_points)` method that returns reference points on the true Pareto front. Pass these to the IGD or GD indicators as the `reference_front` argument.
11
+
ZDT classes also have a `pareto_front(num_points)` method that returns true-front reference points. Pass these to the IGD or GD indicators as `reference_front`.
12
12
13
-
One runnable example per benchmark is available under `examples/benchmarks/`.
13
+
A runnable example per benchmark lives under `examples/benchmarks/`.
14
14
15
15
## Single-Objective Problems
16
16
@@ -28,7 +28,7 @@ Available in `pygad.benchmarks.classic`:
28
28
29
29
## Multi-Objective Problems (ZDT family)
30
30
31
-
Available in `pygad.benchmarks.zdt`. All ZDT problems have two objectives and variables in `[0, 1]` (except ZDT4 which uses `[-5, 5]` for the rest of the variables).
31
+
In `pygad.benchmarks.zdt`. Two objectives, variables in `[0, 1]` (ZDT4 uses `[-5, 5]` for the rest).
32
32
33
33
| Class | Pareto front shape |
34
34
|---|---|
@@ -40,7 +40,7 @@ Available in `pygad.benchmarks.zdt`. All ZDT problems have two objectives and va
40
40
41
41
## Many-Objective Problems (DTLZ family)
42
42
43
-
Available in `pygad.benchmarks.dtlz`. All DTLZ problems support an arbitrary number of objectives `M`. The number of decision variables is `M + k - 1` where `k` is a "distance" variable count.
43
+
In `pygad.benchmarks.dtlz`. Any number of objectives `M`. Decision variables: `M + k - 1`, where `k` is the distance-variable count.
44
44
45
45
| Class | Default M | Pareto front shape |
46
46
|---|---|---|
@@ -51,13 +51,13 @@ Available in `pygad.benchmarks.dtlz`. All DTLZ problems support an arbitrary num
51
51
52
52
## Combinatorial Problems
53
53
54
-
Two combinatorial benchmarks are available: the 0/1 `Knapsack` and the`TSP`.
54
+
Two combinatorial benchmarks: 0/1 `Knapsack` and `TSP`.
55
55
56
56
### Knapsack
57
57
58
-
Available in `pygad.benchmarks.knapsack`. The 0/1 `Knapsack`class takes three arguments: a 1D array of item `weights`, a 1D array of item `values`, and a numeric `capacity`. A solution is a binary vector where a 1 means the item is picked. The fitness is the total value when the candidate is within the capacity, and a negative penalty scaled by how much the candidate is over the limit otherwise.
58
+
In `pygad.benchmarks.knapsack`. `Knapsack` takes three arguments: 1D arrays of `weights` and `values`, and a numeric `capacity`. A solution is a binary vector (1 = pick the item). Fitness is the total value within capacity, or a negative penalty scaled by the overweight amount.
59
59
60
-
The class exposes `gene_space=[0, 1]` and `gene_type=int`so you can plug it directly into PyGAD:
60
+
Class attributes `gene_space=[0, 1]` and `gene_type=int` plug into PyGAD as is:
61
61
62
62
```python
63
63
import pygad
@@ -81,9 +81,9 @@ ga.run()
81
81
82
82
### Travelling Salesman Problem
83
83
84
-
Available in `pygad.benchmarks.tsp`. The`TSP`class can be built from either a 2D array of city `coordinates` or a square `distance_matrix`. A solution is a permutation of the city indices and the fitness is the negative tour length (the tour closes back to the first city). Any non-permutation candidate gets a large negative penalty so the GA keeps a gradient toward feasibility.
84
+
In `pygad.benchmarks.tsp`. Build`TSP` from either a 2D `coordinates`array or a square `distance_matrix`. A solution is a permutation of city indices and the fitness is the negative tour length (the tour closes back to the start). Non-permutation candidates get a large negative penalty.
85
85
86
-
The class exposes `gene_space=list(range(num_cities))`, `gene_type=int`, and `allow_duplicate_genes=False`so the permutation constraint is respected:
86
+
Class attributes `gene_space=list(range(num_cities))`, `gene_type=int`, and `allow_duplicate_genes=False`keep the permutation constraint:
87
87
88
88
```python
89
89
import pygad
@@ -156,7 +156,7 @@ ga = pygad.GA(
156
156
)
157
157
ga.run()
158
158
159
-
#Measure how close the final population is to the true Pareto front
0 commit comments