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

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

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

revision 4396 by caltinay, Thu Jan 31 03:18:56 2013 UTC revision 4397 by jfenwick, Thu May 9 06:17:15 2013 UTC
# Line 68  class CostFunction(object): Line 68  class CostFunction(object):
68          *f(x)* and *grad f(x)* and the Hessian operator. The default          *f(x)* and *grad f(x)* and the Hessian operator. The default
69          implementation returns an empty tuple.          implementation returns an empty tuple.
70    
71            .. note:: The tuple returned by this call will be passed back to this `CostFunction` in other
72               calls(eg: `getGradient`). Its contents are not specified at this level because no code,
73               other than the `CostFunction`
74               which created it, will be interacting with it.
75               That is, the implementor can put whatever information they find useful in it.        
76            
77          :param x: location of derivative          :param x: location of derivative
78          :type x: x-type          :type x: x-type
79          :rtype: ``tuple``          :rtype: ``tuple``
# Line 269  class MeteredCostFunction(CostFunction): Line 275  class MeteredCostFunction(CostFunction):
275          returns precalculated values that are shared in the calculation of          returns precalculated values that are shared in the calculation of
276          *f(x)* and *grad f(x)* and the Hessian operator          *f(x)* and *grad f(x)* and the Hessian operator
277    
278            .. note:: The tuple returned by this call will be passed back to this `CostFunction` in other
279               calls(eg: ``getGradient``). Its contents are not specified at this level because no code, other than the `CostFunction`
280               which created it, will be interacting with it.
281               That is, the implementor can put whatever information they find useful in it.
282            
283          :param x: location of derivative          :param x: location of derivative
284          :type x: x-type          :type x: x-type
285            :rtype: ``tuple``
286          """          """
287          self.Arguments_calls+=1          self.Arguments_calls+=1
288          return self._getArguments(x)          return self._getArguments(x)
# Line 278  class MeteredCostFunction(CostFunction): Line 290  class MeteredCostFunction(CostFunction):
290      def _getArguments(self, x):      def _getArguments(self, x):
291          """          """
292          returns precalculated values that are shared in the calculation of          returns precalculated values that are shared in the calculation of
293          *f(x)* and *grad f(x)* and the Hessian operator          *f(x)* and *grad f(x)* and the Hessian operator.
294            
295    
296    
297          :param x: location of derivative          :param x: location of derivative
298          :type x: x-type          :type x: x-type
         :note: Overwrite this function to implement a specific cost function  
299          """          """
300          return ()          return ()
301    
# Line 292  class MeteredCostFunction(CostFunction): Line 305  class MeteredCostFunction(CostFunction):
305          operator of the cost function for a given gradient *r* at a given          operator of the cost function for a given gradient *r* at a given
306          location *x*: *H(x) p = r*          location *x*: *H(x) p = r*
307    
308            .. note:: In general it is assumed that the Hessian *H(x)* needs to be
309               calculate in each call for a new location *x*. However, the
310               solver may suggest that this is not required, typically when
311               the iteration is close to completeness.
312              
313          :param x: location of Hessian operator to be evaluated.          :param x: location of Hessian operator to be evaluated.
314          :type x: x-type          :type x: x-type
315          :param r: a given gradient          :param r: a given gradient
316          :type r: r-type          :type r: r-type
317          :param args: pre-calculated values for ``x`` from `getArguments()`          :param args: pre-calculated values for ``x`` from `getArguments()`
318          :rtype: x-type          :rtype: x-type
319          :note: In general it is assumed that the Hessian *H(x)* needs to be  
                calculate in each call for a new location *x*. However, the  
                solver may suggest that this is not required, typically when  
                the iteration is close to completeness.  
320          """          """
321          self.InverseHessianApproximation_calls+=1          self.InverseHessianApproximation_calls+=1
322          return self._getInverseHessianApproximation(x, r, *args)          return self._getInverseHessianApproximation(x, r, *args)

Legend:
Removed from v.4396  
changed lines
  Added in v.4397

  ViewVC Help
Powered by ViewVC 1.1.26