use crate::config::defaults;
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct PerceptronConfig {
#[serde(default = "PerceptronConfig::default_history")]
pub history_length: usize,
#[serde(default = "PerceptronConfig::default_table_bits")]
pub table_bits: usize,
}
impl Default for PerceptronConfig {
fn default() -> Self {
Self { history_length: Self::default_history(), table_bits: Self::default_table_bits() }
}
}
impl PerceptronConfig {
const fn default_history() -> usize {
defaults::PERCEPTRON_HISTORY
}
const fn default_table_bits() -> usize {
defaults::PERCEPTRON_TABLE_BITS
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct TournamentConfig {
#[serde(default = "TournamentConfig::default_global")]
pub global_size_bits: usize,
#[serde(default = "TournamentConfig::default_local_hist")]
pub local_hist_bits: usize,
#[serde(default = "TournamentConfig::default_local_pred")]
pub local_pred_bits: usize,
}
impl Default for TournamentConfig {
fn default() -> Self {
Self {
global_size_bits: Self::default_global(),
local_hist_bits: Self::default_local_hist(),
local_pred_bits: Self::default_local_pred(),
}
}
}
impl TournamentConfig {
const fn default_global() -> usize {
defaults::TOURNAMENT_GLOBAL_BITS
}
const fn default_local_hist() -> usize {
defaults::TOURNAMENT_LOCAL_HIST_BITS
}
const fn default_local_pred() -> usize {
defaults::TOURNAMENT_LOCAL_PRED_BITS
}
}