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
- Extend the general usage docs to mention the status object
- Move the result analysis snippets to outside of the main example
- Add link to the detailed status item explanations
Copy file name to clipboardExpand all lines: docs/user_guide/general_usage.md
+50-1
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,55 @@ searcher.run(10)
40
40
# Process the information accumulated by the loggers.
41
41
...
42
42
progress = pandas_logger.to_dataframe()
43
-
progress.mean_eval.plot() #Display a graph of the evolutionary progress by using the pandas data frame
43
+
progress.mean_eval.plot() #Plot the evolutionary progress
44
44
...
45
+
46
+
# We now analyze the current status using the dictionary-like status object.
47
+
# The status object allows one to get evaluation results (i.e. fitness, etc.)
48
+
# and decision values of the best solution in the population
49
+
# (via the key "pop_best"), center of the search distribution
50
+
# (via the key "center", in case a distribution-based evolutionary
51
+
# algorithm is being used), etc.
52
+
53
+
for status_key in searcher.iter_status_keys():
54
+
print("===", status_key, "===")
55
+
print(searcher.status[status_key])
56
+
print()
45
57
```
58
+
59
+
## Extracting and analyzing results
60
+
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`.
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]:
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:
evals_as_tensor = solution_object.evals # fitness(es), evaluation data, etc.
75
+
```
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
+
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
+
```
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`.
86
+
87
+
```python
88
+
for solution in searcher.population:
89
+
print("Decision values:", solution.values)
90
+
print("Evaluation:", solution.evals) # fitnesses, evaluation data, etc.
91
+
print()
92
+
```
93
+
94
+
Please see also [here](algorithm_usage.md#accessing-the-status) for details regarding the status items.
0 commit comments