summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xWrappers/Python/ccpi/optimisation/functions/IndicatorBox.py27
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)
+
+
+
+