Skip to main content

SolverConfig

Struct SolverConfig 

Source
#[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 iterations
  • learning_rate: Step size for gradient updates
  • momentum: Momentum coefficient for velocity accumulation
  • discretize_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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§max_iterations: u32

Maximum 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: f32

Learning 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: f32

Momentum 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: f32

Threshold 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

Source

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 iterations
  • learning_rate - Step size for gradient updates
  • momentum - Momentum coefficient
  • discretize_threshold - Threshold for boolean conversion
Source

pub const fn fast() -> Self

Creates a configuration optimized for fast convergence on small instances.

Uses higher learning rate and fewer iterations.

Source

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.

Source

pub const fn with_max_iterations(self, max_iterations: u32) -> Self

Sets the maximum iterations, consuming and returning self.

Source

pub const fn with_learning_rate(self, learning_rate: f32) -> Self

Sets the learning rate, consuming and returning self.

Source

pub const fn with_momentum(self, momentum: f32) -> Self

Sets the momentum, consuming and returning self.

Source

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

Source§

fn clone(&self) -> SolverConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SolverConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SolverConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for SolverConfig

Source§

fn eq(&self, other: &SolverConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for SolverConfig

Source§

impl StructuralPartialEq for SolverConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,