Soft robot evolution using:
- EvolutionGym benchmark, to co-optimize control and design and run simulations
- Map Elites, provided by QDPY, to promote diversity
Clone the repository:
git clone https://github.com/elisacomposta/soft-robot-evolution.git
Install qdpy:
pip3 install qdpy[all]
Inside the main folder, clone EvolutionGym repository:
git clone --recurse-submodules https://github.com/elisacomposta/evogym.git
and follow the instructions to install it at evogym repository
Parameters can be defined in run_qd.py
:
experiment_name
= name of the experiment; all results are saved in results/experiment_nameconfigFileName
= name of the YAML configuration filenum_cores
= number of robots to train in parallelparallelismType
= type of parallelism used for the illumination process.
Note: QDPY proposes many types of executors ('sequential', 'multithreading', 'multiprocessing', 'concurrent', 'scoop', 'ray'). For more details seeqdpy/base.py
.
The environment name and other parameters can be defined in the configuration file. See the examples in conf/
.
Run the example using the following command.
python run_qd.py --algo ppo --use-gae --lr 2.5e-4 --clip-param 0.1 --value-loss-coef 0.5 --num-processes 4 --num-steps 128 --num-mini-batch 4 --log-interval 100 --use-linear-lr-decay --entropy-coef 0.01 --no-cuda --eval-interval 20
All PPO hyperparameters are specified through command line arguments. For more details please see this repo.
It allows the realization of single or mediated maps and trends after an experiment has finished, thanks to the stored plot data.
Set the parameters:
qd_plot
,evogym_plot
,compare_exp
: one of them shoud be True, to choose which plot to makeexperiments
: names of the stored experimentsresults_dir
: path where to save the plotsfitness_domain
: set the domain of the fitness (optional)features
: features used in the experimenttot_random
: number of randomly generated individuals, to plot vertical line (optionl)
Store images of the evaluated individuals. Set the following parameters:
exp_name
: name of the experimentgen_algo
: if true, looks for the experiment in evogym/examples/saved_datainds
: list of labels of the individual to storestore_in_order
: if true, store design as num_indLabelgeneration
: if using gen algo experiment
Run python visualize.py
and follow the instructions to visualize the simulation an individual from a stored experiment.