Ultra 0.9.4
Loading...
Searching...
No Matches
ultra::ga::problem Class Reference

#include <problem.h>

Inheritance diagram for ultra::ga::problem:
ultra::problem

Public Member Functions

 problem (std::size_t, const interval< int > &)
 problem (const std::vector< interval< int > > &)
std::size_t parameters () const noexcept
template<symbol_set::weight_t = symbol_set::default_weight>
integer * insert (const interval< int > &, symbol::category_t=symbol::undefined_category)
Public Member Functions inherited from ultra::problem
template<Symbol S, symbol_set::weight_t = symbol_set::default_weight, class ... Args>
requires std::constructible_from<S, Args...>
std::add_pointer_t< S > insert (Args &&...)
template<std::derived_from< function > F, symbol_set::weight_t W = symbol_set::default_weight, std::convertible_to< symbol::category_t > C = symbol::category_t>
std::add_pointer_t< F > insert (symbol::category_t, std::initializer_list< C >)
template<std::derived_from< function > F, symbol_set::weight_t W = symbol_set::default_weight, std::convertible_to< symbol::category_t > C = symbol::category_t>
std::add_pointer_t< F > insert (std::initializer_list< C >)
virtual bool is_valid () const

Additional Inherited Members

Public Attributes inherited from ultra::problem
parameters params {}
symbol_set sset {}

Detailed Description

Provides a GA-specific interface to the generic problem class.

The class is a facade that provides a simpler interface to represent GA-specific problems.

Constructor & Destructor Documentation

◆ problem() [1/2]

ultra::ga::problem::problem ( std::size_t nparam,
const interval< int > & itval )

Sets up a GA problem for which a solution has the given number of (uniform, same range) parameters.

Parameters
[in]nparamnumber of parameters (aka genes in the chromosome)
[in]itvala half-open interval (the value of each parameter falls within this range)

The typical solution of a combinatorial problem can often be represented as a sequence of integers in a given range (and this is the raison d'etre of this constructor).

◆ problem() [2/2]

ultra::ga::problem::problem ( const std::vector< interval< int > > & intervals)
explicit

Sets up a GA problem for which a solution has the given number of (uniform but not same range) parameters.

Parameters
[in]intervalsa sequence of half-open intervals (one for each parameter)

This is a more flexible form of the other constructor. Each parameter has its own range.

Member Function Documentation

◆ insert()

template<symbol_set::weight_t W>
integer * ultra::ga::problem::insert ( const interval< int > & itval,
symbol::category_t category = symbol::undefined_category )

Adds a ga::integer terminal to the internal symbol set.

Parameters
[in]itvalthe half open interval for the integer terminal
[in]categoryan optional category
Returns
a raw pointer to the symbol just added (or nullptr in case of error)

◆ parameters()

std::size_t ultra::ga::problem::parameters ( ) const
nodiscardnoexcept
Returns
genome size / number of parameters / elements in the container

The documentation for this class was generated from the following files: