Commit fb5e7e20 authored by jansen31's avatar jansen31
Browse files

tabs to spaces

parent 47b5e1c5
......@@ -26,9 +26,9 @@ from numpy import exp
from proxtoolbox import ProxOperators
class CAARL(SimpleAlgorithm):
def __init__(self,config):
"""
def __init__(self,config):
"""
Parameters
----------
config : dict
......@@ -44,17 +44,16 @@ class CAARL(SimpleAlgorithm):
beta_switch: int
Iteration at which beta moves from beta_0 -> beta_max
iter: int
prox_idx: int
prox_idx: int
"""
self.prox1 = config['proxoperators'][0](config)
self.prox2 = config['proxoperators'][1](config)
self.prox = config['proxoperators'](config)
self.prox = config['proxoperators'](config)
self.iter = config['iter']
self.beta0 = config['beta0']
self.beta_max = config['beta_max']
self.beta_switch = config['beta_switch']
self.prox_idx = config['prox_idx']
self.beta0 = config['beta0']
self.beta_max = config['beta_max']
self.beta_switch = config['beta_switch']
self.prox_idx = config['prox_idx']
if 'truth' in config:
self.truth = config['truth']
......@@ -63,29 +62,29 @@ class CAARL(SimpleAlgorithm):
if 'diagnostic' in config:
self.diagnostic = True
else:
else:
self.diagnostic = False
def evaluate(self, u):
prox = self.prox
beta0 =self.beta0
beta_max = self.beta_max
beta_switch = self.beta_switch
iter = self.iter
beta = exp((-iter/beta_switch)**3)*beta0+(1-exp((-iter/beta_switch)**3))*beta_max
tmp_u=u
nProx = len(prox)
for j in range(nProx-1):
self.prox_idx = j+1
tmp1= 2*prox[j].work(tmp_u) - tmp_u
self.prox_idx = j
tmp2 = prox[j-1].work(tmp1)
tmp_u = (beta*(2*tmp2 - tmp1) + (1-beta)*tmp1 + tmp_u)/2
self.prox_idx=1
tmp1=2*self.prox1.work(tmp_u) - tmp_u
self.prox_idx = nProx
tmp2=prox[nProx-1].work(tmp1)
unew = (beta*(2*tmp2 - tmp1)+(1-beta)*tmp1+tmp_u)/2
return unew
def evaluate(self, u):
prox = self.prox
beta0 =self.beta0
beta_max = self.beta_max
beta_switch = self.beta_switch
iter = self.iter
beta = exp((-iter/beta_switch)**3)*beta0+(1-exp((-iter/beta_switch)**3))*beta_max
tmp_u=u
nProx = len(prox)
for j in range(nProx-1):
self.prox_idx = j+1
tmp1= 2*prox[j].work(tmp_u) - tmp_u
self.prox_idx = j
tmp2 = prox[j-1].work(tmp1)
tmp_u = (beta*(2*tmp2 - tmp1) + (1-beta)*tmp1 + tmp_u)/2
self.prox_idx=1
tmp1=2*self.prox1.work(tmp_u) - tmp_u
self.prox_idx = nProx
tmp2=prox[nProx-1].work(tmp1)
unew = (beta*(2*tmp2 - tmp1)+(1-beta)*tmp1+tmp_u)/2
return unew
......@@ -19,8 +19,8 @@ from .SimpleAlgortihm import SimpleAlgorithm
import numpy as np
class CPrand(SimpleAlgorithm):
def __init__(self,config):
"""
def __init__(self,config):
"""
Parameters
----------
config : dict
......@@ -31,18 +31,18 @@ class CPrand(SimpleAlgorithm):
list of ProxOperators (the class, no instance)
prox_idx: int
"""
self.prox = config['proxoperators'](config)
self.prox_idx = config['prox_idx']
self.prox = config['proxoperators'](config)
self.prox_idx = config['prox_idx']
def evaluate(self, u):
prox = self.prox
tmp_u = u
nProx = len(prox)
jj = np.random.permutation(nProx)
for j in range(nProx):
prox_idx = jj[j-1]
tmp_u = prox[jj[j]].work(tmp_u)
unew = tmp_u
return unew
def evaluate(self, u):
prox = self.prox
tmp_u = u
nProx = len(prox)
jj = np.random.permutation(nProx)
for j in range(nProx):
prox_idx = jj[j-1]
tmp_u = prox[jj[j]].work(tmp_u)
unew = tmp_u
return unew
......@@ -25,41 +25,41 @@ from proxtoolbox import ProxOperators
from .proxoperators import ProxOperator
class DRAP(SimpleAlgorithm):
def __init__(self,config):
"""
def __init__(self,config):
"""
Parameters
----------
config : dict
Dictionary containing the problem configuration.
It must contain the following mappings:
proxoperators: ProxOperators
proxoperators: ProxOperators
list of ProxOperators (the class, no instance)
beta0: number
beta0: number
Starting relaxation parmater
beta_max: number
Maximum relaxation parameter
beta_switch: int
Iteration at which beta moves from beta_0 -> beta_max
iter : int
"""
self.prox1 = config['proxoperators'][0](config)
iter : int
"""
self.prox1 = config['proxoperators'][0](config)
self.prox2 = config['proxoperators'][1](config)
self.beta0 = config['beta0']
self.beta_max = config['beta_max']
self.beta_switch = config['beta_switch']
self.iter = config['iter']
def evaluate(self, u):
beta0 = self.beta0
beta_max = self.beta_max
beta_switch = self.beta_switch
iter = self.iter
beta = exp((-iter/beta_switch)**3)*beta0+(1-exp((-iter/beta_switch)**3))*beta_max # unrelaxes as the
tmp1 = self.prox2.work(u)
tmp2= beta*(tmp1-u) # feval(Prox1,method_input,tmp1)
tmp_3 = self.prox1.work(tmp1+tmp2) # (beta*(2*tmp3-tmp1) + (1-beta)*tmp1 + u)/2
unew = tmp_3-tmp2
return unew
self.beta0 = config['beta0']
self.beta_max = config['beta_max']
self.beta_switch = config['beta_switch']
self.iter = config['iter']
def evaluate(self, u):
beta0 = self.beta0
beta_max = self.beta_max
beta_switch = self.beta_switch
iter = self.iter
beta = exp((-iter/beta_switch)**3)*beta0+(1-exp((-iter/beta_switch)**3))*beta_max # unrelaxes as the
tmp1 = self.prox2.work(u)
tmp2= beta*(tmp1-u) # feval(Prox1,method_input,tmp1)
tmp_3 = self.prox1.work(tmp1+tmp2) # (beta*(2*tmp3-tmp1) + (1-beta)*tmp1 + u)/2
unew = tmp_3-tmp2
return unew
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment