GPLIB++
GeneralObjective.cpp
Go to the documentation of this file.
1 #include "GeneralObjective.h"
2 #include <numeric>
3 #include <cmath>
4 
5 namespace gplib
6  {
8  FitExponent(2), RMS(0.0), ParallelId("single")
9  {
10  }
11 
13  {
14  }
15 
17  FitExponent(Old.FitExponent), RMS(Old.RMS), Misfit(Old.Misfit),
18  SynthData(Old.SynthData), ParallelId(Old.ParallelId)
19  {
20  }
21 
23  const GeneralObjective &source)
24  {
25  if (this != &source)
26  {
27  FitExponent = source.FitExponent;
28  RMS = source.RMS;
29  Misfit = source.Misfit;
30  SynthData = source.SynthData;
31  ParallelId = source.ParallelId;
32  }
33  return *this;
34  }
35 
37  {
38 
39  }
40 
42  {
43 
44  }
45 
47  {
48  PreParallel(member);
49  SafeParallel(member);
50  return PostParallel(member);
51  }
52 
53  double GeneralObjective::CalcMisfit(const double measured,
54  const double predicted, const double measerror,
55  const double errorlevel, const int index)
56  {
57  const double absolutemin = 1e-6;
58  double currvalue = std::abs(measured - predicted);
59  double absoluteerror = std::max(measerror, std::abs(measured * errorlevel));
60  currvalue /= std::max(absolutemin, absoluteerror);
61  currvalue = std::pow(currvalue, GetFitExponent());
62  SetMisfit()(index) = currvalue; //set the misfit vector
63  SetSynthData()(index) = measured;
64  return currvalue;
65 
66  }
67 
68  /* For later implementation
69  *
70  * virtual GeneralObjective::GetGradient()
71  {
72  }
73 
74  virtual GeneralObjective::GetPartialDerivatives()
75  {
76  }*/
77  }
ublas::vector< double > ttranscribed
Definition: gentypes.h:21
virtual void SafeParallel(const ttranscribed &member)
The core performance calculation, has to be safe to be done in parallel.
double CalcPerformance(const ttranscribed &member)
For serial execution CalcPerformance calls the three Parallel functions for more convenient use...
GeneralObjective & operator=(const GeneralObjective &source)
virtual double PostParallel(const ttranscribed &member)=0
Some operations cannot be done in parallel, these are done after, returns the misfit value...
virtual void PreParallel(const ttranscribed &member)
Some operations cannot be done in parallel, these are done before.
int GetFitExponent()
Get the Fit exponent.
double CalcMisfit(const double measured, const double predicted, const double measerror, const double errorlevel, const int index)
The basic object for any objective function, mainly an interface class and some storage.
tdata & SetSynthData()
Only derived classes can write access the Synthetic data.
tmisfit & SetMisfit()
Only derived classes can write access the Misfit.