From 535241a9dfb6ad29a1d41d2aad737478705d5866 Mon Sep 17 00:00:00 2001 From: epapoutsellis Date: Sun, 7 Apr 2019 22:17:08 +0100 Subject: fix pdgap for function composition --- Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'Wrappers/Python') diff --git a/Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py b/Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py index 7c6bc8a..94b0bde 100644 --- a/Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py +++ b/Wrappers/Python/ccpi/optimisation/algorithms/PDHG.py @@ -12,6 +12,7 @@ import matplotlib.pyplot as plt import time from ccpi.optimisation.operators import BlockOperator from ccpi.framework import BlockDataContainer +from ccpi.optimisation.functions import FunctionOperatorComposition import matplotlib.pyplot as plt @@ -138,9 +139,10 @@ def PDHG_old(f, g, operator, tau = None, sigma = None, opt = None, **kwargs): x_old = x y_old = y -# if i%100==0: - - p1 = f(operator.direct(x)) + g(x) +# if isinstance(f, FunctionOperatorComposition): + p1 = f(x) + g(x) +# else: +# p1 = f(operator.direct(x)) + g(x) d1 = -(f.convex_conjugate(y) + g(-1*operator.adjoint(y))) pd1 = p1 - d1 @@ -148,12 +150,12 @@ def PDHG_old(f, g, operator, tau = None, sigma = None, opt = None, **kwargs): dual.append(d1) pdgap.append(pd1) - -# print( i, primal, dual, primal-dual) - -# plt.imshow(x.as_array()) -# plt.show() -# print(f(operator.direct(x)) + g(x), i) + if i%100==0: + print(p1, d1, pd1) +# if isinstance(f, FunctionOperatorComposition): +# p1 = f(x) + g(x) +# else: + t_end = time.time() -- cgit v1.2.3