1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crate::core::*;
use std::collections::HashMap;
pub trait Approximator<I: ?Sized> {
type Value;
fn n_outputs(&self) -> usize;
fn evaluate(&self, input: &I) -> EvaluationResult<Self::Value>;
fn update(&mut self, input: &I, update: Self::Value) -> UpdateResult<()>;
#[allow(unused_variables)]
fn adapt(&mut self, new_features: &HashMap<IndexT, IndexSet>) -> AdaptResult<usize> {
unimplemented!()
}
}
impl<I: ?Sized, T: Approximator<I>> Approximator<I> for Box<T> {
type Value = T::Value;
fn n_outputs(&self) -> usize { (**self).n_outputs() }
fn evaluate(&self, input: &I) -> EvaluationResult<Self::Value> { (**self).evaluate(input) }
fn update(&mut self, input: &I, update: Self::Value) -> UpdateResult<()> {
(**self).update(input, update)
}
fn adapt(&mut self, new_features: &HashMap<IndexT, IndexSet>) -> AdaptResult<usize> {
(**self).adapt(new_features)
}
}