pub struct SolverConfig {
pub environment_mode: EnvironmentMode,
pub random_seed: Option<u64>,
pub move_thread_count: MoveThreadCount,
pub termination: Option<TerminationConfig>,
pub score_director: Option<ScoreDirectorConfig>,
pub phases: Vec<PhaseConfig>,
}Expand description
Main solver configuration.
Fields§
§environment_mode: EnvironmentModeEnvironment mode affecting reproducibility and assertions.
random_seed: Option<u64>Random seed for reproducible results.
move_thread_count: MoveThreadCountNumber of threads for parallel move evaluation.
termination: Option<TerminationConfig>Termination configuration.
score_director: Option<ScoreDirectorConfig>Score director configuration.
phases: Vec<PhaseConfig>Phase configurations.
Implementations§
Source§impl SolverConfig
impl SolverConfig
Sourcepub fn load(path: impl AsRef<Path>) -> Result<Self, ConfigError>
pub fn load(path: impl AsRef<Path>) -> Result<Self, ConfigError>
Loads configuration from a TOML file.
§Errors
Returns error if file doesn’t exist or contains invalid TOML.
Sourcepub fn from_toml_file(path: impl AsRef<Path>) -> Result<Self, ConfigError>
pub fn from_toml_file(path: impl AsRef<Path>) -> Result<Self, ConfigError>
Loads configuration from a TOML file.
Sourcepub fn from_toml_str(s: &str) -> Result<Self, ConfigError>
pub fn from_toml_str(s: &str) -> Result<Self, ConfigError>
Parses configuration from a TOML string.
Sourcepub fn from_yaml_file(path: impl AsRef<Path>) -> Result<Self, ConfigError>
pub fn from_yaml_file(path: impl AsRef<Path>) -> Result<Self, ConfigError>
Loads configuration from a YAML file.
Sourcepub fn from_yaml_str(s: &str) -> Result<Self, ConfigError>
pub fn from_yaml_str(s: &str) -> Result<Self, ConfigError>
Parses configuration from a YAML string.
Sourcepub fn with_termination_seconds(self, seconds: u64) -> Self
pub fn with_termination_seconds(self, seconds: u64) -> Self
Sets the termination time limit.
Sourcepub fn with_random_seed(self, seed: u64) -> Self
pub fn with_random_seed(self, seed: u64) -> Self
Sets the random seed.
Sourcepub fn with_phase(self, phase: PhaseConfig) -> Self
pub fn with_phase(self, phase: PhaseConfig) -> Self
Adds a phase configuration.
Sourcepub fn time_limit(&self) -> Option<Duration>
pub fn time_limit(&self) -> Option<Duration>
Returns the termination time limit, if configured.
Convenience method that delegates to termination.time_limit().
§Examples
use solverforge_config::SolverConfig;
use std::time::Duration;
let config = SolverConfig::from_toml_str(r#"
[termination]
seconds_spent_limit = 30
"#).unwrap();
assert_eq!(config.time_limit(), Some(Duration::from_secs(30)));Trait Implementations§
Source§impl Clone for SolverConfig
impl Clone for SolverConfig
Source§fn clone(&self) -> SolverConfig
fn clone(&self) -> SolverConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SolverConfig
impl Debug for SolverConfig
Source§impl Default for SolverConfig
impl Default for SolverConfig
Source§fn default() -> SolverConfig
fn default() -> SolverConfig
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for SolverConfig
impl<'de> Deserialize<'de> for SolverConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SolverConfig
impl RefUnwindSafe for SolverConfig
impl Send for SolverConfig
impl Sync for SolverConfig
impl Unpin for SolverConfig
impl UnwindSafe for SolverConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more