$ show uqfoundation/mystic
This repository is a Python framework for constrained nonlinear optimization, with a strong emphasis on uncertainty quantification (UQ) and scientific machine learning. It provides a suite of derivative-free global and local optimizers (differential evolution, Nelder-Mead, Powell, etc.) through a common abstract interface, alongside powerful constraint and penalty handling via symbolic equations (using sympy) and decorator-based composition. The library supports ensemble solvers, parallel execution (via pathos/pyina), and includes extensive UQ tools: discrete measures, product measures, expectation bounds, probability of failure, and McDiarmid bounds. It is structured as a reusable Python package with well-documented modules and a large collection of example scripts demonstrating applications from benchmark optimization to XRD surrogate design and geophysical inversion. While the core library is solid and showcases high craftsmanship in its symbolic constraint generation and abstract solver pattern, many example scripts are exploratory and contain hardcoded parameters or incomplete code, reflecting its research origins. The framework is actively maintained but shows some technical drift (e.g., a forked legacy SciPy optimizer, use of eval/exec in logging and plotting, and heavy reliance on optional dependencies like sympy, klepto, and pathos).
The LLM identified 3 files worth highlighting for reuse:
Provides Monitor, VerboseMonitor, and LoggingMonitor classes for recording solver parameter and cost trajectories. These are simple, self-contained, and can be reused in any optimization framework to log progress.
Implements decorators like quadratic_inequality, linear_equality, and lagrange_inequality to convert condition functions into penalty functions. The pattern is clean, composable, and could be extracted for use in other optimization codes.
Defines point_mass, measure, and product_measure classes for representing weighted discrete probability distributions, with methods for flattening, packing, and scenario analysis. This is a well-crafted data structure for UQ that could be reused independently.