pub struct HiveBuilder<Ctx: Context> { /* private fields */ }
Expand description
Manages the parameters of the ABC algorithm.
Implementations§
Source§impl<Ctx: Context> HiveBuilder<Ctx>
impl<Ctx: Context> HiveBuilder<Ctx>
Sourcepub fn new(context: Ctx, workers: usize) -> HiveBuilder<Ctx>
pub fn new(context: Ctx, workers: usize) -> HiveBuilder<Ctx>
Creates a new hive.
context
- Factory-like state that can be used while generating solutions.workers
- Number of working solution candidates to maintain at a time.
Examples found in repository?
More examples
examples/streaming.rs (line 32)
31fn main() {
32 let hive = HiveBuilder::<Foo>::new(Foo, 5)
33 .set_threads(5)
34 .set_observers(4)
35 .set_scaling(scaling::power_rank(10_f64));
36 for candidate in hive.build()
37 .unwrap()
38 .stream()
39 .iter()
40 .skip_while(|c| c.fitness < 200_f64)
41 .take(5) {
42 println!("{:?}", candidate);
43 }
44}
Sourcepub fn set_observers(self, observers: usize) -> HiveBuilder<Ctx>
pub fn set_observers(self, observers: usize) -> HiveBuilder<Ctx>
Sets the number of “bees” that will pick a candidate to work on at random.
This defaults to the number of workers.
Examples found in repository?
examples/streaming.rs (line 34)
31fn main() {
32 let hive = HiveBuilder::<Foo>::new(Foo, 5)
33 .set_threads(5)
34 .set_observers(4)
35 .set_scaling(scaling::power_rank(10_f64));
36 for candidate in hive.build()
37 .unwrap()
38 .stream()
39 .iter()
40 .skip_while(|c| c.fitness < 200_f64)
41 .take(5) {
42 println!("{:?}", candidate);
43 }
44}
Sourcepub fn set_retries(self, retries: usize) -> HiveBuilder<Ctx>
pub fn set_retries(self, retries: usize) -> HiveBuilder<Ctx>
Sets the number of times a candidate can go unimproved before being reinitialized.
This defaults to the number of workers.
Sourcepub fn set_threads(self, threads: usize) -> HiveBuilder<Ctx>
pub fn set_threads(self, threads: usize) -> HiveBuilder<Ctx>
Sets the number of worker threads to use while running.
Examples found in repository?
More examples
examples/streaming.rs (line 33)
31fn main() {
32 let hive = HiveBuilder::<Foo>::new(Foo, 5)
33 .set_threads(5)
34 .set_observers(4)
35 .set_scaling(scaling::power_rank(10_f64));
36 for candidate in hive.build()
37 .unwrap()
38 .stream()
39 .iter()
40 .skip_while(|c| c.fitness < 200_f64)
41 .take(5) {
42 println!("{:?}", candidate);
43 }
44}
Sourcepub fn set_scaling(self, scale: Box<ScalingFunction>) -> HiveBuilder<Ctx>
pub fn set_scaling(self, scale: Box<ScalingFunction>) -> HiveBuilder<Ctx>
Sets the scaling function for observers to use.
Examples found in repository?
More examples
examples/streaming.rs (line 35)
31fn main() {
32 let hive = HiveBuilder::<Foo>::new(Foo, 5)
33 .set_threads(5)
34 .set_observers(4)
35 .set_scaling(scaling::power_rank(10_f64));
36 for candidate in hive.build()
37 .unwrap()
38 .stream()
39 .iter()
40 .skip_while(|c| c.fitness < 200_f64)
41 .take(5) {
42 println!("{:?}", candidate);
43 }
44}
Sourcepub fn build(self) -> AbcResult<Hive<Ctx>>
pub fn build(self) -> AbcResult<Hive<Ctx>>
Activates the HiveBuilder
to create a runnable object.
Examples found in repository?
More examples
examples/streaming.rs (line 36)
31fn main() {
32 let hive = HiveBuilder::<Foo>::new(Foo, 5)
33 .set_threads(5)
34 .set_observers(4)
35 .set_scaling(scaling::power_rank(10_f64));
36 for candidate in hive.build()
37 .unwrap()
38 .stream()
39 .iter()
40 .skip_while(|c| c.fitness < 200_f64)
41 .take(5) {
42 println!("{:?}", candidate);
43 }
44}
Auto Trait Implementations§
impl<Ctx> Freeze for HiveBuilder<Ctx>where
Ctx: Freeze,
impl<Ctx> !RefUnwindSafe for HiveBuilder<Ctx>
impl<Ctx> Send for HiveBuilder<Ctx>
impl<Ctx> Sync for HiveBuilder<Ctx>
impl<Ctx> Unpin for HiveBuilder<Ctx>where
Ctx: Unpin,
impl<Ctx> !UnwindSafe for HiveBuilder<Ctx>
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