Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #500

Merged
merged 6 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .envs/testenv-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ dependencies:
- pytest-cov # tests
- pytest-xdist # dev, tests
- statsmodels # dev, tests
- bokeh<=2.4.3 # run, tests
- click # run, tests
- cloudpickle # run, tests
- joblib # run, tests
- numpy<2.0 # run, tests
Expand All @@ -30,7 +28,6 @@ dependencies:
- Py-BOBYQA # dev, tests
- fides==0.7.4 # dev, tests
- kaleido # dev, tests
- simoptlib==1.0.1 # dev, tests
- pandas-stubs # dev, tests
- types-cffi # dev, tests
- types-openpyxl # dev, tests
Expand Down
3 changes: 0 additions & 3 deletions .envs/testenv-others.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ dependencies:
- pytest-cov # tests
- pytest-xdist # dev, tests
- statsmodels # dev, tests
- bokeh<=2.4.3 # run, tests
- click # run, tests
- cloudpickle # run, tests
- joblib # run, tests
- numpy<2.0 # run, tests
Expand All @@ -29,7 +27,6 @@ dependencies:
- Py-BOBYQA # dev, tests
- fides==0.7.4 # dev, tests
- kaleido # dev, tests
- simoptlib==1.0.1 # dev, tests
- pandas-stubs # dev, tests
- types-cffi # dev, tests
- types-openpyxl # dev, tests
Expand Down
3 changes: 0 additions & 3 deletions .envs/testenv-pandas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ dependencies:
- pytest-cov # tests
- pytest-xdist # dev, tests
- statsmodels # dev, tests
- bokeh<=2.4.3 # run, tests
- click # run, tests
- cloudpickle # run, tests
- joblib # run, tests
- numpy<2.0 # run, tests
Expand All @@ -28,7 +26,6 @@ dependencies:
- Py-BOBYQA # dev, tests
- fides==0.7.4 # dev, tests
- kaleido # dev, tests
- simoptlib==1.0.1 # dev, tests
- types-cffi # dev, tests
- types-openpyxl # dev, tests
- -e ../
18 changes: 17 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@ chronological order. We follow [semantic versioning](https://semver.org/) and al
releases are available on [Anaconda.org](https://anaconda.org/OpenSourceEconomics/estimagic).

Following the [scientific python guidelines](https://scientific-python.org/specs/spec-0000/)
we drop the official support for Python 3.8.
we drop the official support for Python 3.9.


## 0.5.0

This is a major release with several breaking changes and deprecations. On a high level,
the major changes are:

- Implement EP-02: Static typing
- Implement EP-03: Alignment with SciPy
- Rename the package from `estimagic` to `optimagic` (while keeping the `estimagic`
namespace for the estimation capabilities).

### Breaking changes

- {gh}`500` removes the dashboard, the support for simopt optimizers and the
`derivative_plot` ({ghuser}`janosg`)


## 0.4.6
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ provides functionality to perform statistical inference on estimated parameters.
- The complete history of parameters and function evaluations can be saved in a database
for maximum reproducibility.
- Painless and efficient multistart optimization.
- The progress of the optimization is displayed in real time via an interactive
dashboard.
- The progress of the optimization can be displayed in in `criterion_plot` and
janosg marked this conversation as resolved.
Show resolved Hide resolved
`params_plot` while the optimization is still running.

### Estimation and Inference

Expand Down
130 changes: 1 addition & 129 deletions docs/source/algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -2076,7 +2076,7 @@ To use ipopt, you need to have
- `num_linear_variables`: since estimagic may reparametrize your problem
and this changes the parameter problem, we do not support this option.
- derivative checks
- print options. Use estimagic's dashboard to monitor your optimization.
- print options.


- **convergence.relative_criterion_tolerance** (float): The algorithm
Expand Down Expand Up @@ -3894,134 +3894,6 @@ addition to estimagic when using an NLOPT algorithm. To install nlopt run
10 * (number of parameters + 1).
```

## The SimOpt Optimizers (simopt)

estimagic supports the following [SimOpt](https://github.com/simopt-admin/simopt)
algorithms. Please add the
[appropriate citations](https://github.com/simopt-admin/simopt) in addition to estimagic
when using a SimOpt algorithm. To install simopt run `pip install simoptlib==1.0.1`.

```{eval-rst}
.. dropdown:: simopt_adam

.. code-block::

"simopt_adam"

Minimize a scalar function using the ADAM algorithm from SimOpt.

- **stopping_max_iterations** (int): If the maximum number of iterations is reached,
the optimization stops, but we do not count this as convergence.
- **crn_across_solns** (bool): Use CRN across solutions? Default True.
- **r** (int): Number of replications taken at each solution. Default 1.
- **beta_1** (float): Exponential decay of the rate for the first moment estimates.
Default 0.9.
- **beta_2** (float): Exponential decay rate for the second-moment estimates.
Default 0.999.
- **alpha** (float): Step size. Default 1.0.
- **epsilon** (float): A small value to prevent zero-division. Default 10e-8.
- **sensitivity** (float): Shrinking scale for variable bounds. Default 10e-7.
```

```{eval-rst}
.. dropdown:: simopt_astrodf

.. code-block::

"simopt_astrodf"

Minimize a scalar function using the ASTRODF algorithm from SimOpt.

- **stopping_max_iterations** (int): If the maximum number of iterations is reached,
the optimization stops, but we do not count this as convergence.
- **bounds_padding** (float): Subtract (add) this value of the bounds which will be
used by ASTRODF internally. Default 1e-8.
- **crn_across_solns** (bool): Use CRN across solutions? Default True.
- **delta_max** (float): Maximum value of the trust-region radius. Default 50.0
- **eta_1** (float): Threshhold for a successful iteration. Default 0.1.
- **eta_2** (float): Threshhold for a very successful iteration. Default 0.5.
- **gamma_1** (float): Very successful step trust-region radius increase. Default
2.0.
- **gamma_2** (float): Unsuccessful step trust-region radius decrease. Default 0.5.
- **w** (float): Trust-region radius rate of shrinkage in contracation loop. Default
0.85.
- **mu** (int): Trust-region radius ratio upper bound in contraction loop. Default
1000.
- **beta** (int): Trust-region radius ratio lower bound in contraction loop. Default
10.
- **lambda_min** (int): Minimum sample size value. Default 8.
- **simple_solve** (bool): Solve subproblem with Cauchy point (rough approximate)?
Default False.
- **criticality_select** (bool): Skip contraction loop if not near critical
region? Default True.
- **criticality_threshold** (float): Threshold on gradient norm indicating
near-critical region. Default 0.1.

.. note::
To get more accurate results in the case of bounds we revert the subtraction of
a large value from the bounds that is done internally in simopt.
Since the algorithm is numerically instable in the case of binding bounds
without this substraction, we subtract a (small) value defined by
``bounds_padding``. See the ASTRODF `source code
<https://tinyurl.com/5fxcvw2k>`_ for details.

```

```{eval-rst}
.. dropdown:: simopt_spsa

.. code-block::

"simopt_spsa"

Minimize a scalar function using the SPSA algorithm from SimOpt.

- **stopping_max_iterations** (int): If the maximum number of iterations is reached,
the optimization stops, but we do not count this as convergence.
- **crn_across_solns** (bool): Use CRN across solutions? Default True.
- **alpha** (float): Non-negative coefficient in the SPSA gain sequecence ak.
Default 0.602.
- **gamma** (float): Non-negative coefficient in the SPSA gain sequence ck. Default
0.101.
- **step** (float): Initial desired magnitude of change in the theta elements.
Default 0.5.
- **gavg** (int): Averaged SP gradients used per iteration. Default 1.
- **n_reps** (int): Number of replications takes at each solution. Default 2.
- **n_loss** (int): Number of loss function evaluations used in this gain
calculation. Default 2.
- **eval_pct** (float): Percentage of the expected number of loss evaluations per
run. Default 2/3.
- **iter_pct** (float): Percentage of the maximum expected number of iterations.
Default 0.1.
```

```{eval-rst}
.. dropdown:: simopt_strong

.. code-block::

"simopt_strong"

Minimize a scalar function using the STRONG algorithm from SimOpt.

- **stopping_max_iterations** (int): If the maximum number of iterations is reached,
the optimization stops, but we do not count this as convergence.
- **crn_across_solns** (bool): Use CRN across solutions? Default True.
- **n0** (int): Initial sample size Default 10.
- **n_r** (int): Number of replications taken at each solution. Default 1.
- **sensitivity** (float): Shrinking scale for VarBds. Default 10e-7.
- **delta_threshold** (float): Maximum value of the radius. Default 1.2.
- **delta_T** (float): Initial size of trust region. Default 2.0.
- **eta_0** (float): Constant for accepting. Default 0.01.
- **eta_1** (float): Constant for more confident accepting. Default 0.3.
- **gamma_1** (float): Constant for shrinking the trust region. Default 0.9.
- **gamma_2** (float): Constant for expanding the trust region. Default 1.11.
- **lambda** (int): Magnifying factor for n_r inside the finite difference function.
Default 2.
- **lambda_2** (float): Magnifying factor for n_r in stage I and stage II. Default
1.01.
```

## References

```{eval-rst}
Expand Down
3 changes: 1 addition & 2 deletions docs/source/development/styleguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ Your contribution should fulfill the criteria provided below.
are in doubt. Example:

```python
def ordered_logit(formula, data, dashboard=False):
def ordered_logit(formula, data):
"""Estimate an ordered probit model with maximum likelihood.

Args:
formula (str): A patsy formula.
data (str): A pandas DataFrame.
dashboard (bool): Switch on the dashboard.

Returns:
res: optimization result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ The advantages of using the algorithm with estimagic over using it directly are:

- estimagic turns an unconstrained optimizer into constrained ones.
- You can use logging.
- You get a real time dashboard to monitor your optimization.
- You get great error handling for exceptions in the criterion function or gradient.
- You get a parallelized and customizable numerical gradient if the user did not provide
a closed form gradient.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@
"source": [
"For more information on what you can do with the log file and LogReader object, check out [the logging tutorial](../how_to_guides/optimization/how_to_use_logging.ipynb)\n",
"\n",
"The persistent log file is always instantly synchronized when the optimizer tries a new parameter vector. This is very handy if an optimization has to be aborted and you want to extract the current status. It is also used by the [estimagic dashboard](../how_to_guides/optimization/how_to_use_the_dashboard.md). "
"The persistent log file is always instantly synchronized when the optimizer tries a new parameter vector. This is very handy if an optimization has to be aborted and you want to extract the current status. It can be displayed in `criterion_plot` and `params_plot`, even while the optimization is running. "
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"> For an explaination of the argument ``n_steps`` and the Richardson method, please see the API Reference and the Richardson Extrapolation explanation in the documentation.\n",
"\n",
"\n",
"The objects returned when ``return_info`` is ``True`` are rarely of any use directly and can be safely ignored. However, they are necessary data when using the plotting function ``derivative_plot`` as explained below. For better understanding, we print each of these additional objects once:"
"The objects returned when ``return_info`` is ``True`` are rarely of any use directly and can be safely ignored. "
]
},
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,6 @@
"\n",
"It is often the case that, for speed reasons, you set the number of bootstrap draws quite low, so you can look at the results earlier and later decide that you need more draws. \n",
"\n",
"In the long run, we will offer a Dashboard integration for this. For now, you can do it manually.\n",
"\n",
"As an example, we will take an initial sample of 500 draws. We then extend it with another 1500 draws. \n",
"\n",
"*Note*: It is very important to use a different random seed when you calculate the additional outcomes!!!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"source": [
"## 4b. Convergence plots\n",
"\n",
"**Convergence Plots** look at particular problems and show the convergence of each optimizer on each problem. They look similar to what you've seen from estimagic's dashboard."
"**Convergence Plots** look at particular problems and show the convergence of each optimizer on each problem. "
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"# How to use logging\n",
"\n",
"\n",
"Estimagic can keep a persistent log of the parameter and criterion values tried out by an optimizer in a sqlite database. \n",
"\n",
"The sqlite database is also used to exchange data between the optimization and the dashboard."
"Estimagic can keep a persistent log of the parameter and criterion values tried out by an optimizer in a sqlite database. \n"
]
},
{
Expand Down
Loading
Loading