#[non_exhaustive]pub struct SolverConfig {
pub max_iterations: u32,
pub learning_rate: f32,
pub momentum: f32,
pub discretize_threshold: f32,
}Expand description
Configuration parameters for the CLS solver.
These parameters control the behavior of the continuous local search algorithm:
max_iterations: Maximum number of gradient descent iterationslearning_rate: Step size for gradient updatesmomentum: Momentum coefficient for velocity accumulationdiscretize_threshold: Threshold for converting continuous values to boolean
§Default Values
use xlog_solve::SolverConfig;
let config = SolverConfig::default();
assert_eq!(config.max_iterations, 10000);
assert_eq!(config.learning_rate, 0.1);
assert_eq!(config.momentum, 0.9);
assert_eq!(config.discretize_threshold, 0.5);§Example
use xlog_solve::SolverConfig;
let mut config = SolverConfig::default();
config.max_iterations = 5000;
config.learning_rate = 0.05;
config.momentum = 0.95;
config.discretize_threshold = 0.5;Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_iterations: u32Maximum number of iterations before giving up.
The solver will terminate and return the best-effort result if this limit is reached without finding a satisfying assignment.
learning_rate: f32Learning rate for gradient descent updates.
Controls the step size when updating variable assignments. Larger values lead to faster convergence but may overshoot. Typical values are in the range [0.01, 0.5].
momentum: f32Momentum coefficient for velocity accumulation.
Controls how much of the previous velocity is retained. Helps escape local minima and smooths the optimization trajectory. Values close to 1.0 give more weight to history. Typical values are in the range [0.8, 0.99].
discretize_threshold: f32Threshold for discretizing continuous values to boolean.
Values >= threshold become true, values < threshold become false.
The standard value is 0.5 for symmetric treatment.
Implementations§
Source§impl SolverConfig
impl SolverConfig
Sourcepub const fn new(
max_iterations: u32,
learning_rate: f32,
momentum: f32,
discretize_threshold: f32,
) -> Self
pub const fn new( max_iterations: u32, learning_rate: f32, momentum: f32, discretize_threshold: f32, ) -> Self
Creates a new configuration with specified parameters.
§Arguments
max_iterations- Maximum number of iterationslearning_rate- Step size for gradient updatesmomentum- Momentum coefficientdiscretize_threshold- Threshold for boolean conversion
Sourcepub const fn fast() -> Self
pub const fn fast() -> Self
Creates a configuration optimized for fast convergence on small instances.
Uses higher learning rate and fewer iterations.
Sourcepub const fn thorough() -> Self
pub const fn thorough() -> Self
Creates a configuration optimized for thorough search on hard instances.
Uses more iterations and lower learning rate for better exploration.
Sourcepub const fn with_max_iterations(self, max_iterations: u32) -> Self
pub const fn with_max_iterations(self, max_iterations: u32) -> Self
Sets the maximum iterations, consuming and returning self.
Sourcepub const fn with_learning_rate(self, learning_rate: f32) -> Self
pub const fn with_learning_rate(self, learning_rate: f32) -> Self
Sets the learning rate, consuming and returning self.
Sourcepub const fn with_momentum(self, momentum: f32) -> Self
pub const fn with_momentum(self, momentum: f32) -> Self
Sets the momentum, consuming and returning self.
Sourcepub const fn with_discretize_threshold(self, threshold: f32) -> Self
pub const fn with_discretize_threshold(self, threshold: f32) -> Self
Sets the discretize threshold, consuming and returning self.
Trait Implementations§
Source§impl Clone for SolverConfig
impl Clone for SolverConfig
Source§fn clone(&self) -> SolverConfig
fn clone(&self) -> SolverConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more