Coder Social home page Coder Social logo

ia-androsov / deepgroebner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dylanpeifer/deepgroebner

0.0 0.0 0.0 479.67 MB

Applications of reinforcement learning to Groebner basis computation.

License: GNU General Public License v3.0

C++ 17.54% Python 65.26% CMake 0.41% Macaulay2 16.79%

deepgroebner's Introduction

DeepGroebner

Applications of reinforcement learning to selection strategies in Buchberger's algorithm.

This is the main code repository for Dylan Peifer's 2021 PhD thesis at Cornell University and the paper

with corresponding precomputed statistics and training data available at 10.5281/zenodo.3676043 and 10.5281/zenodo.4724144. Refer to these archives for the exact version of the code used to generate results, and see also the releases. This repository is still in active development.

Requirements and Installation

The main codebase is a Python package in the deepgroebner/ directory. To install dependencies create a conda environment from the included YAML file with

conda env create -f deepgroebner.yml
conda activate deepgroebner

and then install the deepgroebner package with

pip install -e .

Macaulay2 packages in the m2/ directory are used for generating statistics and experimenting with known strategies. To generate the statistics, first follow the installation instructions for Macaulay2 and then verify that you can enter the Macaulay2 interpreter by typing

M2

at the command line in this directory. Finally, type

i1: needsPackage("Ideals", FileName => "m2/Ideals.m2");
i2: needsPackage("SelectionStrategies", FileName => "m2/SelectionStrategies.m2");    

to verify that the packages are available.

Tests

After installation, basic tests of the Python code can be run with

python -m pytest

Basic tests for the Macaulay2 packages can be run inside the Macaulay2 interpreter as

i1: needsPackage("Ideals", FileName => "m2/Ideals.m2");
i2: needsPackage("SelectionStrategies", FileName => "m2/SelectionStrategies.m2");    
i3: check Ideals
i4: check SelectionStrategies

The main training script can be called on the OpenAI Gym environments CartPole-v0, CartPole-v1, and LunarLander-v2, which provides a way to check the PPO implementation on known benchmarks. The commands

python scripts/train.py --environment CartPole-v0 --value_model mlp --epochs 25 --verbose 2

python scripts/train.py --environment CartPole-v1 --value_model mlp --epochs 50 --verbose 2

python scripts/train.py --environment LunarLander-v2 --value_model mlp --epochs 500 --verbose 2

should take a couple minutes, several minutes, and a few hours respectively. Final performance should match or exceed mean_returns of 195.0, 475.0, and 200.0 on these environments.

Running Experiments

All experiments start with the train.py script in the scripts directory. For a list of arguments type

python scripts/train.py --help

Defaults are provided for all arguments in the script.

For example, we can train an agent on 3-20-10-weighted using

python scripts/train.py --distribution 3-20-10-weighted --value_model degree

By default, the script will create a subdirectory in data/train/ where it will store TensorBoard logs, model checkpoints, and a complete list of script arguments in the file args.txt. After copying this file to the top directory, we can rerun the same experiment with

python scripts/train.py @args.txt

Evaluation of trained models is performed with the eval.py script in the scripts directory, which has similar arguments. In particular, --policy_weights should receive the file containing the trained model weights.

Generating Statistics

To generate statistics, use the make_dist.m2, make_stats.m2, and make_strat.m2 scripts in the script directory. The basic workflow is to create a file of sampled ideals with

M2 --script scripts/make_dist.m2 <distribution> <samples> <seed>

and then use this sample to compute values with

M2 --script scripts/make_stats.m2 <distribution>

or compute performance of strategies with

M2 --script scripts/make_strat.m2 <distribution> <strategy> <seed>

where seeding is only important for Random selection. Output is stored in CSV files in the data/stats/ directory.

For example, we can compute statistics and run Degree selection on 10000 samples from 3-20-10-weighted with

M2 --script scripts/make_dist.m2 3-20-10-weighted 10000 123
M2 --script scripts/make_stats.m2 3-20-10-weighted
M2 --script scripts/make_strat.m2 3-20-10-weighted degree

deepgroebner's People

Contributors

danielhl avatar dylanpeifer avatar mikestillman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.