Ultra 0.9.4
Loading...
Searching...
No Matches
scored_individual.tcc File Reference

Go to the source code of this file.

Functions

template<Individual I, Fitness F>
auto operator<=> (const scored_individual< I, F > &lhs, const scored_individual< I, F > &rhs) noexcept

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/

Function Documentation

◆ operator<=>()

template<Individual I, Fitness F>
auto operator<=> ( const scored_individual< I, F > & lhs,
const scored_individual< I, F > & rhs )
noexcept

Orders two scored individuals by fitness.

Parameters
lhsfirst scored individual
rhssecond scored individual
Returns
the ordering of lhs.fit and rhs.fit

The comparison is based only on the fitness value and is intended for ranking and selection purposes (e.g. best/worst individual).

Note
This operator deliberately provides ordering only. Equality (operator==) is not defined, because fitness values are typically floating-point and exact equality would be semantically misleading.

As a consequence, scored_individual does not model a totally ordered type and cannot be used with default std::ranges::less. Algorithms requiring ordering should supply an explicit comparator or projection.