Skip to content

Commit b26f31f

Browse files
fix: generated the doce with the second draft version of the PyBADS documentation
1 parent 6ba233d commit b26f31f

18 files changed

+126
-97
lines changed

_images/bads-cartoon.png

275 KB
Loading

_modules/pybads/bads/bads.html

+28-28
Large diffs are not rendered by default.

_modules/pybads/bads/optimize_result.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ <h1>Source code for pybads.bads.optimize_result</h1><div class="highlight"><pre>
356356

357357
<div class="viewcode-block" id="OptimizeResult"><a class="viewcode-back" href="../../../api/classes/optimize_result.html#pybads.bads.OptimizeResult">[docs]</a><span class="k">class</span> <span class="nc">OptimizeResult</span><span class="p">(</span><span class="nb">dict</span><span class="p">):</span>
358358
<span class="sd">&quot;&quot;&quot;</span>
359-
<span class="sd"> It Represents the optimization result.</span>
359+
<span class="sd"> It represents the optimization result.</span>
360360
<span class="sd"> </span>
361361
<span class="sd"> Attributes:</span>
362362
<span class="sd"> </span>

_modules/pybads/variable_transformer/variables_transformer.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ <h1>Source code for pybads.variable_transformer.variables_transformer</h1><div c
357357

358358
<div class="viewcode-block" id="VariableTransformer"><a class="viewcode-back" href="../../../api/classes/parameter_transformer.html#pybads.variable_transformer.VariableTransformer">[docs]</a><span class="k">class</span> <span class="nc">VariableTransformer</span><span class="p">:</span>
359359
<span class="sd">&quot;&quot;&quot;</span>
360-
<span class="sd"> A class enabling linear or non-linear transformation of the bounds (PLB and PUB) and map them to an hypercube [-1, 1]^D</span>
360+
<span class="sd"> A class enabling linear or non-linear transformation of the bounds (plb and pub) and map them to an hypercube [-1, 1]^D</span>
361361
<span class="sd"> </span>
362362
<span class="sd"> Parameters</span>
363363
<span class="sd"> ----------</span>
@@ -392,7 +392,7 @@ <h1>Source code for pybads.variable_transformer.variables_transformer</h1><div c
392392
<span class="n">plausible_upper_bounds</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
393393
<span class="n">apply_log_t</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
394394
<span class="p">):</span>
395-
<span class="c1"># Empty LB and UB are Infs</span>
395+
<span class="c1"># Empty lb and ub are Infs</span>
396396
<span class="k">if</span> <span class="n">lower_bounds</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
397397
<span class="n">lower_bounds</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="n">D</span><span class="p">))</span> <span class="o">*</span> <span class="o">-</span><span class="n">np</span><span class="o">.</span><span class="n">inf</span>
398398
<span class="k">if</span> <span class="n">upper_bounds</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
@@ -471,9 +471,9 @@ <h1>Source code for pybads.variable_transformer.variables_transformer</h1><div c
471471
<span class="k">def</span> <span class="nf">__create_hypercube_trans__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
472472
<span class="sd">&quot;&quot;&quot;</span>
473473
<span class="sd"> Standardize variables via linear or nonlinear transformation.</span>
474-
<span class="sd"> The standardized transform maps PLB and PUB to the hypercube [-1,1]^D.</span>
475-
<span class="sd"> If PLB and/or PUB are empty, LB and/or UB are used instead. Note that</span>
476-
<span class="sd"> at least one among LB, PLB and one among UB, PUB needs to be nonempty.</span>
474+
<span class="sd"> The standardized transform maps plb and pub to the hypercube [-1,1]^D.</span>
475+
<span class="sd"> If plb and/or pub are empty, lb and/or ub are used instead. Note that</span>
476+
<span class="sd"> at least one among lb, plb and one among ub, pub needs to be nonempty.</span>
477477

478478
<span class="sd"> Parameters</span>
479479
<span class="sd"> ----------</span>
@@ -489,13 +489,13 @@ <h1>Source code for pybads.variable_transformer.variables_transformer</h1><div c
489489
<span class="sd"> &quot;&quot;&quot;</span>
490490
<span class="c1"># Check finiteness of plausible range</span>
491491
<span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">isfinite</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">concatenate</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">plb</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">pub</span><span class="p">])))):</span>
492-
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Plausible interval ranges PLB and PUB need to be finite.&quot;</span><span class="p">)</span>
492+
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Plausible interval ranges plb and pub need to be finite.&quot;</span><span class="p">)</span>
493493

494494
<span class="c1"># Check that the order of bounds is respected</span>
495495
<span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lb</span> <span class="o">&lt;=</span> <span class="bp">self</span><span class="o">.</span><span class="n">plb</span><span class="p">)</span> \
496496
<span class="ow">and</span> <span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">plb</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">pub</span><span class="p">)</span>\
497497
<span class="ow">and</span> <span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pub</span> <span class="o">&lt;=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ub</span><span class="p">)):</span>
498-
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Interval bounds needs to respect the order LB &lt;= PLB &lt; PUB &lt;= UB for all coordinates.&quot;</span><span class="p">)</span>
498+
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Interval bounds needs to respect the order lb &lt;= plb &lt; pub &lt;= ub for all coordinates.&quot;</span><span class="p">)</span>
499499

500500

501501
<span class="c1"># A variable is converted to log scale if all bounds are positive and</span>

_sources/about_us.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ About us
44

55
PyBADS is an open-source Python software for resource-efficient optimization problems.
66

7-
The development of PyBADS has been generously funded by the `Finnish Center for Artificial Intelligence FCAI <https://fcai.fi/>`_.
7+
The development of PyBADS has been partly funded by the `Finnish Center for Artificial Intelligence FCAI <https://fcai.fi/>`_.
88

99

1010
Development team

_sources/api/classes/bads.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BADS
66

77
The ``BADS`` class implements the Bayesian Adaptive Direct Search (BADS) algorithm.
88

9-
BADS attempts to solve a constraint optimization for rough and possible noisy functions, by finding optimistically its global minimum.
9+
BADS attempts to solve an unbounded, bounded or nonlinearly constrained optimization (minimization) problem, and is compatible with both noiseless and noisy target functions.
1010

1111
To perform the optimization, first initialize a ``BADS`` object and then call ``bads.optimize()`` on the instance.
1212

_sources/api/options/bads_options.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
============
22
BADS options
33
============
4-
The options can be divided into two types of options:
5-
- **Basic default options:** We expect that these options are changed by many users.
6-
- **Advanced options:** These options are for advanced users of BADS. Do not modify them unless you *know* what you are doing.
4+
The options can be divided into two types:
5+
- **Basic options:** These options are of interest to most users, and cover all regular usage needs.
6+
- **Advanced options:** These options should rarely if ever be touched and are reserved to advanced users / developers of BADS. Do not modify them unless you *know* what you are doing.
77

88
You can find the default options for both groups below.
99

1010
Basic options
1111
=====================
12-
We expect that these options are changed by many users.
12+
We expect these options to be routinely changed by many users.
1313

1414
.. include:: ./../../../../pybads/bads/option_configs/basic_bads_options.ini
1515
:literal:
1616

1717
Advanced Options
1818
=====================
19-
These options are for advanced users of BADS. Do not modify them unless you know
20-
what you are doing.
19+
These options are reserved to advanced users / developers of BADS.
20+
We recommend against changing these, unless you know what you are doing.
2121

2222
.. include:: ./../../../../pybads/bads/option_configs/advanced_bads_options.ini
2323
:literal:

_sources/index.rst

+27-7
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,42 @@
22
PyBADS
33
******
44

5-
PyBADS is a Python implementation of the Bayesian Adaptive Direct Search (BADS) algorithm for solving difficult and moderate expensive optimization problems, originally implemented :labrepos:`in MATLAB <bads>`.
5+
PyBADS is a Python implementation of the Bayesian Adaptive Direct Search (BADS) algorithm for solving difficult and moderately expensive optimization problems, originally implemented :labrepos:`in MATLAB <bads>`.
66

77
What is it?
88
###########
99

1010
BADS is a fast hybrid Bayesian optimization algorithm designed to solve difficult optimization problems, in particular related to fitting computational models (e.g., `via maximum likelihood estimation <https://en.wikipedia.org/wiki/Maximum_likelihood_estimation>`__).
1111

12-
BADS has been intensively tested for fitting a variety of computational models, and is currently being used in many computational labs around the world (see `Google Scholar <https://scholar.google.co.uk/scholar?cites=7209174494000095753&as_sdt=2005&sciodt=0,5&hl=en>`__ for many example applications). In our benchmark with real model-fitting problems, BADS performed on par or better than many other common and state-of-the-art optimizers, such as `fminsearch`, `fmincon`, and `cmaes` as shown in the original paper presented at NeurIPS in 2017 `(Acerbi, 2017) <#references>`_.
12+
BADS has been intensively tested for fitting a variety of computational models, and is currently being used in many computational labs around the world (see `Google Scholar <https://scholar.google.co.uk/scholar?cites=7209174494000095753&as_sdt=2005&sciodt=0,5&hl=en>`__ for many example applications).
1313

14-
BADS requires no specific tuning and runs off-the-shelf like other built-in MATLAB optimizers such as `fminsearch`.
14+
In our benchmark with real model-fitting problems, BADS performed on par or better than many other common and state-of-the-art optimizers, as shown in the original BADS paper (`Acerbi and Ma, 2017 <#references>`_).
15+
16+
BADS requires no specific tuning and runs off-the-shelf similarly to other Python optimizers, such as those in `scipy.optimize.minimize`.
1517

1618
*Note*: If you are interested in estimating posterior distributions (i.e., uncertainty and error bars) over model parameters, and not just point estimates, you might also want to check out Variational Bayesian Monte Carlo for Python (:labrepos:`PyVBMC <pyvbmc>`), a package for Bayesian posterior and model inference which can be used in synergy with PyBADS.
1719

18-
Example run
20+
How does it work?
1921
-----------
20-
TODO: Put a Gif here showing a BADS run on a simple problem (e.g on the Rosenbrock's banana function).
22+
23+
PyBADS/BADS follows a `mesh adaptive direct search <http://epubs.siam.org/doi/abs/10.1137/040603371>`__ (MADS) procedure for function minimization that alternates **poll** steps and **search** steps (see **Fig 1**).
24+
25+
- In the **poll** stage, points are evaluated on a mesh by taking steps in one direction at a time, until an improvement is found or all directions have been tried. The step size is doubled in case of success, halved otherwise.
26+
- In the **search** stage, a `Gaussian process <https://en.wikipedia.org/wiki/Gaussian_process>`__ (GP) is fit to a (local) subset of the points evaluated so far. Then, we iteratively choose points to evaluate according to a *lower confidence bound* strategy that trades off between exploration of uncertain regions (high GP uncertainty) and exploitation of promising solutions (low GP mean).
27+
28+
.. image:: _static/bads-cartoon.png
29+
:align: center
30+
:alt: Fig 1: BADS procedure
31+
32+
Fig 1: BADS procedure
33+
34+
See `here <https://github.com/lacerbi/optimviz>`__ for a visualization of several optimizers at work, including BADS.
35+
36+
See our paper for more details (`Acerbi and Ma, 2017 <#references>`_).
37+
38+
.. Example run
39+
-----------
40+
TODO: Put a Gif here showing a BADS run on a simple problem (e.g on the Rosenbrock's banana function).
2141
2242
Should I use PyBADS?
2343
--------------------
@@ -61,7 +81,7 @@ Contributing
6181
References
6282
###############
6383

64-
1. Acerbi, L. (2017). Practical Bayesian Optimization for Model Fitting with Bayesian Adaptive Direct Search. In *Advances in Neural Information Processing Systems 31*: 8222-8232. (`paper + supplement on arXiv <https://arxiv.org/abs/1705.04405>`__, `NeurIPS Proceedings <https://papers.nips.cc/paper/2017/hash/df0aab058ce179e4f7ab135ed4e641a9-Abstract.html>`__)
84+
1. Acerbi, L. & Ma, W. J. (2017). Practical Bayesian Optimization for Model Fitting with Bayesian Adaptive Direct Search. In *Advances in Neural Information Processing Systems 31*: 8222-8232. (`paper + supplement on arXiv <https://arxiv.org/abs/1705.04405>`__, `NeurIPS Proceedings <https://papers.nips.cc/paper/2017/hash/df0aab058ce179e4f7ab135ed4e641a9-Abstract.html>`__)
6585

6686
You can cite BADS in your work with something along the lines of
6787

@@ -90,7 +110,7 @@ You may also want to check out the original :labrepos:`MATLAB toolbox <bads>`.
90110

91111
Acknowledgments:
92112
################
93-
Work on the PyBADS package was funded by the `Finnish Center for Artificial Intelligence FCAI <https://fcai.fi/>`_.
113+
Work on the PyBADS package was supported by the Academy of Finland Flagship programme: `Finnish Center for Artificial Intelligence FCAI <https://fcai.fi/>`_.
94114

95115
.. toctree::
96116
:maxdepth: 1

_sources/quickstart.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,26 @@ Running the optimizer in step 3 only involves a couple of lines of code:
2323
2424
from pybads import BADS
2525
# ...
26-
bads = BADS(target, x0, LB, UB, PLB, PUB)
26+
bads = BADS(target, x0, lb, ub, plb, pub)
2727
optimize_result = bads.optimize()
2828
2929
with input arguments:
3030

3131
- ``target``: the target function, it takes as input a vector and returns its function evaluation;
3232
- ``x0``: the starting point of the optimization problem. If it is not given, the starting point is randomly drawn from the problems bounds;
33-
- ``LB`` and ``UB``: hard lower and upper bounds for the optimization region (can be ``-inf`` and ``inf``, or bounded);
34-
- ``PLB`` and ``PUB``: *plausible* lower and upper bounds, that represent our best guess at bounding the region where the solution might lie;
33+
- ``lb`` and ``ub``: hard lower and upper bounds for the optimization region (can be ``-inf`` and ``inf``, or bounded);
34+
- ``plb`` and ``pub``: *plausible* lower and upper bounds, that represent our best guess at bounding the region where the solution might lie;
3535
- ``non_box_cons`` (optional): a callable non-bound constraints function.
3636

3737
The outputs are:
3838

39-
- ``optimize_result``: a ``OptimizeResult`` which presents the most important information about the solution and the optimization problem.
39+
- ``optimize_result``: a ``OptimizeResult`` which presents the most important information about the solution and the optimization problem. In particular:
4040

4141
- ``"x"``: the minimum point found by the optimizer;
4242
- ``"fval"``: the value of the function at the given solution.
4343

44-
The ``optimize_result`` object can be manipulated in various ways, see the :ref:`OptimizeResult` class documentation.
44+
The ``optimize_result`` object contains more information about the optimization solution, see the :ref:`OptimizeResult` class documentation.
4545

4646
See the examples for more detailed information. The :ref:`Basic options` may also be useful.
4747

48-
In addition, checkout the `BADS FAQ <https://github.com/acerbilab/bads/wiki#bads-frequently-asked-questions>`__ page for practical recommendations, such as how to set `LB` and `UB`, and other practical insights. Although, the FAQ refers to the MATLAB version of BADS, most of the concepts still apply for PyBADS.
48+
In addition, checkout the `BADS FAQ <https://github.com/acerbilab/bads/wiki#bads-frequently-asked-questions>`__ page for practical recommendations, such as how to set `lb` and `ub`, and other practical insights. Even though the FAQ refers to the MATLAB version of BADS, most of the concepts still apply to PyBADS.

about_us.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ <h2> Contents </h2>
488488
<section id="about-us">
489489
<h1>About us<a class="headerlink" href="#about-us" title="Permalink to this headline">#</a></h1>
490490
<p>PyBADS is an open-source Python software for resource-efficient optimization problems.</p>
491-
<p>The development of PyBADS has been generously funded by the <a class="reference external" href="https://fcai.fi/">Finnish Center for Artificial Intelligence FCAI</a>.</p>
491+
<p>The development of PyBADS has been partly funded by the <a class="reference external" href="https://fcai.fi/">Finnish Center for Artificial Intelligence FCAI</a>.</p>
492492
<section id="development-team">
493493
<h2>Development team<a class="headerlink" href="#development-team" title="Permalink to this headline">#</a></h2>
494494
<p>PyBADS is actively developed mainly by members of <a class="reference external" href="https://www2.helsinki.fi/en/researchgroups/machine-and-human-intelligence">Luigi Acerbi’s research group</a> at the University of Helsinki.</p>

0 commit comments

Comments
 (0)