refactor: add eoOperatorFoundry
- Simpler relationships between encoding and set of operators in foundry. - Rename "instanciate" in "instantiate"
This commit is contained in:
parent
2e23b837e4
commit
ae81793f7c
8 changed files with 193 additions and 112 deletions
|
|
@ -77,11 +77,11 @@ int main(int /*argc*/, char** /*argv*/)
|
|||
pop.append(pop_size, init);
|
||||
eval(pop,pop);
|
||||
|
||||
foundry.at(foundry.index_of.continuators) = i_cont;
|
||||
foundry.at(foundry.index_of.crossovers) = i_cross;
|
||||
foundry.at(foundry.index_of.mutations) = i_mut;
|
||||
foundry.at(foundry.index_of.selectors) = i_sel;
|
||||
foundry.at(foundry.index_of.replacements) = i_rep;
|
||||
foundry.at(foundry.continuators.index()) = i_cont;
|
||||
foundry.at(foundry.crossovers.index()) = i_cross;
|
||||
foundry.at(foundry.mutations.index()) = i_mut;
|
||||
foundry.at(foundry.selectors.index()) = i_sel;
|
||||
foundry.at(foundry.replacements.index()) = i_rep;
|
||||
|
||||
// Or, if you know the order.
|
||||
foundry.select({i_cont, i_cross, i_mut, i_sel, i_rep});
|
||||
|
|
|
|||
|
|
@ -54,19 +54,19 @@ int main(int /*argc*/, char** /*argv*/)
|
|||
std::string best_algo = "";
|
||||
|
||||
for(auto& forge_cont : continuators) {
|
||||
auto& continuator = forge_cont->instanciate();
|
||||
auto& continuator = forge_cont->instantiate();
|
||||
|
||||
for(auto& forge_cross : crossovers) {
|
||||
auto& crossover = forge_cross->instanciate();
|
||||
auto& crossover = forge_cross->instantiate();
|
||||
|
||||
for(auto& forge_mut : mutations ) {
|
||||
auto& mutation = forge_mut->instanciate();
|
||||
auto& mutation = forge_mut->instantiate();
|
||||
|
||||
for(auto& forge_sel : selectors) {
|
||||
auto& selector = forge_sel->instanciate();
|
||||
auto& selector = forge_sel->instantiate();
|
||||
|
||||
for(auto& forge_rep : replacors) {
|
||||
auto& replacor = forge_rep->instanciate();
|
||||
auto& replacor = forge_rep->instantiate();
|
||||
|
||||
std::ostringstream algo_name;
|
||||
algo_name << continuator.className() << " + "
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ int main(int /*argc*/, char** /*argv*/)
|
|||
// Forge container using indices.
|
||||
eoForgeVector<OpInterface> indexed_factories;
|
||||
|
||||
// Capture constructor's parameters and defer instanciation.
|
||||
// Capture constructor's parameters and defer instantiation.
|
||||
indexed_factories.add<OpA>("I'm A");
|
||||
indexed_factories.setup<OpA>(0, "I'm actually A"); // Edit
|
||||
indexed_factories.add<OpB>("I'm B", " prime");
|
||||
indexed_factories.add<OpB>("I'm a B", " junior");
|
||||
|
||||
// Actually instanciante and call.
|
||||
indexed_factories.instanciate(0)();
|
||||
indexed_factories.instanciate(1)();
|
||||
indexed_factories.instanciate(2)();
|
||||
// Actually instantiante and call.
|
||||
indexed_factories.instantiate(0)();
|
||||
indexed_factories.instantiate(1)();
|
||||
indexed_factories.instantiate(2)();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue