Skip to content

Commit 8301131

Browse files
committed
feature: add variable tau to HQS
1 parent df014ce commit 8301131

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

pyproximal/optimization/primal.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,13 @@ def HQS(proxf, proxg, x0, tau, niter=10, gfirst=True,
451451
Proximal operator of g function
452452
x0 : :obj:`numpy.ndarray`
453453
Initial vector
454-
tau : :obj:`float`, optional
454+
tau : :obj:`float` or :obj:`numpy.ndarray`, optional
455455
Positive scalar weight, which should satisfy the following condition
456456
to guarantees convergence: :math:`\tau \in (0, 1/L]` where ``L`` is
457-
the Lipschitz constant of :math:`\nabla f`.
457+
the Lipschitz constant of :math:`\nabla f`. Finally note that
458+
:math:`\tau` can be chosen to be a vector of size ``niter`` such that
459+
different :math:`\tau` is used at different iterations (i.e., continuation
460+
strategy)
458461
niter : :obj:`int`, optional
459462
Number of iterations of iterative scheme
460463
gfirst : :obj:`bool`, optional
@@ -494,26 +497,33 @@ def HQS(proxf, proxg, x0, tau, niter=10, gfirst=True,
494497
4, 7, pp. 932-946, 1995.
495498
496499
"""
500+
# check if epgs is a ve
501+
if np.asarray(tau).size == 1.:
502+
tau_print = str(tau)
503+
tau = tau * np.ones(niter)
504+
else:
505+
tau_print = 'Variable'
506+
497507
if show:
498508
tstart = time.time()
499509
print('HQS\n'
500510
'---------------------------------------------------------\n'
501511
'Proximal operator (f): %s\n'
502512
'Proximal operator (g): %s\n'
503-
'tau = %10e\tniter = %d\n' % (type(proxf), type(proxg),
504-
tau, niter))
513+
'tau = %s\tniter = %d\n' % (type(proxf), type(proxg),
514+
tau_print, niter))
505515
head = ' Itn x[0] f g J = f + g'
506516
print(head)
507517

508518
x = x0.copy()
509519
z = np.zeros_like(x)
510520
for iiter in range(niter):
511521
if gfirst:
512-
z = proxg.prox(x, tau)
513-
x = proxf.prox(z, tau)
522+
z = proxg.prox(x, tau[iiter])
523+
x = proxf.prox(z, tau[iiter])
514524
else:
515-
x = proxf.prox(z, tau)
516-
z = proxg.prox(x, tau)
525+
x = proxf.prox(z, tau[iiter])
526+
z = proxg.prox(x, tau[iiter])
517527

518528
# run callback
519529
if callback is not None:

0 commit comments

Comments
 (0)