/[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 4397 by jfenwick, Thu May 9 06:17:15 2013 UTC revision 4416 by jfenwick, Fri May 17 02:32:33 2013 UTC
# Line 338  class InversionCostFunction(MeteredCostF Line 338  class InversionCostFunction(MeteredCostF
338    
339          :param m: current approximation of the level set function          :param m: current approximation of the level set function
340          :type m: `Data`          :type m: `Data`
341          :param args: tuple of of values of the parameters, pre-computed values          :param args: tuple of values of the parameters, pre-computed values
342                       for the forward model and pre-computed values for the                       for the forward model and pre-computed values for the
343                       regularization                       regularization
344          :rtype: ``float``          :rtype: ``float``
# Line 355  class InversionCostFunction(MeteredCostF Line 355  class InversionCostFunction(MeteredCostF
355          for i in range(self.numModels):          for i in range(self.numModels):
356              f=self.forward_models[i]              f=self.forward_models[i]
357              if isinstance(f, ForwardModel):              if isinstance(f, ForwardModel):
358                  J_f = f.getValue(props[0],*args_f[i])                  J_f = f.getDefect(props[0],*args_f[i])
359              elif len(f) == 1:              elif len(f) == 1:
360                  J_f=f[0].getValue(props[0],*args_f[i])                  J_f=f[0].getDefect(props[0],*args_f[i])
361              else:              else:
362                  idx = f[1]                  idx = f[1]
363                  f=f[0]                  f=f[0]
364                  if isinstance(idx, int):                  if isinstance(idx, int):
365                      J_f = f.getValue(props[idx],*args_f[i])                      J_f = f.getDefect(props[idx],*args_f[i])
366                  else:                  else:
367                      args=tuple( [ props[j] for j in idx] + args_f[i])                      args=tuple( [ props[j] for j in idx] + args_f[i])
368                      J_f = f.getValue(*args)                      J_f = f.getDefect(*args)
369              self.logger.debug("J_f[%d] = %e"%(i, J_f))              self.logger.debug("J_f[%d] = %e"%(i, J_f))
370              self.logger.debug("mu_model[%d] = %e"%(i, self.mu_model[i]))              self.logger.debug("mu_model[%d] = %e"%(i, self.mu_model[i]))
371              J += self.mu_model[i] * J_f              J += self.mu_model[i] * J_f
# Line 427  class InversionCostFunction(MeteredCostF Line 427  class InversionCostFunction(MeteredCostF
427                       regularization                       regularization
428    
429          :rtype: `ArithmeticTuple`          :rtype: `ArithmeticTuple`
430            
431            :note: returns (Y^,X) where Y^ is gradient from regularisation plus gradients of fwd models.
432                   X is the gradient of the regularisation wrt gradient of m.
433          """          """
434          if len(args)==0:          if len(args)==0:
435              args = self.getArguments(m)              args = self.getArguments(m)
# Line 447  class InversionCostFunction(MeteredCostF Line 450  class InversionCostFunction(MeteredCostF
450                  dpdm = mm[0].getDerivative(m[mm[1]])                  dpdm = mm[0].getDerivative(m[mm[1]])
451              p_diffs.append(dpdm)              p_diffs.append(dpdm)
452    
453          Y=g_J[0]          Y=g_J[0]      # Beacause g_J==(Y,X)  Y_k=dKer/dm_k
454          for i in range(self.numModels):          for i in range(self.numModels):
455              mu=self.mu_model[i]              mu=self.mu_model[i]
456              f=self.forward_models[i]              f=self.forward_models[i]

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

  ViewVC Help
Powered by ViewVC 1.1.26