Skip to content
Merged
33 changes: 18 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
name: Publish

on: ['workflow_dispatch']
on: ["workflow_dispatch"]

env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }}

jobs:
publish:
runs-on: ubuntu-latest
environment: publish
publish:
runs-on: ubuntu-latest
environment: publish

steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
- name: "Publish common"
run: cargo +nightly publish -p genetic-rs-common --token ${{ secrets.CARGO_TOKEN }}
- name: "Publish macros"
run: cargo +nightly publish -p genetic-rs-macros --token ${{ secrets.CARGO_TOKEN }}
- name: "Publish main"
run: cargo +nightly publish -p genetic-rs --cfg publish --token ${{ secrets.CARGO_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
- name: "Publish common"
run: cargo +nightly publish -p genetic-rs-common
- name: "Publish macros"
run: cargo +nightly publish -p genetic-rs-macros
- name: "Publish main"
run: cargo +nightly publish -p genetic-rs --config publish
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
A small framework for managing genetic algorithms.

### Features
First off, this crate comes with the `builtin`, `crossover`, and `genrand` features by default. If you want it to be parallelized (which is true in most cases), you can add the `rayon` feature. If you want your crossover to be speciated, you can add the `speciation` feature.
First off, this crate comes with the `builtin`, `genrand`, `crossover`, `knockout`, and `speciation` features by default. If you want the simulation to be parallelized (which is most usecases), add the `rayon` feature. There are also some convenient macros with the `derive` feature.

### How to Use
> [!NOTE]
> If you are interested in implementing NEAT with this, or just want a more complex example, try out the [neat](https://crates.io/crates/neat) crate
> If you are interested in implementing NEAT with this, or just want a more complex example, check out the [neat](https://crates.io/crates/neat) crate

Here's a simple genetic algorithm:

Expand All @@ -33,7 +33,7 @@ impl RandomlyMutable for MyGenome {
}
}

// allows us to use `Vec::gen_random` for the initial population. note that `Vec::gen_random` has a slightly different function signature depending on whether the `rayon` feature is enabled.
// allows us to use `Vec::gen_random` for the initial population. note that with the `rayon` feature, we can also use `Vec::par_gen_random`.
impl GenerateRandom for MyGenome {
fn gen_random(rng: &mut impl Rng) -> Self {
Self { field1: rng.random() }
Expand All @@ -50,7 +50,7 @@ fn main() {
let mut rng = rand::rng();
let mut sim = GeneticSim::new(
// you must provide a random starting population.
// size will be preserved in builtin nextgen fns, but it is not required to keep a constant size if you were to build your own nextgen function.
// size will be preserved in builtin repopulators, but it is not required to keep a constant size if you were to build your own.
// in this case, the compiler can infer the type of `Vec::gen_random` because of the input of `my_fitness_fn`.
Vec::gen_random(&mut rng, 100),
FitnessEliminator::new_with_default(my_fitness_fn),
Expand Down