* indentations + whitespace cleanup
This commit is contained in:
parent
8457e39efe
commit
56c6edab04
285 changed files with 6068 additions and 6223 deletions
|
|
@ -8,16 +8,16 @@
|
|||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
Contact: cahon@lifl.fr
|
||||
*/
|
||||
|
||||
|
|
@ -32,26 +32,26 @@
|
|||
#include <eoOp.h>
|
||||
|
||||
/**
|
||||
The abstract cellular easy algorithm.
|
||||
The abstract cellular easy algorithm.
|
||||
|
||||
@ingroup Algorithms
|
||||
*/
|
||||
template <class EOT> class eoCellularEasyEA : public eoAlgo <EOT> {
|
||||
|
||||
|
||||
public :
|
||||
|
||||
|
||||
/**
|
||||
Two constructors
|
||||
*/
|
||||
|
||||
eoCellularEasyEA (eoContinue <EOT> & _cont, // Stop. criterion
|
||||
eoEvalFunc <EOT> & _eval, // Evaluation function
|
||||
eoSelectOne <EOT> & _sel_neigh, // To choose a partner
|
||||
eoBinOp <EOT> & _cross, // Cross-over operator
|
||||
eoMonOp <EOT> & _mut, // Mutation operator
|
||||
eoSelectOne <EOT> & _sel_repl /* Which to keep between the new
|
||||
child and the old individual ? */
|
||||
) :
|
||||
eoEvalFunc <EOT> & _eval, // Evaluation function
|
||||
eoSelectOne <EOT> & _sel_neigh, // To choose a partner
|
||||
eoBinOp <EOT> & _cross, // Cross-over operator
|
||||
eoMonOp <EOT> & _mut, // Mutation operator
|
||||
eoSelectOne <EOT> & _sel_repl /* Which to keep between the new
|
||||
child and the old individual ? */
|
||||
) :
|
||||
cont (_cont),
|
||||
eval (_eval),
|
||||
popEval (_eval),
|
||||
|
|
@ -60,18 +60,18 @@ public :
|
|||
mut (_mut),
|
||||
sel_child (eoSelectFirstOne ()),
|
||||
sel_repl (_sel_repl) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
eoCellularEasyEA (eoContinue <EOT> & _cont,
|
||||
eoEvalFunc <EOT> & _eval,
|
||||
eoSelectOne <EOT> & _sel_neigh,
|
||||
eoQuadOp <EOT> & _cross,
|
||||
eoMonOp <EOT> & _mut,
|
||||
eoSelectOne <EOT> & _sel_child, /* To choose one from
|
||||
the both children */
|
||||
eoSelectOne <EOT> & _sel_repl
|
||||
) :
|
||||
eoEvalFunc <EOT> & _eval,
|
||||
eoSelectOne <EOT> & _sel_neigh,
|
||||
eoQuadOp <EOT> & _cross,
|
||||
eoMonOp <EOT> & _mut,
|
||||
eoSelectOne <EOT> & _sel_child, /* To choose one from
|
||||
the both children */
|
||||
eoSelectOne <EOT> & _sel_repl
|
||||
) :
|
||||
cont (_cont),
|
||||
eval (_eval),
|
||||
popEval (_eval),
|
||||
|
|
@ -80,7 +80,7 @@ public :
|
|||
mut (_mut),
|
||||
sel_child (_sel_child),
|
||||
sel_repl (_sel_repl) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -88,55 +88,55 @@ public :
|
|||
*/
|
||||
|
||||
void operator () (eoPop <EOT> & pop) {
|
||||
|
||||
|
||||
do {
|
||||
|
||||
|
||||
for (unsigned i = 0 ; i < pop.size () ; i ++) {
|
||||
|
||||
// Who are neighbouring to the current individual ?
|
||||
eoPop <EOT> neigh = neighbours (pop, i) ;
|
||||
|
||||
// To select a partner
|
||||
EOT part, old_sol = pop [i] ;
|
||||
part = sel_neigh (neigh) ;
|
||||
|
||||
// To perform cross-over
|
||||
cross (pop [i], part) ;
|
||||
// Who are neighbouring to the current individual ?
|
||||
eoPop <EOT> neigh = neighbours (pop, i) ;
|
||||
|
||||
// To perform mutation
|
||||
mut (pop [i]) ;
|
||||
mut (part) ;
|
||||
|
||||
pop [i].invalidate () ;
|
||||
part.invalidate () ;
|
||||
eval (pop [i]) ;
|
||||
eval (part) ;
|
||||
// To select a partner
|
||||
EOT part, old_sol = pop [i] ;
|
||||
part = sel_neigh (neigh) ;
|
||||
|
||||
// To choose one of the two children ...
|
||||
eoPop <EOT> pop_loc ;
|
||||
pop_loc.push_back (pop [i]) ;
|
||||
pop_loc.push_back (part) ;
|
||||
// To perform cross-over
|
||||
cross (pop [i], part) ;
|
||||
|
||||
pop [i] = sel_child (pop_loc) ;
|
||||
// To perform mutation
|
||||
mut (pop [i]) ;
|
||||
mut (part) ;
|
||||
|
||||
// To choose only one between the new made child and the old individual
|
||||
pop_loc.clear () ;
|
||||
pop_loc.push_back (pop [i]) ;
|
||||
|
||||
pop_loc.push_back (old_sol) ;
|
||||
|
||||
pop [i] = sel_repl (pop_loc) ;
|
||||
pop [i].invalidate () ;
|
||||
part.invalidate () ;
|
||||
eval (pop [i]) ;
|
||||
eval (part) ;
|
||||
|
||||
// To choose one of the two children ...
|
||||
eoPop <EOT> pop_loc ;
|
||||
pop_loc.push_back (pop [i]) ;
|
||||
pop_loc.push_back (part) ;
|
||||
|
||||
pop [i] = sel_child (pop_loc) ;
|
||||
|
||||
// To choose only one between the new made child and the old individual
|
||||
pop_loc.clear () ;
|
||||
pop_loc.push_back (pop [i]) ;
|
||||
|
||||
pop_loc.push_back (old_sol) ;
|
||||
|
||||
pop [i] = sel_repl (pop_loc) ;
|
||||
}
|
||||
|
||||
|
||||
} while (cont (pop)) ;
|
||||
}
|
||||
|
||||
protected :
|
||||
|
||||
|
||||
virtual eoPop <EOT> neighbours (const eoPop <EOT> & pop, int rank) = 0 ;
|
||||
|
||||
private :
|
||||
|
||||
|
||||
eoContinue <EOT> & cont ;
|
||||
eoEvalFunc <EOT> & eval ;
|
||||
eoPopLoopEval <EOT> popEval ;
|
||||
|
|
@ -145,18 +145,18 @@ private :
|
|||
eoMonOp <EOT> & mut ;
|
||||
eoSelectOne <EOT> & sel_child ;
|
||||
eoSelectOne <EOT> & sel_repl ;
|
||||
|
||||
|
||||
class eoSelectFirstOne : public eoSelectOne <EOT> {
|
||||
|
||||
|
||||
public :
|
||||
|
||||
|
||||
const EOT & operator () (const eoPop <EOT> & pop) {
|
||||
|
||||
return pop [0] ;
|
||||
|
||||
return pop [0] ;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
} ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Reference in a new issue