catopt-graph-graph-calculus.../tests/admm_lite/solver.py

20 lines
820 B
Python

from __future__ import annotations
from typing import Tuple
def admm_step(x: float, y: float, u: float, rho: float, a: float, b: float) -> Tuple[float, float, float]:
# Simple quadratic objective example:
# minimize 0.5*a*x^2 + 0.5*b*y^2
# with constraint x + y = 1
# Standard ADMM update on a toy problem to illustrate API:
# x^{k+1} = argmin_x L_gamma(x, y^k, u^k)
# For demonstration, perform a plain projection step toward constraint and dual update.
# This is intentionally tiny and not a production solver.
# Update primal via a simple gradient-descent-like projection
x_new = (1.0 - y) # enforce x+y=1
y_new = 1.0 - x_new
# Dual ascent step (additional stability term)
u_new = u + rho * (x_new + y_new - 1.0)
return float(x_new), float(y_new), float(u_new)