How to run the code ?¶
This short page explains quickly how to install the requirements for this project, and then how to use the code to run simulations.
First, install the requirements, globally (or with a virtualenv, see below):
pip install -r requirements.txt
Some requirements are only needed for one policy (mostly the experimental ones), and for the documentation.
Running some simulations¶
Then, it should be very straight forward to run some experiment.
This will run the simulation, average them (by
repetitions) and plot the results.
python main.py configuration_comparing_aggregation_algorithms # or make comparing_aggregation_algorithms
See these explainations: Aggregation.md
python main.py configuration_comparing_doubling_algorithms # or make comparing_doubling_algorithms
See these explainations: DoublingTrick.md
python main.py configuration_sparse # or make sparse
See these explainations: SparseBandits.md
env variables ?¶
For all simulations, I recently added the support for environment variable, to ease the customization of the main parameters of every simulations.
For instance, if the
configuration_multiplayers_more.py file is correct,
then you can customize to use
N=4 repetitions, for horizon
M=3 players, parallelized with
N_JOBS=4 jobs (use the number of cores of your CPU for optimal performance):
N=4 T=1000 M=3 DEBUG=True SAVEALL=False N_JOBS=4 make moremulti
If you prefer to not install the requirements globally on your system-wide Python setup, you can (and should) use
$ virtualenv . Using base prefix '/usr' New python executable in /your/path/to/SMPyBandits/bin/python3 Also creating executable in /your/path/to/SMPyBandits/bin/python Installing setuptools, pip, wheel...done. $ source bin/activate # in bash, use activate.csh or activate.fish if needed $ type pip # just to check pip is /your/path/to/SMPyBandits/bin/pip $ pip install -r requirements.txt Collecting numpy (from -r requirements.txt (line 5)) ... Installing collected packages: numpy, scipy, cycler, pytz, python-dateutil, matplotlib, joblib, pandas, seaborn, tqdm, sphinx-rtd-theme, commonmark, docutils, recommonmark Successfully installed commonmark-0.5.4 cycler-0.10.0 docutils-0.13.1 joblib-0.11 matplotlib-2.0.0 numpy-1.12.1 pandas-0.19.2 python-dateutil-2.6.0 pytz-2016.10 recommonmark-0.4.0 scipy-0.19.0 seaborn-0.7.1 sphinx-rtd-theme-0.2.4 tqdm-4.11.2
And then be sure to use the virtualenv binary for Python,
bin/python, instead of the system-wide one, to launch the experiments (the Makefile should use it by default, if
source bin/activate was executed).
You can also use the provided
Makefile file to do this simply:
make install # install the requirements make multiplayers # run and log the main.py script
make lint lint3 # check the code with pylint
It is also used to clean the code, build the doc, send the doc, etc. (This should not be used by others)