/[escript]/trunk/doc/inversion/CostFunctions.tex
ViewVC logotype

Annotation of /trunk/doc/inversion/CostFunctions.tex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4133 - (hide annotations)
Fri Jan 11 06:41:10 2013 UTC (6 years, 7 months ago) by gross
Original Path: trunk/doc/inversion/Drivers.tex
File MIME type: application/x-tex
File size: 25862 byte(s)
some documentation on Inversion Cost function added.
1 gross 4119
2 gross 4131 \chapter{Inversion Drivers}\label{chapter:ref:Drivers}
3 gross 4119
4 gross 4131 \section{Driver Classes}
5     The inversion minimizes an appropriate cost function $J$ to find the physical parameter distribution
6     (or more precisely the level set function) which gives the best fit to measured data. A
7     particular inversion case (gravity, magnetic or joint) is managed through
8     an instance of a specialization of the \class{InversionDriver} class. The task of the class instance
9     is to set up the appropriate cost function, to manage solution parameters and to run the optimization process.
10    
11     \subsection{Template}
12     \begin{classdesc*}{InversionDriver}
13     template for inversion drivers. By default the limited-memory Broyden-Fletcher-Goldfarb-Shanno (\emph{L-BFGS})~\cite{L-BFGS}\index{L-BFGS} solver is used.
14     \end{classdesc*}
15    
16     \begin{methoddesc}[InversionDriver]{getCostFunction}{}
17 gross 4133 returns the cost function of the inversion. This will be an instance of the \class{InversionCostFunction} class, see section~\ref{chapter:ref:inversion cost function}.
18 gross 4131 Use this method to access or alter attribute or methods of the underlying cost function.
19     \end{methoddesc}
20    
21     \begin{methoddesc}[InversionDriver]{getDomain}{}
22     returns the domain of the inversion as an \escript \class{Domain} object.
23     \end{methoddesc}
24    
25    
26     \begin{methoddesc}[InversionDriver]{setSolverMaxIterations}{\optional{maxiter=\None}}
27     set the maximum number of iteration steps for the solver used to minimize the cost function. The default value is 200.
28     If the maximum number is reached, the iteration will be terminated and the \exception{MinimizerMaxIterReached} is thrown.
29     \end{methoddesc}
30    
31     \begin{methoddesc}[InversionDriver]{setSolverTolerance}{\optional{tol=\None} \optional{, atol=\None}}
32     set the tolerance for the the solver used to minimize the cost function. If \member{tol} is set the iteration is terminated
33     if the relative change of the level set function is less or equal \member{tol}.
34     If \member{atol} is set the iteration is terminated
35     if the change of the cost function relative to the initial value is less or equal \member{atol}. If both
36     tolerances are set both stopping criteria need to be meet. By default \member{tol}=1e-4 and \member{atol}=\None.
37     \end{methoddesc}
38    
39     \begin{methoddesc}[InversionDriver]{getLevelSetFunction}{}
40     returns the level set function as solution of the optimization problem. This method can only be called if the
41     optimization process as been completed. If the iteration failed the last available approximation of the
42     solution is returned.
43     \end{methoddesc}
44    
45     \begin{methoddesc}[InversionDriver]{run}{}
46     this method run the optimization solver and returns the physical parameter(s)
47     from the output of the inversion. Notice that the \method{setup} method must be called before the first call
48     of \method{run}.
49     The call can fail as the maximum number is reached in which case
50     an \exception{MinimizerMaxIterReached} exception is thrown or as there is an incurable break down in the
51     iteration in which case an \exception{MinimizerIterationIncurableBreakDown} exception is thrown.
52     \end{methoddesc}
53    
54     \subsection{Gravity Inversion Driver}
55     For examples of usage please see Chapter~\ref{Chp:cook:gravity inversion}.
56    
57     \begin{classdesc}{GravityInversion}{}
58     Driver class to perform an inversion of Gravity (Bouguer) anomaly data. This class
59     is a sub-class of the \class{InversionDriver} class. The class uses the standard
60     \class{Regularization} class for a single level set function, see Chapter~\ref{Chp:ref:regularization},
61     \class{DensityMapping} mapping, see Section~\ref{Chp:ref:mapping density}, and the
62     gravity forward model \class{GravityModel}, see Section~\ref{sec:forward gravity}.
63     \end{classdesc}
64    
65     \begin{methoddesc}[GravityInversion]{setup}{
66     domainbuilder
67     \optional{, rho0=\None}
68     \optional{, drho=\None}
69     \optional{, z0=\None}
70     \optional{, beta=\None}
71     \optional{, w0=\None}
72     \optional{, w1=\None}}
73     sets up the inversion from an instance \member{domainbuilder} of a \class{DomainBuilder}, see Section~\ref{Chp:ref:domain builder}.
74     Only gravitational data attached to the \member{domainbuilder} are considered in the inversion.
75     \member{rho0} defines a reference density anomaly (defaults is 0),
76     \member{drho} defines a density anomaly (defaults is $2750 \frac{kg}{m^3}$),
77     \member{z0} defines the depth weighting reference depth (defaults is \None), and
78     \member{beta} defines the depth weighting exponent (defaults is \None),
79     see \class{DensityMapping} in Section~\ref{Chp:ref:mapping density}.
80     \member{w0} and \member{w1} define the weighting factors
81     $\omega^{(0)}$ and
82     $\omega^{(1)}$, respectively (see equation~\ref{EQU:REG:1}).
83     As default \member{w0}=\None and \member{w1}=1 are used.
84     \end{methoddesc}
85    
86     \begin{methoddesc}[GravityInversion]{setInitialGuess}{\optional{rho=\None}}
87     set an initial guess for the density anomaly. As default zero is used.
88     \end{methoddesc}
89    
90     \subsection{Magnetic Inversion Driver}
91     For examples of usage please see Chapter~\ref{Chp:cook:magnetic inversion}.
92    
93    
94     \begin{classdesc}{MagneticInversion}{}
95     Driver class to perform an inversion of magnetic anomaly data. This class
96     is a sub-class of the \class{InversionDriver} class. The class uses the standard
97     \class{Regularization} class for a single level set function, see Chapter~\ref{Chp:ref:regularization},
98 gross 4133 \class{SusceptibilityMapping} mapping, see Section~\ref{Chp:ref:mapping susceptibility}, and the linear
99 gross 4131 magnetic forward model \class{MagneticModel}, see Section~\ref{sec:forward magnetic}.
100     \end{classdesc}
101    
102    
103     \begin{methoddesc}[MagneticInversion]{setup}{
104     domainbuilder
105     \optional{, k0=\None}
106     \optional{, dk=\None}
107     \optional{, z0=\None}
108     \optional{, beta=\None}
109     \optional{, w0=\None}
110     \optional{, w1=\None}}
111    
112     sets up the inversion from an instance \member{domainbuilder} of a \class{DomainBuilder}, see Section~\ref{Chp:ref:domain builder}.
113     Only magnetic data attached to the \member{domainbuilder} are considered in the inversion.
114     \member{k0} defines a reference susceptibility anomaly (defaults is 0),
115     \member{dk} defines a susceptibility anomaly scale (defaults is $1$),
116     \member{z0} defines the depth weighting reference depth (defaults is \None), and
117     \member{beta} defines the depth weighting exponent (defaults is \None),
118     see \class{SusceptibilityMapping} in Section~\ref{Chp:ref:mapping susceptibility}.
119     \member{w0} and \member{w1} define the weighting factors
120     $\omega^{(0)}$ and
121     $\omega^{(1)}$, respectively (see equation~\ref{EQU:REG:1}).
122     As default \member{w0}=\None and \member{w1}=1 are used.
123     \end{methoddesc}
124    
125     \begin{methoddesc}[MagneticInversion]{setInitialGuess}{\optional{k=\None}}
126     set an initial guess for the susceptibility anomaly. As default zero is used.
127     \end{methoddesc}
128    
129     \subsection{Gravity and Magnetic Joint Inversion Driver}
130     For examples of usage please see Chapter~\ref{Chp:cook:joint inversion}.
131    
132     \begin{classdesc}{JointGravityMagneticInversion}{}
133     Driver class to perform a joint inversion of Gravity (Bouguer) and magnetic anomaly data. This class
134     is a sub-class of the \class{InversionDriver} class.
135     The class uses the standard
136     \class{Regularization} class for a two level set functions with cross-gradient correlation, see Chapter~\ref{Chp:ref:regularization},
137     \class{DensityMapping} and \class{SusceptibilityMapping} mappings, see Section~\ref{Chp:ref:mapping}, the
138     gravity forward model \class{GravityModel}, see Section~\ref{sec:forward gravity}
139     and the linear
140     magnetic forward model \class{MagneticModel}, see Section~\ref{sec:forward magnetic}.
141     \end{classdesc}
142    
143    
144     \begin{methoddesc}[JointGravityMagneticInversion]{setup}{
145     domainbuilder
146     \optional{, rho0=\None}
147     \optional{, drho=\None}
148     \optional{, rho_z0=\None}
149     \optional{, rho_beta=\None}
150     \optional{, k0=\None}
151     \optional{, dk=\None}
152     \optional{, k_z0=\None}
153     \optional{, k_beta=\None}
154     \optional{, w0=\None}
155     \optional{, w1=\None}
156     \optional{, w_gc=\None}
157     }
158     sets up the inversion from an instance \member{domainbuilder} of a \class{DomainBuilder}, see Section~\ref{Chp:ref:domain builder}.
159     Gravity and magnetic data attached to the \member{domainbuilder} are considered in the inversion.
160     \member{rho0} defines a reference density anomaly (defaults is 0),
161     \member{drho} defines a density anomaly (defaults is $2750 \frac{kg}{m^3}$),
162     \member{rho_z0} defines the depth weighting reference depth for density (defaults is \None), and
163     \member{rho_beta} defines the depth weighting exponent for density (defaults is \None),
164     see \class{DensityMapping} in Section~\ref{Chp:ref:mapping density}.
165     \member{k0} defines a reference susceptibility anomaly (defaults is 0),
166     \member{dk} defines a susceptibility anomaly scale (defaults is $1$),
167     \member{k_z0} defines the depth weighting reference depth for susceptibility (defaults is \None), and
168     \member{k_beta} defines the depth weighting exponent for susceptibility (defaults is \None),
169     see \class{SusceptibilityMapping} in Section~\ref{Chp:ref:mapping susceptibility}.
170     \member{w0} and \member{w1} define the weighting factors
171     $\omega^{(0)}$ and
172     $\omega^{(1)}$, respectively (see equation~\ref{EQU:REG:1}).
173     \member{w_gc} sets the weighting factor $\omega^{(c)}$ for the cross gradient term.
174     As default \member{w0}=\None, \member{w1}=1 and \member{w_gc}=1 are used.
175     \end{methoddesc}
176    
177     \begin{methoddesc}[JointGravityMagneticInversion]{setInitialGuess}{\optional{rho=None, } \optional{k=\None}}
178     set initial guesses for density and susceptibility anomaly. As default zeros are used.
179     \end{methoddesc}
180    
181    
182    
183 gross 4133 \section{Cost Function for Inversion}\label{chapter:ref:inversion cost function}
184     The general form of the cost function minimized in the inversion is given in the form (see also Chapter~\ref{Chp:ref:introduction})
185     \begin{equation}\label{REF:EQU:DRIVE:10}
186     J(m) = J^{reg}(m) + \sum_{f} \mu^{data}_{f} \cdot J^{f}(p^f)
187     \end{equation}
188     where $m$ represents the level set function, $J^{reg}$ is the regularization term, see Chapter~\ref{Chp:ref:regularization},
189     and $J^{f}$ are a set of forward problems, see Chapter~\ref{Chp:ref:forward models} depending of
190     physical parameters $p^f$. The physical parameters $p^f$ are known functions
191     of the level set function $m$ which is the unknown to be calculated by the optimization process.
192     $\mu^{data}_{f}$ are trade-off factors. It is pointed out that the regularization term includes additional trade-off factors
193     The \class{InversionCostFunction} is class to define cost functions of an inversion. It is pointed out that
194     the \class{InversionCostFunction} class implements the \class{CostFunction} template class, see Chapter~\ref{chapter:ref:Minimization}.
195 gross 4131
196 gross 4133 In the simplest case there is a single forward model using a single physical parameter which is
197     derived form single-values level set function. The following script snippet shows the creation of the
198     \class{InversionCostFunction} for the case of a gravity inversion:
199     \begin{verbatim}
200     p=DensityMapping(...)
201     f=GravityModel(...)
202     J=InversionCostFunction(Regularization(...), \
203     mappings=p, \
204     forward_models=f)
205     \end{verbatim}
206     The argument \verb|...| refers to an appropriate argument list.
207 gross 4131
208 gross 4133 If two forward models are coming into play using two different physical parameters
209     the \member{mappings} and \member{forward_models} are defined as lists in the following form:
210     \begin{verbatim}
211     p_rho=DensityMapping(...)
212     p_k=SusceptibilityMapping(...)
213     f_mag=MagneticModel(...)
214     f_grav=GravityModel(...)
215    
216     J=InversionCostFunction(Regularization(...), \
217     mappings=[p_rho, p_k], \
218     forward_models=[(f_mag, 1), (f_grav,0)])
219     \end{verbatim}
220     Here we define a joint inversion of gravity and magnetic data. \member{forward_models} is given as a list of
221     a tuple of a forward model and an index which referring to parameter in the \member{mappings} list to be used as an input.
222     The magnetic forward model \member{f_mag} is using the the second parameter (=\member{p_k}) in \member{mappings} list.
223     In this case the physical parameters are defined by a single-valued level set function. It is also possible
224     to link physical parameters to components of a level set function:
225     \begin{verbatim}
226     p_rho=DensityMapping(...)
227     p_k=SusceptibilityMapping(...)
228     f_mag=MagneticModel(...)
229     f_grav=GravityModel(...)
230    
231     J=InversionCostFunction(Regularization(numLevelSets=2,...), \
232     mappings=[(p_rho,0), (p_k,1)], \
233     forward_models=[[(f_mag, 1), (f_grav,0)])
234     \end{verbatim}
235     The \member{mappings} argument is now a list of pairs where the first pair entry specifies the parameter mapping and
236     the second pair entry specifies the index of the component of the level set function to be used to evaluate the parameter.
237     In this case the level set function has two components, where the density mapping uses the first component of the level set function
238     while the susceptibility mapping uses the second component.
239    
240     The \class{InversionCostFunction} API is defined as follows:
241    
242     \begin{classdesc}{InversionCostFunction}{regularization, mappings, forward_models}
243     Constructor for the inversion cost function. \member{regularization} sets the regularization to be used, see Chapter~\ref{Chp:ref:regularization}.
244     \member{mappings} is a list of pairs where each pair comprises of a
245     physical parameter mapping (see Chapter~\ref{Chp:ref:mapping}) and an index which refers to the component of level set function
246     defined by the \member{regularization} to be used to calculate the corresponding physical parameter. If
247     the level set function has a single component the index can be omitted. If in addition there is a single physical parameter
248     the mapping can be given instead of a list. \member{forward_models} is a list of pairs where the
249     first pair component is a forward model ( see Chapter~\ref{Chp:ref:forward models}) and the second
250     pair component referring to the physical parameter in the \member{mappings} list providing the physical parameter for the model.
251     If a single physical parameter is present the index can be omitted. If in addition a single forward model is used this
252     forward model can be assigned to \member{forward_models} in replacement of a list.
253 gross 4119 \end{classdesc}
254 gross 4133
255    
256     \begin{methoddesc}[InversionCostFunction]{getDomain}{}
257     """
258     returns the domain of the cost function
259     :rtype: 'Domain`
260     """
261     self.regularization.getDomain()
262     \end{methoddesc}
263    
264     \begin{methoddesc}[InversionCostFunction]{getNumTradeOffFactors}{}
265     """
266     returns the number of trade-off factors being used including the
267     trade-off factors used in the regularization component.
268    
269     :rtype: ``int``
270     """
271     return self.__num_tradeoff_factors
272     \end{methoddesc}
273    
274     \begin{methoddesc}[InversionCostFunction]{getForwardModel}{idx=None}
275     """
276     returns the *idx*-th forward model.
277    
278     :param idx: model index. If cost function contains one model only `idx`
279     can be omitted.
280     :type idx: ``int``
281     """
282     if idx==None: idx=0
283     f=self.forward_models[idx]
284     if isinstance(f, ForwardModel):
285     F=f
286     else:
287     F=f[0]
288     return F
289     \end{methoddesc}
290    
291     \begin{methoddesc}[InversionCostFunction]{getRegularization}{}
292     """
293     returns the regularization
294     """
295     return self.regularization
296     \end{methoddesc}
297    
298    
299     \begin{methoddesc}[InversionCostFunction]{setTradeOffFactorsModels}{mu=None}
300     """
301     sets the trade-off factors for the forward model components.
302    
303     :param mu: list of the trade-off factors. If not present ones are used.
304     :type mu: ``float`` in case of a single model or a ``list`` of ``float``
305     with the length of the number of models.
306     """
307     if mu==None:
308     self.mu_model=np.ones((self.numModels, ))
309     else:
310     if self.numModels > 1:
311     mu=np.asarray(mu)
312     if min(mu) > 0:
313     self.mu_model= mu
314     else:
315     raise ValueError("All value for trade-off factor mu must be positive.")
316     else:
317     mu=float(mu)
318     if mu > 0:
319     self.mu_model= [mu, ]
320     else:
321     raise ValueError("Trade-off factor must be positive.")
322     \end{methoddesc}
323    
324     \begin{methoddesc}[InversionCostFunction]{setTradeOffFactorsRegularization}{mu=None, mu_c=None}
325     """
326     sets the trade of factors for the regularization component of the cost
327     function, see `Regularization` for details.
328    
329     :param mu: trade-off factors for the level-set variation part
330     :param mu_c: trade-off factors for the cross gradient variation part
331     """
332     self.regularization.setTradeOffFactorsForVariation(mu)
333     self.regularization.setTradeOffFactorsForCrossGradient(mu_c)
334     \end{methoddesc}
335    
336     \begin{methoddesc}[InversionCostFunction]{setTradeOffFactors}{mu=None}
337     """
338     sets the trade-off factors for the forward model and regularization
339     terms.
340    
341     :param mu: list of trade-off factors.
342     :type mu: ``list`` of ``float``
343     """
344     if mu is None:
345     mu=np.ones((self.__num_tradeoff_factors,))
346     self.setTradeOffFactorsModels(mu[:self.numModels])
347     self.regularization.setTradeOffFactors(mu[self.numModels:])
348     \end{methoddesc}
349    
350     \begin{methoddesc}[InversionCostFunction]{createLevelSetFunction}{*props}
351     """
352     returns an instance of an object used to represent a level set function
353     initialized with zeros. Components can be overwritten by physical
354     properties 'props'. If present entries must correspond to the
355     `mappings` arguments in the constructor. Use `None` for properties for
356     which no value is given.
357     """
358     m=self.regularization.getPDE().createSolution()
359     if len(props) > 0:
360     for i in xrange(self.numMappings):
361     if props[i]:
362     mm=self.mappings[i]
363     if isinstance(mm, Mapping):
364     m=mm.getInverse(props[i])
365     elif len(mm) == 1:
366     m=mm[0].getInverse(props[i])
367     else:
368     m[mm[1]]=mm[0].getInverse(props[i])
369     return m
370     \end{methoddesc}
371    
372     \begin{methoddesc}[InversionCostFunction]{getProperties}{m, return_list=False}
373     """
374     returns a list of the physical properties from a given level set
375     function *m* using the mappings of the cost function.
376    
377     :param m: level set function
378     :type m: `Data`
379     :param return_list: if True a list is returned.
380     def _:type return_list: `bool`
381     :rtype: `list` of `Data`
382     """
383     props=[]
384     for i in xrange(self.numMappings):
385     mm=self.mappings[i]
386     if isinstance(mm, Mapping):
387     p=mm.getValue(m)
388     elif len(mm) == 1:
389     p=mm[0].getValue(m)
390     else:
391     p=mm[0].getValue(m[mm[1]])
392     props.append(p)
393     if self.numMappings > 1 or return_list:
394     return props
395     else:
396     return props[0]
397     \end{methoddesc}
398    
399     \begin{methoddesc}[InversionCostFunction]{getDualProduct}{x, r}
400     """
401     Returns the dual product, see `Regularization.getDualProduct`
402    
403     :type x: `Data`
404     :type r: `ArithmeticTuple`
405     :rtype: `float`
406     """
407     return self.regularization.getDualProduct(x, r)
408     \end{methoddesc}
409    
410     \begin{methoddesc}[InversionCostFunction]{getArguments}{m}
411     """
412     returns pre-computed values that are shared in the calculation of
413     *J(m)* and *grad J(m)*. In this implementation returns a tuple with the
414     mapped value of ``m``, the arguments from the forward model and the
415     arguments from the regularization.
416    
417     :param m: current approximation of the level set function
418     :type m: `Data`
419     :return: tuple of of values of the parameters, pre-computed values for the forward model and
420     pre-computed values for the regularization
421     :rtype: `tuple`
422     """
423     args_reg=self.regularization.getArguments(m)
424    
425     props=self.getProperties(m, return_list=True)
426     args_f=[]
427     for i in xrange(self.numModels):
428     f=self.forward_models[i]
429     if isinstance(f, ForwardModel):
430     aa=f.getArguments(props[0])
431     elif len(f) == 1:
432     aa=f[0].getArguments(props[0])
433     else:
434     idx = f[1]
435     f=f[0]
436     if isinstance(idx, int):
437     aa=f.getArguments(props[idx])
438     else:
439     pp=tuple( [ props[i] for i in idx] )
440     aa=f.getArguments(*pp)
441     args_f.append(aa)
442    
443     return props, args_f, args_reg
444     \end{methoddesc}
445    
446     \begin{methoddesc}[InversionCostFunction]{getValue}{m, *args}
447     """
448     Returns the value *J(m)* of the cost function at *m*.
449     If the pre-computed values are not supplied `getArguments()` is called.
450    
451     :param m: current approximation of the level set function
452     :type m: `Data`
453     :param args: tuple of of values of the parameters, pre-computed values for the forward model and
454     pre-computed values for the regularization
455     :rtype: `float`
456     """
457    
458     if len(args)==0:
459     args=self.getArguments(m)
460    
461     props=args[0]
462     args_f=args[1]
463     args_reg=args[2]
464    
465     J = self.regularization.getValue(m, *args_reg)
466     print "J_reg = %e"%J
467    
468     for i in xrange(self.numModels):
469    
470     f=self.forward_models[i]
471     if isinstance(f, ForwardModel):
472     J_f = f.getValue(props[0],*args_f[i])
473     elif len(f) == 1:
474     J_f=f[0].getValue(props[0],*args_f[i])
475     else:
476     idx = f[1]
477     f=f[0]
478     if isinstance(idx, int):
479     J_f = f.getValue(props[idx],*args_f[i])
480     else:
481     args=tuple( [ props[j] for j in idx] + args_f[i])
482     J_f = f.getValue(*args)
483     print "J_f[%d] = %e"%(i, J_f)
484     print "mu_model[%d] = %e"%(i, self.mu_model[i])
485     J += self.mu_model[i] * J_f
486    
487     return J
488     \end{methoddesc}
489    
490     \begin{methoddesc}[InversionCostFunction]{getGradient}{m, *args}
491     """
492     returns the gradient of the cost function at *m*.
493     If the pre-computed values are not supplied `getArguments()` is called.
494    
495     :param m: current approximation of the level set function
496     :type m: `Data`
497     :param args: tuple of of values of the parameters, pre-computed values for the forward model and
498     pre-computed values for the regularization
499    
500     :rtype: `ArithmeticTuple`
501     """
502     if len(args)==0:
503     args = self.getArguments(m)
504    
505     props=args[0]
506     args_f=args[1]
507     args_reg=args[2]
508    
509     g_J = self.regularization.getGradient(m, *args_reg)
510     p_diffs=[]
511     for i in xrange(self.numMappings):
512     mm=self.mappings[i]
513     if isinstance(mm, Mapping):
514     dpdm = mm.getDerivative(m)
515     elif len(mm) == 1:
516     dpdm = mm[0].getDerivative(m)
517     else:
518     dpdm = mm[0].getDerivative(m[mm[1]])
519     p_diffs.append(dpdm)
520    
521     Y=g_J[0]
522     for i in xrange(self.numModels):
523     mu=self.mu_model[i]
524     f=self.forward_models[i]
525     if isinstance(f, ForwardModel):
526     Ys= f.getGradient(props[0],*args_f[i]) * p_diffs[0] * mu
527     if self.numLevelSets == 1 :
528     Y +=Ys
529     else:
530     Y[0] +=Ys
531     elif len(f) == 1:
532     Ys=f[0].getGradient(props[0],*args_f[i]) * p_diffs[0] * mu
533     if self.numLevelSets == 1 :
534     Y +=Ys
535     else:
536     Y[0] +=Ys
537     else:
538     idx = f[1]
539     f=f[0]
540     if isinstance(idx, int):
541     Ys = f.getGradient(props[idx],*args_f[i]) * p_diffs[idx] * mu
542     if self.numLevelSets == 1 :
543     if idx == 0:
544     Y+=Ys
545     else:
546     raise IndexError("Illegal mapping index.")
547     else:
548     Y[idx] += Ys
549     else:
550     args=tuple( [ props[j] for j in idx] + args_f[i])
551     Ys = f.getGradient(*args)
552     for ii in xrange(len(idx)):
553     Y[idx[ii]]+=Ys[ii]* p_diffs[idx[ii]] * mu
554    
555     return g_J
556     \end{methoddesc}
557    
558    
559     \begin{methoddesc}[InversionCostFunction]{getInverseHessianApproximation}{m, r, *args}
560     """
561     returns an approximative evaluation *p* of the inverse of the Hessian operator of the cost function
562     for a given gradient type *r* at a given location *m*: *H(m) p = r*
563    
564     :param m: level set approximation where to calculate Hessian inverse
565     :type m: `Data`
566     :param r: a given gradient
567     :type r: `ArithmeticTuple`
568     :param args: tuple of of values of the parameters, pre-computed values for the forward model and
569     pre-computed values for the regularization
570     :rtype: `Data`
571     :note: in the current implementation only the regularization term is
572     considered in the inverse Hessian approximation.
573    
574     """
575     m=self.regularization.getInverseHessianApproximation(m, r, *args[2])
576     return m
577    
578     \end{methoddesc}
579    
580     \begin{methoddesc}[InversionCostFunction]{getNorm}{m}
581     """
582     returns the norm of ``m``
583    
584     :param m: level set function
585     :type m: `Data`
586     :rtype: ``float``
587     """
588    
589     \end{methoddesc}

  ViewVC Help
Powered by ViewVC 1.1.26