From 6c9b8e5bbf571de3c748a8abc1d9c768d5896b67 Mon Sep 17 00:00:00 2001 From: epapoutsellis Date: Mon, 13 May 2019 16:15:32 +0100 Subject: fix method Indi --- .../ccpi/optimisation/functions/IndicatorBox.py | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Wrappers/Python/ccpi/optimisation/functions/IndicatorBox.py b/Wrappers/Python/ccpi/optimisation/functions/IndicatorBox.py index 6c18ebf..ace0ba7 100755 --- a/Wrappers/Python/ccpi/optimisation/functions/IndicatorBox.py +++ b/Wrappers/Python/ccpi/optimisation/functions/IndicatorBox.py @@ -22,6 +22,7 @@ from ccpi.optimisation.functions import Function import numpy +from ccpi.framework import ImageData class IndicatorBox(Function): '''Box constraints indicator function. @@ -39,7 +40,7 @@ class IndicatorBox(Function): def __call__(self,x): - + if (numpy.all(x.array>=self.lower) and numpy.all(x.array <= self.upper) ): val = 0 @@ -51,8 +52,9 @@ class IndicatorBox(Function): return ValueError('Not Differentiable') def convex_conjugate(self,x): - # support function sup - return 0 + # support function sup , z \in [lower, upper] + # ???? + return x.maximum(0).sum() def proximal(self, x, tau, out=None): @@ -78,7 +80,7 @@ class IndicatorBox(Function): if __name__ == '__main__': - from ccpi.framework import ImageGeometry + from ccpi.framework import ImageGeometry, BlockDataContainer N, M = 2,3 ig = ImageGeometry(voxel_num_x = N, voxel_num_y = M) @@ -109,6 +111,23 @@ if __name__ == '__main__': numpy.testing.assert_array_equal(p.as_array(), u.as_array()) + d = f.convex_conjugate(u) + print(d) + + + + # what about n-dimensional Block + #uB = BlockDataContainer(u,u,u) + #lowerB = BlockDataContainer(1,2,3) + #upperB = BlockDataContainer(10,21,30) + + #fB = IndicatorBox(lowerB, upperB) + + #z1B = fB.proximal(uB, tau) + + + + -- cgit v1.2.3