Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 854e08ca authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Improving the implementation of the rational quadprog fitter. There is still an

issue with big problems (d.size() > 10K).
parent fc440402
......@@ -11,7 +11,9 @@ class quadratic_program
{
public:
//! \brief Constructor need to specify the number of coefficients
quadratic_program(int np, int nq) : _np(np), _nq(nq), CI(0.0, _np+_nq, 0) { }
quadratic_program(int np, int nq) :
_np(np), _nq(nq), CI(0.0, _np+_nq, 0)
{ }
//! \brief Remove the already defined constraints
void clear_constraints()
......@@ -73,6 +75,12 @@ class quadratic_program
return CI.ncols();
}
//! Set the indices of the remaining data
void set_training_set(const std::list<unsigned int>& ts)
{
this->training_set = ts;
}
//! \brief Solves the quadratic program and update the p and
//! q vector if necessary.
inline bool solve_program(QuadProgPP::Vector<double>& x, double& delta, vec& p, vec& q)
......@@ -164,12 +172,14 @@ class quadratic_program
int nb_failed = 0;
double max_dev = 0.0; // Maximum absolute distance of the current
// solution to the data.
std::list<unsigned int>::iterator max_ind;
vec cu, cl;
for(int n=0; n<data->size(); ++n)
std::list<unsigned int>::iterator it;
for(it = training_set.begin(); it != training_set.end(); it++)
{
vec x, yl, yu;
data->get(n, x, yl, yu);
vec x, yl, yu;
data->get(*it, x, yl, yu);
vec y = r->value(x);
bool fail_upper = y[ny] > yu[ny];
......@@ -184,6 +194,7 @@ class quadratic_program
{
get_constraint(x, yl, yu, ny, r, cu, cl);
max_dev = dev;
max_ind = it;
}
}
}
......@@ -196,6 +207,10 @@ class quadratic_program
{
add_constraints(cu);
add_constraints(cl);
training_set.erase(max_ind);
#ifdef DEBUG
std::cout << "<<DEBUG>> number of remaining training elements: " << training_set.size() << std::endl;
#endif
return false;
}
......@@ -239,6 +254,10 @@ class quadratic_program
protected:
int _np, _nq;
QuadProgPP::Matrix<double> CI;
//! Contains the indices of the vertical segment unused during the
//! rational interpolation.
std::list<unsigned int> training_set;
};
......
......@@ -13,6 +13,7 @@
#include <algorithm>
#include <cmath>
#include <string>
#include <list>
#include "quadratic_program.h"
......@@ -200,21 +201,29 @@ bool rational_fitter_parallel::fit_data(const vertical_segment* d, int np, int n
quadratic_program qp(np, nq);
// Starting with only a nb_starting_points vertical segments
const int di = (m-1) / (nb_starting_points-1);
for(int i=0; i<m; i+=di)
std::list<unsigned int> training_set;
const int di = std::max((m-1) / (nb_starting_points-1), 1);
for(int i=0; i<m; ++i)
{
if(i % di == 0)
{
// Create two vector of constraints
vec c1(n), c2(n);
get_constraint(i, np, nq, ny, d, r, c1, c2);
// Create two vector of constraints
vec c1(n), c2(n);
get_constraint(i, np, nq, ny, d, r, c1, c2);
qp.add_constraints(c1);
qp.add_constraints(c2);
qp.add_constraints(c1);
qp.add_constraints(c2);
}
else
{
training_set.push_back(i);
}
}
qp.set_training_set(training_set);
while(qp.nb_constraints() < 2*m)
do
{
#ifdef DEBUG
std::cout << "<<DEBUG>> thread " << omp_get_thread_num() << ", number of intervals tested = " << qp.nb_constraints()/2 << std::endl ;
......@@ -240,7 +249,7 @@ bool rational_fitter_parallel::fit_data(const vertical_segment* d, int np, int n
#endif
return false;
}
}
} while(qp.nb_constraints() < 2*m);
return false;
}
......
......@@ -18,7 +18,7 @@
<action name="data2brdf">
<!-- Input and output arguments of the action -->
<input name="../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D_dense__nbsgrid_81.alta" />
<input name="../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D_dense__nbsgrid_162.alta" />
<!--<input name="/tmp/yellow_slice_inc30.dat" />-->
<output name="./results/3d/retro/half/Bande_orange_rat.brdf" />
......@@ -28,9 +28,9 @@
<!-- Define the ftting procedure to use -->
<!--<plugin type="fitter" name="rational_fitter_quadprog" />-->
<plugin type="fitter" name="rational_fitter_parallel" />
<parameter name="min-np" value="40" />
<parameter name="min-np" value="20" />
<!--<parameter name="min-np" value="53" />-->
<parameter name="min-nq" value="10" />
<parameter name="min-nq" value="20" />
<parameter name="np" value="100" />
<parameter name="nq" value="100" />
<parameter name="dt" value="0.5" />
......
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