feat: add a new operator: eoAlgoReset
- Used in eoAlgoRestart, useful if one wants to reset some things before a restart. - Add operators to reset a pop (EO) and a distrib (EDO) and a wrapper to combine several reset operators.
This commit is contained in:
parent
412e054933
commit
d03f2abb46
3 changed files with 267 additions and 15 deletions
55
edo/src/edoDistribReset.h
Normal file
55
edo/src/edoDistribReset.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
/*
|
||||
The Evolving Objects framework is a template-based,
|
||||
ANSI-C++ evolutionary computation library which helps you to write your
|
||||
own evolutionary algorithms.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation;
|
||||
version 2.1 of the License.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Copyright (C) 2020 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _EDODISTRIBRESET_H_
|
||||
#define _EDODISTRIBRESET_H_
|
||||
|
||||
#include <eoAlgoReset.h>
|
||||
|
||||
/** Reset a distrib when called (as an algorithm).
|
||||
*
|
||||
* @ingroup Reset
|
||||
*/
|
||||
template<class D>
|
||||
class edoDistribReset : public eoAlgoReset<typename D::EOType>
|
||||
{
|
||||
public:
|
||||
using EOType = typename D::EOType;
|
||||
edoDistribReset( D& distrib ) :
|
||||
_distrib(distrib)
|
||||
{ }
|
||||
|
||||
virtual void operator()( eoPop<EOType>& pop )
|
||||
{
|
||||
_distrib.reset();
|
||||
}
|
||||
|
||||
protected:
|
||||
D& _distrib;
|
||||
};
|
||||
|
||||
#endif // _EDODISTRIBRESET_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue