pub struct GenConfig {Show 18 fields
pub max_lhs_complexity: u32,
pub max_rhs_complexity: u32,
pub max_length: usize,
pub constants: Vec<Symbol>,
pub unary_ops: Vec<Symbol>,
pub binary_ops: Vec<Symbol>,
pub rhs_constants: Option<Vec<Symbol>>,
pub rhs_unary_ops: Option<Vec<Symbol>>,
pub rhs_binary_ops: Option<Vec<Symbol>>,
pub symbol_max_counts: HashMap<Symbol, u32>,
pub rhs_symbol_max_counts: Option<HashMap<Symbol, u32>>,
pub min_num_type: NumType,
pub generate_lhs: bool,
pub generate_rhs: bool,
pub user_constants: Vec<UserConstant>,
pub user_functions: Vec<UserFunction>,
pub show_pruned_arith: bool,
pub symbol_table: Arc<SymbolTable>,
}Expand description
Configuration for expression generation
Controls which symbols are available, complexity limits, and various generation options for creating candidate expressions that may solve a given equation.
§Architecture
Expressions are generated in two categories:
- LHS (Left-Hand Side): Expressions containing
x, representing functions likef(x) - RHS (Right-Hand Side): Constant expressions not containing
x, likeπ²orsqrt(2)
The generator creates all valid expressions up to the configured complexity limits,
then the solver finds pairs where LHS(target) ≈ RHS.
§Example
use ries_rs::gen::GenConfig;
use ries_rs::symbol::Symbol;
use std::collections::HashMap;
let config = GenConfig {
max_lhs_complexity: 50,
max_rhs_complexity: 30,
max_length: 12,
constants: vec![Symbol::One, Symbol::Two, Symbol::Pi, Symbol::E],
unary_ops: vec![Symbol::Neg, Symbol::Sqrt, Symbol::Square],
binary_ops: vec![Symbol::Add, Symbol::Sub, Symbol::Mul, Symbol::Div],
..GenConfig::default()
};Fields§
§max_lhs_complexity: u32Maximum complexity score for left-hand-side expressions.
LHS expressions contain x and represent the function side of equations.
Higher values allow more complex expressions (e.g., sin(x) + x²), but
exponentially increase search time and memory usage.
Default: 128 (allows fairly complex expressions)
max_rhs_complexity: u32Maximum complexity score for right-hand-side expressions.
RHS expressions are constants not containing x. Since they don’t need
to be solved for, they can typically use lower complexity limits than LHS.
Default: 128
max_length: usizeMaximum number of symbols in a single expression.
This is a hard limit on expression length regardless of complexity score. Prevents pathological cases with many low-complexity symbols.
Default: MAX_EXPR_LEN (255)
constants: Vec<Symbol>Symbols available for constants and variables (Seft::A type).
These push a value onto the expression stack. Typically includes:
One,Two,Three, etc. (numeric constants)Pi,E(mathematical constants)X(the variable to solve for)
Default: All built-in constants from Symbol::constants()
unary_ops: Vec<Symbol>Symbols available for unary operations (Seft::B type).
These transform a single value: f(a). Includes operations like:
Neg(negation:-a)Sqrt,Square(powers and roots)SinPi,CosPi(trigonometric functions)Ln,Exp(logarithmic and exponential)Recip(reciprocal:1/a)
Default: All built-in unary operators from Symbol::unary_ops()
binary_ops: Vec<Symbol>Symbols available for binary operations (Seft::C type).
These combine two values: f(a, b). Includes operations like:
Add,Sub,Mul,Div(arithmetic)Pow,Root,Log(power functions and logarithms)
Default: All built-in binary operators from Symbol::binary_ops()
rhs_constants: Option<Vec<Symbol>>Optional override for RHS-only constant symbols.
When set, RHS expressions use these symbols instead of constants.
Useful for generating LHS with more symbols but keeping RHS simple.
Default: None (use constants for both LHS and RHS)
rhs_unary_ops: Option<Vec<Symbol>>Optional override for RHS-only unary operators.
When set, RHS expressions use these operators instead of unary_ops.
Example: allow Lambert W in LHS only, exclude from RHS constants.
Default: None (use unary_ops for both LHS and RHS)
rhs_binary_ops: Option<Vec<Symbol>>Optional override for RHS-only binary operators.
When set, RHS expressions use these operators instead of binary_ops.
Default: None (use binary_ops for both LHS and RHS)
symbol_max_counts: HashMap<Symbol, u32>Maximum usage count per symbol within a single expression.
Maps each symbol to the maximum number of times it can appear.
Useful for limiting redundancy (e.g., max 2 uses of Pi).
Corresponds to the -O command-line option.
Default: Empty (no limits)
rhs_symbol_max_counts: Option<HashMap<Symbol, u32>>Optional RHS-only symbol count limits.
When set, applies different symbol count limits to RHS expressions.
Corresponds to the --O-RHS command-line option.
Default: None (use symbol_max_counts for both)
min_num_type: NumTypeMinimum numeric type required for generated expressions.
Filters expressions by the “sophistication” of numbers they produce:
Integer: Only integer resultsRational: Rational numbers (fractions)Algebraic: Algebraic numbers (roots of polynomials)Transcendental: Any real number (including π, e, trig)
Lower values restrict output to simpler mathematical constructs.
Default: NumType::Transcendental (accept all)
generate_lhs: boolWhether to generate LHS expressions containing x.
Set to false if you only need constant RHS expressions.
Can significantly reduce generation time when LHS is not needed.
Default: true
generate_rhs: boolWhether to generate RHS constant expressions.
Set to false if you only need LHS expressions.
Useful for specific analysis tasks.
Default: true
user_constants: Vec<UserConstant>User-defined constants for custom searches.
These constants are available during expression evaluation,
allowing searches involving domain-specific values.
Defined via -N command-line option.
Default: Empty
user_functions: Vec<UserFunction>User-defined functions for custom searches.
Custom functions that can appear in generated expressions,
extending the available operations beyond built-in symbols.
Defined via -F command-line option.
Default: Empty
show_pruned_arith: boolEnable diagnostic output for arithmetic pruning.
When true, prints information about expressions that were
discarded due to arithmetic errors (overflow, domain errors, etc.).
Useful for debugging generation behavior.
Default: false
symbol_table: Arc<SymbolTable>Symbol table with weights and display names.
Provides complexity weights for each symbol and custom display names. Weights control how “expensive” each symbol is toward the complexity limit.
Default: Empty table (uses built-in default weights)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GenConfig
impl RefUnwindSafe for GenConfig
impl Send for GenConfig
impl Sync for GenConfig
impl Unpin for GenConfig
impl UnsafeUnpin for GenConfig
impl UnwindSafe for GenConfig
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