From 42d01d8f150fd893509a408e233ad0b19480b22d Mon Sep 17 00:00:00 2001 From: epapoutsellis Date: Tue, 2 Apr 2019 13:12:25 +0100 Subject: add old pdhg, test gap --- .../Python/ccpi/optimisation/algorithms/PDHG.py | 7 ++--- Wrappers/Python/wip/test_pdhg_gap.py | 31 +++++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) (limited to 'Wrappers/Python') diff --git a/Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py b/Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py index 8600e07..1229c4e 100644 --- a/Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py +++ b/Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py @@ -72,9 +72,10 @@ class PDHG(Algorithm): self.xbar *= self.theta self.xbar += self.x - self.x_old.fill(self.x) - self.y_old.fill(self.y) - #self.y_old = y.copy() +# self.x_old.fill(self.x) +# self.y_old.fill(self.y) + self.y_old = self.y.copy() + self.x_old = self.x.copy() #self.y = self.y_old def update_objective(self): diff --git a/Wrappers/Python/wip/test_pdhg_gap.py b/Wrappers/Python/wip/test_pdhg_gap.py index b196e36..6c7ccc9 100644 --- a/Wrappers/Python/wip/test_pdhg_gap.py +++ b/Wrappers/Python/wip/test_pdhg_gap.py @@ -102,22 +102,33 @@ pdhg = PDHG(f=f,g=g,operator=operator, tau=tau, sigma=sigma) pdhg.max_iteration = 2000 pdhg.update_objective_interval = 100 -#pdhg.run(5000) +pdhg.run(5000) +#%% opt = {'niter':2000} res = PDHG_old(f, g, operator, tau = tau, sigma = sigma, opt = opt) #%% -#sol = pdhg.get_output().as_array() -#fig = plt.figure() -#plt.subplot(1,2,1) -#plt.imshow(noisy_data.as_array()) -##plt.colorbar() -#plt.subplot(1,2,2) -#plt.imshow(sol) -##plt.colorbar() -#plt.show() +sol = pdhg.get_output().as_array() +sol_old = res[0].as_array() +fig = plt.figure(figsize=(20,10)) +plt.subplot(1,3,1) +plt.imshow(noisy_data.as_array()) +#plt.colorbar() +plt.subplot(1,3,2) +plt.imshow(sol) +#plt.colorbar() + +plt.subplot(1,3,3) +plt.imshow(sol_old) +plt.show() + +plt.imshow(np.abs(sol-sol_old)) +plt.colorbar() +plt.show() + + # # ##%% -- cgit v1.2.3