Skip to content

Example: Add graph coloring example with DIMACS benchmarks#396

Open
eilamt wants to merge 11 commits intoalgorithmicsuperintelligence:mainfrom
eilamt:feature/graph-coloring-example
Open

Example: Add graph coloring example with DIMACS benchmarks#396
eilamt wants to merge 11 commits intoalgorithmicsuperintelligence:mainfrom
eilamt:feature/graph-coloring-example

Conversation

@eilamt
Copy link

@eilamt eilamt commented Feb 5, 2026

Summary

A complete graph coloring example demonstrating OpenEvolve's ability to evolve sophisticated algorithms from simple starting points.

  • 3-stage cascade evaluation with standard DIMACS benchmark graphs (22 graphs, 11-864 vertices)
  • Simple greedy initial algorithm that evolves into DSatur
  • Comprehensive test suite with known chromatic numbers
  • Benchmark runner (run_benchmarks.py) for testing algorithms

Results

After 100 iterations, OpenEvolve evolved a DSatur algorithm:

Metric Initial (Greedy) Evolved (DSatur)
Total Colors 389 362
Optimal Colorings 10/22 15/22

The evolved algorithm uses 27 fewer colors and achieves optimal coloring on 5 additional graphs.

eilamt and others added 11 commits January 31, 2026 13:27
New OpenEvolve example demonstrating evolution of graph coloring algorithms:
- Simple greedy coloring as initial program with EVOLVE-BLOCK
- Evaluator testing on Petersen, K5, bipartite, cycle, and random graphs
- Visualization support with networkx/matplotlib
- Custom graph file loading with sample graphs
- 26 unit tests covering coloring validity and file loading

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ring

- Implement 3-stage cascade evaluation:
  - Stage 1: Validity gate (quick pass/fail on 3 small graphs)
  - Stage 2: Quick scoring on small graphs with chromatic numbers
  - Stage 3: Full evaluation on all 6 test graphs
- Enforce combined_score = 0 for any invalid coloring
- Add TestEvaluatorFailureCases class with 10 mock program tests:
  - Invalid coloring, partial coloring, suboptimal coloring
  - Missing functions, syntax errors, runtime errors
  - Exception handling for all stages
- Update config.yaml with cascade threshold documentation
- Total test count: 50 tests (40 existing + 10 new failure cases)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Crown, Mycielski, Chvátal graphs that trip up greedy/DSatur
- Add DSatur-adversarial random graphs (seeds 19, 70)
- Archive Gemini run (score 0.9667) and Claude manual evolution (score 1.0)
- Switch config from Gemini to Claude API

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement quadratic time budget formula that scales with graph complexity:
- budget = BASE_TIME_BUDGET + COEFF_TIME × (n² + m)
- BASE_TIME_BUDGET = 1ms, COEFF_TIME = 8.8e-7 seconds
- TIME_PENALTY_WEIGHT = 0.3 (30% of combined score)
- Time score decays as 1/overage_ratio with floor at 0.1

This penalizes brute-force multi-start algorithms while allowing
efficient single-pass algorithms to pass comfortably.

Add 12 unit tests for time budget functionality covering:
- Formula correctness and quadratic scaling
- Time score calculation and decay behavior
- Integration with evaluate() function

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add DIMACS .col file parser with 1-indexed to 0-indexed conversion
- Create benchmarks directory with 22 full and 5 small benchmark graphs
- Add chromatic numbers registry JSON for known optimal values
- Update evaluator to use DIMACS benchmarks when available
- Add fallback to built-in graphs if benchmarks not present
- Handle unknown chromatic numbers with max_degree/2 heuristic
- Add 15 unit tests for DIMACS functionality
- Archive previous Claude OpenEvolve run results

Benchmark includes challenging graphs: queen (n=5-13), myciel,
le450_15c, mulsol, zeroin, inithx - current DSatur scores 0.916.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add archived experiment run_20260202_claude_openevolve_dimacs with:
  - DSatur initial program, evolved best program, config, and run notes
  - Key finding: post-processing is dead code (0 recolorings)
  - Improvement came from starting with highest-degree vertex
- Add analyze_postprocessing.py script for analyzing recoloring effectiveness

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
OpenEvolve successfully evolved simple greedy to DSatur algorithm:
- Score improved from 0.8934 to 0.9384 (+5%)
- Optimal colorings: 10 → 15 out of 22 DIMACS graphs
- Total colors: 389 → 362 (-27)
- DSatur discovered at iteration 2, no improvement in 107 more iterations

Config updated with exploration-focused parameters (temp 0.9, 70% exploration).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
A complete graph coloring example demonstrating OpenEvolve's ability to
evolve sophisticated algorithms from simple starting points.

Features:
- 3-stage cascade evaluation with DIMACS benchmark graphs
- Simple greedy initial algorithm that evolves into DSatur
- Comprehensive test suite with 22 benchmark graphs
- Benchmark runner for testing algorithms (run_benchmarks.py)

Results from 100 iterations:
- Initial greedy: 389 colors, 10/22 optimal
- Evolved DSatur: 362 colors, 15/22 optimal

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace environment variable references with placeholder strings
  to avoid CI test failures
- Add Prerequisites section to README explaining API key setup

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@eilamt
Copy link
Author

eilamt commented Feb 5, 2026

Fixed API Key issue (failed test). Added use of placeholder strings like YOUR_API_KEY instead of ${ENV_VAR}

1 similar comment
@eilamt
Copy link
Author

eilamt commented Feb 5, 2026

Fixed API Key issue (failed test). Added use of placeholder strings like YOUR_API_KEY instead of ${ENV_VAR}

@eilamt
Copy link
Author

eilamt commented Feb 7, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant