00001 """
00002 Theshold schemes to pass to landweber solver
00003 """
00004
00005 __copyright__ = """
00006 Copyright 2008 Sean Ross-Ross
00007 """
00008 __license__ = """
00009 This file is part of SLIMpy .
00010
00011 SLIMpy is free software: you can redistribute it and/or modify
00012 it under the terms of the GNU Lesser General Public License as published by
00013 the Free Software Foundation, either version 3 of the License, or
00014 (at your option) any later version.
00015
00016 SLIMpy is distributed in the hope that it will be useful,
00017 but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 GNU Lesser General Public License for more details.
00020
00021 You should have received a copy of the GNU Lesser General Public License
00022 along with SLIMpy . If not, see <http://www.gnu.org/licenses/>.
00023 """
00024
00025 from slimpy_base.SLIMmath.Steppers import OneDimStepN
00026
00027 class threshobj( object ):
00028 """
00029 Base class for the shreshold schemes.
00030
00031 """
00032 def __init__( self ):
00033 pass
00034
00035 def choose( self, param=0.007, **kargs ):
00036 """
00037 choose must be called with the key word param
00038 """
00039 return param
00040
00041 class LinearCooling( threshobj ):
00042 """
00043 Linear Threshold scheme for landweber
00044 """
00045 def __init__( self, lambdaMax, lambdaMin, OuterN ):
00046 self.lambdaMax = lambdaMax
00047 self.lambdaMin = lambdaMin
00048 self.OuterN = OuterN
00049 self.prev_i = None
00050 stepper = OneDimStepN( lambdaMax, lambdaMin, OuterN )
00051 self.slist = list(stepper)
00052 self.stepper = self.slist.__iter__()
00053
00054
00055 def choose( self, coefs, i, OuterN, **kargs ):
00056 """
00057 """
00058 if self.prev_i != i:
00059
00060 self.prev_i = i
00061 self.step =self.stepper.next( )
00062
00063 return self.step