From 412e054933355a12f8a249cda6a64136f69aefc1 Mon Sep 17 00:00:00 2001 From: nojhan Date: Sun, 12 Apr 2020 10:02:25 +0200 Subject: [PATCH] feat: add an eoAlgoFoundry interface Mainly expose the "algo = encoding" entrface. --- eo/src/eoAlgoFoundry.h | 68 ++++++++++++++++++++++++++++++++++++++++ eo/src/eoAlgoFoundryEA.h | 18 ++--------- 2 files changed, 70 insertions(+), 16 deletions(-) create mode 100644 eo/src/eoAlgoFoundry.h diff --git a/eo/src/eoAlgoFoundry.h b/eo/src/eoAlgoFoundry.h new file mode 100644 index 000000000..e7d067cc2 --- /dev/null +++ b/eo/src/eoAlgoFoundry.h @@ -0,0 +1,68 @@ + +/* + 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + © 2020 Thales group + + Authors: + Johann Dreo +*/ + +#ifndef _eoAlgoFoundry_H_ +#define _eoAlgoFoundry_H_ + +#include +#include + +/** + * + * @ingroup Core + * @ingroup Foundry + * @ingroup Algorithms + */ +template +class eoAlgoFoundry : public eoAlgo +{ + public: + static const size_t dim = NBOP; + + /** The constructon only take an eval, because all other operators + * are stored in the public containers. + */ + eoAlgoFoundry() + { + _encoding = { 0 }; // dim * 0 + } + + /** Access to the index of the currently selected operator. + */ + size_t& at(size_t i) + { + return _encoding.at(i); + } + + /** Select indices of all the operators. + */ + void operator=( std::array a) + { + _encoding = a; + } + + protected: + std::array _encoding; + +}; + +#endif // _eoAlgoFoundry_H_ diff --git a/eo/src/eoAlgoFoundryEA.h b/eo/src/eoAlgoFoundryEA.h index 5868c5771..179aa1f9d 100644 --- a/eo/src/eoAlgoFoundryEA.h +++ b/eo/src/eoAlgoFoundryEA.h @@ -76,10 +76,10 @@ * @ingroup Algorithms */ template -class eoAlgoFoundryEA : public eoAlgo +class eoAlgoFoundryEA : public eoAlgoFoundry { public: - static const size_t dim = 5; + using eoAlgoFoundry::dim; struct Indices { @@ -104,20 +104,6 @@ class eoAlgoFoundryEA : public eoAlgo _encoding = { 0 }; // dim * 0 } - /** Access to the index of the currently selected operator. - */ - size_t& at(size_t i) - { - return _encoding.at(i); - } - - /** Select indices of all the operators. - */ - void operator=( std::array a) - { - _encoding = a; - } - /* Operators containers @{ */ eoForgeVector< eoContinue > continuators; eoForgeVector< eoQuadOp > crossovers;