Skip to content

Commit

Permalink
Add attributes field to the candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
KRM7 committed Dec 11, 2024
1 parent 74747d6 commit 7859ebc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/encodings.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ recommendation is to use `std::variant` or a similar type for the gene
type.


### Extending the candidates

The candidates contain an additional `attributes` field that may hold any
additional data that is associated with the candidate. This field will always
be empty by default, as the library does not use it for anything by default.
The purpose of this field is to allow the user to extend the candidates with
arbitrary data if neccessary, and it may be used freely to do so.


### Variable chromosome lengths

The length of the chromosomes is specified as part of the fitness function.
Expand Down
4 changes: 4 additions & 0 deletions src/core/candidate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "../utility/iterators.hpp"
#include <vector>
#include <algorithm>
#include <any>
#include <utility>
#include <concepts>
#include <cstddef>
Expand Down Expand Up @@ -107,6 +108,9 @@ namespace gapp
/** The solution's degree of constraint violation for each constraint. */
CVVector constraint_violation;

/** Arbitrary data associated with the candidate. */
std::any attributes;


/**
* @returns The number of objectives associated with the candidate.
Expand Down

0 comments on commit 7859ebc

Please sign in to comment.