* some cleaner updates
This commit is contained in:
parent
fc1adfcc78
commit
fde64b063b
7 changed files with 31 additions and 50 deletions
|
|
@ -11,11 +11,13 @@ FOREACH(file ${RESOURCES})
|
||||||
EXECUTE_PROCESS(
|
EXECUTE_PROCESS(
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/${file}
|
${CMAKE_CURRENT_SOURCE_DIR}/${file}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${file}
|
${DO_BINARY_DIR}/${file}
|
||||||
)
|
)
|
||||||
ENDFOREACH(file)
|
ENDFOREACH(file)
|
||||||
|
|
||||||
FILE(GLOB SOURCES *.cpp)
|
FILE(GLOB SOURCES *.cpp)
|
||||||
|
|
||||||
|
SET(EXECUTABLE_OUTPUT_PATH ${DO_BINARY_DIR})
|
||||||
|
|
||||||
ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})
|
ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})
|
||||||
TARGET_LINK_LIBRARIES(${PROJECT_NAME} do ${EO_LIBRARIES} ${MO_LIBRARIES})
|
TARGET_LINK_LIBRARIES(${PROJECT_NAME} do ${EO_LIBRARIES} ${MO_LIBRARIES})
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,6 @@ int main(int ac, char** av)
|
||||||
doModifierMass< doNormal< EOT > >* modifier = new doNormalCenter< EOT >();
|
doModifierMass< doNormal< EOT > >* modifier = new doNormalCenter< EOT >();
|
||||||
state.storeFunctor(modifier);
|
state.storeFunctor(modifier);
|
||||||
|
|
||||||
// EOT min(2, 42);
|
|
||||||
// EOT max(2, 32);
|
|
||||||
|
|
||||||
//eoEvalFunc< EOT >* plainEval = new BopoRosenbrock< EOT, double, const EOT& >();
|
//eoEvalFunc< EOT >* plainEval = new BopoRosenbrock< EOT, double, const EOT& >();
|
||||||
eoEvalFunc< EOT >* plainEval = new Sphere< EOT >();
|
eoEvalFunc< EOT >* plainEval = new Sphere< EOT >();
|
||||||
state.storeFunctor(plainEval);
|
state.storeFunctor(plainEval);
|
||||||
|
|
@ -119,11 +116,11 @@ int main(int ac, char** av)
|
||||||
// stopping criteria
|
// stopping criteria
|
||||||
// ... and creates the parameter letters: C E g G s T
|
// ... and creates the parameter letters: C E g G s T
|
||||||
|
|
||||||
eoContinue< EOT >& monitoringContinue = do_make_continue(parser, state, eval);
|
eoContinue< EOT >& monitoring_continue = do_make_continue(parser, state, eval);
|
||||||
|
|
||||||
// output
|
// output
|
||||||
|
|
||||||
eoCheckPoint< EOT >& checkpoint = do_make_checkpoint(parser, state, eval, monitoringContinue);
|
eoCheckPoint< EOT >& checkpoint = do_make_checkpoint(parser, state, eval, monitoring_continue);
|
||||||
|
|
||||||
// appends some missing code to checkpoint
|
// appends some missing code to checkpoint
|
||||||
|
|
||||||
|
|
@ -146,10 +143,10 @@ int main(int ac, char** av)
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
|
||||||
// eoPopStat< EOT >* popStat = new eoPopStat<EOT>;
|
eoPopStat< EOT >* popStat = new eoPopStat<EOT>;
|
||||||
// state.storeFunctor(popStat);
|
state.storeFunctor(popStat);
|
||||||
|
|
||||||
// checkpoint.add(*popStat);
|
checkpoint.add(*popStat);
|
||||||
|
|
||||||
// eoMonitor* fileSnapshot = new doFileSnapshot< std::vector< std::string > >("ResPop");
|
// eoMonitor* fileSnapshot = new doFileSnapshot< std::vector< std::string > >("ResPop");
|
||||||
// state.storeFunctor(fileSnapshot);
|
// state.storeFunctor(fileSnapshot);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,18 @@ public:
|
||||||
: _params(n)
|
: _params(n)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
doDistribParams(const doDistribParams& p) { *this = p; }
|
||||||
|
|
||||||
|
doDistribParams& operator=(const doDistribParams& p)
|
||||||
|
{
|
||||||
|
if (this != &p)
|
||||||
|
{
|
||||||
|
this->_params = p._params;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
EOT& param(unsigned int i = 0){return _params[i];}
|
EOT& param(unsigned int i = 0){return _params[i];}
|
||||||
|
|
||||||
unsigned int param_size(){return _params.size();}
|
unsigned int param_size(){return _params.size();}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@
|
||||||
#include "doUniform.h"
|
#include "doUniform.h"
|
||||||
#include "doStats.h"
|
#include "doStats.h"
|
||||||
|
|
||||||
// TODO: calcule de la moyenne + covariance dans une classe derivee
|
|
||||||
|
|
||||||
template < typename EOT >
|
template < typename EOT >
|
||||||
class doEstimatorNormal : public doEstimator< doNormal< EOT > >
|
class doEstimatorNormal : public doEstimator< doNormal< EOT > >
|
||||||
{
|
{
|
||||||
|
|
@ -19,32 +17,23 @@ public:
|
||||||
unsigned int dimsize = pop[0].size();
|
unsigned int dimsize = pop[0].size();
|
||||||
assert(dimsize > 0);
|
assert(dimsize > 0);
|
||||||
|
|
||||||
//std::vector< doVar > var(dimsize);
|
|
||||||
doCovMatrix cov(dimsize);
|
doCovMatrix cov(dimsize);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < popsize; ++i)
|
for (unsigned int i = 0; i < popsize; ++i)
|
||||||
{
|
{
|
||||||
cov.update(pop[i]);
|
cov.update(pop[i]);
|
||||||
// for (unsigned int d = 0; d < dimsize; ++d)
|
|
||||||
// {
|
|
||||||
// var[d].update(pop[i][d]);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EOT mean(dimsize);
|
EOT mean(dimsize);
|
||||||
EOT variance(dimsize);
|
EOT covariance(dimsize);
|
||||||
|
|
||||||
for (unsigned int d = 0; d < dimsize; ++d)
|
for (unsigned int d = 0; d < dimsize; ++d)
|
||||||
{
|
{
|
||||||
// mean[d] = var[d].get_mean();
|
|
||||||
// variance[d] = var[d].get_var();
|
|
||||||
//variance[d] = var[d].get_std(); // perhaps I should use this !?!
|
|
||||||
|
|
||||||
mean[d] = cov.get_mean(d);
|
mean[d] = cov.get_mean(d);
|
||||||
variance[d] = cov.get_var(d);
|
covariance[d] = cov.get_var(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
return doNormal< EOT >(mean, variance);
|
return doNormal< EOT >(mean, covariance);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,20 +83,13 @@ public :
|
||||||
// now make sure there is a dir without any genXXX file in it
|
// now make sure there is a dir without any genXXX file in it
|
||||||
if (res) // no dir present
|
if (res) // no dir present
|
||||||
{
|
{
|
||||||
//s = std::string("mkdir ")+dirname;
|
|
||||||
::mkdir(dirname.c_str(), 0755);
|
::mkdir(dirname.c_str(), 0755);
|
||||||
}
|
}
|
||||||
else if (!res && _rmFiles)
|
else if (!res && _rmFiles)
|
||||||
{
|
{
|
||||||
//s = std::string("/bin/rm ")+dirname+ "/" + filename + "*";
|
|
||||||
std::string s = dirname+ "/" + filename + "*";
|
std::string s = dirname+ "/" + filename + "*";
|
||||||
::unlink(s.c_str());
|
::unlink(s.c_str());
|
||||||
}
|
}
|
||||||
// else
|
|
||||||
// s = " ";
|
|
||||||
|
|
||||||
//int nothing = system(s.c_str());
|
|
||||||
// all done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** accessor: has something changed (for gnuplot subclass)
|
/** accessor: has something changed (for gnuplot subclass)
|
||||||
|
|
@ -148,43 +141,23 @@ public :
|
||||||
*/
|
*/
|
||||||
eoMonitor& operator()(std::ostream& _os)
|
eoMonitor& operator()(std::ostream& _os)
|
||||||
{
|
{
|
||||||
//eo::log << eo::debug << "TOTO" << std::endl;
|
|
||||||
|
|
||||||
//_os << "TOTO" << "\n";
|
|
||||||
|
|
||||||
//_os << v[0] << "\n";
|
|
||||||
|
|
||||||
// const eoValueParam<std::vector<double> > * ptParam =
|
|
||||||
// static_cast<const eoValueParam<std::vector<double> >* >(vec[0]);
|
|
||||||
|
|
||||||
// what's the size of vec ?!?
|
|
||||||
|
|
||||||
eo::log << eo::debug;
|
|
||||||
|
|
||||||
eo::log << "vec size: " << vec.size() << std::endl;
|
|
||||||
|
|
||||||
const eoValueParam< EOTParam > * ptParam =
|
const eoValueParam< EOTParam > * ptParam =
|
||||||
static_cast< const eoValueParam< EOTParam >* >(vec[0]);
|
static_cast< const eoValueParam< EOTParam >* >(vec[0]);
|
||||||
|
|
||||||
//const std::vector<double> v = ptParam->value();
|
|
||||||
EOTParam v(ptParam->value());
|
EOTParam v(ptParam->value());
|
||||||
if (vec.size() == 1) // only one std::vector: -> add number in front
|
if (vec.size() == 1) // only one std::vector: -> add number in front
|
||||||
{
|
{
|
||||||
eo::log << "I am here..." << std::endl;
|
eo::log << "I am here..." << std::endl;
|
||||||
|
|
||||||
//eo::log << *vec[0] << std::endl;
|
|
||||||
|
|
||||||
for (unsigned k=0; k<v.size(); k++)
|
for (unsigned k=0; k<v.size(); k++)
|
||||||
_os << k << " " << v[k] << "\n" ;
|
_os << k << " " << v[k] << "\n" ;
|
||||||
}
|
}
|
||||||
else // need to get all other std::vectors
|
else // need to get all other std::vectors
|
||||||
{
|
{
|
||||||
//std::vector<std::vector<double> > vv(vec.size());
|
|
||||||
std::vector< EOTParam > vv(vec.size());
|
std::vector< EOTParam > vv(vec.size());
|
||||||
vv[0]=v;
|
vv[0]=v;
|
||||||
for (unsigned i=1; i<vec.size(); i++)
|
for (unsigned i=1; i<vec.size(); i++)
|
||||||
{
|
{
|
||||||
//ptParam = static_cast<const eoValueParam<std::vector<double> >* >(vec[1]);
|
|
||||||
ptParam = static_cast< const eoValueParam< EOTParam >* >(vec[1]);
|
ptParam = static_cast< const eoValueParam< EOTParam >* >(vec[1]);
|
||||||
vv[i] = ptParam->value();
|
vv[i] = ptParam->value();
|
||||||
if (vv[i].size() != v.size())
|
if (vv[i].size() != v.size())
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@ public:
|
||||||
variance() = _variance;
|
variance() = _variance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doNormalParams(const doNormalParams& p)
|
||||||
|
: doDistribParams< EOT >( p )
|
||||||
|
{}
|
||||||
|
|
||||||
EOT& mean(){return this->param(0);}
|
EOT& mean(){return this->param(0);}
|
||||||
EOT& variance(){return this->param(1);}
|
EOT& variance(){return this->param(1);}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@ public:
|
||||||
max() = _max;
|
max() = _max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doVectorBounds(const doVectorBounds& v)
|
||||||
|
: doDistribParams< EOT >( v )
|
||||||
|
{}
|
||||||
|
|
||||||
EOT& min(){return this->param(0);}
|
EOT& min(){return this->param(0);}
|
||||||
EOT& max(){return this->param(1);}
|
EOT& max(){return this->param(1);}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Reference in a new issue