Skip to content

Commit 6265eb0

Browse files
committed
feature: added z0 in HQS
1 parent 8301131 commit 6265eb0

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

pyproximal/optimization/primal.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def GeneralizedProximalGradient(proxfs, proxgs, x0, tau=None,
427427
return x
428428

429429

430-
def HQS(proxf, proxg, x0, tau, niter=10, gfirst=True,
430+
def HQS(proxf, proxg, x0, tau, niter=10, z0=None, gfirst=True,
431431
callback=None, callbackz=False, show=False):
432432
r"""Half Quadratic splitting
433433
@@ -460,6 +460,8 @@ def HQS(proxf, proxg, x0, tau, niter=10, gfirst=True,
460460
strategy)
461461
niter : :obj:`int`, optional
462462
Number of iterations of iterative scheme
463+
z0 : :obj:`numpy.ndarray`, optional
464+
Initial z vector (not required when ``gfirst=True``
463465
gfirst : :obj:`bool`, optional
464466
Apply Proximal of operator ``g`` first (``True``) or Proximal of
465467
operator ``f`` first (``False``)
@@ -484,13 +486,20 @@ def HQS(proxf, proxg, x0, tau, niter=10, gfirst=True,
484486
485487
.. math::
486488
487-
\mathbf{z}^{k+1} = \prox_{\tau g}(\mathbf{x}^{k})
488-
\mathbf{x}^{k+1} = \prox_{\tau f}(\mathbf{z}^{k+1})\\
489+
\mathbf{z}^{k+1} = \prox_{\tau g}(\mathbf{x}^{k}) \\
490+
\mathbf{x}^{k+1} = \prox_{\tau f}(\mathbf{z}^{k+1})
489491
490-
Note that ``x`` and ``z`` converge to each other, however if iterations are
491-
stopped too early ``x`` is guaranteed to belong to the domain of ``f``
492-
while ``z`` is guaranteed to belong to the domain of ``g``. Depending on
493-
the problem either of the two may be the best solution.
492+
for ``gfirst=False``, or
493+
494+
.. math::
495+
496+
\mathbf{x}^{k+1} = \prox_{\tau f}(\mathbf{z}^{k}) \\
497+
\mathbf{z}^{k+1} = \prox_{\tau g}(\mathbf{x}^{k+1})
498+
499+
for ``gfirst=False``. Note that ``x`` and ``z`` converge to each other,
500+
however if iterations are stopped too early ``x`` is guaranteed to belong to
501+
the domain of ``f`` while ``z`` is guaranteed to belong to the domain of ``g``.
502+
Depending on the problem either of the two may be the best solution.
494503
495504
.. [1] D., Geman, and C., Yang, "Nonlinear image recovery with halfquadratic
496505
regularization", IEEE Transactions on Image Processing,
@@ -516,7 +525,10 @@ def HQS(proxf, proxg, x0, tau, niter=10, gfirst=True,
516525
print(head)
517526

518527
x = x0.copy()
519-
z = np.zeros_like(x)
528+
if z0 is not None:
529+
z = z0.copy()
530+
else:
531+
z = np.zeros_like(x)
520532
for iiter in range(niter):
521533
if gfirst:
522534
z = proxg.prox(x, tau[iiter])

0 commit comments

Comments
 (0)