Skip to content

Commit

Permalink
Documentation for Engine class (just the class definition, not its me…
Browse files Browse the repository at this point in the history
…thods)
  • Loading branch information
gAldeia committed Jun 11, 2024
1 parent 5210dd7 commit f70d32e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
12 changes: 12 additions & 0 deletions src/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ using namespace Var;
using namespace nlohmann;

template <ProgramType T>
/**
* @brief The `Engine` class represents the core engine of the brush library.
*
* It encapsulates the functionality for training and predicting with programs
* in a genetic programming framework. The `Engine` class manages the population
* of programs, selection algorithms, evaluation code, variation operators, and
* survival algorithms. It also provides methods for training the model, making
* predictions, and accessing runtime statistics.
*
* The `Engine` class is parameterized by the program type `T`, which determines
* the type of programs that can be evolved and evaluated by the engine.
*/
class Engine{
public:
Engine(const Parameters& p=Parameters())
Expand Down
41 changes: 30 additions & 11 deletions src/selection/selection_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,41 @@ using namespace Pop;
* @brief base class for selection operators.
*/
template<ProgramType T>
class SelectionOperator
/**
* @brief The SelectionOperator class represents a base class for selection operators in a genetic algorithm.
*
* This class provides common functionality and interface for selection operators.
*/
class SelectionOperator
{
public:
bool survival;
string name;

// shoudn't have a constructor
// SelectionOperator(){};
bool survival; /**< Flag indicating whether the selection operator is used for survival selection. */
string name; /**< The name of the selection operator. */

/**
* @brief Destructor for the SelectionOperator class.
*/
virtual ~SelectionOperator();

virtual vector<size_t> select(Population<T>& pop, int island,
const Parameters& p);

/**
* @brief Selects individuals from the population based on the selection operator's strategy.
*
* @param pop The population from which to select individuals.
* @param island The index of the island in a parallel genetic algorithm.
* @param p The parameters for the selection operator.
* @return A vector of indices representing the selected individuals.
*/
virtual vector<size_t> select(Population<T>& pop, int island, const Parameters& p);

virtual vector<size_t> survive(Population<T>& pop, int island,
const Parameters& p);
/**
* @brief Applies the selection operator to determine which individuals survive in the population.
*
* @param pop The population in which to apply the survival selection.
* @param island The index of the island in a parallel genetic algorithm.
* @param p The parameters for the selection operator.
* @return A vector of indices representing the surviving individuals.
*/
virtual vector<size_t> survive(Population<T>& pop, int island, const Parameters& p);
};

} // selection
Expand Down

0 comments on commit f70d32e

Please sign in to comment.