Commit 829ca38b authored by alexander.dornheim's avatar alexander.dornheim
Browse files

Added test for tasse AP

parent 6931c211
...@@ -78,6 +78,9 @@ class AP(Algorithm): ...@@ -78,6 +78,9 @@ class AP(Algorithm):
change = zeros(maxiter+1); change = zeros(maxiter+1);
change[0] = 999; change[0] = 999;
gap = change.copy(); gap = change.copy();
if hasattr(self, 'truth'):
Relerrs = change.copy()
tmp1 = prox2.work(u); tmp1 = prox2.work(u);
...@@ -93,12 +96,13 @@ class AP(Algorithm): ...@@ -93,12 +96,13 @@ class AP(Algorithm):
tmp_change= (norm(u-tmp_u, 'fro')/normM)**2 tmp_change= (norm(u-tmp_u, 'fro')/normM)**2
tmp_gap = (norm(tmp1-tmp_u,'fro')/normM)**2 tmp_gap = (norm(tmp1-tmp_u,'fro')/normM)**2
if hasattr(self, 'truth'): if hasattr(self, 'truth'):
if self.truth_dim[0] == 1: if self.truth_dim[0] == 1:
z=tmp_u[0,:] z=tmp_u[0,:]
elif self.truth_dim[1]==1: elif self.truth_dim[1]==1:
z=tmp_u[:,0] z=tmp_u[:,0]
else: else:
z=tmp_u z=tmp_u
Relerrs[iter] = norm(self.truth - exp(-1j*angle(trace(self.truth.T*z))) * z, 'fro')/self.norm_truth
elif q==1: elif q==1:
for j in range(self.product_space_dimension): for j in range(self.product_space_dimension):
...@@ -136,4 +140,4 @@ class AP(Algorithm): ...@@ -136,4 +140,4 @@ class AP(Algorithm):
change = change[1:iters+1]; change = change[1:iters+1];
gap = gap[1:iters+1]; gap = gap[1:iters+1];
return {'u1': u1, 'u2': u2, 'iter': iter, 'change': change, 'gap': gap} return {'u1': u1, 'u2': u2, 'iter': iters, 'change': change, 'gap': gap}
...@@ -235,9 +235,11 @@ class Phase(Problem): ...@@ -235,9 +235,11 @@ class Phase(Problem):
""" """
Routine to test and verify results by comparing to matlab Routine to test and verify results by comparing to matlab
Note that this is only for development and should not be used by a normal user Note that this is only for development and should not be used by a normal user
For result to match u_0 should be chosen as np.multiply(config['abs_illumination'],exp(1j*2*pi*0.5*np.ones(newres)))'] = For result to match u_0 should be chosen as np.multiply(config['abs_illumination'],exp(1j*2*pi*0.5*np.ones(newres)))']
""" """
print(self.config['proxoperators'])
if self.config['experiment'] == 'JWST': if self.config['experiment'] == 'JWST':
if self.config['MAXIT'] == 1: if self.config['MAXIT'] == 1:
f = h5py.File('Phase_test_data/u1_1.mat') f = h5py.File('Phase_test_data/u1_1.mat')
...@@ -260,17 +262,12 @@ class Phase(Problem): ...@@ -260,17 +262,12 @@ class Phase(Problem):
print("No file available to compare to.") print("No file available to compare to.")
return return
elif self.config['beta_0'] == 0.50: elif self.config['beta_0'] == 0.50:
if self.config['MAXIT'] == 20: f = h5py.File('Phase_test_data/tasse_u1_'+ str(self.config['MAXIT']) + '_beta_0_5.mat')
f = h5py.File('Phase_test_data/tasse_u1_20_beta_0_5.mat')
else:
print("No file available to compare to.")
return
else: else:
print("No file available to compare to.") print("No file available to compare to.")
return return
elif self.config['algorithm'] == 'AP': elif self.config['algorithm'] == 'AP':
if self.config['MAXIT'] == 20: f = h5py.File('Phase_test_data/tasse_u1_ap_' + str(self.config['MAXIT']) + '.mat')
f = h5py.File('Phase_test_data/tasse_u1_ap_20.mat')
u1 = f['u1'].value.view(np.float) u1 = f['u1'].value.view(np.float)
......
...@@ -85,11 +85,11 @@ new_config = { ...@@ -85,11 +85,11 @@ new_config = {
#if(strcmp('problem_family,'Phase')) #if(strcmp('problem_family,'Phase'))
## maximum number of iterations and tolerances ## maximum number of iterations and tolerances
'MAXIT' : 20, 'MAXIT' : 5,
'TOL' : 1e-12, 'TOL' : 1e-12,
## relaxaton parameters in RAAR, HPR and HAAR ## relaxaton parameters in RAAR, HPR and HAAR
'beta_0' : 0.95, #0.95 # starting relaxation prameter (only used with 'beta_0' : 0.50, #0.95 # starting relaxation prameter (only used with
# HAAR, HPR and RAAR) # HAAR, HPR and RAAR)
'beta_max' :0.50, # maximum relaxation prameter (only used with 'beta_max' :0.50, # maximum relaxation prameter (only used with
# HAAR, RAAR, and HPR) # HAAR, RAAR, and HPR)
......
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