Ultra 0.9.4
Loading...
Searching...
No Matches
individual.cc File Reference
#include "kernel/gp/individual.h"
#include "kernel/nullary.h"
#include "kernel/value_format.h"
#include "kernel/gp/src/variable.h"
#include "utility/log.h"
#include "utility/misc.h"
#include <cstdint>
#include <expected>
#include <ranges>
#include <vector>

Namespaces

namespace  ultra

Typedefs

using ultra::gp::internal::relocation_result_t = std::expected<relocation_result, relocation_error>

Enumerations

enum class  ultra::gp::internal::relocation_error { insufficient_rows }
 Recoverable relocation failures. More...

Functions

locus ultra::gp::random_locus (const individual &prg)
decision_vector ultra::gp::extract_decision_vector (const individual &ind)
relocation_result_t ultra::gp::internal::relocate_exons (const individual &from, locus::index_t first_index, matrix< gene > &to)

Detailed Description

Remarks
This file is part of ULTRA.
License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/

Enumeration Type Documentation

◆ relocation_error

Recoverable relocation failures.

Enumerator
insufficient_rows 

The destination matrix has too few rows for the active source rows.

Function Documentation

◆ extract_decision_vector()

decision_vector ultra::gp::extract_decision_vector ( const individual & ind)
nodiscard

Extracts the decision vector associated with an individual.

Returns
a valid decision vector

The returned decision_vector provides a flat, optimiser-friendly view of all tunable scalar parameters (currently D_DOUBLE and D_INT) appearing in the active portion of the genome.

Note
Only parameters in active genes (exons) are included. Inactive code is ignored.
Integer parameters are converted to double for optimisation. The original type information is preserved in decision_vector::coordinate::kind and restored when applying the vector.
The ordering of parameters is deterministic for a fixed individual and reflects the traversal order of its active genes. The returned vector is therefore compatible with apply_decision_vector() as long as the structure of the individual is unchanged.

◆ relocate_exons()

relocation_result_t ultra::gp::internal::relocate_exons ( const individual & from,
locus::index_t first_index,
matrix< gene > & to )
nodiscard

Copies the active graph of from into to, compacting active rows.

Returns
the relocated root locus and the first unused row index

Active rows are relocated into the consecutive range starting at first_index. Active loci keep their original categories and address arguments are rewritten to point at the corresponding relocated rows.