00001 """
00002 @package slimpy_contrib.problems.l2_minimization_problem
00003 @brief basic l1 minimisaton problem
00004 @detail
00005 This package defines a basic l1 minimisaton problem
00006 to be solved by the SLIMpy/SCons
00007 \ref slimproj_core.builders.NewSolve.SolveBuilder "Solve Builder"
00008
00009 @par Example
00010 @code
00011 from slimproj import *
00012 # build 'res.rsf' from 'data.rsf'
00013 Solve( 'res', 'data', OuterN=4, log='dnoise.log', problem=l2_min_problem )
00014 @endcode
00015
00016 @author Sean Ross-Ross
00017 """
00018
00019 from slimpy_contrib.ana.lsqr import LSQRsolver
00020 from slimpy_base.utils.slim_decorators import depends_on
00021 from SLIMpy.linear_operators import Identity
00022
00023 __copyright__ = """
00024 Copyright 2008 Sean Ross-Ross
00025 """
00026 __license__ = """
00027 This file is part of SLIMpy .
00028
00029 SLIMpy is free software: you can redistribute it and/or modify
00030 it under the terms of the GNU Lesser General Public License as published by
00031 the Free Software Foundation, either version 3 of the License, or
00032 (at your option) any later version.
00033
00034 SLIMpy is distributed in the hope that it will be useful,
00035 but WITHOUT ANY WARRANTY; without even the implied warranty of
00036 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00037 GNU Lesser General Public License for more details.
00038
00039 You should have received a copy of the GNU Lesser General Public License
00040 along with SLIMpy . If not, see <http://www.gnu.org/licenses/>.
00041 """
00042
00043
00044
00045
00046
00047 Get = lambda env, item: env.get( item ) or env.get( 'problem', env.get('default_pack',{})).get(item)
00048
00049 @depends_on( 'maxiter', 'tol' )
00050 @depends_on( 'fastlsqr' )
00051 def solver_callback( target, source, env, A ):
00052 """
00053 solver_callback( target, source, env, space ) -> Solver
00054 Set the default value for the solver.
00055 \param A not used but kept for compatibility
00056 """
00057
00058 maxiter = Get( env,'maxiter' )
00059 tol = Get( env,'tol' )
00060 fastlsqr = Get( env,'fastlsqr' )
00061
00062 solver = LSQRsolver( maxiter=maxiter, tol=tol, fastlsqr=fastlsqr )
00063 return solver
00064
00065
00066
00067 def precondition_callback( t,s,e, space ):
00068 return Identity( space )
00069
00070
00071
00072 l2_min_problem = {}
00073 l2_min_problem['name'] = 'l_2 Minimization Problem'
00074 l2_min_problem['doc'] = { }
00075
00076
00077 l2_min_problem['solver_callback'] = solver_callback
00078 l2_min_problem['precondition_callback'] = precondition_callback
00079
00080 l2_min_problem['maxiter'] = 200
00081 l2_min_problem['doc']['maxiter'] = """
00082 Maximum number of iteration for solver.
00083 """
00084 l2_min_problem['tol'] = 1e-6
00085 l2_min_problem['doc']['tol'] = """
00086 Desired tolerance for solution.
00087 """
00088
00089 l2_min_problem['fastlsqr'] = False
00090 l2_min_problem['doc']['fastlsqr'] = """
00091 bool to calcualte reside if governed by max tol.
00092
00093 """
00094
00095
00096