DRl.py 1.68 KB
Newer Older
Russell Luke's avatar
Russell Luke committed
1
2
3
4
5
6
7
8
9
10
11
12
13
#                      DRl.m
#             written on Dez.5 , 2018 by
#                   Russell Luke
#   Inst. Fuer Numerische und Angewandte Mathematik
#
# DESCRIPTION:  User-friendly version of the Relaxed Douglas-Rachford algorithm.  
# 		For background see:
#                D.R.Luke, Inverse Problems 21:37-50(2005)
#                D.R. Luke, SIAM J. Opt. 19(2): 714--739 (2008).

from .SimpleAlgortihm import SimpleAlgorithm
from numpy import exp

jansen31's avatar
jansen31 committed
14

Russell Luke's avatar
Russell Luke committed
15
class DRl(SimpleAlgorithm):
16
17
18
19
20
21
22
23
24
25
    def __init__(self, config):
        super(DRl, self).__init__(config)
        for parameter_key_extension in ['_0', '_max', '_switch']:
            key = 'lambda'+parameter_key_extension
            alternative = 'beta'+parameter_key_extension
            try:
                if key not in config:
                    config[key] = config[alternative]
            except KeyError:
                raise KeyError('config should contain %s, or %s must be given as alternative')
Russell Luke's avatar
Russell Luke committed
26
27

    def evaluate(self, u):
jansen31's avatar
jansen31 committed
28
29
30
        iter = self.config['iter'] + 1
        # add 1 to conform with matlab version (iter influences lambda and we sometimes want to compare results between
        # python and matlab), matlab counts starting at 1, python starts at 0
Russell Luke's avatar
Russell Luke committed
31
32
33
        lambda0 = self.config['lambda_0']
        lambda_max = self.config['lambda_max']
        lambda_switch = self.config['lambda_switch']
jansen31's avatar
jansen31 committed
34
35
        tmp1 = 2 * self.prox2.work(u) - u
        tmp2 = self.prox1.work(tmp1)
Russell Luke's avatar
Russell Luke committed
36
        # update
jansen31's avatar
jansen31 committed
37
38
39
        lambda1 = exp((-iter / lambda_switch) ** 3) * lambda0 + (
                    1 - exp((-iter / lambda_switch) ** 3)) * lambda_max  # unrelaxes as the
        unew = (lambda1 * (2 * tmp2 - tmp1) + (1 - lambda1) * tmp1 + u) / 2
Russell Luke's avatar
Russell Luke committed
40
        return unew