GPLIB++
MTRecObjective.cpp
Go to the documentation of this file.
1 #include "MTRecObjective.h"
2 #include <boost/numeric/ublas/matrix_proxy.hpp>
3 #include <boost/numeric/ublas/vector_proxy.hpp>
4 #include <boost/bind.hpp>
5 #include <algorithm>
6 #include <iostream>
7 #include "Adaptors.h"
8 
9 namespace gplib
10  {
11  MTRecObjective::MTRecObjective(const CMTStation &LocalMTData,
12  SeismicDataComp &TheRecData, const int myshift, const double myomega,
13  const double mysigma, const double myc, const double myslowness) :
14  recweight(1), RecObjective(TheRecData, myshift, myomega, mysigma, myc,
15  myslowness), MTObjective(LocalMTData)
16  {
17 
18  }
19 
21  {
22  }
23 
25  {
26  const int nlayers = member.size() / 3;
27  ttranscribed mtmember(nlayers * 2), recmember(nlayers * 2);
28  mtmember = ublas::project(member, ublas::range(0, nlayers * 2));
29  recmember = ublas::project(member, ublas::range(nlayers, nlayers * 3));
30  double mtperf = MTObjective.CalcPerformance(mtmember);
31  double recperf = RecObjective.CalcPerformance(recmember);
32  const int ndata = MTObjective.GetSynthData().size()
33  + RecObjective.GetSynthData().size();
34  SetMisfit().resize(ndata); //make sure Misfit in base class can hold enough elements
35  SetSynthData().resize(ndata); // and same for data
36  project(SetSynthData(), ublas::range(0,
37  MTObjective.GetSynthData().size())) = MTObjective.GetSynthData();
38  project(SetSynthData(), ublas::range(MTObjective.GetSynthData().size(),
39  MTObjective.GetSynthData().size()
40  + RecObjective.GetSynthData().size()))
41  = RecObjective.GetSynthData();
42  project(SetMisfit(), ublas::range(0, MTObjective.GetMisfit().size()))
43  = MTObjective.GetMisfit();
44  project(SetMisfit(), ublas::range(MTObjective.GetMisfit().size(),
45  MTObjective.GetMisfit().size() + RecObjective.GetMisfit().size()))
46  = RecObjective.GetMisfit();
47  SetRMS(mtperf + recweight * recperf);
48 
49  return mtperf + recweight * recperf;
50  }
51  }
ublas::vector< double > ttranscribed
Definition: gentypes.h:21
double CalcPerformance(const ttranscribed &member)
For serial execution CalcPerformance calls the three Parallel functions for more convenient use...
boost::shared_ptr< PlottableObjective > MTObjective
Definition: cadianiso.cpp:16
const tdata & GetSynthData()
Return the current synthetic data.
C1DRecObjective RecObjective(RecData, Configuration.shift, Configuration.omega, Configuration.sigma, Configuration.wlevel, Configuration.slowness)
const tmisfit & GetMisfit()
Return the misfit vector.
tdata & SetSynthData()
Only derived classes can write access the Synthetic data.
tmisfit & SetMisfit()
Only derived classes can write access the Misfit.
MTRecObjective(const CMTStation &LocalMTData, SeismicDataComp &TheRecData, const int myshift, const double myomega, const double mysigma, const double myc, const double myslowness)
virtual double PostParallel(const ttranscribed &member)
Some operations cannot be done in parallel, these are done after, returns the misfit value...
void SetRMS(const double x)