Skip to main content
TSRoots_Logo

Test Suite License Python Version PyPI

BO Iterations GIF

Paper, Paper, Tutorials

 
TSRoots

A Python package for efficient Gaussian process Thompson sampling in Bayesian optimization via rootfinding.

 
Bayesian optimization (BO) uses acquisition functions to guide the optimization of expensive objective functions. Gaussian process Thompson sampling (GP-TS), a popular BO acquisition strategy, optimizes posterior samples to guide exploration and exploitation. However, these samples can be highly complex, which makes their global optimization computationally challenging.

TSRoots accelerates this process by leveraging the separability of multivariate Gaussian Process priors and a decoupled representation of the posterior. Integrated with advanced root-finding techniques, TSRoots efficiently and adaptively selects starting points for gradient-based multistart optimization. This results in high-quality solutions for GP-TS, enabling robust performance in both low- and high-dimensional settings.

Installation

Requirements

  • Python >= 3.7
  • PyTorch
  • chebpy

Requirements Installation Dependencies

Some required dependencies, such as torch and chebpy are not installed by default.

  • To install PyTorch, we recommend installing the appropriate version of PyTorch for your system by following the instructions here: PyTorch Installation Instructions. Although least preferred, you can directly install for CPU version by running pip install torch.
  • To install chebpy, you can see installation instructions here: Chepy Installation Instructions. You can also directly install chebpy via pip install git+https://github.com/chebpy/chebpy.git

Once the above requirements have been satisfied, you can install the TSRoots package in various ways: using pip, or directly from Github.

Lightweight Installation of TSRoots

Using pip:

pip install tsroots

Development Version

If you are contributing a pull request or for a full installation with examples, tests, and the latest updates, it is best to perform a manual installation:

git clone https://github.com/UQUH/TSRoots.git
cd TSRoots
pip install -e .[docs,pytorch,test]
pip install git+https://github.com/chebpy/chebpy.git  # Install Chebpy from git

To verify correct installation, you can run on the test suite on your terminal via:

python shell/run_all_tests.py

Quick Start

This example demonstrates TSRoots' core functionality of generating new observation points for Bayesian optimization using normalized data and gradient-based rootfinding techniques. For a more detailed overview of model fitting, rootfinding, decoupled GP representation, and BO implementation including generating the animated plot above, check out the Getting Started Notebook.

from tsroots.optim import TSRoots
from tsroots.utils import generate_Xdata, generate_Ydata

import numpy as np
import matplotlib.pyplot as plt

# Define the objective function
def f_objective_example(x):
    return x * np.sin(x)

# Define bounds and generate sample data
lb_x_physical = np.array([-15])
ub_x_physical = np.array([15])
no_sample = 5
D = 1
seed = 42

# Generate initial samples and normalize them
X_physical_space, X_normalized = generate_Xdata(no_sample, D, seed, lb_x_physical, ub_x_physical)
Y_physical_space, Y_normalized = generate_Ydata(f_objective_example, X_physical_space)

# Instantiate and use TSRoots for optimization
TSRoots_BO = TSRoots(X_normalized, Y_normalized.flatten(), -np.ones(D), np.ones(D))
x_new_normalized, y_new_normalized, _ = TSRoots_BO.xnew_TSroots(plot=True)
# plot selected point
plt.scatter(x_new_normalized, y_new_normalized, color='blue', marker='x', linewidth=3.0, label='Selected Point')
plt.show()

print(f"New observation location: {x_new_normalized}")
print(f"New function value: {y_new_normalized}")

Citation

If you found TSRoots helpful, please cite the following paper:

@inproceedings{Adebiyi2025tsroots,
title={Optimizing Posterior Samples for Bayesian Optimization via Rootfinding},
author={Taiwo Adebiyi and Bach Do and Ruda Zhang},
booktitle={The Thirteenth International Conference on Learning Representations},
year={2025},
url={https://openreview.net/forum?id=I6UbnkUveF}
}

The Team

TSRoots is produced by the Uncertainty Quantification Lab at the University of Houston. The primary maintainers are:

  • Taiwo A. Adebiyi
  • Bach Do
  • Ruda Zhang

Release files for tsroots 0.1.22

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tsroots 0.1.22
File Size Uploaded
tsroots-0.1.22.tar.gz 29.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tsroots 0.1.22
File Interpreter ABI Platform
tsroots-0.1.22-py3-none-any.whl Python 3 none any Details

Total release size: 55.5 kB

Release files / tsroots-0.1.22.tar.gz

Download URL tsroots-0.1.22.tar.gz
Size 29.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4ea1774a806aada277e982ea47f7093930fdf1e64c70de7e32836be02517315d
BLAKE2b-256 checksum
How to use checksums
010cae2e7b15dd571b56e328c5738320172b081e5487d82324bf9044afbe7597
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.0

Release files / tsroots-0.1.22-py3-none-any.whl

Download URL tsroots-0.1.22-py3-none-any.whl
Size 26.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
727e870fb66dcdd105a11d4c1114172827ae62c645ab285df9976c1ec2bc0516
BLAKE2b-256 checksum
How to use checksums
75dc5b5029658927040d5c8d43a07ac39843fe5471581188cb695f0794d5c7a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.0

Release history Release notifications | RSS feed

This release

0.1.22 This release

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.12

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page