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
39
40
41
42
43
44
45
use ;
/**
## Description
Flipping mutation is a mutation only for binary encoded individuals.
Given the `mutation_probability` and `individual` it iterates through the boolean vector of `individual`
and generates a random number between `0.0` and `1.0`. If the number is less than `mutation_probability`
then we _flip_ the value at that index else it remains the same.
_Note: The function can also take in an optional `seed` value of type `Option<u64>` for deterministic results._
## Return
The return value is a `Result<(), &'static str>` which will return error only if the `mutation_probability` is greater than `1`
## Example
```rust
use genx::mutation::flipping_mutation;
let mut individual = vec![false, true, false, false,
true, true, true, false, false, true, false,
false, true, false, false, true];
let original_individual = individual.clone();
match flipping_mutation(&mut individual, 0.5, Some(42)) {
Ok(_) => (),
Err(error) => panic!("{:?}", error)
};
assert_ne!(original_individual, individual);
```
*/