Add your description here
Project description
minimally-disruptive-curves
A pure JAX implementation of Minimally Disruptive Curves (MDC). The full user guide is here. It is pointed at the Julia implementation, but should still be useful.
MDC finds relationships between parameters that leave a cost function approximately unchanged. It avoids the curse of dimensionality by building out directed curves, rather than an entire space of neutral/sloppy parameters.
Diffrax limitations slightly change the method of evolution from the standard Julia version: there is no discrete 'momentum readjustment' event. I made a continuous approximation of this, and the tests included in the package seem to work. However I haven't tested it as thoroughly as the Julia version, and I predict that the Julia version will build slightly more accurate curves.
Features
- Pure JAX Backend: Fully differentiable, JIT-compilable, and GPU/TPU ready.
- Diffrax Integration: Robust ODE solving under the hood.
- Transform Chains: Explore in optimizer space (e.g., log-transforms) and map automatically to physical space.
- Event Handling: Terminate curves if cost exceeds momentum or parameters hit bounds.
Installation
pip install minimally-disruptive-curves
Quickstart
import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
from minimally_disruptive_curves import MDCProblem, solve_mdc, plot_curve, animate_mdc
# Define a simple cost function
def cost_fn(theta):
return 0.5 * jnp.sum((theta - jnp.array([1.0, 2.0, 3.0])) ** 2)
# Set up the problem
sys = MDCProblem(
cost_fn=cost_fn,
theta0=jnp.array([4.0, 5.0, 6.0]), # Starting parameters
dtheta0=jnp.array([1.0, 0.0, 0.0]), # Initial direction
momentum=100.0 # Energy headroom
)
# Solve for the curve
result = solve_mdc(sys, span=(-3.0, 3.0))
# Access the trajectory
print(result.all_t) # Arc lengths
print(result.all_theta) # Parameter values (N_timesteps, N_params)
# --- Visualization ---
# 1. Static plot of the parameter trajectories
fig, ax = plot_curve(result, raw=True)
plt.show()
# 2. Animate the curve's evolution
# Define a function to draw the live system state on panel 1
def live_sandbox(ax, theta_physical):
ax.plot(theta_physical, 'go-', markersize=10)
ax.set_ylim(0, 10)
ax.set_title("Live Parameters")
anim = animate_mdc(result, live_sandbox, density=50)
anim.save("mdc_curve.gif", fps=10)
Using Transform Chains
You can wrap your cost function in a TransformChain:
- Scaling parameters by a constant $c > 1$ will bias the curve to explore those parameters more.
- Fix parameters you aren't interested in
- Log transform parameters if you are interested in relative, not absolute, changes. If you have negative-valued parameters, first make them positive through a scaling transform (scale by -1).
from minimally_disruptive_curves.transforms import ScaleTransform, TransformChain
chain = TransformChain(ScaleTransform(jnp.array([1.0, 1.0, 0.5])))
The solver will automatically differentiate through the chain .
Citation
There will be a forthcoming software paper you can cite. In the meantime, the algorithm is published Raman, Dhruva V., James Anderson, and Antonis Papachristodoulou. "Delineating parameter unidentifiabilities in complex models." Physical Review E 95.3 (2017): 032314.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file minimally_disruptive_curves-0.1.0.tar.gz.
File metadata
- Download URL: minimally_disruptive_curves-0.1.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
307f7585f882f6eba54e691caa0fff9dbb1c62ff7c19d9562066b7941ded975b
|
|
| MD5 |
0b285d0fe9f30e3dce46b9a87c8e4ebb
|
|
| BLAKE2b-256 |
413a350ab556a160a1626c85117a2e1042fd72d53651aec78ef1d21454d7edc3
|
File details
Details for the file minimally_disruptive_curves-0.1.0-py3-none-any.whl.
File metadata
- Download URL: minimally_disruptive_curves-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1e601223cb93409d24973dc09220ee9ddd9884d2b9b424f4aea84677f93c38e
|
|
| MD5 |
a48759c7cc7fa65316044e7137b95c8d
|
|
| BLAKE2b-256 |
8b8cb047e7ea9b4027b529618a738bc69a4902cd15e8a13fac68680c8263d391
|