Commit 69aaab3b authored by s.gretchko's avatar s.gretchko
Browse files

Added 5 tasse demos (cdr, cdrl, cp, drap, drl)

parent 04c76934
import SetProxPythonPath
from proxtoolbox.experiments.phase.CDI_Experiment import CDI_Experiment
CDI = CDI_Experiment(algorithm = 'CDRl', lambda_0 = 1.0, lambda_max = 1.0, MAXIT = 2000)
CDI.run()
CDI.show()
import SetProxPythonPath
from proxtoolbox.experiments.phase.CDI_Experiment import CDI_Experiment
CDI = CDI_Experiment(algorithm = 'CDRl', lambda_0 = 0.9, lambda_max = 0.9)
CDI.run()
CDI.show()
import SetProxPythonPath
from proxtoolbox.experiments.phase.CDI_Experiment import CDI_Experiment
CDI = CDI_Experiment(algorithm = 'CP', MAXIT = 5000)
CDI.run()
CDI.show()
import SetProxPythonPath
from proxtoolbox.experiments.phase.CDI_Experiment import CDI_Experiment
CDI = CDI_Experiment(algorithm = 'DRAP', lambda_0 = 0.02, lambda_max = 0.02)
CDI.run()
CDI.show()
import SetProxPythonPath
from proxtoolbox.experiments.phase.CDI_Experiment import CDI_Experiment
CDI = CDI_Experiment(algorithm = 'DRl')
CDI.run()
CDI.show()
from proxtoolbox.algorithms.algorithm import Algorithm
from proxtoolbox.Utilities.cell import Cell, isCell
from numpy import exp
class CDRl(Algorithm):
"""
User-friendly relaxed version of a cyclic averaged
alternating reflections method (CAAR) proposed by
Borwein and Tam, Journal of Nonlinear and Convex Analysis
Volume 16, Number 4. The relaxation is the relaxed
Douglas Rachford algorithm proposed and analysed by Luke,
Inverse Problems, 2005 and SIAM J. on Optimization, 2008
Based on Matlab code written by Russell Luke (Inst. Fuer
Numerische und Angewandte Mathematik, Universitaet
Gottingen) on Aug 18, 2017.
"""
def evaluate(self, u):
"""
Update for the relaxed version of a cyclic averaged
alternating reflections algorithm
Parameters
----------
u : ndarray
The current iterate.
Returns
-------
u_new : ndarray (same type as input parameter u)
The new iterate.
"""
lmbd = self.computeRelaxation()
tmp_u = u
nProx = len(self.proxOperators)
for j in range(nProx-1):
tmp1 = 2*self.proxOperators[j+1].eval(tmp_u, j+1) - tmp_u # reflection
tmp2 = self.proxOperators[j].eval(tmp1, j) # projection of the reflection
tmp_u = (lmbd*(2*tmp2 - tmp1) + (1 - lmbd)*tmp1 + tmp_u)/2
tmp1 = 2*self.proxOperators[0].eval(tmp_u, 0) - tmp_u # reflection
tmp2 = self.proxOperators[nProx-1].eval(tmp1, nProx-1) # projection of the reflection
u_new = (lmbd*(2*tmp2 - tmp1) + (1 - lmbd)*tmp1 + tmp_u)/2
return u_new
def getDescription(self):
return self.getDescriptionHelper("\\lambda", self.lambda_0, self.lambda_max)
\ No newline at end of file
......@@ -22,7 +22,7 @@ class CP(Algorithm):
u_new = u
nProx = len(self.proxOperators)
for j in range(nProx):
u_new = self.proxOperators[j-1].eval(u_new, j)
u_new = self.proxOperators[j].eval(u_new, j)
return u_new
from proxtoolbox.algorithms.RAAR import RAAR
from proxtoolbox.Utilities.cell import Cell, isCell
from numpy import exp
class DRl(RAAR):
"""
User-friendly version of the Relaxed Averaged Alternating
Reflection algorithm. For background see:
D.R.Luke, Inverse Problems 21:37-50(2005)
D.R. Luke, SIAM J. Opt. 19(2): 714--739 (2008).
Based on Matlab code written by Russell Luke (Inst. Fuer
Numerische und Angewandte Mathematik, Universitaet
Gottingen) on Aug 18, 2017.
"""
# Same code as RAAR algorithm
......@@ -15,6 +15,8 @@ from .QNAP import *
from .CP import *
from .AvP import *
from .QNAvP import *
from .DRl import *
from .CDRl import *
from .iterateMonitor import *
from .feasibilityIterateMonitor import *
......@@ -25,12 +27,10 @@ from .AP_expert import *
from .RAAR_expert import *
from .GRAAL import *
# from .HAAR import *
from .DRl import *
from .ADMM import *
from .RRR import *
from .CAARL import *
from .CADRl import *
from .CDRl import *
from .CDRlrand import *
from .CPrand import *
from .DRl import *
......
Markdown is supported
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