Skip to main content

A simple automatic algorithm design tool

Project description

autoad

A simple automated algorithm design (AAD) tool.

Overview

This tool optimizes code by iteratively maximizing multiple measurable objectives. The core concepts are:

  • Prompt-driven Optimization: Accepts improvement instructions and evaluation criteria as prompts to guide the optimization process
  • Coding Agent Delegation: Delegates code improvement tasks to a coding agent within the optimization loop
  • Git-based Progress Tracking: Stores evaluation scores in Git tags to inform future optimization decisions
  • Evolutionary Approach: Simulates genetic and evolutionary algorithms by growing, merging, and selecting branches based on their performance scores

The optimization process starts when you provide improvement goals and evaluation metrics. The system then creates new branches where a coding agent implements suggested improvements. Each variant is evaluated using your specified metrics, with scores stored in Git tags. Based on these scores, the system selects high-performing branches for further improvement or merging, continuously evolving your codebase towards better solutions.

Usage

The tool requires:

  • --improvement-prompt: Describes what you want to improve
  • --objective NAME "PROMPT": Defines evaluation criteria (can be used multiple times)

Optional parameters:

  • --optional-prompt: Supplementary instructions for the optimization process
  • --sync-remote: Automatically sync with remote repository (fetches at start, pushes at end)
uvx autoad \
  --improvement-prompt "Improve accuracy of milwrap/countbase.py by increasing the higher value of the two iter 9 MIL instance unit accuracy metrics obtained from running 'uv run pytest -s .'" \
  --objective accuracy-auto-init "Run 'uv run pytest -s .' and use the first iter 9 MIL instance unit accuracy value as the score" \
  --objective accuracy-external-init "Run 'uv run pytest -s .' and use the second iter 9 MIL instance unit accuracy value as the score" \
  --iterations 300 \
  --branch-prefix optim-mil \
  --optional-prompt "Please report progress in Japanese."

The tool follows these steps to evolve your codebase:

  1. User Actions

    • Define optimization goals by providing:
      • Improvement prompt describing desired changes
      • Evaluation prompts specifying metrics
  2. System Actions - Code Generation

    • Generates improved code versions by:
      • Creating new branches
      • Delegating improvements to coding agent
      • Implementing suggested changes
  3. System Actions - Evaluation

    • Evaluates each variant by:
      • Running specified evaluation metrics
      • Calculating objective scores
      • Recording results in Git tags
  4. System Actions - Evolution

    • Evolves solution space through:
      • Selecting high-performing branches
      • Merging promising variants
      • Continuing optimization process

Example Application

As a practical example, this tool was applied to improve the algorithm performance in a multiple instance learning framework (inoueakimitsu/milwrap).

Optimization Progress

The optimization process ran for 2 days, focusing on enhancing the algorithm's performance on test data. The accuracy improved from 0.914 to 0.956 (with a theoretical maximum of 0.970). The graph shows the evaluation results of various algorithm variants generated during the optimization process.

Custom Iterations and Branch Prefix

You can specify the maximum number of iterations and customize the branch prefix using the following parameters:

  • --iterations N: Set the maximum number of optimization iterations (default: 100)
  • --branch-prefix PREFIX: Set custom prefix for optimization branches (default: "optim")

Remote Synchronization

The --sync-remote option enables automatic synchronization with a remote Git repository:

  • Before optimization: Fetches all branches and tags from the remote repository to ensure you're working with the latest state
  • After optimization: Force pushes all branches and tags to the remote repository to share your optimization results

This is particularly useful for:

  • Distributed optimization: Run optimization on multiple machines and combine results
  • Collaborative workflows: Share optimization progress with team members
  • Backup and persistence: Ensure optimization results are saved to remote repository

Example:

uvx autoad \
  --improvement-prompt "Optimize performance" \
  --objective speed "Measure execution time" \
  --sync-remote

Note: The --force flag is used when pushing, which will overwrite remote branches. Ensure you have appropriate permissions and understand the implications before using this option.

Requirements

  • Python 3.10+
  • macOS, Linux or WSL
  • Claude Code installed and configured. Due to intensive usage of the coding agent, we strongly recommend subscribing to the Claude MAX plan for optimal performance and to avoid rate limiting.
  • Git repository (for tracking optimization history)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autoad-0.1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autoad-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file autoad-0.1.0.tar.gz.

File metadata

  • Download URL: autoad-0.1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.6

File hashes

Hashes for autoad-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a17a039e7cd452f141a027dd056db3432b371d14c2f40ce9ddae61c04a38b89b
MD5 82cc619d734919388ea26e3ca64dcbf2
BLAKE2b-256 0d2d0bd93ff898861608a4a10b66a589b0f444feb1b59fc9cca1959e76118bf1

See more details on using hashes here.

File details

Details for the file autoad-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: autoad-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.6

File hashes

Hashes for autoad-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c304fe89db1b2b45983dd8ba353de3bd4516095fbcd8e001de4fdcac9a2b4ac
MD5 19502360a5d53226c59cd55cb12c6a43
BLAKE2b-256 87fc8400176b302e3cd5a715b30f5ae2d16d8a8601c7cfbe8b4ba0e93a1abb32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page