Git Product home page Git Product logo

sat's Introduction

Learning local search heuristics for SAT

Code accompanying the NeurIPS 2019 paper Learning local search heuristics for Boolean satisfiability.

Setup

Make sure to have minisat in your path. It is available here: http://minisat.se/MiniSat.html

Run the following sequence of commands to clone the repository and create the required conda environments.

git clone --recursive https://github.com/emreyolcu/sat.git
cd sat
conda env create -f sat.yaml
conda env create -f cnfgen.yaml
(cd code/PyMiniSolvers && make)

Instructions

Data generation

scripts directory includes bash scripts to generate the data used for training. As an example, to generate the coloring formulas, run the following commands.

conda activate cnfgen
scripts/generate_kcolor.sh

When generating the SR formulas, activate the sat environment instead of cnfgen before running the script.

Training

configs/search directory includes training configurations for each set of formulas. Run the following commands to train models on sets of coloring formulas of increasing size.

conda activate sat
python code/train_search.py --config_path configs/search/kcolor/5.yaml
python code/train_search.py --config_path configs/search/kcolor/10.yaml
python code/train_search.py --config_path configs/search/kcolor/15.yaml
python code/train_search.py --config_path configs/search/kcolor/20.yaml

If a configuration file has the line eval_multi: True, the training script will create 25 processes to perform evaluation during training. Remove this line or change the value to False if you prefer to use a single process instead.

When attempting to use multiple processes you may see the error Too many open files. This can be avoided by executing ulimit -n 4096 (or another large value that your system allows) before starting training.

Evaluation

After training is completed, run the following commands to evaluate a learned model and WalkSAT on a set of formulas.

conda activate sat
python code/evaluate.py --dir_path data/kcolor/3-10-0.5 --samples 5 --model_path results/search/kcolor/5/model_best.pth --no_multi
python code/walksat.py --dir_path data/kcolor/3-10-0.5 --samples 5

Arguments used:

  • --dir_path: Directory containing the formulas.
  • --samples: Number of formulas to run the solver on.
  • --model_path: Saved parameters of the graph neural network to evaluate.
  • --no_multi: Whether to use a single process for evaluation. Without this argument, the script creates 25 processes.

sat's People

Contributors

emreyolcu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sat's Issues

Pre trained model

Can you upload the pre trained weights that you used to achieve the paper's results?

Missing configuration keys in "configs/search/kcolor/5.yaml"

Hi, I'm trying to reproduce the results of your Neurips 2019 paper. After generating data for kcolor with: sh scripts/generate_kcolor.sh, I tried to run python code/train_search.py -c configs/search/kcolor/5.yaml but it failed because of missing configuration keys.

First: KeyError: 'mlp_arch', which I copied from configs/search/sr/10.yaml. Then, the same error, with gnn_iter and gnn_async keys, which I copied from sr/10.yaml. Then, with data_shuffle and eval_multi keys, which I copied from configs/search/sr/10_2.yaml.

After adding all those keys, the code seems to run (it fails on another part, please see #3 ).

My fork has the updated configs/search/kcolor/5.yaml, I can create a PR if you want.

[EDIT: added the pointer to the other issue]

TypeError on train_search.py

Hi, after updating the config. file configs/search/kcolor/5.yaml (see #2 ), I tried to run python code/train_search.py -c configs/search/kcolor/5.yaml but I got the following output:

python code/train_search.py -c configs/search/kcolor/5.yaml                 
/home/anderson/code/yolcusatfork/code/util.py:27: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader
 is unsafe. Please read https://msg.pyyaml.org/load for full details.                                                        
  config = yaml.load(config_data)
[some logs with the config keys]

17:25:46 INFO Device: cpu
17:25:48 INFO Loaded 817 training problems from data/kcolor
17:25:48 INFO Loaded 10 evaluation problems from data/kcolor
17:25:48 INFO Cycle: 1
17:25:48 INFO Train set: 3-5-0.5
Traceback (most recent call last):
  File "code/train_search.py", line 318, in <module>
    main()
  File "code/train_search.py", line 314, in main
    train(ls, optimizer, scheduler, (train_set, eval_set), config)
  File "code/train_search.py", line 211, in train
    new_stats = eval(ls, eval_set, config)
  File "code/train_search.py", line 199, in eval
    flip_update(fp, flips, eval_set['max_flips'])
  File "code/train_search.py", line 171, in flip_update
    med = np.median(flips)
  File "/datalinux/code/miniconda3/envs/mlsat/lib/python3.7/site-packages/numpy/lib/function_base.py", line 3497, in median
    overwrite_input=overwrite_input)
  File "/datalinux/code/miniconda3/envs/mlsat/lib/python3.7/site-packages/numpy/lib/function_base.py", line 3405, in _ureduce
    r = func(a, **kwargs)
  File "/datalinux/code/miniconda3/envs/mlsat/lib/python3.7/site-packages/numpy/lib/function_base.py", line 3530, in _median
    part = partition(a, kth, axis=axis)
  File "/datalinux/code/miniconda3/envs/mlsat/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 734, in partition
    a.partition(kth, axis=axis, kind=kind, order=order)
TypeError: '<' not supported between instances of 'list' and 'int'

Please let me know if I need to run the code in a different way, or if you need additional information.

Thanks in advance!

How curriculum learning is implemented?

We thank the authors for publishing an open-source implementation of their paper. Looking at the repo, it is not immediately clear how curricula are implemented. Can the authors please clarify this point for work on a successor paper? Thank you very much.

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.