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.
A pinned Nix environment is available:
nix-shell
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
# or
make main
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
python main.py configuration_markovian
# or
make markovian
python main.py configuration_nonstationary
# or
make nonstationary
See these explainations: NonStationaryBandits.md
python main_multiplayers.py
# or
make multi
python main_multiplayers_more.py
# or
make moremulti
See these explainations: MultiPlayers.md
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 T=1000
and 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
In a virtualenv
?
If you prefer to not install the requirements globally on your system-wide Python setup, you can (and should) use virtualenv
.
$ 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).
Or with a Makefile
?
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
It can be used to check the quality of the code with pylint:
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)
Or within a Jupyter notebook ?
I am writing some Jupyter notebooks, in this folder (
notebooks/
), so if you want to do the same for your small experiments, you can be inspired by the few notebooks already written.
MIT Licensed (file LICENSE).
漏 2016-2018 Lilian Besson.