00001 #include <iostream>
00002 #include "GeneralGA.h"
00003 #include "C1DRecObjective.h"
00004 #include "SeismicDataComp.h"
00005 #include <boost/bind.hpp>
00006 #include <algorithm>
00007
00008 struct CopyFromPointer
00009 {
00010 boost::shared_ptr<GeneralObjective>operator()(boost::shared_ptr<GeneralObjective> param)
00011 {
00012 return boost::shared_ptr<GeneralObjective>(param->clone());
00013 }
00014 };
00015
00016 struct GenObjective
00017 {
00018 GeneralGA::tObjectiveVector operator()(const GeneralGA::tObjectiveVector &IndObjective)
00019 {
00020 GeneralGA::tObjectiveVector result(IndObjective.size());
00021 transform(IndObjective.begin(),IndObjective.end(),result.begin(),CopyFromPointer());
00022 return result;
00023 }
00024 };
00025
00026 int main()
00027 {
00028 const unsigned int nelements = 3;
00029 typedef std::vector<boost::shared_ptr<GeneralObjective> > tObjectiveVector;
00030 tObjectiveVector Objective;
00031 SeismicDataComp Data;
00032 std::vector< tObjectiveVector > ParObjective(nelements);
00033
00034 boost::shared_ptr<C1DRecObjective> RecObjective(new C1DRecObjective(Data,1,2.0,
00035 3.0,4.0,5.0));
00036 RecObjective->SetPoisson(6.0);
00037 RecObjective->SetTimeWindow(7.0,8.0);
00038 RecObjective->SetErrorLevel(9.0);
00039 RecObjective->SetFitExponent(10);
00040 Objective.push_back(RecObjective);
00041 Objective.push_back(RecObjective);
00042
00043 generate_n(ParObjective.begin(),nelements,
00044 boost::bind<tObjectiveVector>(GenObjective(),Objective));
00045 for (int i = 0; i < nelements; ++i)
00046 {
00047 std::cout << "FitExp: " << ParObjective.at(i).front()->GetFitExponent() << std::endl;
00048 }
00049 }