test and documentation added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1698 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
92251dc96f
commit
cad0320e57
25 changed files with 317 additions and 37 deletions
|
|
@ -46,33 +46,51 @@
|
|||
class moCounterMonitorSaver : public eoUpdater {
|
||||
public :
|
||||
|
||||
moCounterMonitorSaver(unsigned _interval, eoMonitor& _mon) : interval(_interval), counter(0) {
|
||||
monitors.push_back(&_mon);
|
||||
}
|
||||
|
||||
void operator()(void) {
|
||||
|
||||
if (++counter % interval == 0)
|
||||
for (unsigned i = 0; i < monitors.size(); ++i)
|
||||
(*monitors[i])();
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _interval frequency to call monitors
|
||||
* @param _mon a monitor
|
||||
*/
|
||||
moCounterMonitorSaver(unsigned _interval, eoMonitor& _mon) : interval(_interval), counter(0) {
|
||||
monitors.push_back(&_mon);
|
||||
}
|
||||
|
||||
void lastCall(void) {
|
||||
for (unsigned i = 0; i < monitors.size(); ++i)
|
||||
monitors[i]->lastCall();
|
||||
/**
|
||||
* call monitors if interval is reach by a counter
|
||||
*/
|
||||
void operator()(void) {
|
||||
if (counter++ % interval == 0)
|
||||
for (unsigned i = 0; i < monitors.size(); i++)
|
||||
(*monitors[i])();
|
||||
}
|
||||
|
||||
void add(eoMonitor& _mon) {
|
||||
monitors.push_back(&_mon);
|
||||
}
|
||||
/**
|
||||
* last call of monitors
|
||||
*/
|
||||
void lastCall(void) {
|
||||
for (unsigned i = 0; i < monitors.size(); i++)
|
||||
monitors[i]->lastCall();
|
||||
}
|
||||
|
||||
virtual std::string className(void) const { return "moCounterMonitorSaver"; }
|
||||
/**
|
||||
* attach another monitor to this class
|
||||
* @param _mon the monitor to attach
|
||||
*/
|
||||
void add(eoMonitor& _mon) {
|
||||
monitors.push_back(&_mon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const { return "moCounterMonitorSaver"; }
|
||||
|
||||
private :
|
||||
unsigned interval, counter;
|
||||
/** interval and counter value */
|
||||
unsigned int interval, counter;
|
||||
|
||||
std::vector<eoMonitor*> monitors;
|
||||
/** monitor's vector */
|
||||
std::vector<eoMonitor*> monitors;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -206,7 +206,9 @@ public :
|
|||
/**
|
||||
* @return the class name
|
||||
*/
|
||||
virtual std::string className(void) const { return "moNeigborhoodStat"; }
|
||||
virtual std::string className(void) const {
|
||||
return "moNeighborhoodStat";
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -39,25 +39,36 @@
|
|||
|
||||
/**
|
||||
* The statistic which only give the current solution
|
||||
* becarefull, the solution is given by copy
|
||||
* be careful, the solution is given by copy
|
||||
*
|
||||
*/
|
||||
*/
|
||||
template <class EOT>
|
||||
class moSolutionStat : public moStat<EOT, EOT>
|
||||
{
|
||||
public :
|
||||
using moStat< EOT, EOT >::value;
|
||||
|
||||
moSolutionStat(std::string _description = "solution")
|
||||
: moStat<EOT, EOT>(EOT(), _description)
|
||||
{}
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _description a description of the parameter
|
||||
*/
|
||||
moSolutionStat(std::string _description = "solution"):
|
||||
moStat<EOT, EOT>(EOT(), _description){}
|
||||
|
||||
virtual void operator()(EOT & _sol)
|
||||
{
|
||||
/**
|
||||
* Set the solution by copy
|
||||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol){
|
||||
value() = _sol;
|
||||
}
|
||||
|
||||
virtual std::string className(void) const { return "moSolutionStat"; }
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const{
|
||||
return "moSolutionStat";
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -41,18 +41,26 @@
|
|||
* The actual class that will be used as base for all statistics
|
||||
* that need to be calculated over the solution
|
||||
* It is a moStatBase AND an eoValueParam so it can be used in Monitors.
|
||||
*/
|
||||
*/
|
||||
template <class EOT, class T>
|
||||
class moStat : public eoValueParam<T>, public moStatBase<EOT>
|
||||
{
|
||||
public:
|
||||
|
||||
moStat(T _value, std::string _description)
|
||||
: eoValueParam<T>(_value, _description)
|
||||
{}
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _value a default parameter's value
|
||||
* @param _description a description of the parameter
|
||||
*/
|
||||
moStat(T _value, std::string _description):
|
||||
eoValueParam<T>(_value, _description){}
|
||||
|
||||
virtual std::string className(void) const
|
||||
{ return "moStat"; }
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const{
|
||||
return "moStat";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,8 +49,17 @@ template <class EOT>
|
|||
class moStatBase : public eoUF<EOT &, void>
|
||||
{
|
||||
public:
|
||||
virtual void lastCall(EOT &) {}
|
||||
virtual std::string className(void) const { return "moStatBase"; }
|
||||
/**
|
||||
* last call of a statistical operator
|
||||
*/
|
||||
virtual void lastCall(EOT &) {}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const{
|
||||
return "moStatBase";
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue