A suite of benchmarks to test e-graph extraction algorithms

Overview

Extraction Gym

A suite of benchmarks to test e-graph extraction algorithms.

Add your algorithm in src/extract and then add a line in src/main.rs. To run, type make.

Data

Please add data! It's just a csv with the following schema:

eclass:str, cost:float, node_name:str, eclass_children:str*

There is a special ## directive to specify the root(s) of the e-graph. You can have multiple of these on separate lines.

Make sure all ids (including roots) are canonical!

Example

Here's an e-graph with f(g(x)) = h(y, x), and everything has cost 1 except for h which has cost 7.5:

## root: 2
0,   1, x
1,   1, g, 0
2,   1, f, 1
# this is a comment, starting the second "term"
3,   1, y
2, 7.5, h, 3, 0

Snippet

Here's a snippet that you can base your csv printing code on if you want. Make sure to also print the ## root: directive to specify the roots!

>(); ids.sort(); for id in ids { for node in &egraph[id].nodes { let cost = 1; write!(w, "{},{},{}", id, cost, node)?; for child in node.children() { write!(w, ",{}", child)?; } writeln!(w)?; } } Ok(()) }">
pub fn write_to_csv<L, A>(egraph: &EGraph<L, A>, w: &mut impl std::io::Write) -> std::io::Result<()>
where
    L: Language + std::fmt::Display,
    A: Analysis<L>,
{
    writeln!(w, "# generated by egg {}", env!("CARGO_PKG_VERSION"))?;
    let mut ids = egraph.classes().map(|c| c.id).collect::<Vec<_>>();
    ids.sort();
    for id in ids {
        for node in &egraph[id].nodes {
            let cost = 1;
            write!(w, "{},{},{}", id, cost, node)?;
            for child in node.children() {
                write!(w, ",{}", child)?;
            }
            writeln!(w)?;
        }
    }
    Ok(())
}
You might also like...
Benchmarks of algorithms for convex min-plus convolutions

Convex min-plus convolution を実現するアルゴリズムの実行時間を比較します。 やり方 長さ N の convex な Veci32 を2本生成して、それらの min-plus convolution を3通りの方法で計算します。 brute: 定義どおり計算します。(Θ

Egui node graph is a featureful, customizable library to create node graph applications using egui
Egui node graph is a featureful, customizable library to create node graph applications using egui

Egui node graph is a featureful, customizable library to create node graph applications using egui. The library takes care of presenting a node graph to your users, and allows customizing many aspects of the interaction, creating the semantics you want for your specific application.

A library that can be used as a building block for high-performant graph algorithms.

graph A library that can be used as a building block for high-performant graph algorithms. Graph provides implementations for directed and undirected

A general-purpose, transactional, relational database that uses Datalog and focuses on graph data and algorithms

cozo A general-purpose, transactional, relational database that uses Datalog for query and focuses on graph data and algorithms. Features Relational d

A fast isosurface extraction algorithm.
A fast isosurface extraction algorithm.

fast-surface-nets A fast, chunk-friendly implementation of Naive Surface Nets on regular grids. Surface Nets is an algorithm for extracting an isosurf

An implementation of request routing via a singular grouped regex (with support for path parameter extraction).

rs-regex-router An implementation of request routing via a singular grouped regex (with support for path parameter extraction). Features Design approa

Peakrs Dataframe is a library and framework facilitates the extraction, transformation, and loading (ETL) of data.

Peakrs Dataframe Peakrs Dataframe is a library and framework facilitates the extraction, transformation, and loading (ETL) of data. Its first applicat

A simple tool to test sqlx with postgres. It will automatically create a database and drop it after the test.

sqlx-db-tester This a tool to test sqlx with postgres. It only supports tokio runtime at this moment. How to use it You should first create a TestDb d

Formats output of Solana's cargo test-bpf/test-sbf command
Formats output of Solana's cargo test-bpf/test-sbf command

solfmt Formats output of Solana's cargo test-bpf/test-sbf command. Installation cargo install solfmt Usage Run the your test command as usual (cargo t

OpenAPI-based test coverage analysis tool that helps teams improve integration test coverage in CI/CD pipelines
OpenAPI-based test coverage analysis tool that helps teams improve integration test coverage in CI/CD pipelines

Ready-to-use OpenAPI test coverage analysis tool that helps teams improve integration CoveAPI is an advanced test coverage analysis tool based on the

This repository contains the Rust source code for the algorithms in the textbook Algorithms, 4th Edition

Overview This repository contains the Rust source code for the algorithms in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

An NLP-suite powered by deep learning
An NLP-suite powered by deep learning

DeepFrog - NLP Suite Introduction DeepFrog aims to be a (partial) successor of the Dutch-NLP suite Frog. Whereas the various NLP modules in Frog wre b

Hidden parameters discovery suite

x8 Hidden parameters discovery suite written in Rust. How does it work Features Examples Send parameters via query Send parameters via body Custom tem

Terra development suite

rover Terra development suite Planned features Usage Commands Planned features Includes a starter smart contract, can be cw-template or similar. Has a

A suite of programs for Solana key management and security.
A suite of programs for Solana key management and security.

🔑 goki Goki is a suite of programs for Solana key management and security. It currently features: Goki Smart Wallet: A wallet loosely based on the Se

Suite for automatically testing algorithm questions from the Polish Algorithm Olympiad.

oisuite Your number #1 tool to managing your algo questions! This software only works on UNIX-based operating systems (macOS, Linux, BSD, etc.) Projec

A mail suite written in rust meant to be easy to use.

Erooster A mail suite written in rust meant to be easy to use. Getting started Currently the setup is quite rough. You need some certificates for your

An ability management suite for Bevy.

About A fully-featured set of tools for managing abilities in Bevy. This crate is meant to be used with Leafwing Input Manager, which converts inputs

Holo is a suite of routing protocols designed to support high-scale and automation-driven networks.

Holo is a suite of routing protocols designed to support high-scale and automation-driven networks. For a description of what a routing protocol is, p

Comments
  • ASP extraction

    ASP extraction

    Add extraction algorithm via Answer Set Programming. The idea is to let ASP pick a set of leaf nodes, then grow "upwards" until reaching the roots.

    TODO:

    • [ ] Use clingo-rs API
    • [ ] Timeout: integ_part2
    • [ ] Timeout: λ_function_repeat
    • [ ] Timeout: math_associate_adds
    opened by remysucre 1
  • Answer Set Programming

    Answer Set Programming

    An initial answer set programming based extractor. Answer set programming has an intrinsic cycle breaking mechanism, which makes it fairly natural to model the DAG extraction problem. It appears to be slow on the large problems. There is probably still refinement / redundant constraints / symmettry breaking / hints that could speed it up. In addition, giving an upper bound cost from the bottom up method may speed it up.

    % we may choose to select this enode if we have selected that class of all it's children.
    { sel(E,I) } :- enode(E,I,_,_), selclass(Ec) : child(E,I,Ec).
    
    % if we select an enode in an eclass, we select that eclass
    selclass(E) :- sel(E,_).
    
    % It is inconsistent for a eclass to be a root and not selected.
    % This is *not* the same as saying  selclass(E) :- root(E). 
    :- root(E), not selclass(E).
    
    % As a redundant constraint, each eclass should have at most one enode selected
    :- enode(E,_,_,_), #count { E,I : sel(E,I)} > 1.
    
    % Minimize the sum of costs of all selected enodes.
    #minimize { C,E,I : sel(E,I), enode(E,I,_,C) }.
    
    opened by philzook58 2
Owner
Using e-graphs to build cool stuff
null
Label Propagation Algorithm by Rust. Label propagation (LP) is graph-based semi-supervised learning (SSL). LGC and CAMLP have been implemented.

label-propagation-rs Label Propagation Algorithm by Rust. Label propagation (LP) is graph-based semi-supervised learning (SSL). A simple LGC and a mor

vaaaaanquish 4 Sep 15, 2021
Rust library for genetic algorithms

Spiril Spiril is an implementation of a genetic algorithm for obtaining optimum variables (genetics) for a task through mutation and natural selection

Ashley Jeffs 25 Apr 29, 2022
darwin-rs, evolutionary algorithms with rust

darwin-rs This library allows you to write evolutionary algorithms (EA) using the Rust programming language. Written by Willi Kappler, License: MIT -

Willi Kappler 95 Jan 1, 2023
DBSCAN and OPTICS clustering algorithms.

petal-clustering A collection of clustering algorithms. Currently this crate provides DBSCAN and OPTICS. Examples The following example shows how to c

Petabi 15 Dec 15, 2022
Nearest neighbor search algorithms including a ball tree and a vantage point tree.

petal-neighbors Nearest neighbor search algorithms including a ball tree and a vantage point tree. Examples The following example shows how to find tw

Petabi 6 Oct 19, 2022
🧮 alphatensor matrix breakthrough algorithms + simd + rust.

simd-alphatensor-rs tldr; alphatensor matrix breakthrough algorithims + simd + rust. This repo contains the cutting edge matrix multiplication algorit

drbh 50 Feb 11, 2023
Personal experiments with genetic algorithms and neuroevolution, in Rust, with the Bevy engine.

The Tango Problem Personal experiments with genetic algorithms and neuroevolution, in Rust, with the Bevy engine. A number of "Psychics" are placed in

null 3 Nov 20, 2023
Coppers is a custom test harnass for Rust that measures the energy usage of your test suite.

Coppers Coppers is a test harness for Rust that can measure the evolution of power consumptions of a Rust program between different versions with the

Thijs Raymakers 175 Dec 4, 2022
Theorem relational dependencies automatic extraction and visualization as a graph for Lean4.

Lean Graph Interactive visualization of dependencies for any theorem/definitions in your Lean project. How to use In your browser: lean-graph.com Or r

Patrik Číhal 8 Jan 3, 2024
ABQ is a universal test runner that runs test suites in parallel. It’s the best tool for splitting test suites into parallel jobs locally or on CI

?? abq.build   ?? @rwx_research   ?? discord   ?? documentation ABQ is a universal test runner that runs test suites in parallel. It’s the best tool f

RWX 13 Apr 7, 2023