diff --git a/CHANGELOG.md b/CHANGELOG.md index c009ddd..3c9f86d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,23 @@ All user visible changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/), as described for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/text/1105-api-evolution.md) -## 0.5.0 : +## 0.6.0 : 2021-11-07 + +* bump `fixedbitset` optional dependency to version 0.4 +* bump `rand` crate dependency to version 0.8 +* bump `rand_xoshiro` crate dependency to version 0.6 +* bump `proptest` crate dependency to version 1 + +### Fixed issues: + +* fix index out of bounds exception in `OrderOneCrossover` and `PartiallyMappedCrossover` operations. +* fix typos in docs. + +### Internal: + +* replace deprecated method with new one in Criterion benchmark tests + +## 0.5.0 : 2019-11-10 * bump `rand` crate dependency to version 0.7 * bump `rand_xoshiro` crate dependency to version 0.3 diff --git a/Cargo.toml b/Cargo.toml index 508fa76..837b866 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "genevo" -version = "0.5.0" +version = "0.6.0" authors = ["haraldmaida"] license = "MIT/Apache-2.0" description = """ diff --git a/README.md b/README.md index 9b78b0f..0545146 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -genevo = "0.5" +genevo = "0.6" ``` If you are not using Rust 2018 edition add this to your crate root: diff --git a/examples/queens/main.rs b/examples/queens/main.rs index 4656bd1..bcc7b32 100644 --- a/examples/queens/main.rs +++ b/examples/queens/main.rs @@ -101,7 +101,7 @@ impl RandomValueMutation for Pos { { Pos { x: value.x, - y: rng.gen_range(min_value.y, max_value.y), + y: rng.gen_range(min_value.y..max_value.y), } } } @@ -117,7 +117,7 @@ impl GenomeBuilder for QueensPositions { (0..NUM_ROWS) .map(|row| Pos { x: row, - y: rng.gen_range(0, NUM_COLS), + y: rng.gen_range(0..NUM_COLS), }) .collect() } @@ -179,7 +179,7 @@ fn main() { for row in best_solution.solution.genome.as_board() { println!(" {:?}", row); } - }, + } Ok(SimResult::Final(step, processing_time, duration, stop_reason)) => { let best_solution = step.result.best_solution; println!("{}", stop_reason); @@ -196,11 +196,11 @@ fn main() { println!(" {:?}", row); } break; - }, + } Err(error) => { println!("{}", error); break; - }, + } } } } diff --git a/src/lib.rs b/src/lib.rs index cb53a41..043fa7b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,7 +80,7 @@ //! searches for solutions of the //! [N Queens Problem](https://en.wikipedia.org/wiki/Eight_queens_puzzle) -#![doc(html_root_url = "https://docs.rs/genevo/0.5.0")] +#![doc(html_root_url = "https://docs.rs/genevo/0.6.0")] #![warn( bare_trait_objects, missing_copy_implementations, diff --git a/src/mutation/value.rs b/src/mutation/value.rs index e0b5ff7..c4c75a4 100644 --- a/src/mutation/value.rs +++ b/src/mutation/value.rs @@ -197,7 +197,7 @@ macro_rules! impl_random_value_mutation { fn random_mutated(_: $t, min_value: &$t, max_value: &$t, rng: &mut R) -> $t where R: Rng + Sized { - rng.gen_range(*min_value, *max_value) + rng.gen_range(*min_value..*max_value) } } )* diff --git a/src/population/mod.rs b/src/population/mod.rs index 851c094..01908a5 100644 --- a/src/population/mod.rs +++ b/src/population/mod.rs @@ -80,7 +80,7 @@ //! (0..8).map(|row| //! Pos { //! x: row, -//! y: rng.gen_range(0, 8) +//! y: rng.gen_range(0..8) //! } //! ).collect() //! } @@ -346,7 +346,7 @@ where R: Rng + Sized, { (0..self.genome_length) - .map(|_| rng.gen_range(self.min_value.clone(), self.max_value.clone())) + .map(|_| rng.gen_range(self.min_value.clone()..self.max_value.clone())) .collect() } } @@ -400,7 +400,7 @@ mod smallvec_genome_builder { R: Rng + Sized, { (0..self.genome_length) - .map(|_| rng.gen_range(self.min_value.clone(), self.max_value.clone())) + .map(|_| rng.gen_range(self.min_value.clone()..self.max_value.clone())) .collect() } } diff --git a/src/random/mod.rs b/src/random/mod.rs index d3db83c..dc3dc46 100644 --- a/src/random/mod.rs +++ b/src/random/mod.rs @@ -43,7 +43,7 @@ pub fn random_index_from_range(rng: &mut R, min: usize, max: usize) -> usize where R: Rng + Sized, { - rng.gen_range(min, max) + rng.gen_range(min..max) } /// Generates two cut points for a slice of given length using the given `Prng`. @@ -65,8 +65,8 @@ where assert!(max >= min + 4); let max_slice = max - min - 2; loop { - let cutpoint1 = rng.gen_range(min, max); - let cutpoint2 = rng.gen_range(min, max); + let cutpoint1 = rng.gen_range(min..max); + let cutpoint2 = rng.gen_range(min..max); if cutpoint1 < cutpoint2 { if cutpoint2 - cutpoint1 >= max_slice { continue; @@ -93,12 +93,12 @@ where match n { 1 => { cutpoints.push(random_index(rng, length)); - }, + } 2 => { let (cp1, cp2) = random_cut_points(rng, length); cutpoints.push(cp1); cutpoints.push(cp2); - }, + } _ => { let slice_len = length / n; let mut start = 0; @@ -121,7 +121,7 @@ where end += slice_len; } } - }, + } } cutpoints } diff --git a/src/recombination/discrete.rs b/src/recombination/discrete.rs index eaee8e4..b7858be 100644 --- a/src/recombination/discrete.rs +++ b/src/recombination/discrete.rs @@ -58,7 +58,7 @@ where // for each value in the genotype for locus in 0..genome_length { // pick the value of a randomly chosen parent - let random = rng.gen_range(0, num_parents); + let random = rng.gen_range(0..num_parents); let value = parents[random][locus].clone(); genome.push(value); } @@ -92,7 +92,7 @@ mod fixedbitset_uniform_cross_breeder { // for each value in the genotype for locus in 0..genome_length { // pick the value of a randomly chosen parent - let random = rng.gen_range(0, num_parents); + let random = rng.gen_range(0..num_parents); let value = parents[random][locus]; genome.set(locus, value); } @@ -129,7 +129,7 @@ mod smallvec_uniform_cross_breeder { // for each value in the genotype for locus in 0..genome_length { // pick the value of a randomly chosen parent - let random = rng.gen_range(0, num_parents); + let random = rng.gen_range(0..num_parents); let value = parents[random][locus].clone(); genome.push(value); } @@ -254,7 +254,7 @@ where let mut p_index = num_parents; loop { loop { - let index = rng.gen_range(0, num_parents); + let index = rng.gen_range(0..num_parents); if index != p_index { p_index = index; break; @@ -312,7 +312,7 @@ mod smallvec_multipoint_crossover { let mut p_index = num_parents; loop { loop { - let index = rng.gen_range(0, num_parents); + let index = rng.gen_range(0..num_parents); if index != p_index { p_index = index; break; @@ -366,7 +366,7 @@ mod fixedbitset_multipoint_crossover { let mut p_index = num_parents; loop { loop { - let index = rng.gen_range(0, num_parents); + let index = rng.gen_range(0..num_parents); if index != p_index { p_index = index; break; diff --git a/tests/population_builder.rs b/tests/population_builder.rs index 504f342..2db2035 100644 --- a/tests/population_builder.rs +++ b/tests/population_builder.rs @@ -49,7 +49,7 @@ fn create_population_of_custom_genotype_uniform_at_random() { (0..8) .map(|row| Pos { x: row, - y: rng.gen_range(0, 8), + y: rng.gen_range(0..8), }) .collect() }