Skip to main content

SearchConfig

Struct SearchConfig 

Source
pub struct SearchConfig {
Show 21 fields pub target: f64, pub max_matches: usize, pub max_error: f64, pub stop_at_exact: bool, pub stop_below: Option<f64>, pub zero_value_threshold: f64, pub newton_iterations: usize, pub user_constants: Vec<UserConstant>, pub user_functions: Vec<UserFunction>, pub trig_argument_scale: f64, pub refine_with_newton: bool, pub rhs_allowed_symbols: Option<HashSet<u8>>, pub rhs_excluded_symbols: Option<HashSet<u8>>, pub show_newton: bool, pub show_match_checks: bool, pub show_pruned_arith: bool, pub show_pruned_range: bool, pub show_db_adds: bool, pub match_all_digits: bool, pub derivative_margin: f64, pub ranking_mode: RankingMode,
}
Expand description

Configuration for the search process.

Controls matching thresholds, result limits, symbol filtering, and search behavior. This struct is the main entry point for customizing how RIES searches for equations.

§Example

use ries_rs::search::SearchConfig;
use ries_rs::pool::RankingMode;

let config = SearchConfig {
    target: std::f64::consts::PI,
    max_matches: 50,
    max_error: 1e-10,
    stop_at_exact: true,
    ranking_mode: RankingMode::Complexity,
    ..SearchConfig::default()
};

§Fields Overview

  • Target: target - the value to search for equations matching it
  • Limits: max_matches, max_error - control result quantity and quality
  • Stopping: stop_at_exact, stop_below - early termination conditions
  • Refinement: newton_iterations, refine_with_newton, derivative_margin - Newton-Raphson settings
  • Filtering: zero_value_threshold, rhs_allowed_symbols, rhs_excluded_symbols - prune unwanted results
  • Extensions: user_constants, user_functions - custom symbols
  • Diagnostics: show_newton, show_match_checks, etc. - debug output
  • Ranking: ranking_mode - how to order results

Fields§

§target: f64

Target value to find equations for.

The search will find equations where LHS ≈ RHS ≈ target. This is the number you’re trying to “solve” or represent symbolically.

Default: 0.0

§max_matches: usize

Maximum number of matches to return in results.

Once this many matches are found and confirmed, the pool will start evicting lower-quality matches to make room for better ones.

Default: 100

§max_error: f64

Maximum acceptable error for a match to be included.

Only expressions within this absolute error from the target are considered matches. Smaller values give more precise but fewer results.

Default: 1.0

§stop_at_exact: bool

Stop search when an exact match is found.

When true and an expression matches within the exact match tolerance, the search terminates early. Useful when you only need one good solution.

Default: false

§stop_below: Option<f64>

Stop search when error goes below this threshold.

If set, the search will terminate once a match is found with error below this value. Set to Some(1e-12) for high-precision early stopping.

Default: None

§zero_value_threshold: f64

Threshold for pruning LHS expressions with near-zero values.

LHS expressions with absolute values below this threshold are pruned to prevent flooding results with trivial matches like cospi(2.5) = 0. Set to 0.0 to disable this filtering.

Default: 1e-4

§newton_iterations: usize

Maximum Newton-Raphson iterations for root refinement.

Controls how many iterations are used to refine candidate solutions. Higher values may find more precise roots but take longer.

Default: 15

§user_constants: Vec<UserConstant>

User-defined constants for evaluation.

Custom constants that can be used in expressions, defined via -N\'name=value\'. Each constant has a name, value, and optional description.

Default: empty

§user_functions: Vec<UserFunction>

User-defined functions for evaluation.

Custom functions that can be used in expressions, defined via -F\'name:formula\'. These extend the built-in functions (sin, cos, etc.).

Default: empty

§trig_argument_scale: f64

Argument scale for sinpi/cospi/tanpi evaluation.

The default is π, matching original sinpi(x) = sin(πx) semantics. Override this for alternate trig conventions without relying on global state.

§refine_with_newton: bool

Whether to refine candidate roots with Newton-Raphson iteration.

When true, initial coarse matches are refined using Newton-Raphson to find more precise solutions. Disable for faster but less precise search.

Default: true

§rhs_allowed_symbols: Option<HashSet<u8>>

Optional RHS-only allowed symbol set.

If set, all symbols used on the RHS must be in this set (specified as ASCII bytes). This allows restricting RHS expressions to a subset of available symbols. Combined with rhs_excluded_symbols, both filters apply.

Default: None (all symbols allowed)

§rhs_excluded_symbols: Option<HashSet<u8>>

Optional RHS-only excluded symbol set.

If set, RHS expressions using any of these symbols are rejected. This allows excluding specific symbols from RHS expressions. Combined with rhs_allowed_symbols, both filters apply.

Default: None (no symbols excluded)

§show_newton: bool

Show Newton-Raphson iteration diagnostic output.

When true, prints detailed information about each Newton-Raphson iteration. Enabled by -Dn command-line flag. Useful for debugging convergence issues.

Default: false

§show_match_checks: bool

Show match check diagnostic output.

When true, prints information about each candidate match evaluation. Enabled by -Do command-line flag.

Default: false

§show_pruned_arith: bool

Show pruned arithmetic diagnostic output.

When true, prints information about arithmetic expressions that were pruned. Enabled by -DA command-line flag.

Default: false

§show_pruned_range: bool

Show pruned range/zero diagnostic output.

When true, prints information about expressions pruned due to range constraints or near-zero values. Enabled by -DB command-line flag.

Default: false

§show_db_adds: bool

Show database adds diagnostic output.

When true, prints information about expressions added to the database. Enabled by -DG command-line flag.

Default: false

§match_all_digits: bool

When true, matches must match all significant digits of the target.

When enabled, the tolerance is computed based on the magnitude of the target value to require full precision matching. The actual tolerance is computed in main.rs and passed as max_error.

Default: false

§derivative_margin: f64

Threshold below which derivative is considered degenerate in Newton-Raphson.

If |derivative| < derivative_margin during Newton-Raphson iteration, the refinement is skipped to avoid numerical instability and division by near-zero values.

Default: 1e-12 (from DEGENERATE_DERIVATIVE constant)

§ranking_mode: RankingMode

Ranking mode for pool ordering and eviction.

Determines how matches are ranked in the result pool:

  • Complexity: Sort by expression complexity (simpler is better)
  • Error: Sort by match error (more precise is better)

Default: RankingMode::Complexity

Implementations§

Source§

impl SearchConfig

Source

pub fn context(&self) -> SearchContext<'_>

Build an explicit search context for this configuration.

Trait Implementations§

Source§

impl Clone for SearchConfig

Source§

fn clone(&self) -> SearchConfig

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 SearchConfig

Source§

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

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

impl Default for SearchConfig

Source§

fn default() -> Self

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.