Diffusion Models as Constrained Samplers for Optimization with Unknown Constraints

Lingkai Kong, Yuanqi Du, Wenhao Mu, Kirill Neklyudov, Valentin De Bortoli, Dongxia Wu, Haorui Wang, Aaron M. Ferber, Yian Ma, Carla P. Gomes, Chao Zhang

Abstract

Addressing real-world optimization problems becomes particularly challenging when analytic objective functions or constraints are unavailable. While numerous studies have addressed the issue of unknown objectives, limited research has focused on scenarios where feasibility constraints are not given explicitly. Overlooking these constraints can lead to spurious solutions that are unrealistic in practice. To deal with such unknown constraints, we propose to perform optimization within the data manifold using diffusion models. To constrain the optimization process to the data manifold, we reformulate the original optimization problem as a sampling problem from the product of the Boltzmann distribution defined by the objective function and the data distribution learned by the diffusion model. Depending on the differentiability of the objective function, we propose two different sampling methods. For differentiable objectives, we propose a two-stage framework that begins with a guided diffusion process for warm-up, followed by a Langevin dynamics stage for further correction. For non-differentiable objectives, we propose an iterative importance sampling strategy using the diffusion model as the proposal distribution. Comprehensive experiments on a synthetic dataset, six real-world black-box optimization datasets, and a multi-objective molecule optimization dataset show that our method achieves better or comparable performance with previous state-of-the-art baselines.

Introduction

Optimization in real-world scenarios frequently encounters challenges where analytic objective functions or feasibility constraints are not explicitly available. While much progress has been made in black-box optimization for unknown objectives, the problem of unknown constraints remains relatively under-explored. In domains such as drug discovery or material science, finding a solution that maximizes an objective (e.g., binding affinity) is insufficient if the solution is physically or chemically impossible to realize. These implicit constraints are often only represented by a dataset of feasible examples. Overlooking them can lead to "hallucinated" solutions that perform well on surrogate models but are useless in practice.

Methodology

To address this, we propose DiffOPT, a framework that performs optimization within the data manifold learned by a diffusion model. We reformulate the optimization problem as a sampling task from a target distribution $\pi_\beta(x)$, defined as the product of the data distribution $p(x)$ (representing the constraints) and a Boltzmann distribution $q_\beta(x)$ (representing the objective function):

$$\pi_\beta(x) \propto p(x) \exp(-\beta h(x))$$

where $h(x)$ is the objective function and $\beta$ is the inverse temperature. As $\beta \to \infty$, sampling from $\pi_\beta(x)$ converges to finding the global minimum of $h(x)$ within the support of $p(x)$.

Conceptual overview of DiffOPT: combining the objective function and data manifold into a target distribution.

Depending on the differentiability of $h(x)$, we employ two strategies:

  1. Differentiable Objectives (Two-Stage Sampling): Stage I uses guided diffusion for a "warm-up" to move particles toward high-density, low-objective regions. Stage II employs Langevin dynamics (specifically MALA) to correct biases and ensure samples accurately represent the target distribution.
  2. Non-Differentiable Objectives (Iterative Importance Sampling): An iterative strategy where the diffusion model serves as a proposal distribution, refined through repeated denoising and re-weighting based on objective values.

Experiments

We evaluated DiffOPT across a diverse range of benchmarks to test its ability to navigate complex manifolds and handle implicit constraints:

  • Synthetic Branin Function: Used to visualize how the model handles additional known constraints on a complex surface.
  • DesignBench: Six real-world offline black-box optimization tasks, including Superconductor (material science), Ant/D’Kitty (robot morphology), TFBind8/10 (DNA binding), and ChEMBL (drug properties).
  • Multi-objective Molecule Optimization: Simultaneously optimizing for drug-likeness (QED), synthesizability (SA), and biological activity (GSK3B).

Results

DiffOPT demonstrates state-of-the-art performance across diverse tasks. On the DesignBench suite, it achieved a mean rank of 2.0, outperforming established baselines like DDOM, CbAS, and COMs.

Performance of DiffOPT across six real-world black-box optimization tasks in DesignBench.

In the Superconductor task, DiffOPT improved upon the best baseline by 9.6%. Furthermore, in molecule optimization, our method significantly outperformed gradient-based and reinforcement learning approaches in terms of "validity," generating structures that adhere to chemical feasibility constraints while maintaining high objective scores. This highlights the advantage of treating constraints as a data manifold rather than relying on fragile surrogate models.

Discussion

While DiffOPT effectively handles unknown constraints, its performance is tied to the quality of the learned score function and the reliability of the objective surrogate. Future work includes incorporating explicit manifold constraints to prevent drift during the warm-up stage and extending the framework to online settings where new feedback can be integrated into the optimization process to further improve efficiency.

Summary updated

BibTeX
@inproceedings{kong2025diffusion,
  author = {Lingkai Kong and Yuanqi Du and Wenhao Mu and Kirill Neklyudov and Valentin De Bortoli and Dongxia Wu and Haorui Wang and Aaron M. Ferber and Yian Ma and Carla P. Gomes and Chao Zhang},
  title = {{Diffusion Models as Constrained Samplers for Optimization with Unknown Constraints}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2025},
  url = {https://openreview.net/forum?id=1kan0EJXfc},
}
Figure