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: f64Target 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: usizeMaximum 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: f64Maximum 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: boolStop 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: f64Threshold 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: usizeMaximum 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: f64Argument 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: boolWhether 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: boolShow 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: boolShow match check diagnostic output.
When true, prints information about each candidate match evaluation.
Enabled by -Do command-line flag.
Default: false
show_pruned_arith: boolShow 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: boolShow 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: boolShow 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: boolWhen 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: f64Threshold 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: RankingModeRanking 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
impl SearchConfig
Sourcepub fn context(&self) -> SearchContext<'_>
pub fn context(&self) -> SearchContext<'_>
Build an explicit search context for this configuration.
Trait Implementations§
Source§impl Clone for SearchConfig
impl Clone for SearchConfig
Source§fn clone(&self) -> SearchConfig
fn clone(&self) -> SearchConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SearchConfig
impl Debug for SearchConfig
Auto Trait Implementations§
impl Freeze for SearchConfig
impl RefUnwindSafe for SearchConfig
impl Send for SearchConfig
impl Sync for SearchConfig
impl Unpin for SearchConfig
impl UnsafeUnpin for SearchConfig
impl UnwindSafe for SearchConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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