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)
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 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