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
Copy file name to clipboardExpand all lines: docs/user_guide/general_usage.md
+25-30
Original file line number
Diff line number
Diff line change
@@ -54,44 +54,39 @@ for status_key in searcher.iter_status_keys():
54
54
print("===", status_key, "===")
55
55
print(searcher.status[status_key])
56
56
print()
57
+
```
57
58
59
+
## Extracting and analyzing results
58
60
59
-
# === Further ways of analyzing the results of the evolutionary run: ===
61
+
We now discuss additional ways of analyzing the results of the evolutionary computation. The following code snippets represent possible continuations to the code example above (or to codes similar to it). Therefore, we will continue to refer to the search algorithm as `searcher`.
60
62
63
+
If the evolutionary algorithm that was used is distribution-based (such as [SNES][evotorch.algorithms.distributed.gaussian.SNES], [XNES][evotorch.algorithms.distributed.gaussian.XNES], [CEM][evotorch.algorithms.distributed.gaussian.CEM], [PGPE][evotorch.algorithms.distributed.gaussian.PGPE], [CMAES][evotorch.algorithms.distributed.cmaes.CMAES]), the status object includes an item with key `"center"`, representing the center (i.e. mean) of the search distribution as a [ReadOnlyTensor][evotorch.tools.readonlytensor.ReadOnlyTensor]:
61
64
62
-
# If a distribution-based algorithm is used (e.g. SNES, XNES, CEM, PGPE,
63
-
# CMAES), the status object includes an item with key "center", representing
64
-
# the center (i.e. mean) of the search distribution as a read-only tensor.
Algorithms such as [Cosyne][evotorch.algorithms.ga.Cosyne], [GeneticAlgorithm][evotorch.algorithms.ga.GeneticAlgorithm], etc. do not have a search distribution, therefore, they do not have a center point. However, the best solution of their last population can be obtained via the status key `"pop_best"`, as a [Solution][evotorch.core.Solution] object:
68
70
69
-
# Algorithms such as Cosyne, GeneticAlgorithm, etc. do not have
70
-
# a search distribution, therefore, they do not have a center point.
71
-
# However, the best solution of their last population can be obtained
72
-
# via the status key "pop_best", as an instance of `evotorch.Solution`.
evals_as_tensor = solution_object.evals # fitness(es), evaluation data, etc.
75
+
```
77
76
77
+
If the [Problem][evotorch.core.Problem] object was initialized with `store_solution_stats=True` (which is enabled by default when the device of the Problem is "cpu"), the solution with the best fitness ever observed is available via the status key `"best"`:
78
78
79
-
# If the Problem object was initialized with `store_solution_stats=True`
80
-
# (which is enabled by default when the device of the Problem is "cpu"),
81
-
# the solution with the best fitness ever observed is available via the
82
-
# status key "best".
83
-
#
84
-
# best_sln = searcher.status["best"]
85
-
# best_sln_decision_values = best_solution.values
86
-
# best_sln_evals = best_sln.evals # fitness(s), evaluation data, etc.
79
+
```python
80
+
best_sln = searcher.status["best"]
81
+
best_sln_decision_values = best_solution.values
82
+
best_sln_evals = best_sln.evals # fitness(s), evaluation data, etc.
83
+
```
87
84
85
+
Unless the search algorithm was initialized to work across remote actors (via `distributed=True`), the search algorithm keeps its last population accessible via the attribute named `population`.
88
86
89
-
# Unless the search algorithm was initialized to work across remote
90
-
# actors (via `distributed=True`), the search algorithm keeps its last
91
-
# population accessible via the attribute named `population`.
92
-
#
93
-
# for solution in searcher.population:
94
-
# print("Decision values:", solution.values)
95
-
# print("Evaluation:", solution.evals) # fitnesses, evaluation data, etc.
96
-
# print()
87
+
```python
88
+
for solution in searcher.population:
89
+
print("Decision values:", solution.values)
90
+
print("Evaluation:", solution.evals) # fitnesses, evaluation data, etc.
0 commit comments