Commit d89b5c68 authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Quadprog parallel runs on non OpenMP friendly systems. Warning, it is slow.

parent 11c1f144
...@@ -56,7 +56,8 @@ NLOPT_DIR = ['#external/build/lib'] ...@@ -56,7 +56,8 @@ NLOPT_DIR = ['#external/build/lib']
NLOPT_LIBS = ['nlopt'] NLOPT_LIBS = ['nlopt']
NLOPT_OPT_LIBS = [] NLOPT_OPT_LIBS = []
# MATLAB library and Engine ## MATLAB library and Engine
##
MATLAB_INC = ['/home/pac/MATLAB/R2013b/extern/include/'] MATLAB_INC = ['/home/pac/MATLAB/R2013b/extern/include/']
MATLAB_DIR = ['/home/pac/MATLAB/R2013b/bin/glnxa64/'] MATLAB_DIR = ['/home/pac/MATLAB/R2013b/bin/glnxa64/']
MATLAB_LIBS = [''] MATLAB_LIBS = ['engine']
import os import os
Import('env') Import('env')
env = env.Clone()
if env.GetOption('clean'): if env.GetOption('clean'):
print "Nothing to do in external" print "Nothing to do in external"
......
Import('env')
env = env.Clone()
env.AppendUnique(CPPPATH = env['MATLAB_INC'])
env.AppendUnique(LIBPATH = env['MATLAB_DIR'])
env.AppendUnique(LIBS = env['MATLAB_LIBS'])
env.AppendUnique(LIBS = ['core'])
conf = Configure(env)
sources = ['rational_fitter.cpp']
if conf.CheckLib(env['MATLAB_LIBS']):
env.SharedLibrary('../../build/rational_fitter_matlab', sources)
#end
conf.Finish()
...@@ -4,15 +4,19 @@ env = env.Clone() ...@@ -4,15 +4,19 @@ env = env.Clone()
env.AppendUnique(CPPPATH = env['QUADPROG_INC']) env.AppendUnique(CPPPATH = env['QUADPROG_INC'])
env.AppendUnique(LIBPATH = env['QUADPROG_DIR']) env.AppendUnique(LIBPATH = env['QUADPROG_DIR'])
env.AppendUnique(LIBS = env['QUADPROG_LIBS']) env.AppendUnique(LIBS = env['QUADPROG_LIBS'])
env.AppendUnique(CCFLAGS = env['OPENMP_FLAGS'])
env.AppendUnique(LIBS = env['OPENMP_LIBS'])
env.AppendUnique(LIBS = ['core']) env.AppendUnique(LIBS = ['core'])
conf = Configure(env) conf = Configure(env)
sources = ['rational_fitter.cpp'] sources = ['rational_fitter.cpp']
if conf.CheckLib(env['QUADPROG_LIBS']) and conf.CheckLib(env['OPENMP_LIBS']): if conf.CheckLib(env['QUADPROG_LIBS']):
env.AppendUnique(CCFLAGS = env['OPENMP_FLAGS'])
if conf.CheckLib(env['OPENMP_LIBS']):
env.AppendUnique(LIBS = env['OPENMP_LIBS'])
#end
env.SharedLibrary('../../build/rational_fitter_parallel', sources) env.SharedLibrary('../../build/rational_fitter_parallel', sources)
#end #end
conf.Finish() conf.Finish()
...@@ -217,10 +217,11 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int n ...@@ -217,10 +217,11 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int n
std::cout << "]" << std::endl ; std::cout << "]" << std::endl ;
} }
#endif #endif
/*
// Update the ci column with the delta parameter // Update the ci column with the delta parameter
// (See Celis et al. 2007 p.12) // (See Celis et al. 2007 p.12)
Eigen::JacobiSVD<Eigen::MatrixXd, Eigen::HouseholderQRPreconditioner> svd(eCI, Eigen::ComputeThinU | Eigen::ComputeThinV); Eigen::JacobiSVD<Eigen::MatrixXd, Eigen::HouseholderQRPreconditioner> svd(eCI);
const double sigma_m = svd.singularValues()(std::min(2*M, N)-1) ; const double sigma_m = svd.singularValues()(std::min(2*M, N)-1) ;
const double sigma_M = svd.singularValues()(0) ; const double sigma_M = svd.singularValues()(0) ;
...@@ -235,6 +236,10 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int n ...@@ -235,6 +236,10 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int n
double delta = sigma_m / sigma_M ; double delta = sigma_m / sigma_M ;
#ifndef DEBUG
std::cout << "<<DEBUG>> delta factor: " << sigma_m << " / " << sigma_M << " = " << delta << std::endl ;
#endif
if(isnan(delta) || (std::abs(delta) == std::numeric_limits<double>::infinity())) if(isnan(delta) || (std::abs(delta) == std::numeric_limits<double>::infinity()))
{ {
std::cerr << "<<ERROR>> delta factor is NaN of Inf" << std::endl ; std::cerr << "<<ERROR>> delta factor is NaN of Inf" << std::endl ;
...@@ -244,10 +249,9 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int n ...@@ -244,10 +249,9 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int n
{ {
delta = 1.0 ; delta = 1.0 ;
} }
/*/
#ifndef DEBUG const double delta = 1.0;
std::cout << "<<DEBUG>> delta factor: " << sigma_m << " / " << sigma_M << " = " << delta << std::endl ; //*/
#endif
for(int i=0; i<2*M; ++i) for(int i=0; i<2*M; ++i)
{ {
ci[i] = ci[i] * delta ; ci[i] = ci[i] * delta ;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment