Struct programinduction::domains::strings::Evaluator
source · pub struct Evaluator;
Expand description
An Evaluator
for the strings domain.
Examples
use polytype::{ptp, tp};
use programinduction::domains::strings;
use programinduction::{lambda, ECParams, EC};
let dsl = strings::dsl();
let examples = vec![
// Replace delimiter '>' with '/'
(
vec![strings::Space::Str("OFJQc>BLVP>eMS".to_string())],
strings::Space::Str("OFJQc/BLVP/eMS".to_string()),
),
];
let task = lambda::task_by_evaluation(
strings::Evaluator,
ptp!(@arrow[tp!(str), tp!(str)]),
&examples,
);
let ec_params = ECParams {
frontier_limit: 10,
search_limit_timeout: None,
search_limit_description_length: Some(12.0),
};
let frontiers = dsl.explore(&ec_params, &[task]);
let solution = &frontiers[0].best_solution().unwrap().0;
assert_eq!(
"(λ (join (char->str /) (split > $0)))",
dsl.display(solution)
);
Trait Implementations§
source§impl Evaluator for Evaluator
impl Evaluator for Evaluator
§type Space = Space
type Space = Space
The value space of a domain. The inputs of every primitive and the result of every
evaluation must be of this type.
fn evaluate( &self, name: &str, inps: &[Self::Space] ) -> Result<Self::Space, Self::Error>
fn lift(&self, f: LiftedFunction<Self::Space, Self>) -> Option<Self::Space>
impl Copy for Evaluator
Auto Trait Implementations§
impl RefUnwindSafe for Evaluator
impl Send for Evaluator
impl Sync for Evaluator
impl Unpin for Evaluator
impl UnwindSafe for Evaluator
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