2024-03-12 16:53:27 -04:00
|
|
|
/*
|
|
|
|
* <Short Description>
|
|
|
|
* Copyright (C) 2024 Brett Terpstra
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LILFBTF5_SYSTEM_H
|
|
|
|
#define LILFBTF5_SYSTEM_H
|
|
|
|
|
|
|
|
#include <lilfbtf/fwddecl.h>
|
2024-03-19 13:48:44 -04:00
|
|
|
#include <lilfbtf/tree.h>
|
2024-03-22 11:52:24 -04:00
|
|
|
#include <blt/std/thread.h>
|
2024-03-19 13:48:44 -04:00
|
|
|
#include <vector>
|
2024-03-12 16:53:27 -04:00
|
|
|
|
|
|
|
namespace fb
|
|
|
|
{
|
2024-03-15 12:06:47 -04:00
|
|
|
|
2024-03-19 13:48:44 -04:00
|
|
|
class gp_population_t
|
2024-03-15 12:06:47 -04:00
|
|
|
{
|
2024-03-22 11:52:24 -04:00
|
|
|
private:
|
|
|
|
blt::thread_pool<true>& pool;
|
|
|
|
std::vector<tree_t> population;
|
|
|
|
|
|
|
|
void crossover();
|
|
|
|
|
|
|
|
void mutate();
|
|
|
|
public:
|
|
|
|
explicit gp_population_t(blt::thread_pool<true>& pool): pool(pool)
|
|
|
|
{}
|
|
|
|
|
|
|
|
void init_pop();
|
|
|
|
|
|
|
|
void execute(const fitness_eval_func_t& fitnessEvalFunc);
|
|
|
|
|
|
|
|
void breed_new_pop();
|
2024-03-15 12:06:47 -04:00
|
|
|
};
|
|
|
|
|
2024-03-19 13:48:44 -04:00
|
|
|
class gp_system_t
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
|
|
|
public:
|
2024-03-22 11:52:24 -04:00
|
|
|
explicit gp_system_t(type_engine_t& types): types(types)
|
2024-03-19 13:48:44 -04:00
|
|
|
{}
|
|
|
|
|
|
|
|
private:
|
|
|
|
type_engine_t& types;
|
|
|
|
};
|
|
|
|
|
2024-03-12 16:53:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif //LILFBTF5_SYSTEM_H
|