pub struct BestProgram<C> { /* private fields */ }Implementations§
Source§impl<C> BestProgram<C>
impl<C> BestProgram<C>
pub fn new(cost_fn: C, root: Id) -> Selfwhere
C: Clone + 'static,
Sourcepub fn new_with(cost_fn: impl Fn() -> C + 'static, root: Id) -> Self
pub fn new_with(cost_fn: impl Fn() -> C + 'static, root: Id) -> Self
Examples found in repository?
examples/simple.rs (line 63)
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}pub fn with_rebuild(self, rebuild: bool) -> Self
Trait Implementations§
Source§impl<L, N, C> Recorder<L, N> for BestProgram<C>
impl<L, N, C> Recorder<L, N> for BestProgram<C>
fn identifier(&self) -> Cow<'static, str>
fn record_before_rewrite( &self, _iteration: usize, egraph: &mut EGraph<L, N>, _rewrite: &Rewrite<L, N>, _matches: &[SearchMatches<'_, L>], ) -> Option<String>
fn record_after_rewrite( &self, _iteration: usize, egraph: &mut EGraph<L, N>, _rewrite: &Rewrite<L, N>, _n_matches: usize, ) -> Option<String>
fn record_before_search<'r>( &self, iteration: usize, egraph: &'r EGraph<L, N>, rewrite: &'r Rewrite<L, N>, ) -> Option<String>
fn record_after_search<'r>( &self, iteration: usize, egraph: &'r EGraph<L, N>, rewrite: &'r Rewrite<L, N>, matches: &[SearchMatches<'_, L>], ) -> Option<String>
Auto Trait Implementations§
impl<C> Freeze for BestProgram<C>
impl<C> !RefUnwindSafe for BestProgram<C>
impl<C> !Send for BestProgram<C>
impl<C> !Sync for BestProgram<C>
impl<C> Unpin for BestProgram<C>
impl<C> !UnwindSafe for BestProgram<C>
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