Enable heuristic selection by default
This commit is contained in:
parent
0c0f35dc1a
commit
0fb389f2af
19
src/lib.rs
19
src/lib.rs
|
@ -16,7 +16,6 @@ use serde::{Deserialize, Serialize};
|
||||||
use serde_big_array::big_array;
|
use serde_big_array::big_array;
|
||||||
|
|
||||||
/// Parameters for building the `Hnsw`
|
/// Parameters for building the `Hnsw`
|
||||||
#[derive(Default)]
|
|
||||||
pub struct Builder {
|
pub struct Builder {
|
||||||
ef_search: Option<usize>,
|
ef_search: Option<usize>,
|
||||||
ef_construction: Option<usize>,
|
ef_construction: Option<usize>,
|
||||||
|
@ -43,8 +42,8 @@ impl Builder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn select_heuristic(mut self, params: Heuristic) -> Self {
|
pub fn select_heuristic(mut self, params: Option<Heuristic>) -> Self {
|
||||||
self.heuristic = Some(params);
|
self.heuristic = params;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +76,20 @@ impl Builder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Builder {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
ef_search: None,
|
||||||
|
ef_construction: None,
|
||||||
|
heuristic: Some(Heuristic::default()),
|
||||||
|
ml: None,
|
||||||
|
seed: None,
|
||||||
|
#[cfg(feature = "indicatif")]
|
||||||
|
progress: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct Heuristic {
|
pub struct Heuristic {
|
||||||
pub extend_candidates: bool,
|
pub extend_candidates: bool,
|
||||||
|
|
|
@ -25,14 +25,14 @@ fn basic() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn random_heuristic() {
|
fn random_heuristic() {
|
||||||
let (seed, recall) = randomized(Builder::default().select_heuristic(Heuristic::default()));
|
let (seed, recall) = randomized(Builder::default());
|
||||||
println!("heuristic (seed = {}) recall = {}", seed, recall);
|
println!("heuristic (seed = {}) recall = {}", seed, recall);
|
||||||
assert!(recall > 98, "expected at least 98, got {}", recall);
|
assert!(recall > 98, "expected at least 98, got {}", recall);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn random_simple() {
|
fn random_simple() {
|
||||||
let (seed, recall) = randomized(Builder::default());
|
let (seed, recall) = randomized(Builder::default().select_heuristic(None));
|
||||||
println!("simple (seed = {}) recall = {}", seed, recall);
|
println!("simple (seed = {}) recall = {}", seed, recall);
|
||||||
assert!(recall > 90, "expected at least 90, got {}", recall);
|
assert!(recall > 90, "expected at least 90, got {}", recall);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue