diff options
author | epapoutsellis <epapoutsellis@gmail.com> | 2019-05-13 16:15:32 +0100 |
---|---|---|
committer | epapoutsellis <epapoutsellis@gmail.com> | 2019-05-13 16:15:32 +0100 |
commit | 6c9b8e5bbf571de3c748a8abc1d9c768d5896b67 (patch) | |
tree | 7a680b01a087cdf07ad7f1b22c4b824438935a16 | |
parent | 73398745ad14b050bf4933b24b3989494e791f5b (diff) | |
download | framework-6c9b8e5bbf571de3c748a8abc1d9c768d5896b67.tar.gz framework-6c9b8e5bbf571de3c748a8abc1d9c768d5896b67.tar.bz2 framework-6c9b8e5bbf571de3c748a8abc1d9c768d5896b67.tar.xz framework-6c9b8e5bbf571de3c748a8abc1d9c768d5896b67.zip |
fix method Indi
-rwxr-xr-x | Wrappers/Python/ccpi/optimisation/functions/IndicatorBox.py | 27 |
1 files 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 <x^*, x> - return 0 + # support function sup <x, z>, 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) + + + + |