Skip to content

Commit 08c48c7

Browse files
authored
Docs/improving hpc documentation (#3379)
* fix: adding missing import * feat: adding plots * docs: just small adjustment * feat: adding plot call * docs: changing background to fit theme.
1 parent 9580a45 commit 08c48c7

File tree

6 files changed

+24
-3
lines changed

6 files changed

+24
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Docs/improving hpc documentation
30.8 KB
Loading
52.1 KB
Loading

doc/source/examples/extended_examples/hpc/hpc_ml_ga.rst

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ created to run the simulation:
173173

174174
.. literalinclude:: ml_ga_beam.py
175175
:language: python
176-
:start-at: ga_instance = pygad.GA(
176+
:start-at: import pygad
177177
:end-at: To count the number of generations
178178

179179

@@ -188,15 +188,28 @@ Once the model is set, use the ``run()`` method to start the simulation:
188188
:end-at: print(f"Time spent (minutes): {(t1-t0)/60}")
189189

190190

191-
Plot convergence
192-
================
191+
Plot fitness and genes values
192+
=============================
193+
194+
You can plot the solution fitness across generations and the evolution of gene
195+
values using the following code:
193196

194197
.. literalinclude:: ml_ga_beam.py
195198
:language: python
196199
:start-at: import os
197200
:end-at: print(f"Fitness value of the best solution = {solution_fitness}")
198201

199202

203+
.. figure:: fitness_plot.png
204+
205+
Fitness at each generation plot
206+
207+
208+
.. figure:: genes.png
209+
210+
Evolution of genes values
211+
212+
200213
Model storage
201214
==============
202215

doc/source/examples/extended_examples/hpc/ml_ga_beam.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ def mutation_func(offspring, ga_instance):
199199
return offspring
200200

201201

202+
import pygad
203+
202204
ga_instance = pygad.GA(
203205
# Main options
204206
sol_per_pop=sol_per_pop,
@@ -223,6 +225,7 @@ def mutation_func(offspring, ga_instance):
223225
gene_type=gene_type,
224226
init_range_low=init_range_low,
225227
init_range_high=init_range_high,
228+
save_solutions=True,
226229
)
227230

228231
ga_instance.igen = 0 # To count the number of generations
@@ -248,6 +251,8 @@ def mutation_func(offspring, ga_instance):
248251

249252
ga_instance.plot_fitness(label=["Applied force"], save_dir=os.getcwd())
250253

254+
ga_instance.plot_genes(solutions="all")
255+
251256
solution, solution_fitness, solution_idx = ga_instance.best_solution(
252257
ga_instance.last_generation_fitness
253258
)

doc/source/user_guide/hpc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,8 @@ Advanced configuration
614614

615615
The following topics provide some advanced ideas for you to
616616
explore when using PyMAPDL on HPC clusters.
617+
In this section, these topics are just briefly described so
618+
you can use online resources such as `SLURM documentation <slurm_docs_>`_.
617619

618620
Advanced job management
619621
-----------------------

0 commit comments

Comments
 (0)