pub struct LoggingScheduler<'a, S, L, N> { /* private fields */ }Implementations§
source§impl<'a, S, L, N> LoggingScheduler<'a, S, L, N>
impl<'a, S, L, N> LoggingScheduler<'a, S, L, N>
pub fn new(scheduler: S) -> Self
pub fn with_identifier(self, id: impl ToString) -> Self
sourcepub fn with_out_file<W: Write + 'a>(self, out_file: W) -> Self
pub fn with_out_file<W: Write + 'a>(self, out_file: W) -> Self
Examples found in repository?
examples/simple.rs (lines 51-58)
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
fn simplify_with(
s: &str,
scheduler: impl RewriteScheduler<SimpleLanguage, ()> + 'static,
path: impl AsRef<Path>,
) {
// parse the expression, the type annotation tells it which Language to use
let expr: RecExpr<SimpleLanguage> = s.parse().unwrap();
let mut egraph = EGraph::new(());
let root = egraph.add_expr(&expr);
// simplify the expression using a Runner, which creates an e-graph with
// the given expression and runs the given rules over it
Runner::default()
.with_scheduler(
LoggingScheduler::from(scheduler)
.with_out_file(
OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(path.as_ref())
.unwrap(),
)
.with_logging_enabled(true)
.with_recorder(recorders::Timestamp::new(Instant::now()))
.with_recorder(recorders::NumberENodes)
.with_recorder(recorders::NumberEClasses)
.with_recorder(recorders::BestProgram::new_with(|| AstSize, root)),
)
.with_egraph(egraph)
.run(&make_rules());
println!("Wrote {:?}", path.as_ref());
}sourcepub fn with_logging_enabled(self, enabled: bool) -> Self
pub fn with_logging_enabled(self, enabled: bool) -> Self
Examples found in repository?
examples/simple.rs (line 59)
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
fn simplify_with(
s: &str,
scheduler: impl RewriteScheduler<SimpleLanguage, ()> + 'static,
path: impl AsRef<Path>,
) {
// parse the expression, the type annotation tells it which Language to use
let expr: RecExpr<SimpleLanguage> = s.parse().unwrap();
let mut egraph = EGraph::new(());
let root = egraph.add_expr(&expr);
// simplify the expression using a Runner, which creates an e-graph with
// the given expression and runs the given rules over it
Runner::default()
.with_scheduler(
LoggingScheduler::from(scheduler)
.with_out_file(
OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(path.as_ref())
.unwrap(),
)
.with_logging_enabled(true)
.with_recorder(recorders::Timestamp::new(Instant::now()))
.with_recorder(recorders::NumberENodes)
.with_recorder(recorders::NumberEClasses)
.with_recorder(recorders::BestProgram::new_with(|| AstSize, root)),
)
.with_egraph(egraph)
.run(&make_rules());
println!("Wrote {:?}", path.as_ref());
}sourcepub fn with_recorder<D: Recorder<L, N> + 'a>(self, datum: D) -> Self
pub fn with_recorder<D: Recorder<L, N> + 'a>(self, datum: D) -> Self
Examples found in repository?
examples/simple.rs (line 60)
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
fn simplify_with(
s: &str,
scheduler: impl RewriteScheduler<SimpleLanguage, ()> + 'static,
path: impl AsRef<Path>,
) {
// parse the expression, the type annotation tells it which Language to use
let expr: RecExpr<SimpleLanguage> = s.parse().unwrap();
let mut egraph = EGraph::new(());
let root = egraph.add_expr(&expr);
// simplify the expression using a Runner, which creates an e-graph with
// the given expression and runs the given rules over it
Runner::default()
.with_scheduler(
LoggingScheduler::from(scheduler)
.with_out_file(
OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(path.as_ref())
.unwrap(),
)
.with_logging_enabled(true)
.with_recorder(recorders::Timestamp::new(Instant::now()))
.with_recorder(recorders::NumberENodes)
.with_recorder(recorders::NumberEClasses)
.with_recorder(recorders::BestProgram::new_with(|| AstSize, root)),
)
.with_egraph(egraph)
.run(&make_rules());
println!("Wrote {:?}", path.as_ref());
}pub fn identifier(&mut self, id: impl ToString) -> &mut Self
pub fn out_file(&mut self, out_file: impl Write + 'a) -> &mut Self
pub fn logging_enabled(&mut self, enabled: bool) -> &mut Self
pub fn record<D: Recorder<L, N> + 'a>(&mut self, datum: D) -> &mut Self
Trait Implementations§
source§impl<'a, S, L, N> From<S> for LoggingScheduler<'a, S, L, N>
impl<'a, S, L, N> From<S> for LoggingScheduler<'a, S, L, N>
source§impl<'a, S, L, N> RewriteScheduler<L, N> for LoggingScheduler<'a, S, L, N>
impl<'a, S, L, N> RewriteScheduler<L, N> for LoggingScheduler<'a, S, L, N>
source§fn search_rewrite<'s>(
&mut self,
iteration: usize,
egraph: &EGraph<L, N>,
rewrite: &'s Rewrite<L, N>,
) -> Vec<SearchMatches<'s, L>>
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
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>
impl<'a, S, L, N> !UnwindSafe for LoggingScheduler<'a, S, L, N>
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
Mutably borrows from an owned value. Read more