cadianiso.cpp

Go to the documentation of this file.
00001 #include "cadijoint.h"
00002 #include <iostream>
00003 #include "Aniso1DMTObjective.h"
00004 #include "MTStation.h"
00005 #include "gentypes.h"
00006 #include "CLevanisoConf.h"
00007 #include "MTFitSetup.h"
00008 #include <boost/bind.hpp>
00009 #include "PTensor1DMTObjective.h"
00010 #include <boost/shared_ptr.hpp>
00011 #include "PTensorMTStation.h"
00012 
00013 using namespace std;
00014 using namespace gplib;
00015 
00016 boost::shared_ptr<PlottableObjective> MTObjective;
00017 CLevanisoConf Configuration;
00018 
00019 void misfit(float *p, float *misfit, int *m)
00020   {
00021     const int nlayers = abs(*m) / 4;
00022     const int nparam = nlayers * 4;
00023     ttranscribed mtmember(nparam);
00024     for (int i = 0; i < nparam; ++i)
00025       {
00026         mtmember(i) = p[i];
00027       }
00028     *misfit = 0.0;
00029     if (Configuration.weights.at(0) > 0)
00030       {
00031         //cout << "Calculating MT misfit" << endl;
00032         *misfit += Configuration.weights.at(0) * MTObjective->CalcPerformance(
00033             mtmember);
00034       }
00035   }
00036 
00037 void init(int* nd, float* ranges)
00038   {
00039     MTStation MTData;
00040     PTensorMTStation PTData;
00041     Configuration.GetData("levaniso.conf");
00042     try
00043       {
00044         MTData.GetData(Configuration.mtinputdata);
00045       } catch (FatalException &e)
00046       {
00047         cerr << e.what() << endl;
00048       }
00049 
00050     if (Configuration.mtfit == "ptensor")
00051       {
00052 
00053         PTData.GetData(Configuration.ptensordata);
00054         boost::shared_ptr<PTensor1DMTObjective> PTObjective(
00055             new PTensor1DMTObjective(PTData));
00056         MTObjective = PTObjective;
00057       }
00058     else
00059       {
00060 
00061         MTData.GetData(Configuration.mtinputdata);
00062         boost::shared_ptr<Aniso1DMTObjective> AnisoObjective(
00063             new Aniso1DMTObjective(MTData));
00064         SetupMTFitParameters(Configuration, *AnisoObjective);
00065         MTObjective = AnisoObjective;
00066       }
00067 
00068     const int nlayers = Configuration.minres.size();
00069     const int nparams = nlayers * 4;
00070     *nd = nparams;
00071     ttranscribed mtmember(nparams);
00072     copy(Configuration.startres.begin(), Configuration.startres.end(),
00073         mtmember.begin());
00074     copy(Configuration.startthick.begin(), Configuration.startthick.end(),
00075         mtmember.begin() + nlayers);
00076     copy(Configuration.startaniso.begin(), Configuration.startaniso.end(),
00077         mtmember.begin() + 2 * nlayers);
00078     copy(Configuration.startstrike.begin(), Configuration.startstrike.end(),
00079         mtmember.begin() + 3 * nlayers);
00080     MTObjective->CalcPerformance(mtmember);
00081 
00082     for (int i = 0; i < nlayers; ++i)
00083       {
00084         ranges[2 * i] = Configuration.minres.at(i);
00085         ranges[2 * i + 1] = Configuration.maxres.at(i);
00086       }
00087     for (int i = 0; i < nlayers; ++i)
00088       {
00089         ranges[2 * i + 2 * nlayers] = Configuration.minthick.at(i);
00090         ranges[2 * i + 2 * nlayers + 1] = Configuration.maxthick.at(i);
00091       }
00092     for (int i = 0; i < nlayers; ++i)
00093       {
00094         ranges[2 * i + 4 * nlayers] = Configuration.minaniso.at(i);
00095         ranges[2 * i + 4 * nlayers + 1] = Configuration.maxaniso.at(i);
00096       }
00097     for (int i = 0; i < nlayers; ++i)
00098       {
00099         ranges[2 * i + 6 * nlayers] = Configuration.minstrike.at(i);
00100         ranges[2 * i + 6 * nlayers + 1] = Configuration.maxstrike.at(i);
00101       }
00102     cout << "Init finished ! " << endl;
00103     ;
00104   }

Generated on Tue May 4 16:52:14 2010 for GPLIB++ by  doxygen 1.5.8