refactored vectors repairers that are using a function in a more generic way, added a binary function wrapper for vectors repairers, with the modulus function as an example
This commit is contained in:
parent
979f33b721
commit
4d45970767
6 changed files with 213 additions and 17 deletions
|
|
@ -30,38 +30,32 @@ Authors:
|
|||
|
||||
#include <cmath>
|
||||
|
||||
#include "edoRepairer.h"
|
||||
#include "edoRepairerApply.h"
|
||||
|
||||
/**
|
||||
/** A repairer that calls "floor" on each items of a solution
|
||||
*
|
||||
* Just a proxy to "edoRepairerApplyUnary<EOT, EOT::AtomType(EOT::AtomType)> rep( std::floor);"
|
||||
*
|
||||
* @ingroup Repairers
|
||||
*/
|
||||
template < typename EOT >
|
||||
class edoRepairerFloor : public edoRepairer<EOT>
|
||||
class edoRepairerFloor : public edoRepairerApplyUnary<EOT>
|
||||
{
|
||||
public:
|
||||
virtual void operator()( EOT& sol )
|
||||
{
|
||||
for( unsigned int i=0; i < sol.size(); ++i ) {
|
||||
sol[i] = floor( sol[i] );
|
||||
}
|
||||
}
|
||||
edoRepairerFloor() : edoRepairerApplyUnary<EOT>( std::floor ) {}
|
||||
};
|
||||
|
||||
/**
|
||||
/** A repairer that calls "ceil" on each items of a solution
|
||||
*
|
||||
* @see edoRepairerFloor
|
||||
*
|
||||
* @ingroup Repairers
|
||||
*/
|
||||
template < typename EOT >
|
||||
class edoRepairerCeil : public edoRepairer<EOT>
|
||||
class edoRepairerCeil : public edoRepairerApplyUnary<EOT>
|
||||
{
|
||||
public:
|
||||
virtual void operator()( EOT& sol )
|
||||
{
|
||||
for( unsigned int i=0; i < sol.size(); ++i ) {
|
||||
sol[i] = ceil( sol[i] );
|
||||
}
|
||||
}
|
||||
edoRepairerCeil() : edoRepairerApplyUnary<EOT>( std::ceil ) {}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Reference in a new issue