/[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 4283 by caltinay, Thu Mar 7 00:11:36 2013 UTC revision 4367 by plaub, Wed Apr 17 09:55:25 2013 UTC
# Line 366  class InversionCostFunction(MeteredCostF Line 366  class InversionCostFunction(MeteredCostF
366    
367          return J          return J
368    
369        def getComponentValues(self, m, *args):
370            return self._getComponentValues(m, *args)
371    
372        def _getComponentValues(self, m, *args):
373            """
374            returns the values of the individual cost functions that make up *f(x)*
375            using the precalculated values for *x*.
376    
377            :param x: a solution approximation
378            :type x: x-type
379            :rtype: ``list<<float>>``
380            """
381            if len(args)==0:
382                args=self.getArguments(m)
383    
384            props=args[0]
385            args_f=args[1]
386            args_reg=args[2]
387    
388            J_reg = self.regularization.getValue(m, *args_reg)
389            result = [J_reg]
390    
391            for i in range(self.numModels):
392                f=self.forward_models[i]
393                if isinstance(f, ForwardModel):
394                    J_f = f.getValue(props[0],*args_f[i])
395                elif len(f) == 1:
396                    J_f=f[0].getValue(props[0],*args_f[i])
397                else:
398                    idx = f[1]
399                    f=f[0]
400                    if isinstance(idx, int):
401                        J_f = f.getValue(props[idx],*args_f[i])
402                    else:
403                        args=tuple( [ props[j] for j in idx] + args_f[i])
404                        J_f = f.getValue(*args)
405                self.logger.debug("J_f[%d] = %e"%(i, J_f))
406                self.logger.debug("mu_model[%d] = %e"%(i, self.mu_model[i]))
407    
408                result += [J_f] # self.mu_model[i] * ??
409    
410            return result
411    
412      def _getGradient(self, m, *args):      def _getGradient(self, m, *args):
413          """          """
414          returns the gradient of the cost function at *m*.          returns the gradient of the cost function at *m*.

Legend:
Removed from v.4283  
changed lines
  Added in v.4367

  ViewVC Help
Powered by ViewVC 1.1.26