Skip to content

Commit 215ad9d

Browse files
committed
Merge branch 'develop'
2 parents 3396941 + 9c237d9 commit 215ad9d

File tree

6 files changed

+27
-23
lines changed

6 files changed

+27
-23
lines changed

crates/radiate-engines/src/steps/evaluate.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ where
6464
}
6565
}
6666

67-
let problem = Arc::clone(&problem);
68-
let work_results: Vec<_> = jobs
67+
let work_results = jobs
6968
.into_iter()
7069
.map(|(idx, geno)| {
7170
let problem = Arc::clone(&problem);
@@ -74,7 +73,7 @@ where
7473
(idx, score, geno)
7574
})
7675
})
77-
.collect();
76+
.collect::<Vec<_>>();
7877

7978
let count = work_results.len();
8079
for work_result in work_results {

docs/alterers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ As such, the choice of alterer can have a significant impact on the performance
66
Adding alterers to the engine can be done in a few ways. The simplest way is to add a single mutator and a single crossover to the engine as such:
77

88
```rust
9-
let engine = GeneticEngine::from_codex(codex)
9+
let engine = GeneticEngine::builder()
1010
...
1111
.crossover(MultiPointCrossover::new(0.75, 2))
1212
.mutator(UniformMutator::new(0.05))
@@ -16,7 +16,7 @@ Adding alterers to the engine can be done in a few ways. The simplest way is to
1616
However, if more than one is desired it can be done as such:
1717

1818
```rust
19-
let engine = GeneticEngine::from_codex(codex)
19+
let engine = GeneticEngine::builder()
2020
...
2121
.mutators(vec![
2222
Box::new(ScrambleMuator::new(0.75)),
@@ -32,7 +32,7 @@ However, if more than one is desired it can be done as such:
3232
Alternatively, the `alterers` method and macro can be used to add both mutators and crossovers at the same time:
3333

3434
```rust
35-
let engine = GeneticEngine::from_codex(codex)
35+
let engine = GeneticEngine::builder()
3636
...
3737
.alterers(alters![
3838
ScrambleMuator::new(0.75),

docs/examples.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ comprehensive list of examples.
2525
fn main() {
2626
let codex = IntCodex::vector(NUM_GENES, MIN_GENE_VALUE..MAX_GENE_VALUE);
2727

28-
let engine = GeneticEngine::from_codex(codex)
28+
let engine = GeneticEngine::builder()
29+
.codex(codex)
2930
.population_size(150)
3031
.minimizing()
3132
.offspring_selector(EliteSelector::new())
@@ -66,7 +67,8 @@ comprehensive list of examples.
6667

6768
let codex = IntCodex::<i8, Vec<i8>>::vector(N_QUEENS, 0..N_QUEENS as i8);
6869

69-
let engine = GeneticEngine::from_codex(codex)
70+
let engine = GeneticEngine::builder()
71+
.codex(codex)
7072
.minimizing()
7173
.num_threads(5)
7274
.offspring_selector(BoltzmannSelector::new(4.0))
@@ -131,7 +133,8 @@ comprehensive list of examples.
131133
let capacity = knapsack.capacity;
132134
let codex = SubSetCodex::new(knapsack.items);
133135

134-
let engine = GeneticEngine::from_codex(codex)
136+
let engine = GeneticEngine::builder()
137+
.codex(codex)
135138
.max_age(MAX_EPOCHS)
136139
.fitness_fn(move |genotype: Vec<Arc<Item>>| Knapsack::fitness(&capacity, &genotype))
137140
.build();
@@ -268,7 +271,8 @@ comprehensive list of examples.
268271
fn main() {
269272
let codex = FloatCodex::vector(N_GENES, -RANGE..RANGE);
270273

271-
let engine = GeneticEngine::from_codex(codex)
274+
let engine = GeneticEngine::builder()
275+
.codex(codex)
272276
.minimizing()
273277
.population_size(500)
274278
.alter(alters!(
@@ -325,7 +329,8 @@ comprehensive list of examples.
325329
target: target.clone(),
326330
};
327331

328-
let engine = GeneticEngine::from_codex(codex.clone())
332+
let engine = GeneticEngine::builder()
333+
.codex(codex.clone())
329334
.minimizing()
330335
.num_threads(5)
331336
.offspring_selector(BoltzmannSelector::new(4_f32))
@@ -442,13 +447,12 @@ comprehensive list of examples.
442447

443448
> Objective - Evolve a `Graph<Op<f32>>` to solve the XOR problem (NeuroEvolution).
444449
>
445-
> Warning - only available with the `radiate-gp` crate
450+
> Warning - only available with the `gp` feature flag.
446451
447452
??? example
448453

449454
```rust
450455
use radiate::*;
451-
use radiate_gp::*;
452456

453457
const MAX_INDEX: i32 = 500;
454458
const MIN_SCORE: f32 = 0.01;
@@ -466,7 +470,8 @@ comprehensive list of examples.
466470
let graph_codex = GraphCodex::directed(2, 1, values);
467471
let regression = Regression::new(get_dataset(), Loss::MSE, graph_codex);
468472

469-
let engine = GeneticEngine::from_problem(regression)
473+
let engine = GeneticEngine::builder()
474+
.problem(regression)
470475
.minimizing()
471476
.alter(alters!(
472477
GraphCrossover::new(0.5, 0.5),
@@ -515,13 +520,12 @@ comprehensive list of examples.
515520

516521
## Tree - Regression
517522

518-
> Objective - Evolve a `Tree<Op<f32>>` to solve the a regression problem (Genetic Programming).
523+
> Objective - Evolve a `Tree<Op<f32>>` to solve the a regression problem (Genetic Programming) - `gp` feature flag.
519524
520525
??? example
521526

522527
```rust
523528
use radiate::*;
524-
use radiate_gp::*;
525529

526530
const MIN_SCORE: f32 = 0.01;
527531
const MAX_SECONDS: f64 = 1.0;
@@ -537,7 +541,8 @@ comprehensive list of examples.
537541
let tree_codex = TreeCodex::single(3, store).constraint(|root| root.size() < 30);
538542
let problem = Regression::new(get_dataset(), Loss::MSE, tree_codex);
539543

540-
let engine = GeneticEngine::from_problem(problem)
544+
let engine = GeneticEngine::builder()
545+
.problem(problem)
541546
.minimizing()
542547
.mutator(HoistMutator::new(0.01))
543548
.crossover(TreeCrossover::new(0.7))

docs/gp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Genetic Programming
33

4-
The `radiate-gp` crate provides the fundamental building blocks for [Genetic Programming](https://en.wikipedia.org/wiki/Genetic_programming) (GP). It includes **data structures and algorithms** for building and evolving **`Tree`s** and **`Graph`s**.
4+
The `gp` feature provides the fundamental building blocks for [Genetic Programming](https://en.wikipedia.org/wiki/Genetic_programming) (GP). It includes **data structures and algorithms** for building and evolving **`Tree`s** and **`Graph`s**.
55

66
Genetic Programming (GP) is an evolutionary algorithm that **evolves programs** to solve problems. Programs are represented as **expression trees, decision trees, random forests, or neural networks** and evolved over generations.
77

docs/quickstart.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Radiate is inspired from a multitude of other genetic algorithm libraries, all o
99
## Configuration
1010
```toml
1111
[dependencies]
12-
radiate = "1.2.10"
12+
radiate = "1.2.11"
1313
```
1414

1515
## Core Implementations
@@ -37,15 +37,15 @@ Fitness Function
3737

3838
* The fitness function evaluates how well an individual solves the problem at hand. It is a critical component that guides the evolutionary process by assigning scores to individuals based on their performance.
3939

40-
## Extensions
40+
## Features
4141

42-
Radiate offers a separate crate called [radiate-gp](https://crates.io/crates/radiate-gp) which extend the core library with additional features. Mainly it provides data structures and algorithms which facilitate [Genetic Programming](https://en.wikipedia.org/wiki/Genetic_programming#:~:text=In%20artificial%20intelligence%2C%20genetic%20programming,to%20the%20population%20of%20programs.) (GP) - probems that are represented as Trees or Graphs. This is a powerful extension to the core library, allowing users to tackle even more complex or unique problems.
42+
Radiate offers a feature called `gp` which extend the core library with additional features. Mainly it provides data structures and algorithms which facilitate [Genetic Programming](https://en.wikipedia.org/wiki/Genetic_programming#:~:text=In%20artificial%20intelligence%2C%20genetic%20programming,to%20the%20population%20of%20programs.) (GP) - probems that are represented as Trees or Graphs. This is a powerful extension to the core library, allowing users to tackle even more complex or unique problems.
4343

4444
To use it, add the following to your `Cargo.toml`:
4545

4646
```toml
4747
[dependencies]
48-
radiate-gp = "0.0.4"
48+
radiate = { version = "1.2.11", features = ["gp"] }
4949
```
5050

5151
!!! note

examples/graphs/regression-graph/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ version = "0.1.0"
44
edition = "2024"
55

66
[dependencies]
7-
radiate = { path = "../../../crates/radiate", features = ["gp"] }
7+
radiate = { workspace = true, features = ["gp"] }

0 commit comments

Comments
 (0)