Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ lgp run iris_baseline
Run the standalone Rust examples directly with cargo:

```bash
cargo run -p lgp --example cart_pole --features gym
cargo run -p lgp --example iris_classification
cargo run -p lgp-core --example cart_pole --features gym
cargo run -p lgp-core --example iris_classification
```

## CLI Reference
Expand Down Expand Up @@ -226,7 +226,7 @@ RUST_LOG=lgp::core=trace,lgp=info lgp run iris_baseline

| Package | Description |
|---------|-------------|
| [lgp](crates/lgp/README.md) | Core library — traits, evolutionary engine, built-in problems |
| [lgp-core](crates/lgp/README.md) | Core library — traits, evolutionary engine, built-in problems |
| [lgp](crates/lgp-cli/README.md) | CLI binary for running experiments, search, and analysis |

## Extending the Framework
Expand Down
13 changes: 0 additions & 13 deletions crates/lgp-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ lgp analyze
# Run full pipeline (search -> run -> analyze)
lgp experiment iris_baseline --iterations 10

# Run a Rust API example
lgp example cart_pole

# List available examples
lgp example --list
```

## Global Options
Expand Down Expand Up @@ -113,14 +108,6 @@ Run end-to-end pipeline: search -> run -> analyze.
| `--n-threads <N>` | Search threads (default: 4) |
| `--median-trials <N>` | Runs for median (default: 10) |

### `lgp example <NAME>`

Runs a Rust API example from the `examples/` directory.

| Option | Description |
|--------|-------------|
| `--list` | List available examples |

## Available Experiments

| Experiment | Description |
Expand Down
52 changes: 41 additions & 11 deletions crates/lgp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Core Rust library for Linear Genetic Programming.

[![Crates.io](https://img.shields.io/crates/v/lgp.svg)](https://crates.io/crates/lgp)
[![Crates.io](https://img.shields.io/crates/v/lgp-core.svg)](https://crates.io/crates/lgp-core)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](../../LICENSE)

## Overview
Expand All @@ -15,14 +15,14 @@ Add to your `Cargo.toml`:

```toml
[dependencies]
lgp = "1.3"
lgp-core = "1.6"
```

To enable OpenAI Gym environment support:

```toml
[dependencies]
lgp = { version = "1.3", features = ["gym"] }
lgp-core = { version = "1.6", features = ["gym"] }
```

## Core Traits
Expand All @@ -48,22 +48,52 @@ The framework is built around these key traits:
## Quick Example

```rust
use lgp::core::engines::core_engine::CoreEngine;
use lgp::problems::iris::IrisLgp;
use itertools::Itertools;
use lgp::core::engines::core_engine::HyperParametersBuilder;
use lgp::core::engines::status_engine::{Status, StatusEngine};
use lgp::core::instruction::InstructionGeneratorParametersBuilder;
use lgp::core::program::ProgramGeneratorParametersBuilder;
use lgp::problems::iris::IrisEngine;

fn main() {
// Configure and run an Iris classification experiment
let engine = CoreEngine::<IrisLgp>::builder()
.n_generations(100)
.n_individuals(100)
let instruction_parameters = InstructionGeneratorParametersBuilder::default()
.n_actions(3)
.n_inputs(4)
.n_extras(2)
.external_factor(1.0)
.build()
.unwrap();

engine.run();
let program_parameters = ProgramGeneratorParametersBuilder::default()
.max_instructions(50)
.instruction_generator_parameters(instruction_parameters)
.build()
.unwrap();

let parameters = HyperParametersBuilder::<IrisEngine>::default()
.program_parameters(program_parameters)
.population_size(100)
.n_generations(50)
.n_trials(1)
.mutation_percent(0.5)
.crossover_percent(0.5)
.gap(0.5)
.default_fitness(0.0)
.build()
.unwrap();

let populations: Vec<_> = parameters
.build_engine()
.take(parameters.n_generations)
.collect_vec();

let best = populations.last().unwrap().first().unwrap();
let accuracy = (StatusEngine::get_fitness(best) / 150.0) * 100.0;
println!("Best accuracy: {accuracy:.1}%");
}
```

See the [examples](../../examples/) directory and [extension guide](../../skills/lgp-experiment/SKILL.md) for more.
See the [examples](examples/) directory and [extension guide](../../skills/lgp-experiment/SKILL.md) for more.

## Features

Expand Down
2 changes: 1 addition & 1 deletion crates/lgp/examples/cart_pole.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! This example demonstrates how to use the LGP framework to evolve programs
//! that can balance a pole on a cart (the classic CartPole control problem).
//!
//! Run with: `cargo run -p lgp --example cart_pole --features gym`
//! Run with: `cargo run -p lgp-core --example cart_pole --features gym`

use itertools::Itertools;

Expand Down
2 changes: 1 addition & 1 deletion crates/lgp/examples/iris_classification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! This example demonstrates how to use the LGP framework for a classification task
//! using the classic Iris flower dataset.
//!
//! Run with: `cargo run -p lgp --example iris_classification`
//! Run with: `cargo run -p lgp-core --example iris_classification`

use itertools::Itertools;

Expand Down
Loading