diff options
| author | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2010-04-04 09:36:15 +0000 | 
|---|---|---|
| committer | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2010-04-04 09:36:15 +0000 | 
| commit | f017bfbcbd6a6af80e7d2ce7303572e80a42196f (patch) | |
| tree | b5bb6bcfd38674eb5e328dd2de5c18e4ebb0ff13 | |
| parent | b964925cbc2b24a3cd8c1d92e32d94b8520fd3b1 (diff) | |
| download | opt-utilities-f017bfbcbd6a6af80e7d2ce7303572e80a42196f.tar.bz2 | |
git-svn-id: file:///home/svn/opt_utilities@112 ed2142bd-67ad-457f-ba7c-d818d4011675
| -rw-r--r-- | CMakeLists.txt | 13 | ||||
| -rw-r--r-- | dynamical_fit/dynamical_fit.cpp | 63 | 
2 files changed, 75 insertions, 1 deletions
| diff --git a/CMakeLists.txt b/CMakeLists.txt index cf0100a..c5909e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,23 @@  cmake_minimum_required(VERSION 2.6)  PROJECT(opt_utilities,CXX) +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}) + +set(CMAKE_VERBOSE_MAKEFILE true) + +find_package(ltdl REQUIRED)  add_subdirectory(example)  add_subdirectory(interface) +add_subdirectory(dynamical_fit) -include_directories (${PROJECT_SOURCE_DIR}) +include_directories (${PROJECT_SOURCE_DIR} ${LTDL_INCLUDE_DIRS}) +message(${LTDL_LIBRARIES})  set(LIBRARY_OUTPUT_PATH,lib)  ADD_LIBRARY(opt STATIC interface/opt.cc)  ADD_EXECUTABLE(test_fitter example/test_fitter.cpp)  ADD_EXECUTABLE(test_optimizer example/test_optimizer.cpp) +ADD_EXECUTABLE(dynamical_fit.out dynamical_fit/dynamical_fit.cpp) + +target_link_libraries(dynamical_fit.out ${LTDL_LIBRARIES}) + diff --git a/dynamical_fit/dynamical_fit.cpp b/dynamical_fit/dynamical_fit.cpp new file mode 100644 index 0000000..2ab33ce --- /dev/null +++ b/dynamical_fit/dynamical_fit.cpp @@ -0,0 +1,63 @@ +#include <core/fitter.hpp> +#include <interface/optdl.hpp> +#include <misc/data_loaders.hpp> +#include <sstream> +#include <iostream> +#include <fstream> +#include <string> +#include <methods/powell/powell_method.hpp> +#include <statistics/chisq.hpp> +#include <cstdlib> + +using namespace std; +using namespace opt_utilities; + + +int main(int argc,char* argv[]) +{ +  if(argc!=2) +    { +      cerr<<"Usage: "<<argv[0]<<" <config file>"<<endl; +      exit(-1); +    } +  ifstream cfg_file(argv[1]); +  fitter<double,double,std::vector<double>,double,std::string> fit; +  fit.set_opt_method(powell_method<double,vector<double> >()); +  fit.set_statistic(chisq<double,double,vector<double>,double,string>()); +  std::string model_so_name; +  cfg_file>>model_so_name; +  cerr<<"loading model shared object "<<model_so_name<<endl; +  fit.set_model(*load_model<double,double,vector<double>,string>(model_so_name.c_str())); +   +  string data_file_name; +  cfg_file>>data_file_name; +  cerr<<"setting initializational values:"<<endl; +  for(;;) +    { +      string p,v; +      cfg_file>>p>>v; +      if(!cfg_file.good()) +	{ +	  break; +	} +      istringstream oss(v); +       +      double dvp=0; +      oss>>dvp; +      cerr<<p<<"="<<dvp<<endl; +      fit.set_param_value(p,dvp); +    } +  cfg_file.close(); + +  ifstream data_file(data_file_name.c_str()); +   +  dl_x_xu_xl_y_yu_yl<double,double> dl; +  dl.load_from(data_file); +  data_file.close(); + +  fit.load_data(dl.get_data_set()); + +  vector<double> p=fit.fit(); +  cout<<p[0]<<"\t"<<p[1]<<endl; +   +} | 
