Skip to content

Commit ae722b3

Browse files
committed
Merge branch 'develop'
2 parents f7d9285 + 9347b4e commit ae722b3

File tree

176 files changed

+5862
-3760
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+5862
-3760
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ rand = "0.9.2"
6666
pyo3 = "0.27.1"
6767
numpy ="0.27.0"
6868
rayon = "1.11.0"
69-
serde = { version = "1.0.228", features = ["derive"] }
69+
smallvec = { version = "1.13", features = ["serde"] }
70+
thiserror = "2.0.17"
71+
serde = { version = "1.0.228", features = ["derive", "rc"] }
7072
serde_json = { version = "1.0.143" }
7173
tracing = "0.1"
7274
tracing-subscriber = { version = "0.3.20", features = ["env-filter", "fmt"] }

crates/radiate-alters/src/crossovers/blend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ where
4343
let mut cross_count = 0;
4444

4545
for i in 0..std::cmp::min(chrom_one.len(), chrom_two.len()) {
46-
if random_provider::random::<f32>() < rate {
46+
if random_provider::bool(rate) {
4747
let gene_one = chrom_one.get(i);
4848
let gene_two = chrom_two.get(i);
4949

crates/radiate-alters/src/crossovers/intermediate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<C: Chromosome<Gene = FloatGene>> Crossover<C> for IntermediateCrossover {
4242
let mut cross_count = 0;
4343

4444
for i in 0..std::cmp::min(chrom_one.len(), chrom_two.len()) {
45-
if random_provider::random::<f32>() < rate {
45+
if random_provider::bool(rate) {
4646
let gene_one = chrom_one.get_mut(i);
4747
let gene_two = chrom_two.get_mut(i);
4848

crates/radiate-alters/src/crossovers/mean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ where
3737
let mut count = 0;
3838

3939
for (gene_one, gene_two) in chrom_one.iter_mut().zip(chrom_two.iter()) {
40-
if random_provider::random::<f32>() < rate {
40+
if random_provider::bool(rate) {
4141
*gene_one = gene_one.mean(gene_two);
4242
count += 1;
4343
}

crates/radiate-alters/src/crossovers/multipoint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn crossover_multi_point<G>(
5151
return 0;
5252
}
5353

54-
let mut crossover_points = random_provider::indexes(0..length);
54+
let mut crossover_points = random_provider::shuffled_indices(0..length);
5555

5656
let selected_points = &mut crossover_points[..num_points];
5757
selected_points.sort();

crates/radiate-alters/src/crossovers/shuffle.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ impl<C: Chromosome + Clone> Crossover<C> for ShuffleCrossover {
1919
fn cross_chromosomes(&self, chrom_one: &mut C, chrom_two: &mut C, _: f32) -> AlterResult {
2020
let length = std::cmp::min(chrom_one.len(), chrom_two.len());
2121
if length < 2 {
22-
return 0.into();
22+
return AlterResult::empty();
2323
}
2424

25-
let mut indices: Vec<usize> = (0..length).collect();
25+
let mut indices = (0..length).collect::<Vec<usize>>();
2626
random_provider::shuffle(&mut indices);
2727

2828
let temp_chrom_one = chrom_one.clone();
@@ -37,6 +37,6 @@ impl<C: Chromosome + Clone> Crossover<C> for ShuffleCrossover {
3737
}
3838
}
3939

40-
cross_count.into()
40+
AlterResult::from(cross_count)
4141
}
4242
}

crates/radiate-alters/src/crossovers/simulated_binary.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub struct SimulatedBinaryCrossover {
88
}
99

1010
impl SimulatedBinaryCrossover {
11-
pub fn new(contiguty: f32, crossover_rate: f32) -> Self {
11+
pub fn new(crossover_rate: f32, contiguty: f32) -> Self {
1212
Self {
1313
contiguty,
1414
crossover_rate,
@@ -26,7 +26,7 @@ impl<C: Chromosome<Gene = FloatGene>> Crossover<C> for SimulatedBinaryCrossover
2626
let length = std::cmp::min(chrom_one.len(), chrom_two.len());
2727

2828
if length < 2 {
29-
return 0.into();
29+
return AlterResult::empty();
3030
}
3131

3232
let mut count = 0;
@@ -57,6 +57,6 @@ impl<C: Chromosome<Gene = FloatGene>> Crossover<C> for SimulatedBinaryCrossover
5757
}
5858
}
5959

60-
count.into()
60+
AlterResult::from(count)
6161
}
6262
}

crates/radiate-alters/src/mutators/arithmetic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<G: ArithmeticGene, C: Chromosome<Gene = G>> Mutate<C> for ArithmeticMutator
3636
fn mutate_chromosome(&self, chromosome: &mut C, rate: f32) -> AlterResult {
3737
let mut mutations = 0;
3838
for gene in chromosome.iter_mut() {
39-
if random_provider::random::<f32>() < rate {
39+
if random_provider::bool(rate) {
4040
let operator = random_provider::range(0..4);
4141

4242
let new_gene = match operator {
@@ -52,6 +52,6 @@ impl<G: ArithmeticGene, C: Chromosome<Gene = G>> Mutate<C> for ArithmeticMutator
5252
}
5353
}
5454

55-
mutations.into()
55+
AlterResult::from(mutations)
5656
}
5757
}

crates/radiate-alters/src/mutators/gaussian.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<C: Chromosome<Gene = FloatGene>> Mutate<C> for GaussianMutator {
3131
fn mutate_chromosome(&self, chromosome: &mut C, rate: f32) -> AlterResult {
3232
let mut count = 0;
3333
for gene in chromosome.genes_mut() {
34-
if random_provider::random::<f32>() < rate {
34+
if random_provider::bool(rate) {
3535
let min = *gene.min() as f64;
3636
let max = *gene.max() as f64;
3737

@@ -47,6 +47,6 @@ impl<C: Chromosome<Gene = FloatGene>> Mutate<C> for GaussianMutator {
4747
}
4848
}
4949

50-
count.into()
50+
AlterResult::from(count)
5151
}
5252
}

crates/radiate-alters/src/mutators/invert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ impl<C: Chromosome> Mutate<C> for InversionMutator {
3030
fn mutate_chromosome(&self, chromosome: &mut C, rate: f32) -> AlterResult {
3131
let mut mutations = 0;
3232

33-
if random_provider::random::<f32>() < rate {
33+
if random_provider::bool(rate) {
3434
let start = random_provider::range(0..chromosome.len());
3535
let end = random_provider::range(start..chromosome.len());
3636

3737
chromosome.genes_mut()[start..end].reverse();
3838
mutations += 1;
3939
}
4040

41-
mutations.into()
41+
AlterResult::from(mutations)
4242
}
4343
}

0 commit comments

Comments
 (0)