/[escript]/branches/subworld2/downunder/py_src/inversioncostfunctions.py
ViewVC logotype

Diff of /branches/subworld2/downunder/py_src/inversioncostfunctions.py

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

revision 5504 by jfenwick, Wed Mar 4 22:58:13 2015 UTC revision 5505 by jfenwick, Wed Mar 4 23:05:47 2015 UTC
# Line 30  from .mappings import Mapping Line 30  from .mappings import Mapping
30  from .forwardmodels import ForwardModel  from .forwardmodels import ForwardModel
31  from esys.escript.pdetools import ArithmeticTuple  from esys.escript.pdetools import ArithmeticTuple
32  from esys.escript import Data, inner  from esys.escript import Data, inner
33    from esys.escript import SplitWorld
34  import numpy as np  import numpy as np
35    
36    
# Line 74  class InversionCostFunction(MeteredCostF Line 75  class InversionCostFunction(MeteredCostF
75      """      """
76      provides_inverse_Hessian_approximation=True      provides_inverse_Hessian_approximation=True
77    
78      def __init__(self, regularization, mappings, forward_models):  
79        #This is a test at hacking splitworld functionality into downunder
80        #In production code, we may need a new subclass for this
81        def __init__(self, regularization, mappings, forward_models, splitw=None, worldsinit_fn=None):
82          """          """
83          constructor for the cost function.          constructor for the cost function.
84          Stores the supplied object references and sets default weights.          Stores the supplied object references and sets default weights.
# Line 108  class InversionCostFunction(MeteredCostF Line 112  class InversionCostFunction(MeteredCostF
112          if isinstance(mappings, Mapping):          if isinstance(mappings, Mapping):
113              mappings = [ mappings ]              mappings = [ mappings ]
114    
115            if splitw is None:
116          splitw=SplitWorld(1)
117        # calls worlds init in each of the subworlds
118            if worldsinit_fn is not None:
119          for i in range(0,splitw.getWorldCount()):
120            addJob(sw, FunctionJob, worldsinit_fn)
121            
122          self.mappings=[]          self.mappings=[]
123          for i in range(len(mappings)):          for i in range(len(mappings)):
124              mm=mappings[i]              mm=mappings[i]
# Line 145  class InversionCostFunction(MeteredCostF Line 156  class InversionCostFunction(MeteredCostF
156    
157          if isinstance(forward_models, ForwardModel):          if isinstance(forward_models, ForwardModel):
158              forward_models = [ forward_models ]              forward_models = [ forward_models ]
159            temp_fwdmod=[]    
160          self.forward_models=[]          self.forward_models=[]
161          for i in range(len(forward_models)):          for i in range(len(forward_models)):
162              f=forward_models[i]              f=forward_models[i]
# Line 163  class InversionCostFunction(MeteredCostF Line 175  class InversionCostFunction(MeteredCostF
175                      if k<0 or k> self.numMappings:                      if k<0 or k> self.numMappings:
176                          raise ValueError("mapping index %s in model %s is out of range."%(k,i))                          raise ValueError("mapping index %s in model %s is out of range."%(k,i))
177                  fm=f[0]                  fm=f[0]
178              self.forward_models.append((fm,idx))              temp_fwdmod.append((fm,idx))
179            self.forward_models=temp_fwdmod
180          self.numModels=len(self.forward_models)          self.numModels=len(self.forward_models)
181    
182          trafo = self.regularization.getCoordinateTransformation()          trafo = self.regularization.getCoordinateTransformation()

Legend:
Removed from v.5504  
changed lines
  Added in v.5505

  ViewVC Help
Powered by ViewVC 1.1.26