Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include basic usage in Quick Start and Readme #102

Closed
fluegelk opened this issue Jan 16, 2024 · 1 comment · Fixed by #110
Closed

Include basic usage in Quick Start and Readme #102

fluegelk opened this issue Jan 16, 2024 · 1 comment · Fixed by #110
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@fluegelk
Copy link

Currently, the Quick Start page and the Readme only cover the installation of propulate. For a proper quick start, it would be nice to have a short summary of how to use propulate (i.e., less detailed than the step-by-step Tutorials).
Something like a minimum working example of commands I can just copy and paste to get propulate running in my code and tweak it from there using the more detailed docs. Most of it could probably be taken from tutorials/propulator_example.py, but removing all non-essential code like the argparsing and using default parameters where possible.

Sort of like this:

import propulate  
from mpi4py import MPI  
import random  
  
# Set the communicator and the optimization parameters  
comm = MPI.COMM_WORLD  
rng = random.Random(MPI.COMM_WORLD.rank)  
population_size = comm.size * 2  
generations = 100  
crossover_probability = 0.7  
mutation_probability = 0.4  
random_init_probability = 0.1  
checkpoint = 'propulate_checkpoints'  
propulate.utils.set_logger_config()  
  
  
# Define the function to minimize and the search space, e.g. a 2D sphere function on (-5.12, 5.12)^2  
def loss_fn(params):  
    return params['x'] ** 2 + params['y'] ** 2  
  
limits = {"x": (-5.12, 5.12), "y": (-5.12, 5.12)}  
  
# Initialize the propagator and propulator  
propagator = propulate.utils.get_default_propagator(pop_size=population_size, limits=limits,  
                                                    mate_prob=crossover_probability, mut_prob=mutation_probability,  
                                                    random_prob=random_init_probability, rng=rng)  
propulator = propulate.Propulator(loss_fn=loss_fn, propagator=propagator, comm=comm, generations=generations,  
                                  checkpoint_path=checkpoint, rng=rng)  
  
# Run optimization and get summary of results.  
propulator.propulate()  
propulator.summarize()

Ideally, you could make this even shorter by setting more default values, e.g., for the probabilities (if feasible).

Also, the link to the scripts subfolder in Quick Start seems to be outdated and should probably point to the tutorials.

@mcw92 mcw92 self-assigned this Mar 12, 2024
@mcw92 mcw92 added the documentation Improvements or additions to documentation label Mar 12, 2024
@mcw92
Copy link
Member

mcw92 commented Mar 12, 2024

Thanks for your comment! I assigned myself to this issue and will include your suggestions. I also decided to add a more elaborate quickstart section in the README which will be merged into the master branch soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
2 participants