Package: edolab
edolabA command line tool for running experiments withedo.Installationedolabispip-installable:$ python -m pip install edolabUsageExperiment scriptsTo useedolab, you will need to write a Python script configuring the
parameters of your experiment.Required parametersfitness: A function that takes (at least) anedo.Individualinstance
to be used as the fitness function byedodistributions: A list ofedo.distribution.Distributionsubclasses that
will be used to create theedo.Familyinstances foredoVariable assignments for all of the essential arguments inedo.DataOptimiserexcept forfamiliesOptional parametersroot: A directory to which data should be written (and summarised from)processes: A number of processes foredoto use when calculating
population fitnessCustom column distribution classes should be defined in the scriptIf you wish to use a customstopordwindlemethod then define a subclass
ofedo.DataOptimiserand assign that class to a variable calledoptimiserAny keyword arguments to pass tofitnessor thestopanddwindlemethods
should be assigned to the corresponding<func>_kwargsvariable.An example of such a script would be something like this:""" /path/to/experiment/script.py """importedoimportnumpyasnpfromedo.distributionsimportUniformclassCustomOptimiser(edo.DataOptimiser):""" This is an optimiser with custom stopping and dwindling methods. """defstop(self,tol):""" Stop if the median fitness is less than `tol` away from zero. """self.converged=abs(np.median(self.pop_fitness))<toldefdwindle(self,rate):""" Cut the mutation probability in half every `rate` generations. """ifself.generation%rate==0:self.mutation_prob/=2deffitness(individual,size,seed=0):""" Randomly sample `size` values from an individual and return theminimum. """np.random.seed(seed)values=individual.dataframe.values.flatsample=np.random.choice(values,size=size)returnmin(sample)classNegativeUniform(Uniform):""" A copy that only takes negative values. """name="NegativeUniform"param_limits={"bounds":[-1,0]}hard_limits={"bounds":[-100,0]}size=5row_limits=[1,5]col_limits=[1,2]max_iter=3best_prop=0.5mutation_prob=0.5Uniform.param_limits["bounds"]=[0,1]distributions=[Uniform,NegativeUniform]optimiser=CustomOptimiserfitness_kwargs={"size":3}stop_kwargs={"tol":1e-3}dwindle_kwargs={"rate":10}For more details on the parameters ofedo, see its documentation:https://edo.readthedocs.ioRunning the experimentThen, to run an experiment with this script do the following:$ edolab run /path/to/experiment/script.pySummarising the experimentAnd to summarise the data (for easy transfer):$ edolab summarise /path/to/experiment/script.pyFor further details on the commands, use the--helpflag on therunandsummarisecommands.A note on reproducibilityIt is highly recommended that you use a virtual environment when usingedoin
or outside of this command line tool asedousespickleto store various
objects created in a run that may not be retrievable with a different version of
Python.ContributingThis tool has been made to be pretty bare and could use some padding out. If
you'd like to contribute then make a fork and clone the repository locally:$ git clone https://github.com/<your-username>/edolab.gitInstall the package and replicate thecondaenvironment (or install the
development dependencies manually):$ cd edolab
$ python setup.py develop
$ conda env create -f environment.yml
$ conda activate edolab-devMake your changes and write tests to go with them, ensuring they pass:$ python -m pytest --cov=edolab --cov-fail-under=100 testsCommit, push to your fork and open a pull request!