 |
Grail (C++)
1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
|
3 #ifndef GRAIL_FITNESS_REPOSITORY_H
4 #define GRAIL_FITNESS_REPOSITORY_H
6 #include "Individual.hh"
8 #include <unordered_map>
28 std::size_t operator()(
const Individual* individual)
const
34 struct IndividualEqual
61 void AddSampleWithFitnessUpdate(
Individual& individual);
65 void Serialize(
const std::string& filename)
const;
75 std::unordered_map<const Individual*, std::vector<double>, IndividualHash, IndividualEqual> individualFitnessEvaluations{};
76 std::vector<std::unique_ptr<Individual>> ownedIndividuals{};
77 std::size_t maxSamples;
81 #endif //GRAIL_FITNESS_REPOSITORY_H
bool Equals(const Individual &other) const
Tests whether two individuals have the same structure (even if they point to different objects in mem...
Definition: Individual.cpp:101
bool Deserialize(const std::string &filename, const Individual &populationRepresentative)
Loads previously saved contents of the FitnessRepository using the Serialize() method....
Definition: FitnessRepository.cpp:90
std::size_t GetSampleCount(const Individual &individual) const
Returns the number of fitness values currently stored for a given individual.
Definition: FitnessRepository.cpp:15
FitnessRepository(size_t maxSamplesPerIndividual=100)
Constructs a new FitnessRepository instance.
Definition: FitnessRepository.cpp:10
std::size_t GetHashCode() const
Custom hash implementation.
Definition: Individual.cpp:96
Represents an individual for evolutionary algorithms (EA). It stores the encoding consisting of opti...
Definition: Individual.hh:23
bool TryGetFitness(const Individual &individual, double &fitness) const
Definition: FitnessRepository.cpp:26
This class provides a functionality of assigning fitness values as averages from the previous evaluat...
Definition: FitnessRepository.h:24
void Serialize(const std::string &filename) const
Serializes contents of the FitnessRepository so it can be loaded in another session using Deserialize...
Definition: FitnessRepository.cpp:65