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
2 changes: 1 addition & 1 deletion .githooks/.sr-hooks-hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0343981e584c25d0
8d0fafc1174a9d02
3 changes: 3 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
# Generated by sr — edit the hooks section in sr.yaml to modify.
exec sr hook run pre-commit -- "$@"
3 changes: 3 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
# Generated by sr — edit the hooks section in sr.yaml to modify.
exec sr hook run pre-push -- "$@"
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
contents: write
outputs:
released: ${{ steps.sr.outputs.released }}
tag: ${{ steps.sr.outputs.tag }}
steps:
- name: Generate app token
id: app-token
Expand Down Expand Up @@ -89,6 +90,56 @@ jobs:
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates-token.outputs.token }}

binaries:
needs: release
if: needs.release.outputs.released == 'true'
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.tag }}

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml

- name: Build binary
run: cargo build --release --target ${{ matrix.target }} -p lgp-cli

- name: Package binary
run: |
cd target/${{ matrix.target }}/release
tar -czf lgp-${{ matrix.target }}.tar.gz lgp
mv lgp-${{ matrix.target }}.tar.gz "$GITHUB_WORKSPACE/"

- name: Upload release asset
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload ${{ needs.release.outputs.tag }} lgp-${{ matrix.target }}.tar.gz --clobber

experiments:
needs: release
if: needs.release.outputs.released == 'true'
Expand Down
24 changes: 12 additions & 12 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ Pure Rust workspace:

| Task | Command |
|------|---------|
| Build | `just build` or `cargo build --release` |
| Build (with plots) | `just build-plot` or `cargo build --release --features plot` |
| Test | `just test` or `cargo test --release` |
| Bench | `just bench` or `cargo bench` |
| Lint | `just lint` or `cargo clippy -- -D warnings` |
| Format | `just fmt` or `cargo fmt` |
| Run experiment | `just run <name>` (e.g., `just run cart_pole_lgp`) |
| List experiments | `just list` |
| Hyperparameter search | `just search <config>` or `lgp search <config>` |
| Analyze results | `just analyze` or `lgp analyze` |
| Full pipeline | `just experiment <config>` (search -> run -> analyze) |
| Setup | `just init` (Rust build + git hooks) |
| Install | `cargo install --path crates/lgp-cli` |
| Build | `cargo build` |
| Build (with plots) | `cargo build --features plot` |
| Test | `cargo test` |
| Bench | `cargo bench` |
| Lint | `cargo clippy -- -D warnings` |
| Format | `cargo fmt` |
| Run experiment | `lgp run <name>` (e.g., `lgp run cart_pole_lgp`) |
| List experiments | `lgp list` |
| Hyperparameter search | `lgp search <config>` |
| Analyze results | `lgp analyze` |
| Full pipeline | `lgp experiment <config>` (search -> run -> analyze) |

## Code Style

Expand Down
61 changes: 15 additions & 46 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Ensure you have the following installed:
| Tool | Version | Purpose |
|------|---------|---------|
| Rust | 1.70+ | Core framework |
| just | Latest | Task runner |

### Initial Setup

Expand All @@ -28,22 +27,11 @@ Ensure you have the following installed:
git clone https://github.com/urmzd/linear-gp.git
cd linear-gp

# Install just (task runner)
cargo install just
# Install the lgp binary
cargo install --path crates/lgp-cli

# Run setup (builds binary, installs git hooks)
just init

# Verify everything is working
just verify
just test
```

### Manual Setup

```bash
# Build the project
cargo build --release
# Run tests to verify
cargo test
```

### IDE Setup
Expand All @@ -59,20 +47,7 @@ cargo build --release

### Pre-commit Hooks

This project uses custom git hooks in `scripts/` to enforce code quality.

**Setup:**
```bash
# Install hooks
just init_

# Run checks manually
just check
```

**Hooks included:**
- **General:** trailing-whitespace, merge-conflict check
- **Rust:** cargo fmt and clippy on commit, cargo test on push
Git hooks are managed by `sr`. See `sr.yaml` for configuration.

## Code Style

Expand All @@ -83,7 +58,7 @@ We follow standard Rust conventions with some project-specific guidelines:
**Formatting:**
```bash
# Format all code
just fmt
cargo fmt

# Check formatting without modifying
cargo fmt -- --check
Expand All @@ -92,9 +67,6 @@ cargo fmt -- --check
**Linting:**
```bash
# Run clippy with strict warnings
just lint

# Or directly
cargo clippy -- -D warnings
```

Expand Down Expand Up @@ -156,23 +128,20 @@ pub fn run_experiment(name: &str) -> Result<()> {

```bash
# Run all tests
just test
cargo test

# Run tests for specific crate
cargo test -p lgp
cargo test -p lgp-cli

# Run tests with output
just test-verbose
cargo test -- --nocapture

# Run specific test suite
cargo test -p lgp iris

# Run with nextest (faster)
just test-nextest

# Run benchmarks
just bench
cargo bench

# Test experiment CLI (dry-run)
lgp run iris_baseline --dry-run
Expand Down Expand Up @@ -219,10 +188,10 @@ After making changes that affect evolution:

```bash
# Run baseline experiments
just run iris_baseline
lgp run iris_baseline

# Generate analysis
just analyze
lgp analyze
```

## Pull Request Process
Expand All @@ -249,7 +218,7 @@ just analyze

3. **Run checks locally:**
```bash
just check # Runs fmt, lint, and test
cargo fmt && cargo clippy -- -D warnings && cargo test
```

4. **Commit your changes:**
Expand All @@ -273,9 +242,9 @@ just analyze

### PR Requirements

- [ ] All tests pass (`just test`)
- [ ] Code is formatted (`just fmt`)
- [ ] No clippy warnings (`just lint`)
- [ ] All tests pass (`cargo test`)
- [ ] Code is formatted (`cargo fmt`)
- [ ] No clippy warnings (`cargo clippy -- -D warnings`)
- [ ] Documentation updated if needed
- [ ] Commit messages follow convention
- [ ] PR description explains the change
Expand Down
47 changes: 8 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,6 @@ Linear Genetic Programming (LGP) is a variant of genetic programming that evolve
| Dependency | Version | Installation |
|------------|---------|--------------|
| Rust | 1.70+ | [rustup.rs](https://rustup.rs/) |
| just | Latest | `cargo install just` |

**macOS:**
```bash
brew install rust
cargo install just
```

**Ubuntu:**
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install just
```

### Installation

Expand All @@ -69,27 +56,27 @@ cargo install just
git clone https://github.com/urmzd/linear-gp.git
cd linear-gp

# Build and install git hooks
just init
# Install the lgp binary
cargo install --path crates/lgp-cli
```

### First Experiment

```bash
# List available experiments
just list
lgp list

# Run CartPole with pure LGP
just run cart_pole_lgp
lgp run cart_pole_lgp

# Run Iris classification
just run iris_baseline
lgp run iris_baseline

# Run an example
just run-example cart_pole
lgp example cart_pole

# Run benchmarks
just bench
cargo bench
```

## Packages
Expand Down Expand Up @@ -285,24 +272,6 @@ Results are saved to:

## Running Experiments

### Quick Start with Just

```bash
# List available experiments
just list

# Run individual experiments
just run cart_pole_lgp
just run cart_pole_with_q
just run mountain_car_lgp
just run iris_baseline

# Run with dry-run to preview config
just run iris_baseline --dry-run
```

### Running with lgp

```bash
# Run with default config
lgp run cart_pole_lgp
Expand All @@ -321,7 +290,7 @@ lgp run cart_pole_lgp --override hyperparameters.n_generations=200
lgp analyze

# Build with plot feature for PNG chart generation
cargo build --release --features plot
cargo install --path crates/lgp-cli --features plot
lgp analyze
```

Expand Down
4 changes: 2 additions & 2 deletions crates/lgp-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ cargo install lgp-cli
Or build from source:

```bash
cargo build --release -p lgp-cli
cargo install --path crates/lgp-cli

# With plot support (PNG chart generation)
cargo build --release -p lgp-cli --features plot
cargo install --path crates/lgp-cli --features plot
```

## Usage
Expand Down
Loading
Loading