/[escript]/trunk/downunder/py_src/inversioncostfunctions.py
ViewVC logotype

Diff of /trunk/downunder/py_src/inversioncostfunctions.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4095 by caltinay, Wed Dec 5 05:32:22 2012 UTC revision 4097 by caltinay, Fri Dec 7 01:18:35 2012 UTC
# Line 56  class SimpleInversionCostFunction(Metere Line 56  class SimpleInversionCostFunction(Metere
56          """          """
57          sets the weighting factors for the forward model and regularization          sets the weighting factors for the forward model and regularization
58          terms.          terms.
59            
60          :param mu_model: Weighting factor for the forward model (default=1.)          :param mu_model: Weighting factor for the forward model (default=1.)
61          :type mu_model: non-negative `float`          :type mu_model: non-negative `float`
62          :param mu_reg_0: Weighting factor for the regularization (default=1.)          :param mu_reg_0: Weighting factor for the regularization (default=1.)
# Line 67  class SimpleInversionCostFunction(Metere Line 67  class SimpleInversionCostFunction(Metere
67          self.mu_model=mu_model          self.mu_model=mu_model
68          self.regularization.setWeightsForS0(mu_reg_0)          self.regularization.setWeightsForS0(mu_reg_0)
69          self.regularization.setWeightsForS1(mu_reg_1)          self.regularization.setWeightsForS1(mu_reg_1)
70            
71      def _getDualProduct(self, x, r):      def _getDualProduct(self, x, r):
72          """          """
73          returns ``regularization.getDualProduct(x, r)``          returns ``regularization.getDualProduct(x, r)``
# Line 78  class SimpleInversionCostFunction(Metere Line 78  class SimpleInversionCostFunction(Metere
78    
79      def _getArguments(self, m):      def _getArguments(self, m):
80          """          """
81          returns precalculated values that are shared in the calculation of          returns precomputed values that are shared in the calculation of
82          *f(x)* and *grad f(x)*. In this implementation returns a tuple with the          *f(x)* and *grad f(x)*. In this implementation returns a tuple with the
83          mapped value of ``m``, the arguments from the forward model and the          mapped value of ``m``, the arguments from the forward model and the
84          arguments from the regularization.          arguments from the regularization.
# Line 91  class SimpleInversionCostFunction(Metere Line 91  class SimpleInversionCostFunction(Metere
91      def _getValue(self, m, *args):      def _getValue(self, m, *args):
92          """          """
93          returns the function value at m.          returns the function value at m.
94          If the precalculated values are not supplied `getArguments()` is called.          If the precomputed values are not supplied `getArguments()` is called.
95    
96          :rtype: `float`          :rtype: `float`
97          """          """
# Line 107  class SimpleInversionCostFunction(Metere Line 107  class SimpleInversionCostFunction(Metere
107      def _getGradient(self, m, *args):      def _getGradient(self, m, *args):
108          """          """
109          returns the gradient of *f* at *m*.          returns the gradient of *f* at *m*.
110          If the precalculated values are not supplied `getArguments()` is called.          If the precomputed values are not supplied `getArguments()` is called.
111    
112          :rtype: `esys.escript.Data`          :rtype: `esys.escript.Data`
113          """          """
# Line 120  class SimpleInversionCostFunction(Metere Line 120  class SimpleInversionCostFunction(Metere
120          print "grad forward = ", Y          print "grad forward = ", Y
121          print "grad regularization Y  = ", g_reg[0]          print "grad regularization Y  = ", g_reg[0]
122          print "grad regularization X = ", g_reg[1]          print "grad regularization X = ", g_reg[1]
123            
           
124          return self.mu_model * ArithmeticTuple(Y, Data()) + g_reg          return self.mu_model * ArithmeticTuple(Y, Data()) + g_reg
125    
126    
# Line 129  class SimpleInversionCostFunction(Metere Line 128  class SimpleInversionCostFunction(Metere
128          """          """
129          returns an approximative evaluation *p* of the inverse of the Hessian operator of the cost function          returns an approximative evaluation *p* of the inverse of the Hessian operator of the cost function
130          for a given gradient type *r* at a given location *m*: *H(m) p = r*          for a given gradient type *r* at a given location *m*: *H(m) p = r*
131            
132          :param m: level set approximation where to calculate Hessian inverse          :param m: level set approximation where to calculate Hessian inverse
133          :type m: ``Data``          :type m: `Data`
134          :param r: a given gradient          :param r: a given gradient
135          :type r: ``ArithmeticTuple``          :type r: `ArithmeticTuple`
136          :param args: pre-calculated values for ``m`` from ``getArguments()``          :param args: pre-calculated values for ``m`` from `getArguments()`
137          :rtype: ``Data``          :rtype: `Data`
138          :note: in the current implementation only the regularization term is considered in the          :note: in the current implementation only the regularization term is
139            inverse Hessian approximation.                 considered in the inverse Hessian approximation.
140              
141          """          """
142          print "inverse Hessian approximation:"          print "inverse Hessian approximation:"
143          print "Y  = ",r[0]          print "Y  = ",r[0]
# Line 146  class SimpleInversionCostFunction(Metere Line 145  class SimpleInversionCostFunction(Metere
145          m=self.regularization.getInverseHessianApproximation(m, r, *args[2])          m=self.regularization.getInverseHessianApproximation(m, r, *args[2])
146          print "m  = ",m          print "m  = ",m
147          return m          return m
148            
149      def updateHessian(self):      def updateHessian(self):
150          """          """
151          notifies the class that the Hessian operator needs to be updated.          notifies the class that the Hessian operator needs to be updated.

Legend:
Removed from v.4095  
changed lines
  Added in v.4097

  ViewVC Help
Powered by ViewVC 1.1.26