* added the eo features Continue/CheckOut/Stat to DO in order to dump distribution parameters and to have compatibility with eoMonitor/eoUpdater classes
This commit is contained in:
parent
963d59e706
commit
6d9134edbf
15 changed files with 251 additions and 116 deletions
|
|
@ -75,11 +75,11 @@ int main(int ac, char** av)
|
|||
state.storeFunctor(init);
|
||||
|
||||
|
||||
doStats< Distrib >* stats =
|
||||
//new doStatsUniform< EOT >();
|
||||
//new doStatsNormalMono< EOT >();
|
||||
new doStatsNormalMulti< EOT >();
|
||||
state.storeFunctor(stats);
|
||||
// doStats< Distrib >* stats =
|
||||
// //new doStatsUniform< EOT >();
|
||||
// //new doStatsNormalMono< EOT >();
|
||||
// new doStatsNormalMulti< EOT >();
|
||||
// state.storeFunctor(stats);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -122,8 +122,8 @@ int main(int ac, char** av)
|
|||
|
||||
unsigned int rho = parser.createParam((unsigned int)0, "rho", "Rho: metropolis sample size", 'p', section).value(); // p
|
||||
|
||||
moGenSolContinue< EOT >* continuator = new moGenSolContinue< EOT >(rho);
|
||||
state.storeFunctor(continuator);
|
||||
moGenSolContinue< EOT >* sa_continue = new moGenSolContinue< EOT >(rho);
|
||||
state.storeFunctor(sa_continue);
|
||||
|
||||
double threshold = parser.createParam((double)0.1, "threshold", "Threshold: temperature threshold stopping criteria", 't', section).value(); // t
|
||||
double alpha = parser.createParam((double)0.1, "alpha", "Alpha: temperature dicrease rate", 'a', section).value(); // a
|
||||
|
|
@ -134,11 +134,11 @@ int main(int ac, char** av)
|
|||
// stopping criteria
|
||||
// ... and creates the parameter letters: C E g G s T
|
||||
|
||||
eoContinue< EOT >& monitoring_continue = do_make_continue(parser, state, eval);
|
||||
eoContinue< EOT >& eo_continue = do_make_continue(parser, state, eval);
|
||||
|
||||
// output
|
||||
|
||||
eoCheckPoint< EOT >& checkpoint = do_make_checkpoint(parser, state, eval, monitoring_continue);
|
||||
eoCheckPoint< EOT >& monitoring_continue = do_make_checkpoint(parser, state, eval, eo_continue);
|
||||
|
||||
// eoPopStat< EOT >* popStat = new eoPopStat<EOT>;
|
||||
// state.storeFunctor(popStat);
|
||||
|
|
@ -162,6 +162,29 @@ int main(int ac, char** av)
|
|||
// checkpoint.add(*fileSnapshot);
|
||||
|
||||
|
||||
doDummyContinue< Distrib >* dummy_continue = new doDummyContinue< Distrib >();
|
||||
state.storeFunctor(dummy_continue);
|
||||
|
||||
doCheckPoint< Distrib >* distribution_continue = new doCheckPoint< Distrib >( *dummy_continue );
|
||||
state.storeFunctor(distribution_continue);
|
||||
|
||||
doDistribStat< Distrib >* distrib_stat = new doStatNormalMulti< EOT >();
|
||||
state.storeFunctor(distrib_stat);
|
||||
|
||||
distribution_continue->add( *distrib_stat );
|
||||
|
||||
eoMonitor* stdout_monitor = new eoStdoutMonitor();
|
||||
state.storeFunctor(stdout_monitor);
|
||||
|
||||
stdout_monitor->add(*distrib_stat);
|
||||
distribution_continue->add( *stdout_monitor );
|
||||
|
||||
eoFileMonitor* file_monitor = new eoFileMonitor("distribution.txt");
|
||||
state.storeFunctor(file_monitor);
|
||||
|
||||
file_monitor->add(*distrib_stat);
|
||||
distribution_continue->add( *file_monitor );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoEPRemplacement causes the using of the current and previous
|
||||
// sample for sampling.
|
||||
|
|
@ -184,7 +207,8 @@ int main(int ac, char** av)
|
|||
|
||||
doAlgo< Distrib >* algo = new doCMASA< Distrib >
|
||||
(*selector, *estimator, *selectone, *modifier, *sampler,
|
||||
checkpoint, eval, *continuator, *cooling_schedule,
|
||||
monitoring_continue, *distribution_continue,
|
||||
eval, *sa_continue, *cooling_schedule,
|
||||
initial_temperature, *replacor);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
11
src/do
11
src/do
|
|
@ -33,9 +33,12 @@
|
|||
#include "doBounderBound.h"
|
||||
#include "doBounderRng.h"
|
||||
|
||||
#include "doStats.h"
|
||||
#include "doStatsUniform.h"
|
||||
#include "doStatsNormalMono.h"
|
||||
#include "doStatsNormalMulti.h"
|
||||
#include "doContinue.h"
|
||||
#include "doCheckPoint.h"
|
||||
|
||||
#include "doStat.h"
|
||||
#include "doStatUniform.h"
|
||||
#include "doStatNormalMono.h"
|
||||
#include "doStatNormalMulti.h"
|
||||
|
||||
#endif // !_do_
|
||||
|
|
|
|||
148
src/doCMASA.h
148
src/doCMASA.h
|
|
@ -34,7 +34,8 @@
|
|||
#include "doModifierMass.h"
|
||||
#include "doSampler.h"
|
||||
#include "doHyperVolume.h"
|
||||
#include "doStats.h"
|
||||
#include "doStat.h"
|
||||
#include "doContinue.h"
|
||||
|
||||
using namespace boost::numeric::ublas;
|
||||
|
||||
|
|
@ -74,12 +75,12 @@ public:
|
|||
doModifierMass< D > & modifier,
|
||||
doSampler< D > & sampler,
|
||||
eoContinue< EOT > & monitoring_continue,
|
||||
doContinue< D > & distribution_continue,
|
||||
eoEvalFunc < EOT > & evaluation,
|
||||
moSolContinue < EOT > & continuator,
|
||||
moSolContinue < EOT > & sa_continue,
|
||||
moCoolingSchedule & cooling_schedule,
|
||||
double initial_temperature,
|
||||
eoReplacement< EOT > & replacor,
|
||||
doStats< D > & stats
|
||||
eoReplacement< EOT > & replacor
|
||||
)
|
||||
: _selector(selector),
|
||||
_estimator(estimator),
|
||||
|
|
@ -87,20 +88,22 @@ public:
|
|||
_modifier(modifier),
|
||||
_sampler(sampler),
|
||||
_monitoring_continue(monitoring_continue),
|
||||
_distribution_continue(distribution_continue),
|
||||
_evaluation(evaluation),
|
||||
_continuator(continuator),
|
||||
_sa_continue(sa_continue),
|
||||
_cooling_schedule(cooling_schedule),
|
||||
_initial_temperature(initial_temperature),
|
||||
_replacor(replacor),
|
||||
_stats(stats),
|
||||
_replacor(replacor)
|
||||
|
||||
_pop_results_destination("ResPop"),
|
||||
// ,
|
||||
|
||||
// directory where populations state are going to be stored.
|
||||
_ofs_params("ResParams.txt"),
|
||||
_ofs_params_var("ResVars.txt"),
|
||||
// _pop_results_destination("ResPop"),
|
||||
|
||||
_bounds_results_destination("ResBounds")
|
||||
// // directory where populations state are going to be stored.
|
||||
// _ofs_params("ResParams.txt"),
|
||||
// _ofs_params_var("ResVars.txt"),
|
||||
|
||||
// _bounds_results_destination("ResBounds")
|
||||
{
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
|
@ -108,13 +111,13 @@ public:
|
|||
// iteration for plotting.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "rm -rf " << _pop_results_destination;
|
||||
::system(ss.str().c_str());
|
||||
}
|
||||
// {
|
||||
// std::stringstream os;
|
||||
// os << "rm -rf " << _pop_results_destination;
|
||||
// ::system(os.str().c_str());
|
||||
// }
|
||||
|
||||
::mkdir(_pop_results_destination.c_str(), 0755); // create a first time the
|
||||
// ::mkdir(_pop_results_destination.c_str(), 0755); // create a first time the
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
|
@ -123,13 +126,13 @@ public:
|
|||
// Temporary solution to store bounds values for each distribution.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "rm -rf " << _bounds_results_destination;
|
||||
::system(ss.str().c_str());
|
||||
}
|
||||
// {
|
||||
// std::stringstream os;
|
||||
// os << "rm -rf " << _bounds_results_destination;
|
||||
// ::system(os.str().c_str());
|
||||
// }
|
||||
|
||||
::mkdir(_bounds_results_destination.c_str(), 0755); // create once directory
|
||||
//::mkdir(_bounds_results_destination.c_str(), 0755); // create once directory
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
|
@ -159,26 +162,39 @@ public:
|
|||
// several files.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
int number_of_iterations = 0;
|
||||
//int number_of_iterations = 0;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
{
|
||||
D distrib = _estimator(pop);
|
||||
//-------------------------------------------------------------
|
||||
// Estimating a first time the distribution parameter thanks
|
||||
// to population.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
double size = distrib.size();
|
||||
assert(size > 0);
|
||||
D distrib = _estimator(pop);
|
||||
|
||||
doHyperVolume< EOT > hv;
|
||||
double size = distrib.size();
|
||||
assert(size > 0);
|
||||
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
//hv.update( distrib.varcovar()[i] );
|
||||
}
|
||||
//-------------------------------------------------------------
|
||||
|
||||
// _ofs_params_var << hv << std::endl;
|
||||
}
|
||||
|
||||
// {
|
||||
// D distrib = _estimator(pop);
|
||||
|
||||
// double size = distrib.size();
|
||||
// assert(size > 0);
|
||||
|
||||
// doHyperVolume< EOT > hv;
|
||||
|
||||
// for (int i = 0; i < size; ++i)
|
||||
// {
|
||||
// //hv.update( distrib.varcovar()[i] );
|
||||
// }
|
||||
|
||||
// // _ofs_params_var << hv << std::endl;
|
||||
// }
|
||||
|
||||
do
|
||||
{
|
||||
|
|
@ -200,14 +216,14 @@ public:
|
|||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
_continuator.init();
|
||||
_sa_continue.init();
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// (4) Estimation of the distribution parameters
|
||||
//-------------------------------------------------------------
|
||||
|
||||
D distrib = _estimator(selected_pop);
|
||||
distrib = _estimator(selected_pop);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
|
@ -258,7 +274,7 @@ public:
|
|||
current_solution = candidate_solution;
|
||||
}
|
||||
}
|
||||
while ( _continuator( current_solution) );
|
||||
while ( _sa_continue( current_solution) );
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
|
@ -266,12 +282,12 @@ public:
|
|||
// at each iteration for plotting.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << _pop_results_destination << "/" << number_of_iterations;
|
||||
std::ofstream ofs(ss.str().c_str());
|
||||
ofs << current_pop;
|
||||
}
|
||||
// {
|
||||
// std::ostringstream os;
|
||||
// os << _pop_results_destination << "/" << number_of_iterations;
|
||||
// std::ofstream ofs(os.str().c_str());
|
||||
// ofs << current_pop;
|
||||
// }
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
|
@ -281,20 +297,21 @@ public:
|
|||
// several files.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
{
|
||||
double size = distrib.size();
|
||||
// {
|
||||
// double size = distrib.size();
|
||||
|
||||
assert(size > 0);
|
||||
// assert(size > 0);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << _bounds_results_destination << "/" << number_of_iterations;
|
||||
std::ofstream ofs(ss.str().c_str());
|
||||
// std::stringstream os;
|
||||
// os << _bounds_results_destination << "/" << number_of_iterations;
|
||||
// std::ofstream ofs(os.str().c_str());
|
||||
|
||||
ofs << size << " ";
|
||||
std::copy(distrib.mean().begin(), distrib.mean().end(), std::ostream_iterator< double >(ofs, " "));
|
||||
// ofs << size << " ";
|
||||
//ublas::vector< AtomType > mean = distrib.mean();
|
||||
//std::copy(mean.begin(), mean.end(), std::ostream_iterator< double >(ofs, " "));
|
||||
//std::copy(distrib.varcovar().begin(), distrib.varcovar().end(), std::ostream_iterator< double >(ofs, " "));
|
||||
ofs << std::endl;
|
||||
}
|
||||
// ofs << std::endl;
|
||||
// }
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
|
@ -350,11 +367,12 @@ public:
|
|||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
++number_of_iterations;
|
||||
//++number_of_iterations;
|
||||
|
||||
}
|
||||
while ( _cooling_schedule( temperature ) &&
|
||||
_monitoring_continue( selected_pop ) );
|
||||
_monitoring_continue( selected_pop ) &&
|
||||
_distribution_continue( distrib ) );
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -377,11 +395,14 @@ private:
|
|||
//! A EOT monitoring continuator
|
||||
eoContinue < EOT > & _monitoring_continue;
|
||||
|
||||
//! A D continuator
|
||||
doContinue < D > & _distribution_continue;
|
||||
|
||||
//! A full evaluation function.
|
||||
eoEvalFunc < EOT > & _evaluation;
|
||||
|
||||
//! Stopping criterion before temperature update
|
||||
moSolContinue < EOT > & _continuator;
|
||||
moSolContinue < EOT > & _sa_continue;
|
||||
|
||||
//! The cooling schedule
|
||||
moCoolingSchedule & _cooling_schedule;
|
||||
|
|
@ -392,17 +413,14 @@ private:
|
|||
//! A EOT replacor
|
||||
eoReplacement < EOT > & _replacor;
|
||||
|
||||
//! Stats to print distrib parameters out
|
||||
doStats< D > & _stats;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Temporary solution to store populations state at each
|
||||
// iteration for plotting.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
std::string _pop_results_destination;
|
||||
std::ofstream _ofs_params;
|
||||
std::ofstream _ofs_params_var;
|
||||
// std::string _pop_results_destination;
|
||||
// std::ofstream _ofs_params;
|
||||
// std::ofstream _ofs_params_var;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
|
@ -410,7 +428,7 @@ private:
|
|||
// Temporary solution to store bounds values for each distribution.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
std::string _bounds_results_destination;
|
||||
// std::string _bounds_results_destination;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef _doCheckPoint_h
|
||||
#define _doCheckPoint_h
|
||||
|
||||
#include <utils/eoUpdater.h>
|
||||
#include <utils/eoMonitor.h>
|
||||
|
||||
#include "doContinue.h"
|
||||
#include "doStat.h"
|
||||
|
||||
|
|
@ -24,10 +27,20 @@ public:
|
|||
(*_stats[i])( distrib );
|
||||
}
|
||||
|
||||
for ( unsigned int i = 0, size = _updaters.size(); i < size; ++i )
|
||||
{
|
||||
(*_updaters[i])();
|
||||
}
|
||||
|
||||
for ( unsigned int i = 0, size = _monitors.size(); i < size; ++i )
|
||||
{
|
||||
(*_monitors[i])();
|
||||
}
|
||||
|
||||
bool bContinue = true;
|
||||
for ( unsigned int i = 0, size = _continuators.size(); i < size; ++i )
|
||||
{
|
||||
if ( !(*_continuators[i]( distrib )) )
|
||||
if ( !(*_continuators[i])( distrib ) )
|
||||
{
|
||||
bContinue = false;
|
||||
}
|
||||
|
|
@ -39,6 +52,16 @@ public:
|
|||
{
|
||||
_stats[i]->lastCall( distrib );
|
||||
}
|
||||
|
||||
for ( unsigned int i = 0, size = _updaters.size(); i < size; ++i )
|
||||
{
|
||||
_updaters[i]->lastCall();
|
||||
}
|
||||
|
||||
for ( unsigned int i = 0, size = _monitors.size(); i < size; ++i )
|
||||
{
|
||||
_monitors[i]->lastCall();
|
||||
}
|
||||
}
|
||||
|
||||
return bContinue;
|
||||
|
|
@ -46,6 +69,8 @@ public:
|
|||
|
||||
void add(doContinue< D >& cont) { _continuators.push_back( &cont ); }
|
||||
void add(doStatBase< D >& stat) { _stats.push_back( &stat ); }
|
||||
void add(eoMonitor& mon) { _monitors.push_back( &mon ); }
|
||||
void add(eoUpdater& upd) { _updaters.push_back( &upd ); }
|
||||
|
||||
virtual std::string className(void) const { return "doCheckPoint"; }
|
||||
|
||||
|
|
@ -60,6 +85,20 @@ public:
|
|||
}
|
||||
s += "\n";
|
||||
|
||||
s += "Updaters\n";
|
||||
for ( unsigned int i = 0; i < _updaters.size(); ++i )
|
||||
{
|
||||
s += _updaters[i]->className() + "\n";
|
||||
}
|
||||
s += "\n";
|
||||
|
||||
s += "Monitors\n";
|
||||
for ( unsigned int i = 0; i < _monitors.size(); ++i )
|
||||
{
|
||||
s += _monitors[i]->className() + "\n";
|
||||
}
|
||||
s += "\n";
|
||||
|
||||
s += "Continuators\n";
|
||||
for ( unsigned int i = 0, size = _continuators.size(); i < size; ++i )
|
||||
{
|
||||
|
|
@ -73,6 +112,8 @@ public:
|
|||
private:
|
||||
std::vector< doContinue< D >* > _continuators;
|
||||
std::vector< doStatBase< D >* > _stats;
|
||||
std::vector< eoMonitor* > _monitors;
|
||||
std::vector< eoUpdater* > _updaters;
|
||||
};
|
||||
|
||||
#endif // !_doCheckPoint_h
|
||||
|
|
|
|||
|
|
@ -24,4 +24,12 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template < typename D >
|
||||
class doDummyContinue : public doContinue< D >
|
||||
{
|
||||
bool operator()(const D&){ return true; }
|
||||
|
||||
virtual std::string className() const { return "doNoContinue"; }
|
||||
};
|
||||
|
||||
#endif // !_doContinue_h
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "doEstimator.h"
|
||||
#include "doUniform.h"
|
||||
#include "doStats.h"
|
||||
|
||||
template < typename EOT >
|
||||
class doEstimatorNormalMulti : public doEstimator< doNormalMulti< EOT > >
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ public:
|
|||
return _mean.size();
|
||||
}
|
||||
|
||||
EOT& mean(){return _mean;}
|
||||
EOT& variance(){return _variance;}
|
||||
EOT mean(){return _mean;}
|
||||
EOT variance(){return _variance;}
|
||||
|
||||
private:
|
||||
EOT _mean;
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ public:
|
|||
return _mean.size();
|
||||
}
|
||||
|
||||
ublas::vector< AtomType >& mean(){return _mean;}
|
||||
ublas::symmetric_matrix< AtomType, ublas::lower >& varcovar(){return _varcovar;}
|
||||
ublas::vector< AtomType > mean() const {return _mean;}
|
||||
ublas::symmetric_matrix< AtomType, ublas::lower > varcovar() const {return _varcovar;}
|
||||
|
||||
private:
|
||||
ublas::vector< AtomType > _mean;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#include "doSampler.h"
|
||||
#include "doNormalMono.h"
|
||||
#include "doBounder.h"
|
||||
#include "doStats.h"
|
||||
|
||||
/**
|
||||
* doSamplerNormalMono
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include "doSampler.h"
|
||||
#include "doNormalMulti.h"
|
||||
#include "doBounder.h"
|
||||
#include "doStats.h"
|
||||
|
||||
/**
|
||||
* doSamplerNormalMulti
|
||||
|
|
@ -26,7 +25,7 @@ public:
|
|||
class Cholesky
|
||||
{
|
||||
public:
|
||||
virtual void update( const ublas::symmetric_matrix< AtomType, ublas::lower >& V)
|
||||
void update( const ublas::symmetric_matrix< AtomType, ublas::lower >& V)
|
||||
{
|
||||
unsigned int Vl = V.size1();
|
||||
|
||||
|
|
|
|||
34
src/doStat.h
34
src/doStat.h
|
|
@ -13,21 +13,35 @@ public:
|
|||
virtual std::string className() const { return "doStatBase"; }
|
||||
};
|
||||
|
||||
template < typename D >
|
||||
class doStat : doStatBase< D >
|
||||
template < typename D > class doCheckPoint;
|
||||
|
||||
template < typename D, typename T >
|
||||
class doStat : public eoValueParam< T >, public doStatBase< D >
|
||||
{
|
||||
public:
|
||||
typedef typename D::EOType EOType;
|
||||
typedef typename EOType::AtomType AtomType;
|
||||
doStat(T value, std::string description)
|
||||
: eoValueParam< T >(value, description)
|
||||
{}
|
||||
|
||||
virtual std::string className(void) const { return "doStat"; }
|
||||
|
||||
doStat< D, T >& addTo(doCheckPoint< D >& cp) { cp.add(*this); return *this; }
|
||||
|
||||
// TODO: doStat< D, T >& addTo(doMonitor& mon) { mon.add(*this); return *this; }
|
||||
};
|
||||
|
||||
|
||||
//! A parent class for any kind of distribution to dump parameter to std::string type
|
||||
|
||||
template < typename D >
|
||||
class doDistribStat : public doStat< D, std::string >
|
||||
{
|
||||
public:
|
||||
doStat(){}
|
||||
using doStat< D, std::string >::value;
|
||||
|
||||
|
||||
D& distrib() { return _distrib; }
|
||||
|
||||
private:
|
||||
D& _distrib;
|
||||
doDistribStat(std::string desc)
|
||||
: doStat< D, std::string >("", desc)
|
||||
{}
|
||||
};
|
||||
|
||||
#endif // !_doStat_h
|
||||
|
|
|
|||
|
|
@ -5,16 +5,23 @@
|
|||
#include "doNormalMono.h"
|
||||
|
||||
template < typename EOT >
|
||||
class doStatNormalMono : public doStat< doNormalMono< EOT > >
|
||||
class doStatNormalMono : public doDistribStat< doNormalMono< EOT > >
|
||||
{
|
||||
public:
|
||||
doStatNormalMono( doNormalMono< EOT >& distrib )
|
||||
: doStat< doNormalMono< EOT > >( distrib )
|
||||
using doDistribStat< doNormalMono< EOT > >::value;
|
||||
|
||||
doStatNormalMono( std::string desc = "" )
|
||||
: doDistribStat< doNormalMono< EOT > >( desc )
|
||||
{}
|
||||
|
||||
virtual void printOn(std::ostream& os) const
|
||||
void operator()( const doNormalMono< EOT >& distrib )
|
||||
{
|
||||
os << this->distrib().mean() << " " << this->distrib().variance();
|
||||
value() = "\n# ====== mono normal distribution dump =====\n";
|
||||
|
||||
std::ostringstream os;
|
||||
os << distrib.mean() << " " << distrib.variance() << std::endl;
|
||||
|
||||
value() += os.str();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,19 +5,36 @@
|
|||
|
||||
#include "doStat.h"
|
||||
#include "doNormalMulti.h"
|
||||
#include "doDistrib.h"
|
||||
|
||||
template < typename EOT >
|
||||
class doStatNormalMulti : public doStat< doNormalMulti< EOT > >
|
||||
class doStatNormalMulti : public doDistribStat< doNormalMulti< EOT > >
|
||||
{
|
||||
public:
|
||||
doStatNormalMulti( doNormalMulti< EOT >& distrib )
|
||||
: doStat< doNormalMulti< EOT > >( distrib )
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
using doDistribStat< doNormalMulti< EOT > >::value;
|
||||
|
||||
doStatNormalMulti( std::string desc = "" )
|
||||
: doDistribStat< doNormalMulti< EOT > >( desc )
|
||||
{}
|
||||
|
||||
virtual void printOn(std::ostream& os) const
|
||||
void operator()( const doNormalMulti< EOT >& distrib )
|
||||
{
|
||||
os << this->distrib().mean() << this->distrib().varcovar();
|
||||
value() = "\n# ====== multi normal distribution dump =====\n";
|
||||
|
||||
std::ostringstream os;
|
||||
|
||||
os << distrib.mean() << " " << distrib.varcovar() << std::endl;
|
||||
|
||||
// ublas::vector< AtomType > mean = distrib.mean();
|
||||
// std::copy(mean.begin(), mean.end(), std::ostream_iterator< std::string >( os, " " ));
|
||||
|
||||
// ublas::symmetric_matrix< AtomType, ublas::lower > varcovar = distrib.varcovar();
|
||||
// std::copy(varcovar.begin(), varcovar.end(), std::ostream_iterator< std::string >( os, " " ));
|
||||
|
||||
// os << std::endl;
|
||||
|
||||
value() += os.str();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,16 +5,23 @@
|
|||
#include "doUniform.h"
|
||||
|
||||
template < typename EOT >
|
||||
class doStatUniform : public doStat< doUniform< EOT > >
|
||||
class doStatUniform : public doDistribStat< doUniform< EOT > >
|
||||
{
|
||||
public:
|
||||
doStatUniform( doUniform< EOT >& distrib )
|
||||
: doStat< doUniform< EOT > >( distrib )
|
||||
using doDistribStat< doUniform< EOT > >::value;
|
||||
|
||||
doStatUniform( std::string desc = "" )
|
||||
: doDistribStat< doUniform< EOT > >( desc )
|
||||
{}
|
||||
|
||||
virtual void printOn(std::ostream& os) const
|
||||
void operator()( const doUniform< EOT >& distrib )
|
||||
{
|
||||
os << this->distrib().min() << " " << this->distrib().max();
|
||||
value() = "\n# ====== uniform distribution dump =====\n";
|
||||
|
||||
std::ostringstream os;
|
||||
os << distrib.min() << " " << distrib.max() << std::endl;
|
||||
|
||||
value() += os.str();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,8 @@ public:
|
|||
assert(_min.size() == _max.size());
|
||||
}
|
||||
|
||||
EOT& min(){return _min;}
|
||||
EOT& max(){return _max;}
|
||||
|
||||
EOT min(){return _min;}
|
||||
EOT max(){return _max;}
|
||||
|
||||
unsigned int size()
|
||||
{
|
||||
|
|
|
|||
Reference in a new issue