Struct LoggingScheduler

Source
pub struct LoggingScheduler<'a, S, L, N> { /* private fields */ }

Implementations§

Source§

impl<'a, S, L, N> LoggingScheduler<'a, S, L, N>

Source

pub fn new(scheduler: S) -> Self

Source

pub fn with_identifier(self, id: impl ToString) -> Self

Source

pub fn with_out_file<W: Write + 'a>(self, out_file: W) -> Self

Examples found in repository?
examples/simple.rs (lines 51-58)
35fn simplify_with(
36    s: &str,
37    scheduler: impl RewriteScheduler<SimpleLanguage, ()> + 'static,
38    path: impl AsRef<Path>,
39) {
40    // parse the expression, the type annotation tells it which Language to use
41    let expr: RecExpr<SimpleLanguage> = s.parse().unwrap();
42
43    let mut egraph = EGraph::new(());
44    let root = egraph.add_expr(&expr);
45
46    // simplify the expression using a Runner, which creates an e-graph with
47    // the given expression and runs the given rules over it
48    Runner::default()
49        .with_scheduler(
50            LoggingScheduler::from(scheduler)
51                .with_out_file(
52                    OpenOptions::new()
53                        .write(true)
54                        .create(true)
55                        .truncate(true)
56                        .open(path.as_ref())
57                        .unwrap(),
58                )
59                .with_logging_enabled(true)
60                .with_recorder(recorders::Timestamp::new(Instant::now()))
61                .with_recorder(recorders::NumberENodes)
62                .with_recorder(recorders::NumberEClasses)
63                .with_recorder(recorders::BestProgram::new_with(|| AstSize, root)),
64        )
65        .with_egraph(egraph)
66        .run(&make_rules());
67
68    println!("Wrote {:?}", path.as_ref());
69}
Source

pub fn with_logging_enabled(self, enabled: bool) -> Self

Examples found in repository?
examples/simple.rs (line 59)
35fn simplify_with(
36    s: &str,
37    scheduler: impl RewriteScheduler<SimpleLanguage, ()> + 'static,
38    path: impl AsRef<Path>,
39) {
40    // parse the expression, the type annotation tells it which Language to use
41    let expr: RecExpr<SimpleLanguage> = s.parse().unwrap();
42
43    let mut egraph = EGraph::new(());
44    let root = egraph.add_expr(&expr);
45
46    // simplify the expression using a Runner, which creates an e-graph with
47    // the given expression and runs the given rules over it
48    Runner::default()
49        .with_scheduler(
50            LoggingScheduler::from(scheduler)
51                .with_out_file(
52                    OpenOptions::new()
53                        .write(true)
54                        .create(true)
55                        .truncate(true)
56                        .open(path.as_ref())
57                        .unwrap(),
58                )
59                .with_logging_enabled(true)
60                .with_recorder(recorders::Timestamp::new(Instant::now()))
61                .with_recorder(recorders::NumberENodes)
62                .with_recorder(recorders::NumberEClasses)
63                .with_recorder(recorders::BestProgram::new_with(|| AstSize, root)),
64        )
65        .with_egraph(egraph)
66        .run(&make_rules());
67
68    println!("Wrote {:?}", path.as_ref());
69}
Source

pub fn with_recorder<D: Recorder<L, N> + 'a>(self, datum: D) -> Self
where L: Language, N: Analysis<L>,

Examples found in repository?
examples/simple.rs (line 60)
35fn simplify_with(
36    s: &str,
37    scheduler: impl RewriteScheduler<SimpleLanguage, ()> + 'static,
38    path: impl AsRef<Path>,
39) {
40    // parse the expression, the type annotation tells it which Language to use
41    let expr: RecExpr<SimpleLanguage> = s.parse().unwrap();
42
43    let mut egraph = EGraph::new(());
44    let root = egraph.add_expr(&expr);
45
46    // simplify the expression using a Runner, which creates an e-graph with
47    // the given expression and runs the given rules over it
48    Runner::default()
49        .with_scheduler(
50            LoggingScheduler::from(scheduler)
51                .with_out_file(
52                    OpenOptions::new()
53                        .write(true)
54                        .create(true)
55                        .truncate(true)
56                        .open(path.as_ref())
57                        .unwrap(),
58                )
59                .with_logging_enabled(true)
60                .with_recorder(recorders::Timestamp::new(Instant::now()))
61                .with_recorder(recorders::NumberENodes)
62                .with_recorder(recorders::NumberEClasses)
63                .with_recorder(recorders::BestProgram::new_with(|| AstSize, root)),
64        )
65        .with_egraph(egraph)
66        .run(&make_rules());
67
68    println!("Wrote {:?}", path.as_ref());
69}
Source

pub fn identifier(&mut self, id: impl ToString) -> &mut Self

Source

pub fn out_file(&mut self, out_file: impl Write + 'a) -> &mut Self

Source

pub fn logging_enabled(&mut self, enabled: bool) -> &mut Self

Source

pub fn record<D: Recorder<L, N> + 'a>(&mut self, datum: D) -> &mut Self
where L: Language, N: Analysis<L>,

Trait Implementations§

Source§

impl<'a, S, L, N> From<S> for LoggingScheduler<'a, S, L, N>
where S: RewriteScheduler<L, N>, L: Language, N: Analysis<L>,

Source§

fn from(value: S) -> Self

Converts to this type from the input type.
Source§

impl<'a, S, L, N> RewriteScheduler<L, N> for LoggingScheduler<'a, S, L, N>
where S: RewriteScheduler<L, N>, L: Language + Display, N: Analysis<L>,

Source§

fn can_stop(&mut self, iteration: usize) -> bool

Whether or not the Runner is allowed to say it has saturated. Read more
Source§

fn search_rewrite<'s>( &mut self, iteration: usize, egraph: &EGraph<L, N>, rewrite: &'s Rewrite<L, N>, ) -> Vec<SearchMatches<'s, L>>

A hook allowing you to customize rewrite searching behavior. Useful to implement rule management. Read more
Source§

fn apply_rewrite( &mut self, iteration: usize, egraph: &mut EGraph<L, N>, rewrite: &Rewrite<L, N>, matches: Vec<SearchMatches<'_, L>>, ) -> usize

A hook allowing you to customize rewrite application behavior. Useful to implement rule management. Read more

Auto Trait Implementations§

§

impl<'a, S, L, N> Freeze for LoggingScheduler<'a, S, L, N>
where S: Freeze,

§

impl<'a, S, L, N> !RefUnwindSafe for LoggingScheduler<'a, S, L, N>

§

impl<'a, S, L, N> !Send for LoggingScheduler<'a, S, L, N>

§

impl<'a, S, L, N> !Sync for LoggingScheduler<'a, S, L, N>

§

impl<'a, S, L, N> Unpin for LoggingScheduler<'a, S, L, N>
where S: Unpin, L: Unpin, N: Unpin,

§

impl<'a, S, L, N> !UnwindSafe for LoggingScheduler<'a, S, L, N>

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> 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, 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.