├── .clang-format ├── .github └── workflows │ ├── build-and-test-parallel.yml │ ├── build-and-test.yml │ ├── build-werror.yml │ ├── check-changelog.yml │ ├── check-coverage.yml │ ├── check-determinism.yml │ ├── check-diversity.yml │ ├── check-style.yml │ ├── compare-upstream.yml │ ├── mini-competition.yml │ └── unit-tests.yml ├── .gitignore ├── .travis.yml ├── CHANGELOG ├── Dockerfile ├── LICENSE ├── Makefile ├── README ├── README.md ├── core ├── doc ├── ReleaseNotes-2.2.0.txt ├── ReleaseNotes-Glucose-2.1.txt ├── ReleaseNotes-Minisat-2.2.0.txt └── solver_description │ ├── Makefile │ ├── local.bib │ ├── mergesat.tex │ ├── sparrow2mergesat.bib │ └── sparrow2mergesat.tex ├── licence.txt ├── minisat ├── core │ ├── BoundedQueue.h │ ├── Constants.h │ ├── Dimacs.h │ ├── LockGuard.h │ ├── Lookahead.cc │ ├── Lookahead.h │ ├── Makefile │ ├── OnlineProofChecker.h │ ├── Proofs.h │ ├── Solver.cc │ ├── Solver.h │ ├── SolverTypes.h │ └── ipasir.h ├── mtl │ ├── Alg.h │ ├── Alloc.h │ ├── Heap.h │ ├── IntTypes.h │ ├── Map.h │ ├── Queue.h │ ├── Sort.h │ ├── Vec.h │ ├── XAlloc.h │ ├── config.mk │ └── template.mk ├── parallel │ ├── JobQueue.h │ ├── Main.cc │ ├── Makefile │ ├── ParSolver.cc │ ├── ParSolver.h │ ├── Sharing.h │ └── ipasir.cc ├── simp │ ├── Main.cc │ ├── Makefile │ ├── SimpSolver.cc │ ├── SimpSolver.h │ ├── ccadical-mergesat-bridge.h │ └── cmergesat.h ├── tests │ ├── TestSolver.h │ ├── add-from-pool.cc │ ├── add-learned-clause.cc │ ├── double-look-ahead-test.cc │ ├── float-test.cc │ ├── large-proof-clause.cc │ ├── look-ahead-test.cc │ ├── online-proof-checker.cc │ ├── partitioning-formula.cc │ ├── sat-simple.cc │ ├── test_c_interface.cc │ ├── test_interface.cc │ └── test_ipasir.cc └── utils │ ├── Makefile │ ├── Options.cc │ ├── Options.h │ ├── ParseUtils.h │ ├── System.cc │ ├── System.h │ ├── ccnr.cc │ └── ccnr.h ├── mtl ├── parallel ├── simp ├── tools ├── aws_docker │ ├── README.md │ ├── build_images.sh │ ├── common │ │ └── Dockerfile │ ├── leader │ │ ├── Dockerfile │ │ ├── init_solver.sh │ │ ├── run_solver.sh │ │ └── solver │ └── run_parallel.sh ├── cadical-interface │ ├── README.md │ ├── cadical-interface-test.cc │ └── compare-cadical-mergesat.sh ├── check-determinism.sh ├── check-solver-behavior.sh ├── check-style.sh ├── checker │ ├── check-drat.sh │ ├── fuzz-check-configurations.sh │ ├── fuzz-check-diversity.sh │ ├── fuzz-drat.sh │ ├── fuzzcheck.sh │ ├── prepare.sh │ ├── toolCheck.sh │ └── verify_model.c ├── ci.sh ├── ci │ ├── check-determinism.sh │ ├── combine-competition-logs.py │ ├── maxsat │ │ └── UWrMaxSat │ │ │ ├── config.mk │ │ │ └── test-UWrMaxSat.sh │ ├── mini-competition.sh │ └── unsat.cnf.gz ├── compare-to-mainline.sh ├── container-default-command.sh ├── dockerfile │ └── Dockerfile ├── eda-ai │ ├── README │ ├── build.sh │ ├── create-package.sh │ ├── license.txt │ ├── run_config1.sh │ ├── run_config2.sh │ ├── run_config3.sh │ └── run_config_default.sh ├── format-style.sh ├── inject-thp-glibc.sh ├── ipasir_template │ ├── LIBS │ ├── LINK │ └── makefile ├── make-ipasir.sh ├── make-starexec.sh ├── par2-table.sh ├── run_in_container.sh └── starexec_template │ ├── bin │ ├── starexec_run_2threads │ ├── starexec_run_bve_gates │ ├── starexec_run_bve_semgates │ └── starexec_run_thread1 │ └── starexec_build └── utils /.clang-format: -------------------------------------------------------------------------------- 1 | 2 | AccessModifierOffset: 0 3 | AlignEscapedNewlinesLeft: false 4 | AlignTrailingComments: true 5 | AllowAllParametersOfDeclarationOnNextLine: false 6 | AllowShortFunctionsOnASingleLine: true 7 | AllowShortIfStatementsOnASingleLine: true 8 | AllowShortLoopsOnASingleLine: true 9 | AlwaysBreakBeforeMultilineStrings: false 10 | AlwaysBreakTemplateDeclarations: false 11 | BinPackParameters: false 12 | BreakBeforeBinaryOperators: false 13 | BreakBeforeBraces: Linux 14 | BreakBeforeTernaryOperators: false 15 | BreakConstructorInitializersBeforeComma: true 16 | ColumnLimit: 120 17 | CommentPragmas: '' 18 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 19 | ConstructorInitializerIndentWidth: 2 20 | ContinuationIndentWidth: 0 21 | Cpp11BracedListStyle: false 22 | DerivePointerBinding: false 23 | IndentCaseLabels: false 24 | IndentFunctionDeclarationAfterType: false 25 | IndentWidth: 4 26 | Language: Cpp 27 | MaxEmptyLinesToKeep: 2 28 | NamespaceIndentation: None 29 | ObjCSpaceAfterProperty: true 30 | ObjCSpaceBeforeProtocolList: true 31 | PenaltyBreakBeforeFirstCallParameter: 100 32 | PenaltyBreakComment: 100 33 | PenaltyBreakFirstLessLess: 0 34 | PenaltyBreakString: 100 35 | PenaltyExcessCharacter: 1 36 | PenaltyReturnTypeOnItsOwnLine: 20 37 | PointerBindsToType: false 38 | SpaceBeforeAssignmentOperators: true 39 | SpaceBeforeParens: ControlStatements 40 | SpaceInEmptyParentheses: false 41 | SpacesBeforeTrailingComments: 1 42 | SpacesInAngles: false 43 | SpacesInCStyleCastParentheses: false 44 | SpacesInContainerLiterals: false 45 | SpacesInParentheses: false 46 | Standard: Cpp11 47 | TabWidth: 4 48 | UseTab: Never 49 | -------------------------------------------------------------------------------- /.github/workflows/build-and-test-parallel.yml: -------------------------------------------------------------------------------- 1 | name: Build and Test Parallel Solver on Linux and Mac OS 2 | 3 | on: 4 | push: 5 | branches: 6 | - '**' 7 | 8 | pull_request: 9 | branches: 10 | - '**' 11 | 12 | jobs: 13 | Linux: 14 | 15 | runs-on: ubuntu-20.04 16 | 17 | steps: 18 | - name: Install Packages 19 | run: sudo apt-get install zlib1g-dev make cmake picosat 20 | 21 | - uses: actions/checkout@v1 22 | 23 | - name: mergesat build 24 | run: make BUILD_TYPE=parallel d r p sh lr ld lp lsh VERB= 25 | 26 | - name: run CI script 27 | env: 28 | RUNOPENWBO: 0 29 | RUNFUZZ: 0 30 | RUNDIVERSIFY: 0 31 | RUNPARALLELPROOF: 1 32 | run: ./tools/ci.sh 33 | 34 | - name: mergesat re-build 35 | run: | 36 | make BUILD_TYPE=parallel clean -j $(nproc) VERB= 37 | make BUILD_TYPE=parallel d r p sh lr ld lp lsh -j $(nproc) VERB= 38 | 39 | - name: mergesat tests build 40 | run: make BUILD_TYPE=parallel tests-d-all tests-r-all VERB= 41 | 42 | - name: check parallel determinism 43 | run: | 44 | ./tools/check-determinism.sh "build/release/bin/mergesat -cores=3" "build/release/bin/mergesat -cores=3 -no-diversify" "build/release/bin/mergesat -cores=2 -no-pre" "build/debug/bin/mergesat -cores=3" "build/debug/bin/mergesat -cores=3 -no-diversify" "build/debug/bin/mergesat -cores=2 -no-pre" 45 | 46 | 47 | MacOS: 48 | 49 | runs-on: macos-latest 50 | 51 | steps: 52 | - name: Install Packages 53 | run: brew install libzip 54 | 55 | - uses: actions/checkout@v1 56 | 57 | - name: mergesat library build 58 | run: make BUILD_TYPE=parallel sh lr ld lsh VERB= 59 | 60 | - name: mergesat binary build 61 | run: make BUILD_TYPE=parallel d r VERB= 62 | 63 | - name: mergesat tests build 64 | run: make BUILD_TYPE=parallel tests-d-all tests-r-all VERB= 65 | -------------------------------------------------------------------------------- /.github/workflows/build-and-test.yml: -------------------------------------------------------------------------------- 1 | name: Build and Test on Linux and Mac OS 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**' 7 | 8 | jobs: 9 | CrossARM: 10 | 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | - name: Update Dependencies 15 | run: sudo apt-get update 16 | - name: Install Packages 17 | run: sudo apt-get install -y zlib1g-dev make cmake gcc-arm-linux-gnueabi g++-arm-linux-gnueabi 18 | 19 | - uses: actions/checkout@v1 20 | 21 | - name: mergesat build 22 | run: make BUILD_TYPE=parallel d r p sh lr ld lp lsh -j $(nproc) CXX=arm-linux-gnueabi-g++ 23 | 24 | Linux: 25 | 26 | runs-on: ubuntu-18.04 27 | 28 | steps: 29 | - name: Install Packages 30 | run: sudo apt-get install zlib1g-dev make cmake picosat 31 | 32 | - uses: actions/checkout@v1 33 | 34 | - name: mergesat build 35 | run: make d r p sh lr ld lp lsh 36 | 37 | - name: Check working help output 38 | run: ./build/release/bin/mergesat --help 39 | 40 | - name: run CI script 41 | env: 42 | RUNOPENWBO: 0 43 | run: ./tools/ci.sh 44 | 45 | MacOS: 46 | 47 | runs-on: macos-latest 48 | 49 | steps: 50 | - name: Install Packages 51 | run: brew install libzip 52 | 53 | - uses: actions/checkout@v1 54 | 55 | - name: mergesat build 56 | run: make BUILD_TYPE=simp d r sh lr ld lsh 57 | 58 | WebAssembly: 59 | 60 | runs-on: ubuntu-20.04 61 | 62 | steps: 63 | - name: Install Packages 64 | run: sudo apt-get install make 65 | 66 | - uses: actions/checkout@v1 67 | 68 | - uses: actions/cache@v2 69 | with: 70 | path: emsdk-cache 71 | key: emsdk-${{ runner.os }} 72 | 73 | - uses: mymindstorm/setup-emsdk@v9 74 | with: 75 | actions-cache-folder: emsdk-cache 76 | 77 | - name: mergesat build 78 | run: make BUILD_TYPE=simp CXX=em++ lr ld lp 79 | -------------------------------------------------------------------------------- /.github/workflows/build-werror.yml: -------------------------------------------------------------------------------- 1 | name: Build for Warnings on Linux and Mac OS 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**' 7 | 8 | jobs: 9 | Linux: 10 | 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | - name: Install Packages 15 | run: sudo apt-get install zlib1g-dev make cmake picosat 16 | 17 | - uses: actions/checkout@v1 18 | 19 | - name: mergesat build 20 | run: make d r sh lr ld lsh r CXX_EXTRA_FLAGS="-Werror -Wno-sign-compare" LD_EXTRA_FLAGS=-Werror 21 | 22 | - name: run CI script 23 | env: 24 | RUNOPENWBO: 0 25 | run: ./tools/ci.sh 26 | 27 | MacOS: 28 | 29 | runs-on: macos-latest 30 | 31 | steps: 32 | - name: Install Packages 33 | run: brew install libzip 34 | 35 | - uses: actions/checkout@v1 36 | 37 | - name: mergesat build 38 | run: make d r sh lr ld lsh r CXX_EXTRA_FLAGS="-Werror -Wno-sign-compare" LD_EXTRA_FLAGS=-Werror 39 | -------------------------------------------------------------------------------- /.github/workflows/check-changelog.yml: -------------------------------------------------------------------------------- 1 | name: Check CHANGELOG being updated 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**' 7 | 8 | jobs: 9 | Linux: 10 | 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | - uses: actions/checkout@v1 15 | 16 | - name: Check Changelog being rebased on origin/master 17 | run: git merge-base --is-ancestor origin/master $(git log -n 1 --pretty=format:%H -- CHANGELOG) 18 | -------------------------------------------------------------------------------- /.github/workflows/check-coverage.yml: -------------------------------------------------------------------------------- 1 | name: Build and Check Unit Tests with Coverage on Linux 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**' 7 | 8 | jobs: 9 | CrossARM: 10 | 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | - name: Update Dependencies 15 | run: sudo apt-get update 16 | - name: Install Packages 17 | run: sudo apt-get install -y zlib1g-dev make cmake lcov 18 | 19 | - uses: actions/checkout@v1 20 | 21 | - name: mergesat build 22 | run: | 23 | make clean 24 | rm -rf build 25 | make CXX_EXTRA_FLAGS=--coverage LD_EXTRA_FLAGS=--coverage run-tests-d-all 26 | lcov --no-external -f --capture -d build -d minisat --output-file coverage.info 27 | lcov -l coverage.info 28 | 29 | -------------------------------------------------------------------------------- /.github/workflows/check-determinism.yml: -------------------------------------------------------------------------------- 1 | name: Check Determinism 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**' 7 | 8 | jobs: 9 | 10 | Linux: 11 | 12 | runs-on: ubuntu-18.04 13 | 14 | steps: 15 | - name: Install Packages 16 | run: sudo apt-get install zlib1g-dev make cmake picosat 17 | 18 | - uses: actions/checkout@v1 19 | 20 | - name: mergesat build 21 | run: make r 22 | 23 | - name: run CI script 24 | env: 25 | RUNOPENWBO: 0 26 | run: ./tools/ci/check-determinism.sh build/release/bin/mergesat 27 | 28 | -------------------------------------------------------------------------------- /.github/workflows/check-diversity.yml: -------------------------------------------------------------------------------- 1 | name: Check diversity configurations 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**' 7 | 8 | jobs: 9 | Linux: 10 | 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | - name: Install Packages 15 | run: sudo apt-get install zlib1g-dev make cmake picosat 16 | 17 | - uses: actions/checkout@v1 18 | 19 | - name: run CI script 20 | env: 21 | RUNDIVERSIFY: 1 22 | RUNFUZZ: 0 23 | RUNSTAREXEC: 0 24 | RUNIPASIR: 0 25 | RUNOPENWBO: 0 26 | run: ./tools/ci.sh 27 | -------------------------------------------------------------------------------- /.github/workflows/check-style.yml: -------------------------------------------------------------------------------- 1 | name: Check code style 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**' 7 | 8 | jobs: 9 | Linux: 10 | 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | - name: Install Packages 15 | run: sudo apt-get install zlib1g-dev make cmake clang-format-6.0 16 | 17 | - uses: actions/checkout@v1 18 | 19 | - name: mergesat build 20 | run: ./tools/check-style.sh 21 | -------------------------------------------------------------------------------- /.github/workflows/compare-upstream.yml: -------------------------------------------------------------------------------- 1 | name: Compare To Upsteram 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**' 7 | 8 | jobs: 9 | Linux: 10 | 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | - name: Install Packages 15 | run: sudo apt-get install zlib1g-dev make cmake picosat runlim xz-utils p7zip-full bzip2 16 | 17 | - uses: actions/checkout@v1 18 | 19 | - name: mergesat build 20 | run: make r 21 | 22 | - name: run compare script 23 | run: bash -x ./tools/compare-to-mainline.sh -v "build/release/bin/mergesat" 24 | -------------------------------------------------------------------------------- /.github/workflows/mini-competition.yml: -------------------------------------------------------------------------------- 1 | name: Run Mini-Competition Benchmark on Linux 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**' 7 | 8 | jobs: 9 | Linux: 10 | 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | - name: Install Packages 15 | run: sudo apt-get install zlib1g-dev make cmake picosat runlim xz-utils p7zip-full bzip2 16 | 17 | - uses: actions/checkout@v1 18 | 19 | - name: mergesat build 20 | run: make d r p sh lr ld lp lsh 21 | 22 | - name: run copmetition script 23 | run: bash -x ./tools/ci/mini-competition.sh -v "build/release/bin/mergesat" 24 | -------------------------------------------------------------------------------- /.github/workflows/unit-tests.yml: -------------------------------------------------------------------------------- 1 | name: Run Unit Test on Linux and Mac OS 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**' 7 | 8 | jobs: 9 | Linux: 10 | 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | - name: Install Packages 15 | run: sudo apt-get install zlib1g-dev make cmake picosat 16 | 17 | - uses: actions/checkout@v1 18 | 19 | - name: Run mergesat release unit tests 20 | run: make run-tests-r-all 21 | 22 | - name: Run mergesat debug unit tests 23 | run: make run-tests-d-all 24 | 25 | MacOS: 26 | 27 | runs-on: macos-latest 28 | 29 | steps: 30 | - name: Install Packages 31 | run: brew install libzip 32 | 33 | - uses: actions/checkout@v1 34 | 35 | - name: Run mergesat release unit tests 36 | run: make run-tests-r-all 37 | 38 | - name: Run mergesat debug unit tests 39 | run: make run-tests-d-all 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | config.mk 2 | build 3 | *.log 4 | *.cnf 5 | otherSolvers 6 | tmp 7 | glucoses 8 | maplesat 9 | cov-int 10 | cnfs 11 | benchmark 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | dist: xenial 3 | compiler: g++ 4 | sudo: required 5 | 6 | before_install: 7 | - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y 8 | - sudo apt-get update -q 9 | - sudo apt-get remove gcc g++ 10 | - sudo apt-get install g++-7 gcc-7 -y 11 | - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7 12 | - sudo update-alternatives --install /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-7 60 13 | - sudo update-alternatives --install /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-7 60 14 | - sudo update-alternatives --install /usr/bin/x86_64-linux-gnu-gcc x86_64-linux-gnu-gcc /usr/bin/x86_64-linux-gnu-gcc-7 60 --slave /usr/bin/x86_64-linux-gnu-g++ x86_64-linux-gnu-g++ /usr/bin/x86_64-linux-gnu-g++-7 15 | - sudo apt-get install clang-format-6.0 16 | - sudo apt-get install picosat 17 | 18 | # run the typical ci checks, for now, compile 19 | script: 20 | - make d r p sh lr ld lp lsh -j $(nproc) 21 | - git checkout -b travis-ci-test-branch 22 | - ./tools/check-style.sh 23 | - RUNIPASIR=0 RUNOPENWBO=0 ./tools/ci.sh 24 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [unreleased] 9 | 10 | * add AWS docker infrastructure 11 | * add gate detection for portfolio configurations 12 | 13 | ## [4.0-rc3] 14 | 15 | * BVE with syntactic gate detection 16 | * BVE with semantic gate detection 17 | * Use parallel solver as default 18 | * Use parallel solver in incremental IPASIR solver 19 | * Each thread runs its own simplification 20 | 21 | ## [4.0-rc2] 22 | 23 | * Use solver internal math code 24 | * Activity: initialize by variable order 25 | * Use necessary assignment reasoning every 4th level 0 decision 26 | * print 20 variables per model line 27 | 28 | ## [3.3.1] 29 | 30 | * testing: extend incremental interface tests 31 | * GC allow to relocate based on assignment order 32 | * LA: implement one-sided double look-ahead 33 | 34 | ## [3.3.0] 35 | 36 | * pow: implement internal method 37 | * ci: check determinisms 38 | * parallel: support all sequential entry point features, and make it default 39 | 40 | ## [v3.2.4] - 2022-02-28 41 | 42 | * implement detecting necessary assignments 43 | * implement all-strengthening 44 | * implement on-the-fly self-subsumption 45 | * generalized variant of learning all UIP clauses 46 | * implement AllUIP minimization by Feng and Bacchus 47 | * include lookahead as decision heuristic 48 | * improve documentation 49 | 50 | ## [v3.2.3] - 2022-01-16 51 | 52 | * parallel: support proof generation 53 | * testing: use modgen generator during fuzzing runs 54 | * fix FPU control to compile on ARM 55 | 56 | ## [v3.2.1] - 2021-12-20 57 | 58 | * interface: implement CaDiCaL's C interface, and test similar behavior 59 | * interface: provide cmergesat.h C interface 60 | * simp: support freezing a variable multiple times 61 | 62 | ## [v3.2.1] - 2021-12-29 63 | 64 | * parallel: introduce Semaphore class, to compile on Mac 65 | 66 | ## [v3.2.0] - 2021-12-20 67 | 68 | * version: use full semantic versioning 69 | * parallel: fix solving with uniform configuration in all solvers 70 | * parallel: fixing not using simplification for parallel solvers 71 | 72 | ## [v3.1] - 2021-11-27 73 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | tools/dockerfile/Dockerfile -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2021 Norbert Manthey 2 | Copyright (c) 2019-2020 Armin Biere, Johannes Kepler University Linz, Austria 3 | Maple_LCM_Dist_Chrono -- Copyright (c) 2018, Vadim Ryvchin, Alexander Nadel 4 | MapleSAT -- Copyright (c) 2016, Jia Hui Liang, Vijay Ganesh 5 | GlucoseNbSAT -- Copyright (c) 2016, Chu Min LI, Mao Luo and Fan Xiao 6 | Huazhong University of science and technology, China 7 | MIS, Univ. Picardie Jules Verne, France 8 | MiniSat -- Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 9 | Copyright (c) 2007-2010 Niklas Sorensson 10 | 11 | 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the 15 | "Software"), to deal in the Software without restriction, including 16 | without limitation the rights to use, copy, modify, merge, publish, 17 | distribute, sublicense, and/or sell copies of the Software, and to 18 | permit persons to whom the Software is furnished to do so, subject to 19 | the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included 22 | in all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 25 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | README.md -------------------------------------------------------------------------------- /core: -------------------------------------------------------------------------------- 1 | minisat/core -------------------------------------------------------------------------------- /doc/ReleaseNotes-2.2.0.txt: -------------------------------------------------------------------------------- 1 | Release Notes for MiniSat 2.2.0 2 | =============================== 3 | 4 | Changes since version 2.0: 5 | 6 | * Started using a more standard release numbering. 7 | 8 | * Includes some now well-known heuristics: phase-saving and luby 9 | restarts. The old heuristics are still present and can be activated 10 | if needed. 11 | 12 | * Detection/Handling of out-of-memory and vector capacity 13 | overflow. This is fairly new and relatively untested. 14 | 15 | * Simple resource controls: CPU-time, memory, number of 16 | conflicts/decisions. 17 | 18 | * CPU-time limiting is implemented by a more general, but simple, 19 | asynchronous interruption feature. This means that the solving 20 | procedure can be interrupted from another thread or in a signal 21 | handler. 22 | 23 | * Improved portability with respect to building on Solaris and with 24 | Visual Studio. This is not regularly tested and chances are that 25 | this have been broken since, but should be fairly easy to fix if 26 | so. 27 | 28 | * Changed C++ file-extention to the less problematic ".cc". 29 | 30 | * Source code is now namespace-protected 31 | 32 | * Introducing a new Clause Memory Allocator that brings reduced 33 | memory consumption on 64-bit architechtures and improved 34 | performance (to some extent). The allocator uses a region-based 35 | approach were all references to clauses are represented as a 32-bit 36 | index into a global memory region that contains all clauses. To 37 | free up and compact memory it uses a simple copying garbage 38 | collector. 39 | 40 | * Improved unit-propagation by Blocking Literals. For each entry in 41 | the watcher lists, pair the pointer to a clause with some 42 | (arbitrary) literal from the clause. The idea is that if the 43 | literal is currently true (i.e. the clause is satisfied) the 44 | watchers of the clause does not need to be altered. This can thus 45 | be detected without touching the clause's memory at all. As often 46 | as can be done cheaply, the blocking literal for entries to the 47 | watcher list of a literal 'p' is set to the other literal watched 48 | in the corresponding clause. 49 | 50 | * Basic command-line/option handling system. Makes it easy to specify 51 | options in the class that they affect, and whenever that class is 52 | used in an executable, parsing of options and help messages are 53 | brought in automatically. 54 | 55 | * General clean-up and various minor bug-fixes. 56 | 57 | * Changed implementation of variable-elimination/model-extension: 58 | 59 | - The interface is changed so that arbitrary remembering is no longer 60 | possible. If you need to mention some variable again in the future, 61 | this variable has to be frozen. 62 | 63 | - When eliminating a variable, only clauses that contain the variable 64 | with one sign is necessary to store. Thereby making the other sign 65 | a "default" value when extending models. 66 | 67 | - The memory consumption for eliminated clauses is further improved 68 | by storing all eliminated clauses in a single contiguous vector. 69 | 70 | * Some common utility code (I/O, Parsing, CPU-time, etc) is ripped 71 | out and placed in a separate "utils" directory. 72 | 73 | * The DIMACS parse is refactored so that it can be reused in other 74 | applications (not very elegant, but at least possible). 75 | 76 | * Some simple improvements to scalability of preprocessing, using 77 | more lazy clause removal from data-structures and a couple of 78 | ad-hoc limits (the longest clause that can be produced in variable 79 | elimination, and the longest clause used in backward subsumption). 80 | -------------------------------------------------------------------------------- /doc/ReleaseNotes-Glucose-2.1.txt: -------------------------------------------------------------------------------- 1 | Release Notes for Glucose 2.1 2 | ============================= 3 | 4 | Changes since version 2.0: 5 | 6 | * Change restart strategies 7 | - Change restart constants, uses the ones from glueminisat (http://glueminisat.nabelab.org/) 8 | - Add a strategy to block restarts (see CP 2012 paper) 9 | 10 | * Improve logs 11 | 12 | * Add options to play with magic constants 13 | -------------------------------------------------------------------------------- /doc/ReleaseNotes-Minisat-2.2.0.txt: -------------------------------------------------------------------------------- 1 | Release Notes for MiniSat 2.2.0 2 | =============================== 3 | 4 | Changes since version 2.0: 5 | 6 | * Started using a more standard release numbering. 7 | 8 | * Includes some now well-known heuristics: phase-saving and luby 9 | restarts. The old heuristics are still present and can be activated 10 | if needed. 11 | 12 | * Detection/Handling of out-of-memory and vector capacity 13 | overflow. This is fairly new and relatively untested. 14 | 15 | * Simple resource controls: CPU-time, memory, number of 16 | conflicts/decisions. 17 | 18 | * CPU-time limiting is implemented by a more general, but simple, 19 | asynchronous interruption feature. This means that the solving 20 | procedure can be interrupted from another thread or in a signal 21 | handler. 22 | 23 | * Improved portability with respect to building on Solaris and with 24 | Visual Studio. This is not regularly tested and chances are that 25 | this have been broken since, but should be fairly easy to fix if 26 | so. 27 | 28 | * Changed C++ file-extention to the less problematic ".cc". 29 | 30 | * Source code is now namespace-protected 31 | 32 | * Introducing a new Clause Memory Allocator that brings reduced 33 | memory consumption on 64-bit architechtures and improved 34 | performance (to some extent). The allocator uses a region-based 35 | approach were all references to clauses are represented as a 32-bit 36 | index into a global memory region that contains all clauses. To 37 | free up and compact memory it uses a simple copying garbage 38 | collector. 39 | 40 | * Improved unit-propagation by Blocking Literals. For each entry in 41 | the watcher lists, pair the pointer to a clause with some 42 | (arbitrary) literal from the clause. The idea is that if the 43 | literal is currently true (i.e. the clause is satisfied) the 44 | watchers of the clause does not need to be altered. This can thus 45 | be detected without touching the clause's memory at all. As often 46 | as can be done cheaply, the blocking literal for entries to the 47 | watcher list of a literal 'p' is set to the other literal watched 48 | in the corresponding clause. 49 | 50 | * Basic command-line/option handling system. Makes it easy to specify 51 | options in the class that they affect, and whenever that class is 52 | used in an executable, parsing of options and help messages are 53 | brought in automatically. 54 | 55 | * General clean-up and various minor bug-fixes. 56 | 57 | * Changed implementation of variable-elimination/model-extension: 58 | 59 | - The interface is changed so that arbitrary remembering is no longer 60 | possible. If you need to mention some variable again in the future, 61 | this variable has to be frozen. 62 | 63 | - When eliminating a variable, only clauses that contain the variable 64 | with one sign is necessary to store. Thereby making the other sign 65 | a "default" value when extending models. 66 | 67 | - The memory consumption for eliminated clauses is further improved 68 | by storing all eliminated clauses in a single contiguous vector. 69 | 70 | * Some common utility code (I/O, Parsing, CPU-time, etc) is ripped 71 | out and placed in a separate "utils" directory. 72 | 73 | * The DIMACS parse is refactored so that it can be reused in other 74 | applications (not very elegant, but at least possible). 75 | 76 | * Some simple improvements to scalability of preprocessing, using 77 | more lazy clause removal from data-structures and a couple of 78 | ad-hoc limits (the longest clause that can be produced in variable 79 | elimination, and the longest clause used in backward subsumption). 80 | -------------------------------------------------------------------------------- /doc/solver_description/Makefile: -------------------------------------------------------------------------------- 1 | mergesat.pdf: always 2 | pdflatex mergesat 3 | pdflatex mergesat 4 | bibtex -terse mergesat 5 | pdflatex mergesat 6 | 7 | always: 8 | 9 | clean: 10 | rm -f *.pdf *.aux *.bbl *.log *.out *.tex.backup *.tex.bak *.blg 11 | -------------------------------------------------------------------------------- /licence.txt: -------------------------------------------------------------------------------- 1 | Glucose -- Copyright (c) 2009, Gilles Audemard, Laurent Simon 2 | CRIL - Univ. Artois, France 3 | LRI - Univ. Paris Sud, France 4 | 5 | Glucose sources are based on MiniSat (see below MiniSat copyrights). Permissions and copyrights of 6 | Glucose are exactly the same as Minisat on which it is based on. (see below). 7 | 8 | -------- 9 | 10 | MiniSat -- Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 11 | Copyright (c) 2007-2010 Niklas Sorensson 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of this software and associated documentation files (the 15 | "Software"), to deal in the Software without restriction, including 16 | without limitation the rights to use, copy, modify, merge, publish, 17 | distribute, sublicense, and/or sell copies of the Software, and to 18 | permit persons to whom the Software is furnished to do so, subject to 19 | the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included 22 | in all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 25 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | -------------------------------------------------------------------------------- /minisat/core/BoundedQueue.h: -------------------------------------------------------------------------------- 1 | /***********************************************************************************[BoundedQueue.h] 2 | Glucose -- Copyright (c) 2009, Gilles Audemard, Laurent Simon 3 | CRIL - Univ. Artois, France 4 | LRI - Univ. Paris Sud, France 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 7 | associated documentation files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all copies or 13 | substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 16 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 19 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | **************************************************************************************************/ 21 | 22 | 23 | #ifndef MergeSat_BoundedQueue_h 24 | #define MergeSat_BoundedQueue_h 25 | 26 | #include "mtl/Vec.h" 27 | 28 | //================================================================================================= 29 | 30 | namespace MERGESAT_NSPACE 31 | { 32 | 33 | template class bqueue 34 | { 35 | vec elems; 36 | int first; 37 | int last; 38 | unsigned long long sumofqueue; 39 | int maxsize; 40 | int queuesize; // Number of current elements (must be < maxsize !) 41 | bool expComputed; 42 | double exp, value; 43 | 44 | public: 45 | bqueue(void) : first(0), last(0), sumofqueue(0), maxsize(0), queuesize(0), expComputed(false) {} 46 | 47 | void initSize(int size) 48 | { 49 | growTo(size); 50 | exp = 2.0 / (size + 1); 51 | } // Init size of bounded size queue 52 | 53 | void push(T x) 54 | { 55 | expComputed = false; 56 | if (queuesize == maxsize) { 57 | assert(last == first); // The queue is full, next value to enter will replace oldest one 58 | sumofqueue -= elems[last]; 59 | if ((++last) == maxsize) last = 0; 60 | } else 61 | queuesize++; 62 | sumofqueue += x; 63 | elems[first] = x; 64 | if ((++first) == maxsize) { 65 | first = 0; 66 | last = 0; 67 | } 68 | } 69 | 70 | T peek() 71 | { 72 | assert(queuesize > 0); 73 | return elems[last]; 74 | } 75 | void pop() 76 | { 77 | sumofqueue -= elems[last]; 78 | queuesize--; 79 | if ((++last) == maxsize) last = 0; 80 | } 81 | 82 | unsigned long long getsum() const { return sumofqueue; } 83 | unsigned int getavg() const { return (unsigned int)(sumofqueue / ((unsigned long long)queuesize)); } 84 | int maxSize() const { return maxsize; } 85 | double getavgDouble() const 86 | { 87 | double tmp = 0; 88 | for (int i = 0; i < elems.size(); i++) { 89 | tmp += elems[i]; 90 | } 91 | return tmp / elems.size(); 92 | } 93 | int isvalid() const { return (queuesize == maxsize); } 94 | 95 | void growTo(int size) 96 | { 97 | elems.growTo(size); 98 | first = 0; 99 | maxsize = size; 100 | queuesize = 0; 101 | last = 0; 102 | for (int i = 0; i < size; i++) elems[i] = 0; 103 | } 104 | 105 | double getAvgExp() 106 | { 107 | if (expComputed) return value; 108 | double a = exp; 109 | value = elems[first]; 110 | for (int i = first; i < maxsize; i++) { 111 | value += a * ((double)elems[i]); 112 | a = a * exp; 113 | } 114 | for (int i = 0; i < last; i++) { 115 | value += a * ((double)elems[i]); 116 | a = a * exp; 117 | } 118 | value = value * (1 - exp) / (1 - a); 119 | expComputed = true; 120 | return value; 121 | } 122 | void fastclear() 123 | { 124 | first = 0; 125 | last = 0; 126 | queuesize = 0; 127 | sumofqueue = 0; 128 | } // to be called after restarts... Discard the queue 129 | 130 | int size(void) { return queuesize; } 131 | 132 | void clear(bool dealloc = false) 133 | { 134 | elems.clear(dealloc); 135 | first = 0; 136 | maxsize = 0; 137 | queuesize = 0; 138 | sumofqueue = 0; 139 | } 140 | }; 141 | } // namespace MERGESAT_NSPACE 142 | //================================================================================================= 143 | 144 | #endif 145 | -------------------------------------------------------------------------------- /minisat/core/Constants.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************[Constants.h] 2 | Glucose -- Copyright (c) 2009, Gilles Audemard, Laurent Simon 3 | CRIL - Univ. Artois, France 4 | LRI - Univ. Paris Sud, France 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 7 | associated documentation files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all copies or 13 | substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 16 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 19 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | **************************************************************************************************/ 21 | 22 | #ifndef MergeSat_Constants_h 23 | #define MergeSat_Constants_h 24 | 25 | #define DYNAMICNBLEVEL 26 | #define CONSTANTREMOVECLAUSE 27 | #define UPDATEVARACTIVITY 28 | 29 | // Constants for clauses reductions 30 | #define RATIOREMOVECLAUSES 2 31 | 32 | 33 | // Constants for restarts 34 | #define LOWER_BOUND_FOR_BLOCKING_RESTART 10000 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /minisat/core/Dimacs.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************************[Dimacs.h] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #ifndef MergeSat_Dimacs_h 22 | #define MergeSat_Dimacs_h 23 | 24 | #include 25 | 26 | #include "core/SolverTypes.h" 27 | #include "utils/ParseUtils.h" 28 | 29 | namespace MERGESAT_NSPACE 30 | { 31 | 32 | //================================================================================================= 33 | // DIMACS Parser: 34 | 35 | template static void readClause(B &in, Solver &S, vec &lits) 36 | { 37 | int parsed_lit, var; 38 | lits.clear(); 39 | for (;;) { 40 | parsed_lit = parseInt(in); 41 | if (parsed_lit == 0) break; 42 | var = abs(parsed_lit) - 1; 43 | while (var >= S.nVars()) S.newVar(); 44 | lits.push((parsed_lit > 0) ? mkLit(var) : ~mkLit(var)); 45 | } 46 | } 47 | 48 | template static void parse_DIMACS_main(B &in, Solver &S) 49 | { 50 | vec lits; 51 | int vars = 0; 52 | int clauses = 0; 53 | int cnt = 0; 54 | for (;;) { 55 | skipWhitespace(in); 56 | if (*in == EOF) 57 | break; 58 | else if (*in == 'p') { 59 | if (eagerMatch(in, "p cnf")) { 60 | vars = parseInt(in); 61 | clauses = parseInt(in); 62 | 63 | // allow to actually disable simplification 64 | if (clauses > S.max_simp_cls()) S.eliminate(true); 65 | 66 | // reserve space for the given amount of variables 67 | S.reserveVars(vars); 68 | } else { 69 | printf("PARSE ERROR! Unexpected char: %c\n", *in), exit(3); 70 | } 71 | } else if (*in == 'c' || *in == 'p') 72 | skipLine(in); 73 | else { 74 | cnt++; 75 | readClause(in, S, lits); 76 | S.addInputClause_(lits); // initialize online proof checker 77 | S.addClause_(lits); 78 | } 79 | } 80 | if (vars != S.nVars()) fprintf(stderr, "c WARNING! DIMACS header mismatch: wrong number of variables.\n"); 81 | if (cnt != clauses) fprintf(stderr, "c WARNING! DIMACS header mismatch: wrong number of clauses.\n"); 82 | } 83 | 84 | // Inserts problem into solver. 85 | // 86 | #ifdef USE_LIBZ 87 | template static void parse_DIMACS(gzFile input_stream, Solver &S) 88 | #else 89 | template static void parse_DIMACS(FILE *input_stream, Solver &S) 90 | #endif 91 | { 92 | StreamBuffer in(input_stream); 93 | parse_DIMACS_main(in, S); 94 | } 95 | 96 | //================================================================================================= 97 | } // namespace MERGESAT_NSPACE 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /minisat/core/LockGuard.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************[LockGuard.h] 2 | Copyright (c) 2022, Norbert Manthey 3 | **************************************************************************************************/ 4 | 5 | #ifndef LockGuard_h 6 | #define LockGuard_h 7 | 8 | #include "mtl/XAlloc.h" 9 | #include 10 | 11 | namespace MERGESAT_NSPACE 12 | { 13 | 14 | /** Allow to easily grab a lock for the life time of a function or code block.*/ 15 | class LockGuard 16 | { 17 | std::mutex &lock; 18 | bool doUnlock; 19 | 20 | public: 21 | LockGuard(std::mutex &externLock, bool doLock) : lock(externLock), doUnlock(doLock) 22 | { 23 | if (doLock) lock.lock(); 24 | } 25 | ~LockGuard() 26 | { 27 | if (doUnlock) lock.unlock(); 28 | } 29 | }; 30 | 31 | } // namespace MERGESAT_NSPACE 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /minisat/core/Lookahead.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************************** 2 | MiniSat -- Copyright (c) 2022, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #ifndef MergeSat_Lookahead_h 21 | #define MergeSat_Lookahead_h 22 | 23 | #include "core/Solver.h" 24 | 25 | namespace MERGESAT_NSPACE 26 | { 27 | 28 | class Lookahead 29 | { 30 | // private data structures to be used over multiple calls 31 | vec learnt_clause_lits; 32 | 33 | uint64_t stats_dlas, stats_dlaFailedLits; 34 | 35 | Solver &solver; // handle to solver to be used durnig operations 36 | 37 | /** score a given variable, support sorting */ 38 | class VarScore 39 | { 40 | Var var; 41 | double score; 42 | 43 | public: 44 | VarScore() {} 45 | VarScore(Var v, double s) : var(v), score(s) {} 46 | Var getVar() const { return var; } 47 | 48 | bool operator<(const VarScore &vs) const { return (score < vs.score); } 49 | }; 50 | vec preScores; // preselection scores per variable 51 | vec numLitTerClause; // number of ternary clauses with a given literal 52 | 53 | vec doubleQueue; // Literals to be considered during double look ahead 54 | vec doubleQueueSeen; // Flags to be used to de-duplicate literals on queue 55 | 56 | /** represent formula wrt current solver assignment */ 57 | struct ClauseReduct { 58 | CRef cr; 59 | int size; 60 | }; 61 | vec reduct; 62 | bool computedPreScores; // indicate whether we precomputed scores at least once 63 | 64 | void computePreScores(); 65 | void collectPreselectVars(vec &vars, int candidatePoolSize, bool recomputePreScores = false); 66 | 67 | /** create the reduct struct, is allowed to swap all unwatched literals (index != 0,1) */ 68 | bool create_reduct(CRef cr, ClauseReduct &reduct); 69 | 70 | /** create a clause "(decisions) -> l", add to solver, use to imply 'l' */ 71 | void fixViaEnqueueWithDecisionClause(Lit l); 72 | 73 | /** run analysis on 2nd level during double lookahead for literal q, for LA of p */ 74 | CRef runDoubleLookahaed(Lit p, Lit q); 75 | 76 | /** run look-ahead for given literal p, return a conflict clause if p is a conflicting literal, or CRef_Undef */ 77 | CRef localLookAhead(Lit p, double &score, vec &lookaheadTrail, vec &impliedLits, bool collectForDLA = false); 78 | 79 | /** fill doubleQueue with literals relevant for double-LA after propagating p, to be used on ~p for DLA! */ 80 | void collectDoubleLACandidates(Lit p); 81 | 82 | /** clear DLA queue structure again*/ 83 | void cleanDLAqueue(int start = 0); 84 | 85 | public: 86 | Lookahead(Solver &s); 87 | 88 | /** From the available variables, select a literal via look-ahead, or return a detected conflict 89 | * 90 | * Returns lit_Error, in case of an error - sets confl to a conflict clause, or that not literal 91 | * could be detected. 92 | * lit_Undef, LA failed to detect a suitable literal, because either none is available, 93 | * or recomputePreScores needs to be set to true 94 | * literal in case this literal can be used as decision literal 95 | * Note: using double lookahead might introduce additional temporary clauses to the solver 96 | */ 97 | Lit lookaheadDecision(CRef &confl, int candidatePoolSize = 5, bool recomputePreScores = false, bool useDLA = false); 98 | }; 99 | 100 | //================================================================================================= 101 | } // namespace MERGESAT_NSPACE 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /minisat/core/Makefile: -------------------------------------------------------------------------------- 1 | EXEC = mergesat 2 | DEPDIR = mtl utils 3 | MROOT = .. 4 | 5 | include $(MROOT)/mtl/template.mk 6 | -------------------------------------------------------------------------------- /minisat/mtl/Alg.h: -------------------------------------------------------------------------------- 1 | /*******************************************************************************************[Alg.h] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #ifndef MergeSat_Alg_h 22 | #define MergeSat_Alg_h 23 | 24 | #include "mtl/Vec.h" 25 | 26 | namespace MERGESAT_NSPACE 27 | { 28 | 29 | //================================================================================================= 30 | // Useful functions on vector-like types: 31 | 32 | //================================================================================================= 33 | // Removing and searching for elements: 34 | // 35 | 36 | template static inline void remove(V &ts, const T &t) 37 | { 38 | int j = 0; 39 | for (; j < ts.size() && ts[j] != t; j++) 40 | ; 41 | assert(j < ts.size()); 42 | for (; j < ts.size() - 1; j++) ts[j] = ts[j + 1]; 43 | ts.pop(); 44 | } 45 | 46 | /// remove but do not keep the order (push last element to deleted position 47 | template static inline void removeUnSort(V &ts, const T &t) 48 | { 49 | int j = 0; 50 | for (; j < ts.size() && ts[j] != t; j++) { 51 | }; 52 | assert(j < ts.size() && "item must appear in std::vector"); 53 | ts[j] = ts[ts.size() - 1]; 54 | ts.pop(); 55 | } 56 | 57 | 58 | template static inline bool find(V &ts, const T &t) 59 | { 60 | int j = 0; 61 | for (; j < ts.size() && ts[j] != t; j++) 62 | ; 63 | return j < ts.size(); 64 | } 65 | 66 | 67 | //================================================================================================= 68 | // Copying vectors with support for nested vector types: 69 | // 70 | 71 | // Base case: 72 | template static inline void copy(const T &from, T &to) { to = from; } 73 | 74 | // Recursive case: 75 | template static inline void copy(const vec &from, vec &to, bool append = false) 76 | { 77 | if (!append) to.clear(); 78 | for (int i = 0; i < from.size(); i++) { 79 | to.push(); 80 | copy(from[i], to.last()); 81 | } 82 | } 83 | 84 | template static inline void append(const vec &from, vec &to) { copy(from, to, true); } 85 | 86 | //================================================================================================= 87 | } // namespace MERGESAT_NSPACE 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /minisat/mtl/Alloc.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************************[Alloc.h] 2 | Copyright (c) 2008-2010, Niklas Sorensson 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | 21 | #ifndef MergeSat_Alloc_h 22 | #define MergeSat_Alloc_h 23 | 24 | #include "mtl/Vec.h" 25 | #include "mtl/XAlloc.h" 26 | 27 | namespace MERGESAT_NSPACE 28 | { 29 | 30 | class AccessCounter 31 | { 32 | uint64_t clause_access, occurrence_access; 33 | 34 | public: 35 | AccessCounter() : clause_access(0), occurrence_access(0) {} 36 | 37 | void o() { occurrence_access++; } 38 | void c() { clause_access++; } 39 | 40 | uint64_t occurrence() const { return occurrence_access; } 41 | uint64_t clause() const { return clause_access; } 42 | uint64_t sum() const { return clause_access + occurrence_access; } 43 | }; 44 | 45 | //================================================================================================= 46 | // Simple Region-based memory allocator: 47 | 48 | template class RegionAllocator 49 | { 50 | T *memory; 51 | uint32_t sz; 52 | uint32_t cap; 53 | uint32_t wasted_; 54 | AccessCounter &counter; 55 | 56 | void capacity(uint32_t min_cap); 57 | 58 | public: 59 | // TODO: make this a class for better type-checking? 60 | typedef uint32_t Ref; 61 | enum { Ref_Undef = UINT32_MAX }; 62 | enum { Unit_Size = sizeof(uint32_t) }; 63 | 64 | explicit RegionAllocator(AccessCounter &_counter, uint32_t start_cap = 1024 * 1024) 65 | : memory(NULL), sz(0), cap(0), wasted_(0), counter(_counter) 66 | { 67 | capacity(start_cap); 68 | } 69 | ~RegionAllocator() 70 | { 71 | if (memory != NULL) ::free(memory); 72 | } 73 | 74 | 75 | uint32_t size() const { return sz; } 76 | uint32_t wasted() const { return wasted_; } 77 | 78 | Ref alloc(int size); 79 | void free(int size) { wasted_ += size; } 80 | 81 | // Deref, Load Effective Address (LEA), Inverse of LEA (AEL): 82 | T &operator[](Ref r) 83 | { 84 | assert(r < sz); 85 | counter.c(); 86 | return memory[r]; 87 | } 88 | const T &operator[](Ref r) const 89 | { 90 | assert(r < sz); 91 | counter.c(); 92 | return memory[r]; 93 | } 94 | 95 | T *lea(Ref r) 96 | { 97 | assert(r < sz); 98 | return &memory[r]; 99 | } 100 | const T *lea(Ref r) const 101 | { 102 | assert(r < sz); 103 | return &memory[r]; 104 | } 105 | Ref ael(const T *t) 106 | { 107 | assert((void *)t >= (void *)&memory[0] && (void *)t < (void *)&memory[sz - 1]); 108 | return (Ref)(t - &memory[0]); 109 | } 110 | 111 | void moveTo(RegionAllocator &to) 112 | { 113 | if (to.memory != NULL) ::free(to.memory); 114 | to.memory = memory; 115 | to.sz = sz; 116 | to.cap = cap; 117 | to.wasted_ = wasted_; 118 | 119 | memory = NULL; 120 | sz = cap = wasted_ = 0; 121 | } 122 | 123 | void clear() { sz = wasted_ = 0; } 124 | 125 | AccessCounter &get_counter() { return counter; } 126 | }; 127 | 128 | template void RegionAllocator::capacity(uint32_t min_cap) 129 | { 130 | if (cap >= min_cap) return; 131 | 132 | uint32_t prev_cap = cap; 133 | while (cap < min_cap) { 134 | // NOTE: Multiply by a factor (13/8) without causing overflow, then add 2 and make the 135 | // result even by clearing the least significant bit. The resulting sequence of capacities 136 | // is carefully chosen to hit a maximum capacity that is close to the '2^32-1' limit when 137 | // using 'uint32_t' as indices so that as much as possible of this space can be used. 138 | uint32_t delta = ((cap >> 1) + (cap >> 3) + 2) & ~1; 139 | cap += delta; 140 | 141 | if (cap <= prev_cap) throw OutOfMemoryException(); 142 | } 143 | // printf(" .. (%p) cap = %u\n", this, cap); 144 | 145 | assert(cap > 0); 146 | memory = (T *)xrealloc(memory, sizeof(T) * cap); 147 | } 148 | 149 | 150 | template typename RegionAllocator::Ref RegionAllocator::alloc(int size) 151 | { 152 | // printf("ALLOC called (this = %p, size = %d)\n", this, size); fflush(stdout); 153 | assert(size > 0); 154 | capacity(sz + size); 155 | 156 | uint32_t prev_sz = sz; 157 | sz += size; 158 | 159 | // Handle overflow: 160 | if (sz < prev_sz) throw OutOfMemoryException(); 161 | 162 | return prev_sz; 163 | } 164 | 165 | 166 | //================================================================================================= 167 | } // namespace MERGESAT_NSPACE 168 | 169 | #endif 170 | -------------------------------------------------------------------------------- /minisat/mtl/Heap.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************[Heap.h] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #ifndef MergeSat_Heap_h 22 | #define MergeSat_Heap_h 23 | 24 | #include "mtl/Vec.h" 25 | 26 | namespace MERGESAT_NSPACE 27 | { 28 | 29 | //================================================================================================= 30 | // A heap implementation with support for decrease/increase key. 31 | 32 | 33 | template class Heap 34 | { 35 | Comp lt; // The heap is a minimum-heap with respect to this comparator 36 | vec heap; // Heap of integers 37 | vec indices; // Each integers position (index) in the Heap 38 | 39 | // Index "traversal" functions 40 | static inline int left(int i) { return i * 2 + 1; } 41 | static inline int right(int i) { return (i + 1) * 2; } 42 | static inline int parent(int i) { return (i - 1) >> 1; } 43 | 44 | 45 | void percolateUp(int i) 46 | { 47 | int x = heap[i]; 48 | int p = parent(i); 49 | 50 | while (i != 0 && lt(x, heap[p])) { 51 | heap[i] = heap[p]; 52 | indices[heap[p]] = i; 53 | i = p; 54 | p = parent(p); 55 | } 56 | heap[i] = x; 57 | indices[x] = i; 58 | } 59 | 60 | 61 | void percolateDown(int i) 62 | { 63 | int x = heap[i]; 64 | while (left(i) < heap.size()) { 65 | int child = right(i) < heap.size() && lt(heap[right(i)], heap[left(i)]) ? right(i) : left(i); 66 | if (!lt(heap[child], x)) break; 67 | heap[i] = heap[child]; 68 | indices[heap[i]] = i; 69 | i = child; 70 | } 71 | heap[i] = x; 72 | indices[x] = i; 73 | } 74 | 75 | 76 | public: 77 | Heap(const Comp &c) : lt(c) {} 78 | 79 | int size() const { return heap.size(); } 80 | int capacity() const { return indices.size(); } 81 | bool empty() const { return heap.size() == 0; } 82 | bool inHeap(int n) const { return n < indices.size() && indices[n] >= 0; } 83 | int operator[](int index) const 84 | { 85 | assert(index < heap.size()); 86 | return heap[index]; 87 | } 88 | 89 | 90 | void decrease(int n) 91 | { 92 | assert(inHeap(n)); 93 | percolateUp(indices[n]); 94 | } 95 | void increase(int n) 96 | { 97 | assert(inHeap(n)); 98 | percolateDown(indices[n]); 99 | } 100 | 101 | 102 | // Safe variant of insert/decrease/increase: 103 | void update(int n) 104 | { 105 | if (!inHeap(n)) 106 | insert(n); 107 | else { 108 | percolateUp(indices[n]); 109 | percolateDown(indices[n]); 110 | } 111 | } 112 | 113 | 114 | void insert(int n) 115 | { 116 | indices.growTo(n + 1, -1); 117 | assert(!inHeap(n)); 118 | 119 | indices[n] = heap.size(); 120 | heap.push(n); 121 | percolateUp(indices[n]); 122 | } 123 | 124 | template void growTo(const Heap &other) { indices.growTo(other.indices.size(), -1); } 125 | 126 | int removeMin() 127 | { 128 | int x = heap[0]; 129 | heap[0] = heap.last(); 130 | indices[heap[0]] = 0; 131 | indices[x] = -1; 132 | heap.pop(); 133 | if (heap.size() > 1) percolateDown(0); 134 | return x; 135 | } 136 | int min() const 137 | { 138 | assert(!empty()); 139 | return heap[0]; 140 | } 141 | int at(int index) const { return heap[index]; } 142 | 143 | const vec &elements() const { return heap; } 144 | 145 | // Rebuild the heap from scratch, using the elements in 'ns': 146 | void build(const vec &ns) 147 | { 148 | for (int i = 0; i < heap.size(); i++) indices[heap[i]] = -1; 149 | heap.clear(); 150 | 151 | for (int i = 0; i < ns.size(); i++) { 152 | indices[ns[i]] = i; 153 | heap.push(ns[i]); 154 | } 155 | 156 | for (int i = heap.size() / 2 - 1; i >= 0; i--) percolateDown(i); 157 | } 158 | 159 | void clear(bool dealloc = false) 160 | { 161 | for (int i = 0; i < heap.size(); i++) indices[heap[i]] = -1; 162 | heap.clear(dealloc); 163 | } 164 | }; 165 | 166 | 167 | //================================================================================================= 168 | } // namespace MERGESAT_NSPACE 169 | 170 | #endif 171 | -------------------------------------------------------------------------------- /minisat/mtl/IntTypes.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************[IntTypes.h] 2 | Copyright (c) 2009-2010, Niklas Sorensson 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #ifndef MergeSat_IntTypes_h 21 | #define MergeSat_IntTypes_h 22 | 23 | #ifdef __sun 24 | // Not sure if there are newer versions that support C99 headers. The 25 | // needed features are implemented in the headers below though: 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #else 32 | 33 | #include 34 | #include 35 | 36 | #endif 37 | 38 | #include 39 | #include 40 | 41 | //================================================================================================= 42 | 43 | inline uint64_t log2_64(uint64_t x) 44 | { 45 | // calculate ld based on number of leading zeros 46 | return (uint64_t)(8 * sizeof(x) - __builtin_clzll((x)) - 1); 47 | } 48 | 49 | class PowFixedBase 50 | { 51 | double base; 52 | bool useLegacy = false; 53 | 54 | public: 55 | PowFixedBase(double b, bool legacy = false) : base(b), useLegacy(legacy) {} 56 | 57 | double pow(unsigned exponent) 58 | { 59 | /* library */ 60 | if (useLegacy) return ::pow(base, exponent); 61 | 62 | /* trivial case */ 63 | if (!exponent) return (double)1; 64 | 65 | /* get binary representation */ 66 | unsigned binary = ~(~0U >> 1); 67 | while (!(exponent & binary)) binary >>= 1; 68 | double intermediate = base; 69 | 70 | /* only as long as there are bits */ 71 | while (binary >>= 1) { 72 | /* square for next bit in binary representation */ 73 | intermediate *= intermediate; 74 | /* use intermediate result, if bit is set */ 75 | if (exponent & binary) intermediate *= base; 76 | } 77 | return intermediate; 78 | } 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /minisat/mtl/Queue.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************************[Queue.h] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #ifndef MergeSat_Queue_h 22 | #define MergeSat_Queue_h 23 | 24 | #include "mtl/Vec.h" 25 | 26 | namespace MERGESAT_NSPACE 27 | { 28 | 29 | //================================================================================================= 30 | 31 | template class Queue 32 | { 33 | vec buf; 34 | int first; 35 | int end; 36 | 37 | public: 38 | typedef T Key; 39 | 40 | Queue() : buf(1), first(0), end(0) {} 41 | 42 | void clear(bool dealloc = false) 43 | { 44 | buf.clear(dealloc); 45 | buf.growTo(1); 46 | first = end = 0; 47 | } 48 | int size() const { return (end >= first) ? end - first : end - first + buf.size(); } 49 | 50 | const T &operator[](int index) const 51 | { 52 | assert(index >= 0); 53 | assert(index < size()); 54 | return buf[(first + index) % buf.size()]; 55 | } 56 | T &operator[](int index) 57 | { 58 | assert(index >= 0); 59 | assert(index < size()); 60 | return buf[(first + index) % buf.size()]; 61 | } 62 | 63 | T peek() const 64 | { 65 | assert(first != end); 66 | return buf[first]; 67 | } 68 | void pop() 69 | { 70 | assert(first != end); 71 | first++; 72 | if (first == buf.size()) first = 0; 73 | } 74 | void insert(T elem) 75 | { // INVARIANT: buf[end] is always unused 76 | buf[end++] = elem; 77 | if (end == buf.size()) end = 0; 78 | if (first == end) { // Resize: 79 | vec tmp((buf.size() * 3 + 1) >> 1); 80 | //**/printf("queue alloc: %d elems (%.1f MB)\n", tmp.size(), tmp.size() * sizeof(T) / 1000000.0); 81 | int i = 0; 82 | for (int j = first; j < buf.size(); j++) tmp[i++] = buf[j]; 83 | for (int j = 0; j < end; j++) tmp[i++] = buf[j]; 84 | first = 0; 85 | end = buf.size(); 86 | tmp.moveTo(buf); 87 | } 88 | } 89 | }; 90 | 91 | 92 | //================================================================================================= 93 | } // namespace MERGESAT_NSPACE 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /minisat/mtl/XAlloc.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************************[XAlloc.h] 2 | Copyright (c) 2009-2010, Niklas Sorensson 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | 21 | #ifndef MergeSat_XAlloc_h 22 | #define MergeSat_XAlloc_h 23 | 24 | #include 25 | 26 | // To not introduce this multiple times, use this header, as it's rather central 27 | #ifndef MERGESAT_NSPACE 28 | #define MERGESAT_NSPACE Minisat 29 | #endif 30 | 31 | namespace MERGESAT_NSPACE 32 | { 33 | 34 | //================================================================================================= 35 | // Simple layer on top of malloc/realloc to catch out-of-memory situtaions and provide some typing: 36 | 37 | class OutOfMemoryException 38 | { 39 | }; 40 | static inline void *xrealloc(void *ptr, size_t size) 41 | { 42 | void *mem = realloc(ptr, size); 43 | if (mem == NULL) { 44 | throw OutOfMemoryException(); 45 | } else 46 | return mem; 47 | } 48 | 49 | //================================================================================================= 50 | } // namespace MERGESAT_NSPACE 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /minisat/mtl/config.mk: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is for system specific configurations. For instance, on 3 | ## some systems the path to zlib needs to be added. Example: 4 | ## 5 | ## CFLAGS += -I/usr/local/include 6 | ## LFLAGS += -L/usr/local/lib 7 | -------------------------------------------------------------------------------- /minisat/mtl/template.mk: -------------------------------------------------------------------------------- 1 | ## 2 | ## Template makefile for Standard, Profile, Debug, Release, and Release-static versions 3 | ## 4 | ## eg: "make rs" for a statically linked release version. 5 | ## "make d" for a debug version (no optimizations). 6 | ## "make" for the standard version (optimized, but with debug information and assertions active) 7 | 8 | PWD = $(shell pwd) 9 | EXEC ?= $(notdir $(PWD)) 10 | 11 | CSRCS = $(wildcard $(PWD)/*.cc) 12 | DSRCS = $(foreach dir, $(DEPDIR), $(filter-out $(MROOT)/$(dir)/Main.cc, $(wildcard $(MROOT)/$(dir)/*.cc))) 13 | CHDRS = $(wildcard $(PWD)/*.h) 14 | COBJS = $(CSRCS:.cc=.o) $(DSRCS:.cc=.o) 15 | 16 | PCOBJS = $(addsuffix p, $(COBJS)) 17 | DCOBJS = $(addsuffix d, $(COBJS)) 18 | RCOBJS = $(addsuffix r, $(COBJS)) 19 | LCOBJS = $(addsuffix l, $(COBJS)) 20 | DLCOBJS = $(addsuffix L, $(COBJS)) 21 | 22 | 23 | CXX ?= g++ 24 | CFLAGS ?= -Wall -Wno-parentheses -std=c++11 25 | LFLAGS ?= -Wall 26 | 27 | COPTIMIZE ?= -O3 28 | 29 | CFLAGS += -I$(MROOT) -D __STDC_LIMIT_MACROS -D __STDC_FORMAT_MACROS 30 | LFLAGS += -lz 31 | 32 | .PHONY : s p d r rs clean 33 | 34 | s: $(EXEC) 35 | p: $(EXEC)_profile 36 | d: $(EXEC)_debug 37 | r: $(EXEC)_release 38 | rs: $(EXEC)_static 39 | 40 | libs: lib$(LIB)_standard.a 41 | libp: lib$(LIB)_profile.a 42 | libd: lib$(LIB)_debug.a 43 | libr: lib$(LIB)_release.a 44 | 45 | # dynamic library 46 | libl: lib$(LIB)_standard.so 47 | libL: lib$(LIB)_debug.so 48 | 49 | ## Compile options 50 | %.o: CFLAGS +=$(COPTIMIZE) -g -D DEBUG 51 | %.op: CFLAGS +=$(COPTIMIZE) -pg -g -D NDEBUG 52 | %.od: CFLAGS +=-O0 -g -D DEBUG 53 | %.or: CFLAGS +=$(COPTIMIZE) -g -D NDEBUG 54 | %.ol: CFLAGS +=-g -D NDEBUG -fpic $(COPTIMIZE) 55 | %.oL: CFLAGS +=-O0 -g -D DEBUG -fpic 56 | 57 | ## Link options 58 | $(EXEC): LFLAGS += -g 59 | $(EXEC)_profile: LFLAGS += -g -pg 60 | $(EXEC)_debug: LFLAGS += -g 61 | #$(EXEC)_release: LFLAGS += ... 62 | $(EXEC)_static: LFLAGS += --static 63 | 64 | ## Dependencies 65 | $(EXEC): $(COBJS) 66 | $(EXEC)_profile: $(PCOBJS) 67 | $(EXEC)_debug: $(DCOBJS) 68 | $(EXEC)_release: $(RCOBJS) 69 | $(EXEC)_static: $(RCOBJS) 70 | 71 | lib$(LIB)_standard.a: $(filter-out */Main.o, $(COBJS)) 72 | lib$(LIB)_profile.a: $(filter-out */Main.op, $(PCOBJS)) 73 | lib$(LIB)_debug.a: $(filter-out */Main.od, $(DCOBJS)) 74 | lib$(LIB)_release.a: $(filter-out */Main.or, $(RCOBJS)) 75 | 76 | lib$(LIB)_standard.so: $(filter-out */Main.or, $(LCOBJS)) 77 | lib$(LIB)_debug.so: $(filter-out */Main.or, $(DLCOBJS)) 78 | 79 | 80 | ## Build rule 81 | %.o %.op %.od %.or %.ol %.oL: %.cc 82 | @echo Compiling: $(subst $(MROOT)/,,$@) 83 | @$(CXX) $(CFLAGS) -c -o $@ $< 84 | 85 | ## Linking rules (standard/profile/debug/release) 86 | $(EXEC) $(EXEC)_profile $(EXEC)_debug $(EXEC)_release $(EXEC)_static: 87 | @echo Linking: "$@ ( $(foreach f,$^,$(subst $(MROOT)/,,$f)) )" 88 | @$(CXX) $^ $(LFLAGS) -o $@ 89 | 90 | ## Library rules (standard/profile/debug/release) 91 | lib$(LIB)_standard.a lib$(LIB)_profile.a lib$(LIB)_release.a lib$(LIB)_debug.a: 92 | @echo Making library: "$@ ( $(foreach f,$^,$(subst $(MROOT)/,,$f)) )" 93 | @$(AR) -rcsv $@ $^ 94 | 95 | ## Shared library rules (standard/profile/debug/release) 96 | lib$(LIB)_standard.so: 97 | @echo Making library: "$@ ( $(foreach f,$^,$(subst $(MROOT)/,,$f)) )" 98 | @$(CXX) $^ -shared -Wl,-soname,lib$(LIB).so $(LFLAGS) -o $@ 99 | # remove all hidden symbols from the shared object 100 | # strip -x $@ 101 | 102 | ## Shared library rules (standard/profile/debug/release) 103 | lib$(LIB)_debug.so: 104 | @echo Making library: "$@ ( $(foreach f,$^,$(subst $(MROOT)/,,$f)) )" 105 | $(CXX) $^ -shared -Wl,-soname,lib$(LIB).so $(LFLAGS) -o $@ 106 | # remove all hidden symbols from the shared object 107 | # strip -x $@ 108 | 109 | ## Library Soft Link rule: 110 | libs libp libd libr: 111 | @echo "Making Soft Link: $^ -> lib$(LIB).a" 112 | @ln -sf $^ lib$(LIB).a 113 | 114 | ## Dynamic Soft Link rule: 115 | libl: 116 | @echo "Making Soft Link: $^ -> lib$(LIB).so" 117 | @ln -sf $^ lib$(LIB).so 118 | 119 | ## Clean rule 120 | clean: 121 | @rm -f $(EXEC) $(EXEC)_profile $(EXEC)_debug $(EXEC)_release $(EXEC)_static \ 122 | $(COBJS) $(PCOBJS) $(DCOBJS) $(RCOBJS) $(LCOBJS) $(DLCOBJS) *.core depend.mk \ 123 | lib$(LIB)_standard.a lib$(LIB)_profile.a lib$(LIB)_release.a lib$(LIB)_debug.a \ 124 | lib$(LIB).so lib$(LIB)_standard.so lib$(LIB)_debug.so 125 | 126 | ## Make dependencies 127 | depend.mk: $(CSRCS) $(CHDRS) 128 | @echo Making dependencies 129 | @$(CXX) $(CFLAGS) -I$(MROOT) \ 130 | $(CSRCS) -MM | sed 's|\(.*\):|$(PWD)/\1 $(PWD)/\1r $(PWD)/\1d $(PWD)/\1p:|' > depend.mk 131 | @for dir in $(DEPDIR); do \ 132 | if [ -r $(MROOT)/$${dir}/depend.mk ]; then \ 133 | echo Depends on: $${dir}; \ 134 | cat $(MROOT)/$${dir}/depend.mk >> depend.mk; \ 135 | fi; \ 136 | done 137 | 138 | -include $(MROOT)/mtl/config.mk 139 | -include depend.mk 140 | -------------------------------------------------------------------------------- /minisat/parallel/Makefile: -------------------------------------------------------------------------------- 1 | EXEC = mergesat-par 2 | DEPDIR = mtl utils core simp 3 | MROOT = ../ 4 | 5 | include $(MROOT)/mtl/template.mk 6 | -------------------------------------------------------------------------------- /minisat/parallel/Sharing.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************[Sharing.h] 2 | MergeSat -- Copyright (c) 2021, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #ifndef MergeSat_Sharing_h 21 | #define MergeSat_Sharing_h 22 | 23 | #include "core/SolverTypes.h" 24 | #include "mtl/Vec.h" 25 | 26 | #include 27 | 28 | namespace MERGESAT_NSPACE 29 | { 30 | //================================================================================================= 31 | 32 | /** Object that memorizes clauses, re-using known object types. */ 33 | class ClausePool 34 | { 35 | vec clauses; 36 | AccessCounter counter; 37 | ClauseAllocator ca; 38 | 39 | public: 40 | ClausePool() : ca(counter) {} 41 | 42 | int size() const { return clauses.size(); } 43 | 44 | void reset() 45 | { 46 | clauses.clear(); 47 | ca.clear(); 48 | } 49 | 50 | void add_shared_clause(const std::vector &c, int glueValue) 51 | { 52 | 53 | CRef cr = ca.alloc_placeholder(c.size(), true); 54 | clauses.push(cr); 55 | Clause &d = ca[cr]; 56 | d.set_lbd(glueValue); 57 | 58 | // actually copy literals over 59 | for (int i = 0; i < d.size(); i++) d[i] = fromFormal(c[i]); 60 | } 61 | 62 | const Clause &getClause(int index) const { return ca[clauses[index]]; } 63 | }; 64 | 65 | 66 | //================================================================================================= 67 | } // namespace MERGESAT_NSPACE 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /minisat/simp/Makefile: -------------------------------------------------------------------------------- 1 | EXEC = mergesat 2 | DEPDIR = mtl utils core 3 | MROOT = ../ 4 | 5 | include $(MROOT)/mtl/template.mk 6 | -------------------------------------------------------------------------------- /minisat/simp/ccadical-mergesat-bridge.h: -------------------------------------------------------------------------------- 1 | /**********************************************************************[ccadical-mergesat-bridge.h] 2 | MergeSat -- Copyright (c) 2021, Norbert Manthey, Armin Biere 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #ifndef MergeSat_CCaDiCaL_MergeSat_Bridge_h 21 | #define MergeSat_CCaDiCaL_MergeSat_Bridge_h 22 | 23 | /* Get MergeSat C Interface definition */ 24 | #include "simp/cmergesat.h" 25 | 26 | /* This interface code is taken from CaDiCaL 1.4.0 27 | * Basically, each call is forwarded to the matching 28 | * CMergeSat interface. 29 | */ 30 | 31 | /*----- CaDiCaL interface - begin ----------------------------------------*/ 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | /*------------------------------------------------------------------------*/ 36 | 37 | /* 38 | * C wrapper for CaDiCaL's C++ API following IPASIR. 39 | */ 40 | 41 | /* Set a CaDiCaL type to match the function signatures */ 42 | #define CCaDiCaL CMergeSat 43 | 44 | inline const char *ccadical_signature(void) { return cmergesat_signature(); } 45 | inline CCaDiCaL *ccadical_init(void) { return cmergesat_init(); } 46 | inline void ccadical_release(CCaDiCaL *c) { return cmergesat_release(c); } 47 | inline void ccadical_add(CCaDiCaL *c, int lit) { return cmergesat_add(c, lit); } 48 | inline void ccadical_assume(CCaDiCaL *c, int lit) { return cmergesat_assume(c, lit); } 49 | inline int ccadical_solve(CCaDiCaL *c) { return cmergesat_solve(c); } 50 | inline int ccadical_val(CCaDiCaL *c, int lit) { return cmergesat_val(c, lit); } 51 | inline int ccadical_failed(CCaDiCaL *c, int lit) { return cmergesat_failed(c, lit); } 52 | inline void ccadical_set_terminate(CCaDiCaL *c, void *state, int (*terminate)(void *state)) 53 | { 54 | cmergesat_set_terminate(c, state, terminate); 55 | } 56 | inline void ccadical_set_learn(CCaDiCaL *c, void *state, int max_length, void (*learn)(void *state, int *clause)) 57 | { 58 | return cmergesat_set_learn(c, state, max_length, learn); 59 | } 60 | 61 | /*------------------------------------------------------------------------*/ 62 | 63 | // Non-IPASIR conformant 'C' functions. 64 | 65 | inline void ccadical_set_option(CCaDiCaL *c, const char *name, int val) { return cmergesat_set_option(c, name, val); } 66 | inline void ccadical_limit(CCaDiCaL *c, const char *name, int limit) { return cmergesat_limit(c, name, limit); } 67 | inline int ccadical_get_option(CCaDiCaL *c, const char *name) { return cmergesat_get_option(c, name); } 68 | inline void ccadical_print_statistics(CCaDiCaL *c) { return cmergesat_print_statistics(c); } 69 | inline int64_t ccadical_active(CCaDiCaL *c) { return cmergesat_active(c); } 70 | inline int64_t ccadical_irredundant(CCaDiCaL *c) { return cmergesat_irredundant(c); } 71 | inline int ccadical_fixed(CCaDiCaL *c, int lit) { return cmergesat_fixed(c, lit); } 72 | inline void ccadical_terminate(CCaDiCaL *c) { return cmergesat_terminate(c); } 73 | inline void ccadical_freeze(CCaDiCaL *c, int lit) { return cmergesat_freeze(c, lit); } 74 | inline int ccadical_frozen(CCaDiCaL *c, int lit) { return cmergesat_frozen(c, lit); } 75 | inline void ccadical_melt(CCaDiCaL *c, int lit) { return cmergesat_melt(c, lit); } 76 | inline int ccadical_simplify(CCaDiCaL *c) { return cmergesat_simplify(c); } 77 | #if 0 /* parallel backend does not support constrain yet */ 78 | inline void ccadical_constrain(CCaDiCaL *c, int lit) { return cmergesat_constrain(c, lit); } 79 | inline int ccadical_constraint_failed(CCaDiCaL *c) { return cmergesat_constraint_failed(c); } 80 | #endif 81 | 82 | /*------------------------------------------------------------------------*/ 83 | 84 | // Support legacy names used before moving to more IPASIR conforming names. 85 | 86 | #define ccadical_reset ccadical_release 87 | #define ccadical_sat ccadical_solve 88 | #define ccadical_deref ccadical_val 89 | 90 | /*------------------------------------------------------------------------*/ 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | /*----- CaDiCaL interface - end ------------------------------------------*/ 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /minisat/simp/cmergesat.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************[cmergesat.h] 2 | MergeSat -- Copyright (c) 2021, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #ifndef MergeSat_CMergeSat_h 21 | #define MergeSat_CMergeSat_h 22 | 23 | /* MergeSat interface */ 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | 30 | /* Dummy type to improve usage */ 31 | typedef void CMergeSat; 32 | 33 | /* IPASIR like functions */ 34 | const char *cmergesat_signature(void); 35 | CMergeSat *cmergesat_init(void); 36 | void cmergesat_release(CMergeSat *); 37 | 38 | void cmergesat_add(CMergeSat *, int lit); 39 | void cmergesat_assume(CMergeSat *, int lit); 40 | int cmergesat_solve(CMergeSat *); 41 | int cmergesat_val(CMergeSat *, int lit); 42 | int cmergesat_failed(CMergeSat *, int lit); 43 | void cmergesat_set_terminate(CMergeSat *, void *state, int (*terminate)(void *state)); 44 | void cmergesat_set_learn(CMergeSat *, void *state, int max_length, void (*learn)(void *state, int *clause)); 45 | 46 | /* Non-IPASIR conformant 'C' functions. */ 47 | void cmergesat_set_option(CMergeSat *, const char *name, int val); 48 | void cmergesat_limit(CMergeSat *, const char *name, int limit); 49 | int cmergesat_get_option(CMergeSat *, const char *name); 50 | void cmergesat_print_statistics(CMergeSat *); 51 | int64_t cmergesat_active(CMergeSat *); 52 | int64_t cmergesat_irredundant(CMergeSat *); 53 | int cmergesat_fixed(CMergeSat *, int lit); 54 | void cmergesat_terminate(CMergeSat *); 55 | void cmergesat_freeze(CMergeSat *, int lit); 56 | int cmergesat_frozen(CMergeSat *, int lit); 57 | void cmergesat_melt(CMergeSat *, int lit); 58 | int cmergesat_simplify(CMergeSat *); 59 | #if 0 /* parallel backend does not support constrain yet */ 60 | void cmergesat_constrain(CMergeSat *, int lit); 61 | int cmergesat_constraint_failed(CMergeSat *); 62 | #endif 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /minisat/tests/TestSolver.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************[SimpSolver.h] 2 | MiniSat -- Copyright (c) 2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Chanseok Oh's MiniSat Patch Series -- Copyright (c) 2015, Chanseok Oh 6 | 7 | Maple_LCM, Based on MapleCOMSPS_DRUP -- Copyright (c) 2017, Mao Luo, Chu-Min LI, Fan Xiao: implementing a learnt clause 8 | minimisation approach Reference: M. Luo, C.-M. Li, F. Xiao, F. Manya, and Z. L. , “An effective learnt clause 9 | minimization approach for cdcl sat solvers,” in IJCAI-2017, 2017, pp. to–appear. 10 | 11 | Maple_LCM_Dist, Based on Maple_LCM -- Copyright (c) 2017, Fan Xiao, Chu-Min LI, Mao Luo: using a new branching heuristic 12 | called Distance at the beginning of search 13 | 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 16 | associated documentation files (the "Software"), to deal in the Software without restriction, 17 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 18 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in all copies or 22 | substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 25 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 27 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 28 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | **************************************************************************************************/ 30 | 31 | #ifndef MergeSat_TestSolver_h 32 | #define MergeSat_TestSolver_h 33 | 34 | #include "simp/SimpSolver.h" 35 | 36 | namespace MERGESAT_NSPACE 37 | { 38 | 39 | //================================================================================================= 40 | 41 | void test_assert(bool condition, const char *description) 42 | { 43 | /* Allow to stop here during debugging */ 44 | assert(condition); 45 | 46 | if (!condition) { 47 | printf("c condition %s fails, abort\n", (description == NULL ? "" : description)); 48 | _exit(1); 49 | } 50 | } 51 | 52 | /* Provide a class to access solver internals easily */ 53 | class TestSolver : public SimpSolver 54 | { 55 | public: 56 | // Constructor/Destructor: 57 | // 58 | TestSolver(); 59 | ~TestSolver(); 60 | 61 | /* This function has to be implemented by the test itself */ 62 | bool test_entrypoint(); 63 | }; 64 | 65 | inline TestSolver::TestSolver() : SimpSolver() {} 66 | inline TestSolver::~TestSolver() {} 67 | 68 | //================================================================================================= 69 | } // namespace MERGESAT_NSPACE 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /minisat/tests/add-from-pool.cc: -------------------------------------------------------------------------------- 1 | /***********************************************************************************[sat-simple.cc] 2 | Copyright (c) 2021, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #include "tests/TestSolver.h" 21 | 22 | #include "parallel/Sharing.h" 23 | 24 | using namespace MERGESAT_NSPACE; 25 | 26 | bool TestSolver::test_entrypoint() 27 | { 28 | /* Make sure the values are as expected after solving */ 29 | test_assert(okay(), "solver has to be okay"); 30 | 31 | ClausePool pool; 32 | std::vector shared_clause; 33 | shared_clause.push_back(-1); 34 | shared_clause.push_back(-2); 35 | shared_clause.push_back(-3); 36 | pool.add_shared_clause(shared_clause, 3); 37 | shared_clause.push_back(-4); 38 | pool.add_shared_clause(shared_clause, 10); 39 | test_assert(pool.size() == 2, "we added 2 clauses to the pool"); 40 | 41 | for (int idx = 0; idx < pool.size(); ++idx) { 42 | const Clause &c = pool.getClause(idx); 43 | /* add the clause to the thread's solver, and check for conflicts via propagation */ 44 | bool receive_causes_successful; 45 | receive_causes_successful = this->addLearnedClause(c, c.lbd()); 46 | test_assert(receive_causes_successful, "adding the given clauses should be successful"); 47 | } 48 | 49 | pool.reset(); 50 | test_assert(pool.size() == 0, "resetting pool needs to result in empty pool"); 51 | return true; 52 | } 53 | 54 | void test_share_and_receive() 55 | { 56 | TestSolver solver; 57 | solver.verbosity = 0; 58 | 59 | while (solver.nVars() < 5) solver.newVar(); 60 | 61 | solver.addClause(mkLit(1)); 62 | solver.addClause(mkLit(2), mkLit(3)); 63 | 64 | bool ret = solver.test_entrypoint(); 65 | test_assert(ret, "receiving clauses should be successful"); 66 | } 67 | 68 | int main(int argc, char **argv) 69 | { 70 | test_share_and_receive(); 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /minisat/tests/add-learned-clause.cc: -------------------------------------------------------------------------------- 1 | /***********************************************************************************[sat-simple.cc] 2 | Copyright (c) 2021, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #include "tests/TestSolver.h" 21 | 22 | using namespace MERGESAT_NSPACE; 23 | 24 | bool TestSolver::test_entrypoint() 25 | { 26 | /* Make sure the values are as expected after solving */ 27 | test_assert(okay(), "solver has to be okay"); 28 | 29 | test_assert(value(mkLit(1)) == l_True, "first variable has to be true"); 30 | test_assert(value(mkLit(2)) == l_True, "second variable has to be true"); 31 | test_assert(value(mkLit(3)) == l_True, "third variable has to be true"); 32 | 33 | return true; 34 | } 35 | 36 | void test_add_sat_clause() 37 | { 38 | TestSolver solver; 39 | solver.verbosity = 0; 40 | 41 | while (solver.nVars() < 4) solver.newVar(); 42 | 43 | solver.addClause(mkLit(1)); 44 | solver.addClause(mkLit(2)); 45 | solver.addClause(mkLit(3)); 46 | 47 | vec cls; 48 | cls.push(mkLit(1, true)); 49 | cls.push(mkLit(2, false)); 50 | cls.push(mkLit(3, true)); 51 | 52 | bool ret = solver.addLearnedClause(cls); 53 | test_assert(ret == true, "The given clause can be added"); 54 | bool status = solver.solve(); 55 | test_assert(status == true, "The given formula has to be satisfiable"); 56 | } 57 | 58 | void test_add_unsat_clause() 59 | { 60 | TestSolver solver; 61 | solver.verbosity = 0; 62 | 63 | while (solver.nVars() < 4) solver.newVar(); 64 | 65 | solver.addClause(mkLit(1)); 66 | solver.addClause(mkLit(2)); 67 | solver.addClause(mkLit(3)); 68 | 69 | vec cls; 70 | cls.push(mkLit(1, true)); 71 | cls.push(mkLit(2, true)); 72 | cls.push(mkLit(3, true)); 73 | 74 | bool ret = solver.addLearnedClause(cls); 75 | test_assert(ret == false, "The given clause cannot be added"); 76 | bool status = solver.solve(); 77 | test_assert(status == false, "The given formula has to be unsatisfiable"); 78 | } 79 | 80 | void test_add_unit_clause() 81 | { 82 | TestSolver solver; 83 | solver.verbosity = 0; 84 | 85 | while (solver.nVars() < 4) solver.newVar(); 86 | 87 | solver.addClause(mkLit(1)); 88 | solver.addClause(mkLit(2)); 89 | 90 | vec cls; 91 | cls.push(mkLit(1, true)); 92 | cls.push(mkLit(2, true)); 93 | cls.push(mkLit(3, true)); 94 | 95 | bool ret = solver.addLearnedClause(cls); 96 | test_assert(ret == true, "The given clause is a unit"); 97 | bool status = solver.solve(); 98 | test_assert(status == true, "The given formula has to be satisfiable"); 99 | } 100 | 101 | int main(int argc, char **argv) 102 | { 103 | test_add_sat_clause(); 104 | test_add_unsat_clause(); 105 | test_add_unit_clause(); 106 | return 0; 107 | } 108 | -------------------------------------------------------------------------------- /minisat/tests/double-look-ahead-test.cc: -------------------------------------------------------------------------------- 1 | /************************************************************************************************** 2 | Copyright (c) 2022, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #include "core/Lookahead.h" 21 | #include "tests/TestSolver.h" 22 | 23 | using namespace MERGESAT_NSPACE; 24 | 25 | bool TestSolver::test_entrypoint() 26 | { 27 | /* Make sure the values are as expected after solving */ 28 | test_assert(okay(), "solver has to be okay"); 29 | 30 | test_assert(value(mkLit(1)) == l_True, "first variable has to be true"); 31 | test_assert(value(mkLit(2)) == l_True, "second variable has to be true"); 32 | test_assert(value(mkLit(3)) == l_True, "third variable has to be true"); 33 | 34 | return true; 35 | } 36 | 37 | void test_add_sat_clause() 38 | { 39 | TestSolver solver; 40 | solver.verbosity = 0; 41 | 42 | while (solver.nVars() < 4) solver.newVar(); 43 | 44 | solver.addClause(mkLit(1)); 45 | solver.addClause(mkLit(2)); 46 | solver.addClause(mkLit(3)); 47 | 48 | vec cls; 49 | cls.push(mkLit(1, true)); 50 | cls.push(mkLit(2, false)); 51 | cls.push(mkLit(3, true)); 52 | 53 | bool ret = solver.addLearnedClause(cls); 54 | test_assert(ret == true, "The given clause can be added"); 55 | bool status = solver.solve(); 56 | test_assert(status == true, "The given formula has to be satisfiable"); 57 | } 58 | 59 | void test_empty_dla() 60 | { 61 | TestSolver solver; 62 | solver.verbosity = 0; 63 | 64 | Lookahead la(solver); 65 | CRef confl = CRef_Undef; 66 | Lit lookaheadLit = la.lookaheadDecision(confl, 5, false, true); 67 | 68 | test_assert(lookaheadLit == lit_Undef, "there is no literal to be selected"); 69 | } 70 | 71 | void test_failing_dla() 72 | { 73 | TestSolver solver; 74 | solver.verbosity = 3; 75 | 76 | solver.eliminate(true); // disable elimination 77 | 78 | while (solver.nVars() < 3) solver.newVar(); 79 | 80 | solver.addClause(mkLit(0, false), mkLit(1, false), mkLit(2, false)); 81 | solver.addClause(mkLit(0, false), mkLit(1, true), mkLit(2, false)); 82 | solver.addClause(mkLit(0, true), mkLit(1, false), mkLit(2, false)); 83 | solver.addClause(mkLit(0, true), mkLit(1, true), mkLit(2, false)); 84 | solver.addClause(mkLit(0, false), mkLit(1, false), mkLit(2, true)); 85 | solver.addClause(mkLit(0, false), mkLit(1, true), mkLit(2, true)); 86 | solver.addClause(mkLit(0, true), mkLit(1, false), mkLit(2, true)); 87 | solver.addClause(mkLit(0, true), mkLit(1, true), mkLit(2, true)); 88 | 89 | Lookahead la(solver); 90 | 91 | CRef confl = CRef_Undef; 92 | Lit lookaheadLit = la.lookaheadDecision(confl, 5, false, true); 93 | (void)lookaheadLit; 94 | test_assert(lookaheadLit == lit_Error, "an error is expected as soon as one literal is DLA'ed"); 95 | test_assert(confl != CRef_Undef, "an error is expected as soon as 1 literal is propagated"); 96 | } 97 | 98 | int main(int argc, char **argv) 99 | { 100 | test_empty_dla(); 101 | test_failing_dla(); 102 | return 0; 103 | } 104 | -------------------------------------------------------------------------------- /minisat/tests/float-test.cc: -------------------------------------------------------------------------------- 1 | /***************************************************************************[large-proof-clause.cc] 2 | Copyright (c) 2021, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #include "tests/TestSolver.h" 21 | 22 | #include "math.h" 23 | 24 | using namespace MERGESAT_NSPACE; 25 | 26 | bool TestSolver::test_entrypoint() { return true; } 27 | 28 | bool test_iterative_pow() 29 | { 30 | PowFixedBase twoPow(2, false); 31 | test_assert(twoPow.pow(1) == 2, "Pow 2^1 == 2"); 32 | test_assert(twoPow.pow(2) == 4, "Pow 2^2 == 4"); 33 | test_assert(twoPow.pow(3) == 8, "Pow 2^3 == 8"); 34 | test_assert(twoPow.pow(4) == 16, "Pow 2^4 == 16"); 35 | printf("bin pow 2^4: %lf\n", twoPow.pow(4)); 36 | 37 | PowFixedBase fourPow(4, false); 38 | test_assert(fourPow.pow(0) == 1, "Pow 4^0 == 1"); 39 | test_assert(fourPow.pow(1) == 4, "Pow 4^1 == 4"); 40 | test_assert(fourPow.pow(2) == 16, "Pow 4^2 == 16"); 41 | test_assert(fourPow.pow(3) == 64, "Pow 4^3 == 64"); 42 | printf("bin pow 4^3: %lf\n", fourPow.pow(3)); 43 | 44 | 45 | PowFixedBase onethreePow(13, false); 46 | test_assert(onethreePow.pow(5) == 371293, "Pow 13^5 == 371293"); 47 | test_assert(onethreePow.pow(9) == 10604499373, "Pow 13^9 == 10604499373"); 48 | test_assert(onethreePow.pow(11) == 1792160394037, "Pow 13^11 == 1792160394037"); 49 | 50 | return true; 51 | } 52 | 53 | int main(int argc, char **argv) 54 | { 55 | test_iterative_pow(); 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /minisat/tests/large-proof-clause.cc: -------------------------------------------------------------------------------- 1 | /***************************************************************************[large-proof-clause.cc] 2 | Copyright (c) 2021, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #include "tests/TestSolver.h" 21 | 22 | using namespace MERGESAT_NSPACE; 23 | 24 | bool TestSolver::test_entrypoint() 25 | { 26 | // solver okay 27 | test_assert(okay(), "solver has to be okay"); 28 | 29 | // solve formula 30 | vec dummy; 31 | lbool ret = solveLimited(dummy); 32 | test_assert(ret == l_True, "The 1 clause formula has to be satisfiable"); 33 | 34 | return true; 35 | } 36 | 37 | void test_very_large_proof_clause() 38 | { 39 | TestSolver solver; 40 | solver.verbosity = 0; 41 | solver.proof.init("/dev/null", true, false); 42 | test_assert(solver.proof.enabled(), "Need a proof filehandle"); 43 | 44 | // create the large proof clause 45 | vec proof_clause; 46 | proof_clause.push(mkLit(1)); 47 | 48 | for (int i = 0; i < 4 * 1024 * 1024; ++i) proof_clause.push(mkLit(2)); 49 | 50 | // add sufficient variables to the solver 51 | while (solver.nVars() < 5) solver.newVar(); 52 | 53 | // add large clause to solver after activating proof 54 | solver.parsing = true; 55 | solver.addClause(proof_clause); 56 | solver.parsing = false; 57 | 58 | bool ret = solver.test_entrypoint(); 59 | test_assert(ret, "receiving clauses should be successful"); 60 | 61 | solver.proof.finalize(); 62 | } 63 | 64 | int main(int argc, char **argv) 65 | { 66 | test_very_large_proof_clause(); 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /minisat/tests/look-ahead-test.cc: -------------------------------------------------------------------------------- 1 | /************************************************************************************************** 2 | Copyright (c) 2021, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #include "core/Lookahead.h" 21 | #include "tests/TestSolver.h" 22 | 23 | using namespace MERGESAT_NSPACE; 24 | 25 | bool TestSolver::test_entrypoint() 26 | { 27 | /* Make sure the values are as expected after solving */ 28 | test_assert(okay(), "solver has to be okay"); 29 | 30 | test_assert(value(mkLit(1)) == l_True, "first variable has to be true"); 31 | test_assert(value(mkLit(2)) == l_True, "second variable has to be true"); 32 | test_assert(value(mkLit(3)) == l_True, "third variable has to be true"); 33 | 34 | return true; 35 | } 36 | 37 | void test_add_sat_clause() 38 | { 39 | TestSolver solver; 40 | solver.verbosity = 0; 41 | 42 | while (solver.nVars() < 4) solver.newVar(); 43 | 44 | solver.addClause(mkLit(1)); 45 | solver.addClause(mkLit(2)); 46 | solver.addClause(mkLit(3)); 47 | 48 | vec cls; 49 | cls.push(mkLit(1, true)); 50 | cls.push(mkLit(2, false)); 51 | cls.push(mkLit(3, true)); 52 | 53 | bool ret = solver.addLearnedClause(cls); 54 | test_assert(ret == true, "The given clause can be added"); 55 | bool status = solver.solve(); 56 | test_assert(status == true, "The given formula has to be satisfiable"); 57 | } 58 | 59 | void test_empty_la() 60 | { 61 | TestSolver solver; 62 | solver.verbosity = 0; 63 | 64 | Lookahead la(solver); 65 | CRef confl = CRef_Undef; 66 | Lit lookaheadLit = la.lookaheadDecision(confl); 67 | 68 | test_assert(lookaheadLit == lit_Undef, "there is no literal to be selected"); 69 | } 70 | 71 | void test_failing_la() 72 | { 73 | TestSolver solver; 74 | solver.verbosity = 0; 75 | 76 | while (solver.nVars() < 2) solver.newVar(); 77 | 78 | solver.addClause(mkLit(0, false), mkLit(1, false)); 79 | solver.addClause(mkLit(0, false), mkLit(1, true)); 80 | solver.addClause(mkLit(0, true), mkLit(1, false)); 81 | solver.addClause(mkLit(0, true), mkLit(1, true)); 82 | 83 | Lookahead la(solver); 84 | CRef confl = CRef_Undef; 85 | Lit lookaheadLit = la.lookaheadDecision(confl); 86 | (void)lookaheadLit; 87 | test_assert(lookaheadLit == lit_Error, "an error is expected as soon as one literal is propagated"); 88 | test_assert(confl != CRef_Undef, "an error is expected as soon as 1 literal is propagated"); 89 | } 90 | 91 | int main(int argc, char **argv) 92 | { 93 | test_empty_la(); 94 | test_failing_la(); 95 | return 0; 96 | } 97 | -------------------------------------------------------------------------------- /minisat/tests/online-proof-checker.cc: -------------------------------------------------------------------------------- 1 | /*************************************************************************[online-proof-checker.cc] 2 | Copyright (c) 2022, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #include "tests/TestSolver.h" 21 | 22 | using namespace MERGESAT_NSPACE; 23 | 24 | 25 | void test_parallel_proof() 26 | { 27 | /* easy to read, but check incoming clauses */ 28 | bool binary_format = false; 29 | bool check_proof = true; 30 | 31 | Proof proof; 32 | proof.init("/dev/null", binary_format, check_proof); 33 | 34 | /* Create sub proofs and register with parent */ 35 | Proof subproof2; 36 | Proof subproof1; 37 | 38 | subproof2.init(nullptr, binary_format, check_proof, &proof, true); 39 | subproof1.init(nullptr, binary_format, check_proof, &proof, true); 40 | 41 | /* add input formula */ 42 | vec c; 43 | c.clear(); 44 | c.push(mkLit(1)); 45 | c.push(mkLit(2)); 46 | proof.addParsedclause(c); 47 | c.clear(); 48 | c.push(mkLit(1, true)); 49 | c.push(mkLit(2)); 50 | proof.addParsedclause(c); 51 | c.clear(); 52 | c.push(mkLit(2, true)); 53 | c.push(mkLit(3)); 54 | proof.addParsedclause(c); 55 | c.clear(); 56 | c.push(mkLit(3, true)); 57 | c.push(mkLit(4)); 58 | proof.addParsedclause(c); 59 | 60 | /* make the formula unsat */ 61 | c.clear(); 62 | c.push(mkLit(4, true)); 63 | proof.addParsedclause(c); 64 | 65 | /* have 1st subproof add a first clause */ 66 | c.clear(); 67 | c.push(mkLit(1)); 68 | c.push(mkLit(3)); 69 | subproof1.addClause('a', c); 70 | subproof1.flush(); 71 | 72 | /* have 2nd subproof add a first clause */ 73 | c.clear(); 74 | c.push(mkLit(2)); 75 | c.push(mkLit(4)); 76 | subproof2.addClause('a', c); 77 | 78 | /* have 1st subproof add a unit clause */ 79 | c.clear(); 80 | c.push(mkLit(2)); 81 | subproof1.addClause('a', c); 82 | subproof1.flush(); 83 | 84 | /* have 2nd subproof add a unit clause */ 85 | c.clear(); 86 | c.push(mkLit(4, true)); 87 | subproof2.addClause('a', c); 88 | 89 | 90 | /* finish by adding an empty clause to the proof */ 91 | proof.addClause('a', vec()); 92 | proof.finalize(); 93 | } 94 | 95 | int main(int argc, char **argv) 96 | { 97 | test_parallel_proof(); 98 | return 0; 99 | } 100 | -------------------------------------------------------------------------------- /minisat/tests/partitioning-formula.cc: -------------------------------------------------------------------------------- 1 | /***********************************************************************************[sat-simple.cc] 2 | Copyright (c) 2021, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #include "tests/TestSolver.h" 21 | 22 | using namespace MERGESAT_NSPACE; 23 | 24 | bool TestSolver::test_entrypoint() 25 | { 26 | /* Make sure the values are as expected after solving */ 27 | test_assert(okay(), "solver has to be okay"); 28 | 29 | rebuildOrderHeap(); 30 | 31 | std::cout << "c testing creating plain partitions" << std::endl; 32 | if (true) { 33 | for (int partitions = 1; partitions < 10; partitions++) { 34 | vec assumptions; 35 | vec partitionClauses; 36 | lbool ret = partitionFormula(assumptions, partitions, partitionClauses); 37 | std::cout << "c created " << partitions << " partitions vars=" << nVars() << " with ret=" << ret << std::endl; 38 | printPartitionClauses(partitionClauses); 39 | test_assert(ret == l_True, "Creating partitions on base formula is possible"); 40 | } 41 | } 42 | 43 | std::cout << "c testing creating partitions under assumptions" << std::endl; 44 | for (int partitions = 3; partitions < 5; partitions++) { 45 | vec assumptions; 46 | assumptions.push(mkLit(0)); 47 | vec partitionClauses; 48 | lbool ret = partitionFormula(assumptions, partitions, partitionClauses); 49 | std::cout << "c created " << partitions << " partitions vars=" << nVars() << " with ret=" << ret << std::endl; 50 | printPartitionClauses(partitionClauses); 51 | test_assert(ret == l_True, "Creating partitions on base formula is possible"); 52 | } 53 | 54 | std::cout << "c testing creating partitions under negated assumptions" << std::endl; 55 | for (int partitions = 3; partitions < 5; partitions++) { 56 | vec assumptions; 57 | assumptions.push(~mkLit(0)); 58 | vec partitionClauses; 59 | lbool ret = partitionFormula(assumptions, partitions, partitionClauses); 60 | std::cout << "c created " << partitions << " partitions vars=" << nVars() << " with ret=" << ret << std::endl; 61 | printPartitionClauses(partitionClauses); 62 | test_assert(ret == l_True, "Creating partitions on base formula is possible"); 63 | } 64 | 65 | return true; 66 | } 67 | 68 | void test_formula_partitioning() 69 | { 70 | TestSolver solver; 71 | solver.verbosity = 0; 72 | 73 | // 3 variables 74 | solver.newVar(); 75 | solver.newVar(); 76 | solver.newVar(); 77 | 78 | vec clause; 79 | clause.push(mkLit(1)); 80 | clause.push(mkLit(2)); 81 | solver.addClause(clause); 82 | 83 | clause.clear(); 84 | clause.push(mkLit(0)); 85 | clause.push(~mkLit(1)); 86 | solver.addClause(clause); 87 | 88 | solver.test_entrypoint(); 89 | } 90 | 91 | int main(int argc, char **argv) 92 | { 93 | test_formula_partitioning(); 94 | return 0; 95 | } 96 | -------------------------------------------------------------------------------- /minisat/tests/sat-simple.cc: -------------------------------------------------------------------------------- 1 | /***********************************************************************************[sat-simple.cc] 2 | Copyright (c) 2021, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #include "tests/TestSolver.h" 21 | 22 | using namespace MERGESAT_NSPACE; 23 | 24 | bool TestSolver::test_entrypoint() 25 | { 26 | /* Make sure the values are as expected after solving */ 27 | test_assert(okay(), "solver has to be okay"); 28 | 29 | test_assert(value(mkLit(1)) == l_True, "first variable has to be true"); 30 | test_assert(value(mkLit(2)) == l_True, "second variable has to be true"); 31 | test_assert(value(mkLit(3)) == l_True, "third variable has to be true"); 32 | 33 | return true; 34 | } 35 | 36 | int main(int argc, char **argv) 37 | { 38 | TestSolver solver; 39 | 40 | solver.verbosity = 0; 41 | 42 | while (solver.nVars() < 3) solver.newVar(); 43 | 44 | solver.addClause(mkLit(1)); 45 | solver.addClause(mkLit(2)); 46 | solver.addClause(mkLit(3)); 47 | 48 | bool status = solver.solve(); 49 | 50 | test_assert(status == true, "The given formula has to be satisfiable"); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /minisat/tests/test_interface.cc: -------------------------------------------------------------------------------- 1 | /*************************************************************************[online-proof-checker.cc] 2 | Copyright (c) 2022, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #include "simp/cmergesat.h" 21 | #include "tests/TestSolver.h" 22 | 23 | using namespace MERGESAT_NSPACE; 24 | 25 | 26 | int sat_unsat_sat_unsat_sat_solver() 27 | { 28 | printf("run sat_unsat_sat_unsat_sat_cmergesat test\n"); 29 | SimpSolver solver; 30 | solver.eliminate(true); 31 | 32 | /* add all variables in advance! */ 33 | while (solver.nVars() < var(mkLit(50 + 2))) solver.newVar(); 34 | 35 | for (int i = 1; i < 50; i += 2) { 36 | solver.addClause(mkLit(i), mkLit(i + 1), mkLit(i + 2)); 37 | solver.addClause(mkLit(i, true), mkLit(i + 1, true), mkLit(i + 2, true)); 38 | } 39 | 40 | solver.newVar(); 41 | 42 | lbool ret = l_Undef; 43 | bool r = false; 44 | printf("\n\ninitial SAT call\n"); 45 | r = solver.solve(); 46 | printf("c solved with status %d\n", (int)r); 47 | test_assert(r == true, "this formula needs to be satisfiable"); 48 | 49 | solver.newVar(); 50 | 51 | printf("\n\nssumption based UNSAT call\n"); 52 | vec assumps; 53 | assumps.clear(); 54 | for (int i = 1; i < 7; ++i) assumps.push(mkLit(i)); 55 | ret = solver.solveLimited(assumps); 56 | printf("c solved with status False: %d\n", ret == l_False); 57 | test_assert(ret == l_False, "only positive assumptions falsify the formula"); 58 | 59 | solver.newVar(); 60 | 61 | printf("\n\nsecond SAT call\n"); 62 | r = solver.solve(); 63 | printf("c solved with status %d\n", (int)r); 64 | test_assert(r == true, "this formula needs to be satisfiable again"); 65 | 66 | solver.newVar(); 67 | 68 | printf("\n\nsecond UNSAT call\n"); 69 | assumps.clear(); 70 | for (int i = 1; i < 7; ++i) assumps.push(mkLit(i, true)); 71 | ret = solver.solveLimited(assumps); 72 | printf("c solved with status False: %d\n", ret == l_False); 73 | test_assert(ret == l_False, "only negative assumptions falsify the formula"); 74 | 75 | solver.newVar(); 76 | 77 | ret = solver.solveLimited(assumps); 78 | printf("c solved with status False: %d\n", ret == l_False); 79 | test_assert(ret == l_False, "only negative assumptions falsify the formula"); 80 | 81 | vec constain; 82 | constain.push(mkLit(1)); 83 | constain.push(mkLit(2)); 84 | constain.push(mkLit(3, true)); 85 | solver.addConstrainClause(constain); 86 | 87 | printf("\n\nalmost final SAT call\n"); 88 | r = solver.solve(); 89 | printf("c solved with status %d\n", (int)r); 90 | test_assert(r == true, "this formula needs to be satisfiable with constrain clause"); 91 | 92 | printf("\n\nfinal SAT call\n"); 93 | r = solver.solve(); 94 | printf("c solved with status %d\n", (int)r); 95 | test_assert(r == true, "this formula needs to be satisfiable with constrain clause"); 96 | 97 | 98 | printf("\n\nconstraint + assume SAT call\n"); 99 | assumps.clear(); 100 | assumps.push(mkLit(1, true)); 101 | assumps.push(mkLit(2, true)); 102 | solver.addConstrainClause(constain); 103 | ret = solver.solveLimited(assumps); 104 | printf("c solved with status False: %d\n", ret == l_False); 105 | test_assert(ret == l_False, "only negative assumptions falsify the formula"); 106 | test_assert(solver.failed_constraint(), "constrain clause must be marked as failed"); 107 | test_assert(solver.failed_constraint(), "constrain clause must stay marked as failed"); 108 | solver.newVar(); 109 | test_assert(solver.failed_constraint(), "constrain clause must stay marked as failed even with new variables"); 110 | 111 | printf("\n\npost-constraint + assume SAT call\n"); 112 | ret = solver.solveLimited(assumps); 113 | printf("c solved with status False: %d\n", ret == l_False); 114 | test_assert(ret == l_True, "only small assumptions should allow to satisfy the formula"); 115 | test_assert(!solver.failed_constraint(), "constrain clause must not be marked as failed"); 116 | 117 | return 0; 118 | } 119 | 120 | int main(int argc, char **argv) 121 | { 122 | int ret = sat_unsat_sat_unsat_sat_solver(); 123 | return ret; 124 | } 125 | -------------------------------------------------------------------------------- /minisat/tests/test_ipasir.cc: -------------------------------------------------------------------------------- 1 | /*************************************************************************[online-proof-checker.cc] 2 | Copyright (c) 2022, Norbert Manthey 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #include "core/ipasir.h" 21 | #include "tests/TestSolver.h" 22 | 23 | using namespace MERGESAT_NSPACE; 24 | 25 | 26 | void learncb(void *state, int *cls) 27 | { 28 | printf("solver learned "); 29 | while (*cls) { 30 | printf("%d ", *cls); 31 | cls++; 32 | } 33 | printf("\n"); 34 | } 35 | 36 | int sat_unsat_sat_unsat_sat_ipasir() 37 | { 38 | printf("run sat_unsat_sat_unsat_sat_ipasir test\n"); 39 | void *solver = ipasir_init(); 40 | ipasir_set_learn(solver, 0, 2, learncb); 41 | 42 | for (int i = 1; i < 50; i += 2) { 43 | ipasir_add(solver, i); 44 | ipasir_add(solver, i + 1); 45 | ipasir_add(solver, i + 2); 46 | ipasir_add(solver, 0); 47 | ipasir_add(solver, -i); 48 | ipasir_add(solver, -(i + 1)); 49 | ipasir_add(solver, -(i + 2)); 50 | ipasir_add(solver, 0); 51 | } 52 | 53 | int ret = 0; 54 | ret = ipasir_solve(solver); 55 | printf("c solved with status %d\n", ret); 56 | test_assert(ret == 10, "this formula needs to be satisfiable"); 57 | 58 | for (int i = 1; i < 6; ++i) ipasir_assume(solver, i); 59 | ipasir_assume(solver, 0); 60 | ret = ipasir_solve(solver); 61 | printf("c solved with status %d\n", ret); 62 | test_assert(ret == 20, "only positive assumptions falsify the formula"); 63 | 64 | ret = ipasir_solve(solver); 65 | printf("c solved with status %d\n", ret); 66 | test_assert(ret == 10, "without assumptions, the formula needs to be satisfiable again"); 67 | 68 | for (int i = 1; i < 6; ++i) ipasir_assume(solver, -i); 69 | ipasir_assume(solver, 0); 70 | ret = ipasir_solve(solver); 71 | printf("c solved with status %d\n", ret); 72 | test_assert(ret == 20, "only negative assumptions falsify the formula"); 73 | 74 | ret = ipasir_solve(solver); 75 | test_assert(ret == 10, "without assumptions, the formula still needs to be satisfiable"); 76 | 77 | printf("c solved with status %d\n", ret); 78 | ipasir_release(solver); 79 | 80 | return 0; 81 | } 82 | 83 | 84 | int basic_ipasir() 85 | { 86 | printf("run basic_ipasir test\n"); 87 | void *solver = ipasir_init(); 88 | ipasir_set_learn(solver, 0, 2, learncb); 89 | 90 | for (int i = 1; i < 4000; ++i) { 91 | ipasir_add(solver, i); 92 | ipasir_add(solver, i + 1); 93 | ipasir_add(solver, i + 2); 94 | ipasir_add(solver, 0); 95 | ipasir_add(solver, -i); 96 | ipasir_add(solver, -(i + 1)); 97 | ipasir_add(solver, -(i + 2)); 98 | ipasir_add(solver, 0); 99 | } 100 | 101 | for (int i = 1; i < 200; ++i) { 102 | ipasir_assume(solver, i % 2 == 1 ? -i : i); 103 | } 104 | 105 | int ret = ipasir_solve(solver); 106 | printf("c solved with status %d\n", ret); 107 | ipasir_release(solver); 108 | 109 | return 0; 110 | } 111 | 112 | int main(int argc, char **argv) 113 | { 114 | int ret = basic_ipasir(); 115 | ret = sat_unsat_sat_unsat_sat_ipasir() || ret; 116 | return ret; 117 | } 118 | -------------------------------------------------------------------------------- /minisat/utils/Makefile: -------------------------------------------------------------------------------- 1 | EXEC = system_test 2 | DEPDIR = mtl 3 | 4 | include $(MROOT)/mtl/template.mk 5 | -------------------------------------------------------------------------------- /minisat/utils/System.cc: -------------------------------------------------------------------------------- 1 | /***************************************************************************************[System.cc] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #include "utils/System.h" 22 | 23 | #include 24 | unsigned int MERGESAT_NSPACE::nrCores() 25 | { 26 | unsigned int cores = std::thread::hardware_concurrency(); 27 | return cores == 0 ? 4 : cores; 28 | } 29 | 30 | #if defined(_MSC_VER) || defined(__MINGW32__) 31 | 32 | #else 33 | std::chrono::steady_clock::time_point process_start = std::chrono::steady_clock::now(); 34 | #endif 35 | 36 | #if defined(__linux__) 37 | 38 | #include 39 | #include 40 | 41 | using namespace MERGESAT_NSPACE; 42 | 43 | // TODO: split the memory reading functions into two: one for reading high-watermark of RSS, and 44 | // one for reading the current virtual memory size. 45 | 46 | static inline int memReadStat(int field) 47 | { 48 | char name[256]; 49 | pid_t pid = getpid(); 50 | int value = 0; 51 | 52 | snprintf(name, 255, "/proc/%d/statm", pid); 53 | FILE *in = fopen(name, "rb"); 54 | if (in == NULL) return 0; 55 | 56 | for (; field >= 0; field--) 57 | if (fscanf(in, "%d", &value) != 1) 58 | printf("ERROR! Failed to parse memory statistics from \"/proc\".\n"), exit(1); 59 | fclose(in); 60 | return value; 61 | } 62 | 63 | 64 | static inline int memReadPeak(void) 65 | { 66 | char name[256]; 67 | pid_t pid = getpid(); 68 | 69 | snprintf(name, 255, "/proc/%d/status", pid); 70 | FILE *in = fopen(name, "rb"); 71 | if (in == NULL) return 0; 72 | 73 | // Find the correct line, beginning with "VmPeak:": 74 | int peak_kb = 0; 75 | while (!feof(in) && fscanf(in, "VmPeak: %d kB", &peak_kb) != 1) 76 | while (!feof(in) && fgetc(in) != '\n') 77 | ; 78 | fclose(in); 79 | 80 | return peak_kb; 81 | } 82 | 83 | double MERGESAT_NSPACE::memUsed() { return (double)memReadStat(0) * (double)getpagesize() / (1024 * 1024); } 84 | double MERGESAT_NSPACE::memUsedPeak() 85 | { 86 | double peak = memReadPeak() / 1024; 87 | return peak == 0 ? memUsed() : peak; 88 | } 89 | 90 | #elif defined(__FreeBSD__) 91 | 92 | double MERGESAT_NSPACE::memUsed(void) 93 | { 94 | struct rusage ru; 95 | getrusage(RUSAGE_SELF, &ru); 96 | return (double)ru.ru_maxrss / 1024; 97 | } 98 | double MERGESAT_NSPACE::memUsedPeak(void) { return memUsed(); } 99 | 100 | 101 | #elif defined(__APPLE__) 102 | #include 103 | 104 | double MERGESAT_NSPACE::memUsed(void) 105 | { 106 | malloc_statistics_t t; 107 | malloc_zone_statistics(NULL, &t); 108 | return (double)t.max_size_in_use / (1024 * 1024); 109 | } 110 | double MERGESAT_NSPACE::memUsedPeak(void) { return memUsed(); } 111 | #else 112 | double MERGESAT_NSPACE::memUsed() { return 0; } 113 | #endif 114 | -------------------------------------------------------------------------------- /minisat/utils/System.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************************[System.h] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #ifndef MergeSat_System_h 22 | #define MergeSat_System_h 23 | 24 | #if defined(__linux__) 25 | #include 26 | #endif 27 | 28 | #include "mtl/IntTypes.h" 29 | #include "mtl/XAlloc.h" 30 | 31 | //------------------------------------------------------------------------------------------------- 32 | 33 | namespace MERGESAT_NSPACE 34 | { 35 | 36 | static inline double cpuTime(void); // CPU-time in seconds. 37 | static inline double wallClockTime(void); // Wall-Clock-time in seconds 38 | extern double memUsed(); // Memory in mega bytes (returns 0 for unsupported architectures). 39 | extern double memUsedPeak(); // Peak-memory in mega bytes (returns 0 for unsupported architectures). 40 | extern unsigned int nrCores(); // Number of available cores 41 | } // namespace MERGESAT_NSPACE 42 | 43 | //------------------------------------------------------------------------------------------------- 44 | // Implementation of inline functions: 45 | 46 | #if defined(_MSC_VER) || defined(__MINGW32__) 47 | #include 48 | 49 | static inline double MERGESAT_NSPACE::cpuTime(void) { return (double)clock() / CLOCKS_PER_SEC; } 50 | #warning WALLCLOCKTIME NOT SUPPORTED HERE 51 | static inline double Minisat::wallClockTime(void) { return (double)clock() / CLOCKS_PER_SEC; } 52 | 53 | #else 54 | #include 55 | #include 56 | #include 57 | 58 | static inline double MERGESAT_NSPACE::cpuTime(void) 59 | { 60 | struct rusage ru; 61 | getrusage(RUSAGE_SELF, &ru); 62 | return (double)ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec / 1000000; 63 | } 64 | 65 | #include 66 | 67 | extern std::chrono::steady_clock::time_point process_start; 68 | 69 | static inline double Minisat::wallClockTime(void) 70 | { 71 | std::chrono::microseconds us = 72 | std::chrono::duration_cast(std::chrono::steady_clock::now() - process_start); 73 | return us.count() / 1000000.0; 74 | } 75 | 76 | #endif 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /mtl: -------------------------------------------------------------------------------- 1 | minisat/mtl -------------------------------------------------------------------------------- /parallel: -------------------------------------------------------------------------------- 1 | minisat/parallel -------------------------------------------------------------------------------- /simp: -------------------------------------------------------------------------------- 1 | minisat/simp -------------------------------------------------------------------------------- /tools/aws_docker/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Overview 3 | 4 | The content of this directory is highly based on the scripts and tools 5 | explained in the AWS repository to setup infrastructure for the SAT 6 | competition. 7 | 8 | https://github.com/aws-samples/aws-batch-comp-infrastructure-sample.git 9 | 10 | # Running with Infrastructure 11 | 12 | Use the script build_images.sh to build all relevant infrastructure. 13 | Note: if not present, the base infrastructure will be built as well. 14 | 15 | ## Setup Docker Network 16 | 17 | To setup the required docker network, run: 18 | 19 | docker network create mergesat-test 20 | 21 | ## Solving a Formula 22 | 23 | To run the parallel solver with the infrastructure, use the script 24 | run_parallel.sh 25 | 26 | #### Example Command Sequence 27 | 28 | Running the below commands results in building all relevant infrastructure 29 | for running MergeSat in AWS' competition infrastructure as parallel solver, 30 | as well as solving an example formula with the solver. 31 | 32 | ./build_images.sh 33 | ./run_parallel.sh satcomp-mergesat example_cnfs/rook-8-0-0.cnf 34 | -------------------------------------------------------------------------------- /tools/aws_docker/build_images.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | declare -r COMMON_TAG="satcomp-mergesat:common" 4 | declare -r LEADER_TAG="satcomp-mergesat:leader" 5 | 6 | build_competition_base_images() ( 7 | if docker image ls satcomp-infrastructure:leader | grep "satcomp-infrastructure" && 8 | docker image ls satcomp-infrastructure:worker | grep "satcomp-infrastructure"; then 9 | echo "Already detected AWS infrastructure images, not re-building them" 10 | echo "To rebuild, delete images via e.g. docker rmi satcomp-infrastructure:leader" 11 | exit 0 12 | fi 13 | 14 | trap '[ -d $TMP_DOCKER_DIR ] && rm "$TMP_DOCKER_DIR"' EXIT 15 | TMP_DOCKER_DIR$(mktemp -d) 16 | pushd "$TMP_DOCKER_DIR" 17 | # operate in temporary directory 18 | git clone https://github.com/aws-samples/aws-batch-comp-infrastructure-sample.git 19 | cd aws-batch-comp-infrastructure-sample/ 20 | cd docker/ 21 | cd satcomp-images/ 22 | ./build_satcomp_images.sh 23 | docker images ls 24 | popd 25 | ) 26 | 27 | if ! docker info &>/dev/null; then 28 | echo "ERROR Failed to access docker" 29 | fi 30 | 31 | build_competition_base_images 32 | 33 | pushd common 34 | if ! docker build -t "$COMMON_TAG" . | grep "Successfully tagged $COMMON_TAG"; then 35 | docker build -t "$COMMON_TAG" . 36 | echo "ERROR Failed to build common docker image." 37 | exit 1 38 | fi 39 | popd 40 | 41 | pushd leader 42 | if ! docker build -t "$LEADER_TAG" . | grep "Successfully tagged $LEADER_TAG"; then 43 | docker build -t "$LEADER_TAG" . 44 | echo "ERROR Failed to build leader docker image." 45 | exit 1 46 | fi 47 | 48 | popd 49 | 50 | echo "Not building worker image ..." 51 | echo "" 52 | docker image ls "$LEADER_TAG" 53 | echo "" 54 | echo "SUCCESS: Build docker image wit tag '$LEADER_TAG'" 55 | exit 0 56 | -------------------------------------------------------------------------------- /tools/aws_docker/common/Dockerfile: -------------------------------------------------------------------------------- 1 | ################### Build MergeSat 2 | FROM satcomp-infrastructure:common 3 | 4 | # Only build remote for now 5 | # TODO: support host-local repositories 6 | ARG REPO=https://github.com/conp-solutions/mergesat.git 7 | ARG COMMIT=origin/master 8 | 9 | USER root 10 | # Install required softwares 11 | RUN apt-get update \ 12 | && DEBIAN_FRONTEND=noninteractive apt install -y cmake build-essential zlib1g-dev libopenmpi-dev wget unzip build-essential zlib1g-dev cmake python3 build-essential gfortran wget curl 13 | 14 | # Build MergeSat from given repo and commit 15 | RUN git clone --depth=1 $REPO mergesat && cd mergesat && git checkout $COMMIT && cd .. 16 | WORKDIR mergesat 17 | RUN make r -j 6 18 | 19 | -------------------------------------------------------------------------------- /tools/aws_docker/leader/Dockerfile: -------------------------------------------------------------------------------- 1 | ################### Use MergeSat 2 | FROM satcomp-mergesat:common AS builder 3 | USER root 4 | 5 | 6 | ################### Extract MergeSat in run stage 7 | FROM satcomp-infrastructure:leader AS mergesat_liaison 8 | WORKDIR / 9 | 10 | # Show all files we copied 11 | RUN ls /competition 12 | 13 | # Copy solver binary and solver scripts 14 | COPY --from=builder --chown=ecs-user /mergesat/build/release/bin/mergesat /competition/mergesat 15 | COPY --chown=ecs-user ./init_solver.sh /competition 16 | COPY --chown=ecs-user ./run_solver.sh /competition 17 | COPY --chown=ecs-user ./solver /competition 18 | 19 | # Show all files we copied 20 | RUN ls /competition 21 | 22 | USER ecs-user 23 | RUN chmod +x /competition/mergesat 24 | RUN chmod +x /competition/init_solver.sh 25 | RUN chmod +x /competition/run_solver.sh 26 | RUN chmod +x /competition/solver -------------------------------------------------------------------------------- /tools/aws_docker/leader/init_solver.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # start sshd 4 | /usr/sbin/sshd -D -f /home/ecs-user/.ssh/sshd_config & 5 | 6 | # run solver 7 | /competition/solver /rundir -------------------------------------------------------------------------------- /tools/aws_docker/leader/run_solver.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPTPATH=$(readlink -f "$0") 4 | SCRIPTDIR=$(dirname "$SCRIPTPATH") 5 | 6 | # In case a recent-enough glibc is available, use transparent huge pages 7 | export GLIBC_TUNABLES=glibc.malloc.hugetlb=1 8 | 9 | # Use every second CPU 10 | "$SCRIPTDIR"/mergesat -cores=-2 $2 -------------------------------------------------------------------------------- /tools/aws_docker/leader/solver: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import json 3 | import logging 4 | import os 5 | import subprocess 6 | import sys 7 | import threading 8 | 9 | logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 10 | 11 | 12 | class Runner: 13 | def __init__(self, request_directory: str): 14 | self.logger = logging.getLogger("Runner") 15 | self.logger.setLevel(logging.INFO) 16 | self.request_directory = request_directory 17 | os.environ['PYTHONUNBUFFERED'] = "1" 18 | 19 | def process_stream(self, stream, str_name, file_handle): 20 | line = stream.readline() 21 | while line != "": 22 | self.logger.info(f"{str_name}: {line}") 23 | file_handle.write(line) 24 | line = stream.readline() 25 | 26 | def run(self, cmd: list): 27 | self.logger.info("Running command: %s", str(cmd)) 28 | 29 | stdout_target_loc = os.path.join(self.request_directory, "stdout.log") 30 | stderr_target_loc = os.path.join(self.request_directory, "stderr.log") 31 | 32 | with open(stdout_target_loc, "w") as stdout_handle: 33 | with open(stderr_target_loc, "w") as stderr_handle: 34 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, 35 | universal_newlines=True, start_new_session=True) 36 | stdout_t = threading.Thread(target = self.process_stream, args=(proc.stdout, "STDOUT", stdout_handle)) 37 | stderr_t = threading.Thread(target = self.process_stream, args=(proc.stderr, "STDERR", stderr_handle)) 38 | stdout_t.start() 39 | stderr_t.start() 40 | return_code = proc.wait() 41 | stdout_t.join() 42 | stderr_t.join() 43 | 44 | return { 45 | "stdout": stdout_target_loc, 46 | "stderr": stderr_target_loc, 47 | "return_code": return_code, 48 | "output_directory": self.request_directory 49 | } 50 | 51 | def get_input_json(self): 52 | input = os.path.join(self.request_directory, "input.json") 53 | with open(input) as f: 54 | return json.loads(f.read()) 55 | 56 | def create_hostfile(self,ips, request_dir): 57 | hostfile_path = os.path.join(request_dir, 'combined_hostfile') 58 | with open(hostfile_path, 'w+') as f: 59 | for ip in ips: 60 | # f.write(f'{ip} slots=4') # distributed default 61 | f.write(f'{ip} slots=16') # parallel default 62 | f.write('\n') 63 | return hostfile_path 64 | 65 | def get_command(self, input_json): 66 | formula_file = input_json.get("formula_file") 67 | worker_node_ips = input_json.get("worker_node_ips", []) 68 | 69 | combined_hostfile = self.create_hostfile(worker_node_ips, self.request_directory) 70 | 71 | run_list = ["/competition/run_solver.sh"] 72 | run_list.append(combined_hostfile) 73 | run_list.append(formula_file) 74 | 75 | return run_list 76 | 77 | 78 | class MergeSatParser: 79 | @staticmethod 80 | def get_result(output_file): 81 | """ 82 | TODO: Participants should replace this with something more robust for their own solver! 83 | """ 84 | with open(output_file) as f: 85 | raw_logs = f.read() 86 | if "s UNSATISFIABLE" in raw_logs: 87 | return 20 88 | elif "s SATISFIABLE" in raw_logs: 89 | return 10 90 | elif "UNKNOWN" in raw_logs: 91 | return 0 92 | else: 93 | return -1 94 | 95 | if __name__ == "__main__": 96 | request_directory = sys.argv[1] 97 | runner = Runner(request_directory) 98 | 99 | input_json = runner.get_input_json() 100 | cmd = runner.get_command(input_json) 101 | 102 | print (f"cmd: {cmd}") 103 | output = runner.run(cmd) 104 | result = MergeSatParser.get_result(output["stdout"]) 105 | logging.info(f"RESULT: {result}") 106 | solver_output = { 107 | "return_code": result, 108 | "artifacts": { 109 | "stdout_path": output["stdout"], 110 | "stderr_path": output["stderr"] 111 | } 112 | } 113 | 114 | with open(os.path.join(request_directory, "solver_out.json"), "w+") as f: 115 | f.write(json.dumps(solver_output)) -------------------------------------------------------------------------------- /tools/aws_docker/run_parallel.sh: -------------------------------------------------------------------------------- 1 | # /bin/bash 2 | 3 | # run_parallel.sh: Use this script to launch Docker container 4 | # for parallel Mallob. Arguments: 5 | # $1: docker image name (assumes a "leader" tag) 6 | # $2: formula file (relative to HOST_RUNDIR) 7 | # $*: solver arguments (passed directly to solver) 8 | 9 | # check number arguments 10 | if [[ $# -lt 2 ]]; then 11 | echo "run_parallel.sh usage: [solver arguments]" 12 | exit 1 13 | fi 14 | 15 | # read first two command-line arguments 16 | DOCKER_IMAGE_NAME=$1 17 | FORMULA_FILENAME=$2 18 | shift 2 19 | SOLVER_ARGS_SPACED=$* 20 | SOLVER_ARGS="\"${SOLVER_ARGS_SPACED// /\", \"}\"" 21 | 22 | # default config; user can replace DOCKER_NETWORK / HOST_RUNDIR if desired. 23 | DOCKER_NETWORK="mergesat-test" 24 | SCRIPTPATH=$(readlink -f "$0") 25 | SCRIPTDIR=$(dirname "$SCRIPTPATH") 26 | HOST_RUNDIR="$SCRIPTDIR" 27 | 28 | # config to match other scripts 29 | NODE_TYPE="leader" 30 | DOCKER_RUNDIR="/rundir" 31 | 32 | DOCKER_IMAGE="$DOCKER_IMAGE_NAME:$NODE_TYPE" 33 | HOST_FORMULA_FILE="$HOST_RUNDIR/$FORMULA_FILENAME" 34 | DOCKER_FORMULA_FILE="$DOCKER_RUNDIR/$FORMULA_FILENAME" 35 | 36 | # summary 37 | echo "run_parallel.sh, running with" 38 | echo " node type: $NODE_TYPE" 39 | echo " docker network: $DOCKER_NETWORK" 40 | echo " docker image: $DOCKER_IMAGE" 41 | echo " formula file: $FORMULA_FILENAME" 42 | echo " host rundir: $HOST_RUNDIR" 43 | echo " docker rundir: $DOCKER_RUNDIR" 44 | 45 | # does host directory exist? 46 | if [[ ! -d "$HOST_RUNDIR" ]]; then 47 | echo "ERROR - unable to reach host run directory '$HOST_RUNDIR'" 48 | exit 1 49 | fi 50 | 51 | # does formula file exist? 52 | if [[ ! -f "$HOST_FORMULA_FILE" ]]; then 53 | echo "ERROR - unable to read formula file '$HOST_FORMULA_FILE'" 54 | exit 1 55 | fi 56 | 57 | # 58 | # create input.json 59 | # 60 | echo -e "{\n \"formula_file\": \"$DOCKER_FORMULA_FILE\",\n \"worker_node_ips\": [\"leader\"],\n \"timeout_seconds\": \"1000\",\n \"formula_language\": \"\",\n \"solver_argument_list\": [$SOLVER_ARGS]\n}" > "$HOST_RUNDIR/input.json" 61 | 62 | # 63 | # Run docker image as container. Arguments: 64 | # -i // keep STDIN open even if not attached 65 | # --shm-size=XXg // setting up shared memory (for clause DB) 66 | # // default (1G?) is too small 67 | # --network mergesat-test // use the Docker bridge network called 'mergesat-test' 68 | # --entrypoint bash // when the container starts, it runs bash 69 | # --rm // remove the docker container when exiting 70 | # -v // mount $HOST_RUNDIR in the host filesystem at '/$DOCKER_RUNDIR' in docker image 71 | # -t // Docker image name for leader (script hard-codes 'leader' tag) 72 | # -c // gets passed to bash shell 73 | 74 | docker run -i --shm-size=4g --name $NODE_TYPE --network $DOCKER_NETWORK --entrypoint bash --rm -v $HOST_RUNDIR:$DOCKER_RUNDIR -t $DOCKER_IMAGE -c "/competition/init_solver.sh; exec bash" -------------------------------------------------------------------------------- /tools/cadical-interface/README.md: -------------------------------------------------------------------------------- 1 | This directory demonstates how to use MergeSat as a CaDiCal replacement. 2 | The source code of CaDiCaL can be found at 3 | https://github.com/arminbiere/cadical 4 | 5 | ## Preparation 6 | 7 | To be able to use MergeSat as a solving backend, the solver needs to be 8 | compiled. For development and debugging, use the 'ld' compilation target, 9 | while for an actual release, use the 'lr' compilation target. 10 | 11 | ``` 12 | make lr 13 | ``` 14 | 15 | ## Using C Interface of CaDiCaL from MergeSat 16 | 17 | ### Including Declarations 18 | 19 | To use MergeSat as a CaDiCaL replacement, you need to include the following 20 | file: 21 | 22 | ``` 23 | #include "simp/ccadical-mergesat-bridge.h" 24 | ``` 25 | 26 | Make sure to provide MergeSat's `minisat` path to the compiler invocation 27 | line. 28 | 29 | ### Linking Implementation 30 | 31 | Finally, when compiling your application with the solver, make sure you 32 | link against the previously compiled MergeSat library. This is done by 33 | specifying the path to consume the library from (depending on the above 34 | build target, this might be `build/debug/lib`). Furthermore, you need to 35 | actually link against the MergeSat library. The following parameters need 36 | to be added to your link step: 37 | 38 | ``` 39 | -L $MERGESAT_SRC/build/debug/lib -lmergesat 40 | ``` -------------------------------------------------------------------------------- /tools/cadical-interface/compare-cadical-mergesat.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) 4 | declare -r SCRIPT_DIR 5 | 6 | set -e 7 | set -x 8 | 9 | CADICAL= 10 | 11 | get_cadical() { 12 | [ -d cadical ] || git clone https://github.com/arminbiere/cadical.git cadical 13 | pushd cadical 14 | CADICAL=$(pwd) 15 | mkdir -p debug 16 | pushd debug 17 | ../configure -g 18 | make -j $(nproc) 19 | popd 20 | popd 21 | } 22 | 23 | # work in the directory of this script 24 | cd "$SCRIPT_DIR" 25 | 26 | # build and test with mergesat 27 | make BUILD_TYPE=parallel -j6 ld lsh tests-r-all -C "$SCRIPT_DIR/../.." VERB= 28 | g++ cadical-interface-test.cc -o mergesat-test -g -O0 -std=c++11\ 29 | -I "$SCRIPT_DIR/../../minisat" -L "$SCRIPT_DIR"/../../build/debug/lib \ 30 | -lmergesat -DMERGESAT_CADICAL 31 | ./mergesat-test 32 | 33 | # build and test with cadical 34 | get_cadical 35 | g++ cadical-interface-test.cc -o cadical-test -g -O0 -std=c++11\ 36 | -I "$CADICAL"/src -L "$CADICAL"/debug -lcadical 37 | ./cadical-test 38 | -------------------------------------------------------------------------------- /tools/check-determinism.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Given a (list of) solver(s), run them on different benchmarks and check 4 | # whether their behavior is the same on multiple calls. 5 | 6 | declare -i ROUNDS=10 7 | SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 8 | declare -i STATUS=0 9 | MODGEN="" 10 | MODGEN_N="15000" 11 | MODGEN_M="72500" 12 | 13 | trap '[ -d "$WORKDIR" ] && rm -rf "$WORKDIR"' EXIT 14 | WORKDIR=$(mktemp -d check-determinism-XXXXXX) 15 | WORKDIR=$(realpath "$WORKDIR") 16 | echo "Working in $WORKDIR" 17 | 18 | if ! [ -x "$SCRIPT_DIR"/check-solver-behavior.sh ]; then 19 | echo "Error: did not find check-solver-behavior.sh script, aborting" 20 | exit 1 21 | fi 22 | 23 | usage() { 24 | cat < ... location of modgen binary 33 | -m ...... '-m' parameter for modgen tool 34 | -n ...... '-n' parameter for modgen tool 35 | -r ...... number of CNFs to test for each solver (default $ROUNDS) 36 | 37 | Note: 38 | This script uses 'check-solver-behavior.sh' to compare solver output. 39 | EOF 40 | } 41 | 42 | # Allow to specify modgen, parameters, and rounds 43 | while getopts "m:M:n:r:" OPTION; do 44 | case $OPTION in 45 | m) 46 | MODGEN_M="$OPTARG" 47 | ;; 48 | M) 49 | MODGEN="$OPTARG" 50 | ;; 51 | n) 52 | MODGEN_N="$OPTARG" 53 | ;; 54 | r) 55 | ROUNDS="$OPTARG" 56 | ;; 57 | *) 58 | usage 59 | exit 1 60 | ;; 61 | esac 62 | done 63 | shift "$((OPTIND - 1))" 64 | 65 | get_cnf_generator() { 66 | pushd "$WORKDIR" 67 | git clone https://github.com/conp-solutions/modularityGen . 68 | git reset --hard cb88f2f3c7790bb478c4ff9bc9a17d7a3625591a 69 | g++ modularityGen_v2.1.cpp -o modgen || echo "Failed compiling ..." 70 | [ -x "./modgen" ] && MODGEN="$WORKDIR/modgen" 71 | popd 72 | 73 | if [ -z "$MODGEN" ]; then 74 | echo "Error: failed to retrieve and build modgen, aborting" 75 | exit 1 76 | fi 77 | } 78 | 79 | # Do not get modgen, if a copy is presented already 80 | [ -x "$MODGEN" ] || get_cnf_generator 81 | 82 | declare -a MODGEN_CALL=() 83 | for round in $(seq $ROUNDS); do 84 | for solver in "$@"; do 85 | SEED=$((RANDOM % 10000)) 86 | echo "Checking: seed: $SEED solver: '$solver' ..." 87 | 88 | MODGEN_CALL=("$MODGEN" "-s" "$SEED" "-n" "15000" "-m" "72500") 89 | "${MODGEN_CALL[@]}" >"$WORKDIR"/input.cnf || echo "Failed generating input cnf" 90 | grep "^p cnf " "$WORKDIR"/input.cnf 91 | CALL_STATUS=0 92 | "$SCRIPT_DIR"/check-solver-behavior.sh \ 93 | "$WORKDIR"/input.cnf \ 94 | "$solver" \ 95 | "$solver" &>"$WORKDIR"/out.log || CALL_STATUS=$? 96 | if [ "$CALL_STATUS" -ne 0 ]; then 97 | echo "Error: Detected determinism issue in combination modgen call: ${MODGEN_CALL[*]} solver: $solver" 98 | cat "$WORKDIR"/out.log 99 | STATUS=1 100 | fi 101 | done 102 | done 103 | 104 | # Forward exit status 105 | if [ "$STATUS" -ne 0 ]; then 106 | echo "Error: failed to execute comparison" 107 | else 108 | echo "SUCCESS! Did not find any differences in runs" 109 | fi 110 | echo "Terimnate after $SECONDS seconds and $ROUNDS rounds" 111 | exit $STATUS 112 | -------------------------------------------------------------------------------- /tools/check-solver-behavior.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script checks whether 2 solvers behave the same on a given CNF. The 4 | # criteria is the number of decisions and conflicts performed, as well as the 5 | # exit code. 6 | # 7 | 8 | # get to repository base 9 | INPUT="$1" 10 | SOLVER1="$2" 11 | SOLVER2="$3" 12 | 13 | # allow tools to run for about 2 minutes 14 | timeout=180 15 | 16 | usage () 17 | { 18 | $0 input 'solver1 + params' 'solver2 + parames' 19 | } 20 | 21 | 22 | echo "Use input $INPUT" 23 | echo "Run solver1: '$SOLVER1'" 24 | echo "Run solver2: '$SOLVER2'" 25 | 26 | # make sure we clean up 27 | trap 'rm -rf $TMPD' EXIT 28 | TMPD=$(mktemp -d) 29 | 30 | 31 | echo "Run solver 1 (with timeout $timeout s) ..." 32 | declare -i RUNTIME1=$SECONDS 33 | timeout -k $((timeout+2)) "$timeout" $SOLVER1 "$INPUT" > "$TMPD"/out1.log 2> "$TMPD"/err1.log 34 | STATUS1=$? 35 | RUNTIME1=$((SECONDS - RUNTIME1)) 36 | 37 | echo "Run solver 2 (with timeout $timeout s) ..." 38 | declare -i RUNTIME1=$SECONDS 39 | timeout -k $((timeout+2)) "$timeout" $SOLVER2 "$INPUT" > "$TMPD"/out2.log 2> "$TMPD"/err2.log 40 | STATUS2=$? 41 | RUNTIME2=$((SECONDS - RUNTIME2)) 42 | 43 | echo "Evaluate ..." 44 | CON1=$(awk '/c conflicts/ {print $4}' "$TMPD"/out1.log) 45 | CON2=$(awk '/c conflicts/ {print $4}' "$TMPD"/out2.log) 46 | 47 | DEC1=$(awk '/c decisions/ {print $4}' "$TMPD"/out1.log) 48 | DEC2=$(awk '/c decisions/ {print $4}' "$TMPD"/out2.log) 49 | 50 | SUM_CONFLICTS1=$(awk '/c SUM stats conflicts:/ {print $6}' "$TMPD"/out1.log) 51 | SUM_DECISIONS1=$(awk '/c SUM stats decisions:/ {print $6}' "$TMPD"/out1.log) 52 | SUM_RESTARTS1=$(awk '/c SUM stats restarts:/ {print $6}' "$TMPD"/out1.log) 53 | SUM_CONFLICTS2=$(awk '/c SUM stats conflicts:/ {print $6}' "$TMPD"/out2.log) 54 | SUM_DECISIONS2=$(awk '/c SUM stats decisions:/ {print $6}' "$TMPD"/out2.log) 55 | SUM_RESTARTS2=$(awk '/c SUM stats restarts:/ {print $6}' "$TMPD"/out2.log) 56 | 57 | STATUS=0 58 | 59 | # Check for mutual timeout first! 60 | if [ "$STATUS1" -eq 124 ] && [ "$STATUS2" -eq 124 ]; then 61 | echo "Both timeout, ignore" 62 | exit "$STATUS" 63 | fi 64 | 65 | if [ "$STATUS1" -eq 124 ] && [ "$STATUS2" -ne 124 ]; then 66 | echo "Solver 1 hit timeout, solver 2 did not" 67 | STATUS=1 68 | fi 69 | 70 | if [ "$STATUS1" -ne 124 ] && [ "$STATUS2" -eq 124 ]; then 71 | echo "Solver 2 hit timeout, solver 1 did not" 72 | STATUS=1 73 | fi 74 | 75 | if [ "$CON1" != "$CON2" ] 76 | then 77 | echo "Conflicts do not match, $CON1 vs $CON2" 78 | STATUS=1 79 | else 80 | echo "Conflicts match: $CON1" 81 | fi 82 | 83 | 84 | if [ "$DEC1" != "$DEC2" ] 85 | then 86 | echo "Decisions do not match, $DEC1 vs $DEC2" 87 | STATUS=1 88 | else 89 | echo "Decisions match: $DEC1" 90 | fi 91 | 92 | if [ "$SUM_CONFLICTS1" != "$SUM_CONFLICTS2" ] 93 | then 94 | echo "Sum of conflicts do not match, $SUM_CONFLICTS1 vs $SUM_CONFLICTS2" 95 | STATUS=1 96 | else 97 | echo "Sum of conflicts match: $SUM_CONFLICTS1" 98 | fi 99 | 100 | if [ "$SUM_RESTARTS1" != "$SUM_RESTARTS2" ] 101 | then 102 | echo "Sum of restart do not match, $SUM_RESTARTS1 vs $SUM_RESTARTS2" 103 | STATUS=1 104 | else 105 | echo "Sum of restarts match: $SUM_RESTARTS1" 106 | fi 107 | 108 | if [ "$SUM_DECISIONS1" != "$SUM_DECISIONS2" ] 109 | then 110 | echo "Sum of decisions do not match, $SUM_DECISIONS1 vs $SUM_DECISIONS2" 111 | STATUS=1 112 | else 113 | echo "Sum of decisions match: $SUM_DECISIONS1" 114 | fi 115 | 116 | if [ "$STATUS1" != "$STATUS2" ] 117 | then 118 | echo "Exit codes do not match, $STATUS1 vs $STATUS2" 119 | STATUS=1 120 | else 121 | echo "Exit code match: $STATUS1" 122 | fi 123 | 124 | 125 | if [ "$STATUS" -ne 0 ]; then 126 | echo "ERROR: Solver 1 took $RUNTIME1 seconds, solver 2 took $RUNTIME2 seconds" 127 | fi 128 | exit $STATUS 129 | -------------------------------------------------------------------------------- /tools/check-style.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This file checks whether clang-format would modify the style of the repository 4 | # 5 | # This command can be used to get the style up and running: 6 | # 7 | # find minisat -type f | xargs clang-format -i 8 | 9 | # get to repository base 10 | cd $(dirname "${BASH_SOURCE[0]}")/.. 11 | 12 | declare -i STATUS=0 13 | 14 | declare -a TOOL_CANDIDATES=("clang-format-6.0" "clang-format") 15 | 16 | for TOOL in "${TOOL_CANDIDATES[@]}" 17 | do 18 | if ! command -v "$TOOL" &> /dev/null 19 | then 20 | echo "error: could not find clang-format, abort" 21 | exit 1 22 | else 23 | break 24 | fi 25 | done 26 | 27 | echo "info: use clang format, version: $("$TOOL" --version)" 28 | 29 | # iterate over all files and check style 30 | for file in $(find minisat -name "*.cc" -o -name "*.h" -type f) 31 | do 32 | echo "check $file" 33 | REPLACEMENT=$("$TOOL" -i -output-replacements-xml "$file") 34 | 35 | REPLACEMENT_LINES=$(echo "$REPLACEMENT" | wc -l) 36 | 37 | if [ "$REPLACEMENT_LINES" -ne 3 ] 38 | then 39 | echo "style fails for $file" 40 | STATUS=1 41 | fi 42 | done 43 | 44 | if [ "$STATUS" -ne 0 ]; then 45 | echo "error: failed style check with status $STATUS" 46 | fi 47 | exit $STATUS 48 | -------------------------------------------------------------------------------- /tools/checker/check-drat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Solver the given input formula, and in case of being unsatisfiable, the 4 | # produced proof is checked by drat-trim. The produced proof is generated 5 | # in the binary of plain format. 6 | 7 | # input 8 | f="$1" 9 | shift 10 | 11 | # check for file 12 | [ -f "$f" ] || exit 2 13 | 14 | SCRIPT_DIR="$(cd $(dirname "$0") && pwd)" 15 | 16 | # static variables 17 | p=p.proof 18 | o=drat-minimize-output.txt 19 | t=$(realpath ../../build/release/bin/mergesat) 20 | # allow to override the solver location via environment variable 21 | t=${t:-$FUZZ_SOLVER} 22 | d=$(realpath "$SCRIPT_DIR"/drat-trim) 23 | 24 | # run solver 25 | STATUS=0 26 | $t "$f" -drup-file="$p" $@ || STATUS=$? 27 | [ "$STATUS" -ne 127 ] || exit 127 28 | if [ "$STATUS" -ne 0 ] && [ "$STATUS" -ne 10 ] && [ "$STATUS" -ne 20 ]; then 29 | echo "unexpected status code $STATUS" 30 | exit $STATUS 31 | fi 32 | 33 | # exclude trivial unsat 34 | grep "^0$" $f && exit 0 35 | 36 | # run the check 37 | if [ "$STATUS" -ne 20 ]; then 38 | exit $STATUS 39 | fi 40 | 41 | # verify binary proof format 42 | VERIFY_STATUS=0 43 | $d $f $p -v -v -n &>$o || exit $VERIFY_STATUS 44 | echo "verify status: $VERIFY_STATUS" 45 | # for now, don't be too strict 46 | # grep " does not occur: " $o && exit 3 47 | exit 20 48 | 49 | # re-run with plain proof format 50 | "$t" "$f" -drup-file=$p -no-binary-proof $@ || STATUS=$? 51 | 52 | if [ "$STATUS" -ne 0 ] && [ "$STATUS" -ne 10 ] && [ "$STATUS" -ne 20 ]; then 53 | echo "unexpected status code $STATUS" 54 | exit $STATUS 55 | fi 56 | 57 | # exclude trivial unsat 58 | grep "^0$" $f && exit 0 59 | 60 | # run the check 61 | if [ "$STATUS" -ne 20 ]; then 62 | exit $STATUS 63 | fi 64 | 65 | # verify binary proof format 66 | VERIFY_STATUS=0 67 | $d $f $p -v -v -n &>$o || exit $VERIFY_STATUS 68 | echo "verify status: $VERIFY_STATUS" 69 | # for now, don't be too strict 70 | # grep " does not occur: " $o && exit 3 71 | exit 20 72 | -------------------------------------------------------------------------------- /tools/checker/fuzz-check-configurations.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script runs a set of configurations on a set of randomly generated CNF 4 | # formulas. 5 | 6 | # Formulas to test per iteration 7 | declare -i FORMULA_PER_CONFIG_RELEASE=3000 8 | declare -i FORMULA_PER_CONFIG_DEBUG=400 9 | 10 | FUZZ_MULTIPLY=${FUZZ_MULTIPLY:-1} 11 | FORMULA_PER_CONFIG_RELEASE=$((FORMULA_PER_CONFIG_RELEASE * FUZZ_MULTIPLY)) 12 | FORMULA_PER_CONFIG_DEBUG=$((FORMULA_PER_CONFIG_DEBUG * FUZZ_MULTIPLY)) 13 | 14 | # List of configurations to consider 15 | CONFIGURATIONS=("../../build/release/bin/mergesat" 16 | "../../build/debug/bin/mergesat -check-par-sat -check-proof=1 -cpu-lim=4 -drup-file=proof.drat -verb=0 -VSIDS-init-lim=100 -lcm-delay=10 -lcm-delay-inc=10 -rfirst=2" 17 | "../../build/debug/bin/mergesat -check-par-sat -check-proof=1 -cpu-lim=4 -drup-file=proof.drat -verb=0 -no-pre -VSIDS-init-lim=100 -lcm-delay=10 -lcm-delay-inc=10 -rfirst=2" 18 | "../../build/debug/bin/mergesat -check-par-sat" 19 | "../../build/debug/bin/mergesat -check-par-sat -no-pre" 20 | "../../build/debug/bin/mergesat -check-par-sat -rtype=4 -VSIDS-lim=50 -VSIDS-init-lim=50" 21 | "../../build/debug/bin/mergesat -check-par-sat -verb=2 -cores=1" 22 | "../../build/release/bin/mergesat -check-par-sat -la-dec-level=50 -la-every=2" 23 | "../../build/release/bin/mergesat -check-par-sat -i-uip -i-mini" 24 | "../../build/release/bin/mergesat -check-par-sat -all-strength-max=5" 25 | "../../build/release/bin/mergesat -check-par-sat -otfss-lbd=6" 26 | "../../build/release/bin/mergesat -check-par-sat -i-uip -i-mini -drup-file=proof.drat -check-proof=1" 27 | "../../build/release/bin/mergesat -check-par-sat -na-attempt-every=1 -drup-file=proof.drat -check-proof=1" 28 | "../../build/debug/bin/mergesat -check-par-sat -check-proof=1 -drup-file=proof.drat" 29 | "../../build/debug/bin/mergesat -bve-gates -bve-sem-gates -check-proof=1 -drup-file=proof.drat" 30 | "../../build/debug/bin/mergesat -cores=1 -bve-gates -bve-sem-gates -check-proof=1 -drup-file=proof.drat" 31 | "../../build/debug/bin/mergesat -bve-gates -check-par-sat -check-proof=1 -drup-file=proof.drat" 32 | "../../build/release/bin/mergesat -check-par-sat -cores=4 -cpu-lim=30 -mem-lim=2048" 33 | "../../build/release/bin/mergesat -check-par-sat -cores=8 -cpu-lim=30 -mem-lim=2048" 34 | "../../build/release/bin/mergesat -check-par-sat -cores=4 -cpu-lim=30 -mem-lim=2048 -drup-file=proof.drat -check-proof=1" 35 | ) 36 | 37 | # Current directory 38 | SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 39 | 40 | cd "$SCRIPT_DIR" 41 | 42 | declare -i overall_status=0 43 | for CONFIG in "${CONFIGURATIONS[@]}"; do 44 | echo "test configuration: $CONFIG" 45 | 46 | echo "$CONFIG \$1" >check-solver-config.sh 47 | chmod u+x check-solver-config.sh 48 | 49 | status=0 50 | 51 | # select number of formulas to test based on configuration 52 | FORMULA_PER_CONFIG="$FORMULA_PER_CONFIG_RELEASE" 53 | grep -q "debug" check-solver-config.sh && FORMULA_PER_CONFIG="$FORMULA_PER_CONFIG_DEBUG" 54 | 55 | ./fuzzcheck.sh ./check-solver-config.sh "$FORMULA_PER_CONFIG" || status=$? 56 | if [ "$status" -ne 0 ]; then 57 | echo "configuration failed!" 58 | overall_status=$status 59 | fi 60 | done 61 | 62 | exit $overall_status 63 | -------------------------------------------------------------------------------- /tools/checker/fuzz-check-diversity.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script runs a set of configurations on a set of randomly generated CNF 4 | # formulas. 5 | 6 | # Formulas to test per iteration 7 | declare -i FORMULA_PER_CONFIG_RELEASE=1500 8 | 9 | # Current directory 10 | SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 11 | 12 | cd "$SCRIPT_DIR" 13 | 14 | declare -i overall_status=0 15 | for RANK in {0..32}; do 16 | echo "" 17 | echo "test rank: $RANK" 18 | echo "../../build/release/bin/mergesat -diversify-rank=$RANK \$1" >check-solver-config.sh 19 | chmod u+x check-solver-config.sh 20 | 21 | status=0 22 | 23 | # select number of formulas to test based on configuration 24 | FORMULA_PER_CONFIG="$FORMULA_PER_CONFIG_RELEASE" 25 | 26 | ./fuzzcheck.sh ./check-solver-config.sh "$FORMULA_PER_CONFIG" || status=$? 27 | if [ "$status" -ne 0 ]; then 28 | echo "configuration failed!" 29 | overall_status=$status 30 | fi 31 | done 32 | 33 | exit $overall_status 34 | -------------------------------------------------------------------------------- /tools/checker/fuzz-drat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Generate solvers and check whether the DRAT proof is valid. 4 | # Solving and verifying is done in the script check-drat.sh 5 | 6 | LIMIT=$1 7 | TIMEOUT=$2 8 | 9 | [ -n "$TIMEOUT" ] || exit 2 10 | 11 | SCRIPT_DIR="$(cd $(dirname "$0") && pwd)" 12 | 13 | c="$SCRIPT_DIR/modgen" 14 | 15 | I=0 16 | f=fuzz_input.cnf 17 | declare -i found_sat=0 18 | declare -i found_unsat=0 19 | 20 | FAILED=0 21 | while true; do 22 | I=$((I + 1)) 23 | [ "$LIMIT" -ge "$I" ] || break 24 | # echo "[$SECONDS] run $I ..." 25 | seed="$(echo $(($(date +%s%N) / 1000000)))" 26 | cls="" 27 | while [ -z "$cls" ]; do 28 | cls="$(bash -c 'echo $((9000 + $(date +%4N) ))' 2>/dev/null)" 29 | done 30 | modgen_cli_args="-s $seed -n 3500 -m $cls" 31 | $c $modgen_cli_args >$f 32 | STATUS=0 33 | timeout "$TIMEOUT" "$SCRIPT_DIR"/check-drat.sh $f &>output.log || STATUS=$? 34 | # ignore time outs 35 | [ "$STATUS" -ne 124 ] || continue 36 | 37 | # make failures permanent 38 | if [ "$STATUS" -ne 0 ] && [ "$STATUS" -ne 10 ] && [ "$STATUS" -ne 20 ]; then 39 | echo "[$SECONDS] failed for try $I with status $STATUS and header $(grep "p cnf" $f) and generator: $c $modgen_cli_args" 40 | mv $f fuzz_input.$I.cnf 41 | mv output.log output.$I.log 42 | FAILED=$((FAILED + 1)) 43 | fi 44 | [ "$STATUS" -eq 10 ] && found_sat=$((found_sat + 1)) 45 | [ "$STATUS" -eq 20 ] && found_unsat=$((found_unsat + 1)) 46 | done 47 | echo "failed $FAILED out of $LIMIT" 48 | echo "($SECONDS s) sat: $found_sat unsat: $found_unsat" 49 | [ "$FAILED" -eq 0 ] || exit 1 50 | exit 0 51 | -------------------------------------------------------------------------------- /tools/checker/fuzzcheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # create cnf files via fuzzing, check with verifier, apply cnfdd if required 5 | # 6 | 7 | prg=$1 8 | 9 | # this can be initialized to a max. size of an unreduced buggy formula 10 | bestcls=50000 11 | 12 | cnf=/dev/shm/uzz-$$.cnf 13 | sol=/dev/shm/fuzz-$$.sol 14 | err=/dev/shm/fuzz-$$.err 15 | out=/dev/shm/fuzz-$$.out 16 | log=fuzz-$$.log 17 | rm -f $log $cnf $sol 18 | echo "[fuzz] running $prg" 19 | echo "[fuzz] logging $log" 20 | echo "run $1 $2" >$log 21 | echo "[fuzz] run with pid $$" 22 | echo "[fuzz] started at $(date)" 23 | i=0 24 | 25 | # set limit for number of instances to be solved 26 | limit=1 27 | if [ "x$2" != "x" ]; then 28 | limit=$2 29 | fi 30 | test=0 31 | 32 | declare -i status=0 33 | declare -i found_sat=0 34 | declare -i found_unsat=0 35 | 36 | while [ "$test" -lt "$limit" ]; do 37 | rm -f $cnf 38 | seed="$(echo $(($(date +%s%N) / 1000000)))" 39 | cls="" 40 | while [ -z "$cls" ]; do 41 | cls="$(bash -c 'echo $((6000 + $(date +%4N) ))' 2>/dev/null)" 42 | done 43 | modgen_cli_args="-s $seed -n 2800 -m $cls" 44 | ./modgen $modgen_cli_args >$cnf 45 | # control whether algorithm should sleep 46 | seed=$(grep 'c value seed =' $cnf | head -1 | awk '{print $NF}') 47 | head="$(awk '/p cnf /{print $3, $4}' $cnf)" 48 | [ -n "${VERBOSE_FUZZING:-}" ] && printf "%d %16d %6d %6d \r" "$i" "$seed" $head 49 | i=$(expr $i + 1) 50 | rm -f $sol 51 | 52 | # set limit for number of instances to be solved 53 | if [ "x$2" != "x" ]; then 54 | test=$(($test + 1)) 55 | fi 56 | 57 | thiscls=$(awk '/p cnf /{print $4}' $cnf) 58 | if [ "$bestcls" -ne "-1" ]; then 59 | if [ "$bestcls" -le "$thiscls" ]; then 60 | continue 61 | fi 62 | fi 63 | 64 | ./toolCheck.sh $prg $cnf >$out 2>$err 65 | res=$? 66 | # echo "result $res" 67 | case $res in 68 | 124) 69 | echo "($SECONDS s) timeout with $seed" >$log 70 | mv $cnf timeout-$seed.cnf 71 | continue 72 | ;; 73 | 10) 74 | found_sat=$((found_sat + 1)) 75 | continue 76 | ;; 77 | 20) 78 | found_unsat=$((found_unsat + 1)) 79 | continue 80 | ;; 81 | 15) ;; 82 | 83 | 25) ;; 84 | 85 | esac 86 | 87 | status=1 88 | 89 | head="$(awk '/p cnf /{print $3, $4}' $cnf)" 90 | echo "($SECONDS s) [fuzz] bug-$seed $head with exit code $res" 91 | echo "($SECONDS s) To reproduce, run modgen: './modgen $modgen_cli_args > reproduce.cnf' and '$prg reproduce.cnf'" 92 | echo $seed >>$log 93 | echo "($SECONDS s) out" 94 | cat $out 95 | echo "($SECONDS s) err" 96 | cat $err 97 | 98 | # 99 | # consider only bugs that are smaller then the ones we found already 100 | # 101 | if [ "$bestcls" -eq "-1" ]; then 102 | bestcls=$thiscls 103 | echo "($SECONDS s) init bestcls with $bestcls" 104 | elif [ "$bestcls" -le $thiscls ]; then 105 | echo "($SECONDS s) reject new bug with $thiscls clauses" 106 | continue 107 | fi 108 | 109 | bestcls="$thiscls" # store better clause count! 110 | echo "($SECONDS s) set bestcls to $bestcls" 111 | red=red-$seed.cnf 112 | bug=bug-$seed.cnf 113 | mv $cnf $bug 114 | 115 | if [ -f "$red" ]; then 116 | head="$(awk '/p cnf /{print $3, $4}' $red)" 117 | echo "($SECONDS s) [fuzz] $red $head" 118 | fi 119 | gzip "$bug" 120 | done 121 | 122 | echo "($SECONDS s) sat: $found_sat unsat: $found_unsat" 123 | echo "($SECONDS s) did $test out of $limit tests" 124 | 125 | exit $status 126 | -------------------------------------------------------------------------------- /tools/checker/prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script sets up the checker environment (install drat-trim as well as modgen) 4 | 5 | # exits the script immediately if a command exits with a non-zero status 6 | set -e 7 | 8 | # directory of this script (in repo/scripts) 9 | script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 10 | 11 | # get drat-trim 12 | if [ -d drat-trim-src ]; then 13 | pushd drat-trim-src 14 | git fetch origin 15 | git checkout origin/master 16 | popd 17 | else 18 | git clone https://github.com/marijnheule/drat-trim.git drat-trim-src 19 | fi 20 | 21 | # get and build modgen 22 | if [ ! -d modgen-src ]; then 23 | git clone --depth=1 https://github.com/conp-solutions/modularityGen.git modgen-src 24 | fi 25 | make -C modgen-src 26 | cp modgen-src/modgen . 27 | 28 | # build drat-trim 29 | pushd drat-trim-src 30 | make 31 | mv drat-trim .. 32 | popd 33 | 34 | # build verify model 35 | g++ verify_model.c -o verify -O3 36 | 37 | # clean up 38 | rm -rf drat-trim-src fuzz-suite.zip 39 | -------------------------------------------------------------------------------- /tools/checker/toolCheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR="$(cd $(dirname "$0") && pwd)" 4 | rm -f /tmp/verify_$$.cnf 5 | 6 | #echo "run $1 with $2" >> tmp.dat 7 | 8 | timeout 10 $1 $2 >/tmp/verify_$$.cnf 2>/tmp/verify2_$$.cnf 9 | status=$? 10 | # sleep 0.01 11 | 12 | #echo "finish with state= $status" >> tmp.dat 13 | 14 | if [ "$status" -eq "124" ]; then 15 | # we got a timeout here! 16 | rm -f /tmp/verify_$$.cnf /tmp/verify2_$$.cnf 17 | exit 124 18 | fi 19 | 20 | # cat /tmp/verify.cnf 21 | if [ "$status" -eq "10" ]; then 22 | "$SCRIPT_DIR"/verify SAT /tmp/verify_$$.cnf $2 # 2>&1 > /dev/null 23 | vstat="$?" 24 | 25 | if [ "$vstat" -eq "1" ]; then 26 | rm -f /tmp/verify_$$.cnf /tmp/verify2_$$.cnf 27 | exit 10 28 | else 29 | echo "solver out:" 30 | cat /tmp/verify_$$.cnf 31 | echo "solver err:" 32 | cat /tmp/verify2_$$.cnf 33 | rm -f /tmp/verify_$$.cnf /tmp/verify2_$$.cnf 34 | exit 15 35 | fi 36 | else 37 | # if the instance is unsatisfiable or another error occurred, report it 38 | # echo "exit with $status" >> tmp.dat 39 | 40 | if [ "$status" -ne "20" ]; then 41 | echo "solver output:" 42 | cat /tmp/verify_$$.cnf /tmp/verify2_$$.cnf 43 | rm -f /tmp/verify_$$.cnf /tmp/verify2_$$.cnf 44 | exit $status 45 | fi 46 | 47 | timeout 30 picosat $2 2>/dev/null 1>/dev/null 48 | lstat=$? 49 | 50 | if [ "$status" -eq "124" ]; then 51 | # we got a timeout here! 52 | mkdir -p picosatTimeout # collect instances where lingeling performs badly 53 | mv $2 picosatTimeout 54 | rm -f /tmp/verify_$$.cnf /tmp/verify2_$$.cnf 55 | exit 124 56 | fi 57 | 58 | if [ $lstat -ne "20" ]; then 59 | echo "solver output:" 60 | cat /tmp/verify_$$.cnf /tmp/verify2_$$.cnf 61 | rm -f /tmp/verify_$$.cnf /tmp/verify2_$$.cnf 62 | exit 25 63 | fi 64 | rm -f /tmp/verify_$$.cnf /tmp/verify2_$$.cnf 65 | exit 20 66 | fi 67 | -------------------------------------------------------------------------------- /tools/ci/check-determinism.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Run a small benchmark evaluation and report the PAR2 value for a selected 4 | # set of benchmarks. 5 | 6 | set -e 7 | 8 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" 9 | 10 | declare -i TIMEOUT=600 11 | declare -i SPACE_MB=4096 12 | 13 | SOLVER="$1" 14 | SOLVER=$(realpath "$SOLVER") 15 | 16 | # TODO: re-enable this line after debugging! 17 | # trap '[ -d "$WORK_DIR" ] && rm -f "$WORK_DIR"' EXIT 18 | WORK_DIR="$(mktemp -d)" 19 | 20 | get_modgen() { 21 | # get and build modgen 22 | git clone --depth=1 https://github.com/conp-solutions/modularityGen.git modgen-src 23 | make -C modgen-src 24 | cp modgen-src/modgen . 25 | } 26 | 27 | # the given modgen params create CNFs with known MergeSat conflicts required 28 | declare -a PARAMS=("-s 4900 -n 1000 -m 3000" "-s 2400 -n 15000 -m 72500" "-s 4900 -n 1000000 -m 3000000" "-s 3900 -n 10000 -m 38000" "-n 2200 -m 9086 -c 40 -s 158" "-n 45000 -m 171000 -c 40 -s 100") 29 | declare -a EXPECTED_CONFLICTS=(35 856761 364 606458 445420 995426) 30 | declare -i ERROR=0 31 | 32 | # run remaining steps in created temporary directory 33 | pushd "$WORK_DIR" 34 | get_modgen 35 | 36 | for index in $(seq 0 "$((${#PARAMS[@]} - 1))"); do 37 | echo "Run test $index: conflicts: ${CONFLICTS[$index]} params: ${PARAMS[$index]}" 38 | NEXT_PARAM="${PARAMS[$index]}" 39 | ./modgen $NEXT_PARAM >test.cnf 40 | EXPECTED="${EXPECTED_CONFLICTS[$index]}" 41 | CONFLICT_LIMIT=$((EXPECTED+20000)) 42 | echo "Solve CNF with $(grep "p cnf" test.cnf) with expected conflicts $EXPECTED and conflict limit $CONFLICT_LIMIT" 43 | PRINTED_OUTPUT=0 44 | STATUS=0 45 | "$SOLVER" "test.cnf" -no-model -no-lib-math -con-lim="$CONFLICT_LIMIT" &>solver.output || STATUS="$?" 46 | CONFLICTS=$(awk '/c conflicts/ {print $4}' solver.output) 47 | if [ "$EXPECTED" -ne "$CONFLICTS" ]; then 48 | echo "ERROR: detected non-matching conflicts $CONFLICTS instead of $EXPECTED, output:" 49 | cat solver.output 50 | ERROR=1 51 | PRINTED_OUTPUT=1 52 | fi 53 | if [ "$STATUS" -ne 10 ] && [ "$STATUS" -ne 20 ]; then 54 | echo "ERROR: detected unexpected bad exit code $STATUS, output:" 55 | [ "$PRINTED_OUTPUT" -ne 1 ] && cat solver.output 56 | ERROR=1 57 | continue 58 | fi 59 | done 60 | 61 | if [ "$ERROR" -ne 0 ]; then 62 | exit "$ERROR" 63 | fi 64 | exit "$ERROR" 65 | -------------------------------------------------------------------------------- /tools/ci/combine-competition-logs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (C) 2022, Norbert Manthey 4 | 5 | import csv 6 | import logging 7 | import sys 8 | 9 | # Create logger 10 | log = logging.getLogger(__name__) 11 | 12 | 13 | def main(): 14 | 15 | logging.basicConfig( 16 | format="%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s", 17 | datefmt="%Y-%m-%d:%H:%M:%S", 18 | level=logging.DEBUG, 19 | ) 20 | 21 | solvers = set() 22 | benchmarks = set() 23 | benchmark_data = {} 24 | 25 | # benchmark;solver;sat-status;sat-status;time;cputime;memory;status,runlim-status 26 | for logfile in sys.argv[1:]: 27 | log.info("Process logfile '%s'", logfile) 28 | 29 | with open(logfile, newline="") as csvfile: 30 | reader = csv.DictReader(csvfile, delimiter=";") 31 | for row in reader: 32 | benchmark = row["benchmark"] 33 | if ".cnf" not in benchmark: 34 | continue 35 | solver = row["solver"] 36 | if solver not in solvers: 37 | solvers.add(solver) 38 | 39 | if benchmark not in benchmarks: 40 | benchmarks.add(benchmark) 41 | 42 | if benchmark not in benchmark_data: 43 | benchmark_data[benchmark] = {} 44 | benchmark_data[benchmark][solver] = { 45 | "status": row["status"], 46 | "time": row["time"], 47 | } 48 | 49 | log.info( 50 | "Detected %d benchmarks and %d solvers\n", len(benchmark_data), len(solvers) 51 | ) 52 | 53 | sorted_solvers = sorted([x for x in solvers]) 54 | 55 | out_string = f"benchmark " 56 | for solver in sorted_solvers: 57 | out_string += "{} ".format(solver.replace(" ", "_")) 58 | print(out_string) 59 | 60 | for benchmark in benchmarks: 61 | out_string = f"{benchmark} " 62 | for solver in sorted_solvers: 63 | d = benchmark_data[benchmark][solver] 64 | if d["status"] == "ok": 65 | out_string += "{} ".format(str(d["time"])) 66 | else: 67 | out_string += "- " 68 | print(out_string) 69 | 70 | 71 | if __name__ == "__main__": 72 | sys.exit(main()) 73 | -------------------------------------------------------------------------------- /tools/ci/maxsat/UWrMaxSat/config.mk: -------------------------------------------------------------------------------- 1 | BUILD_TYPE?=release 2 | 3 | BUILD_DIR?=build 4 | MAXPRE?=-D MAXPRE 5 | BIGWEIGHTS?=#-D BIG_WEIGHTS 6 | MINISATP_RELSYM?= 7 | MINISATP_REL?=-std=c++11 -O3 -D NDEBUG -Wno-strict-aliasing -D MAPLE -D MAXPRE -D MAXPRE $(MAXPRE) $(BIGWEIGHTS) 8 | MINISATP_DEB?=-std=c++11 -O0 -D DEBUG -Wno-strict-aliasing -D MAPLE -D MAXPRE -D MAXPRE $(MAXPRE) $(BIGWEIGHTS) 9 | MINISATP_PRF?=-std=c++11 -O3 -D NDEBUG -Wno-strict-aliasing -D MAPLE -D MAXPRE -D MAXPRE $(MAXPRE) $(BIGWEIGHTS) 10 | MINISATP_FPIC?=-fpic 11 | MINISAT_INCLUDE?=-I/usr/include -I../mergesat 12 | MINISAT_LIB?=-L/usr/lib -L../mergesat/build/$(BUILD_TYPE)/lib -lmergesat 13 | ifneq ($(MAXPRE),) 14 | MCL_INCLUDE?=-I../maxpre/src 15 | MCL_LIB?=-L../maxpre/src/lib -lmaxpre 16 | else 17 | MCL_INCLUDE?= 18 | MCL_LIB?= 19 | endif 20 | prefix?=/usr 21 | -------------------------------------------------------------------------------- /tools/ci/maxsat/UWrMaxSat/test-UWrMaxSat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Compile for UWrMaxSat 4 | 5 | set -e 6 | set -x 7 | 8 | SCRIPT=$(realpath "$0") 9 | SCRIPTDIR=$(dirname "$SCRIPT") 10 | 11 | # enter the ci directory for this script 12 | cd ${SCRIPTDIR} 13 | 14 | # get solver 15 | [ ! -d uwrmaxsat ] && git clone https://github.com/marekpiotrow/UWrMaxSat uwrmaxsat 16 | pushd uwrmaxsat 17 | git fetch origin 18 | git checkout origin/master 19 | popd 20 | 21 | # compile solver 22 | [ ! -d maxpre ] && git clone https://github.com/Laakeri/maxpre 23 | pushd maxpre 24 | git fetch origin 25 | git checkout origin/master 26 | sed -i 's/-g/-D NDEBUG/' src/Makefile 27 | make lib -j $(nproc) 28 | popd 29 | 30 | # make sure we have mergesat here 31 | ln -s ${SCRIPTDIR}/../../../.. mergesat 32 | pushd mergesat 33 | make r -j $(nproc) 34 | popd 35 | 36 | # build the solver 37 | pushd uwrmaxsat 38 | cp ../config.mk . 39 | make config 40 | make r -j $(nproc) 41 | 42 | -------------------------------------------------------------------------------- /tools/ci/unsat.cnf.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conp-solutions/mergesat/a694893e50eed973c0f01b47c092b86dface1eb5/tools/ci/unsat.cnf.gz -------------------------------------------------------------------------------- /tools/compare-to-mainline.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Run a small benchmark evaluation and report the PAR2 value for a selected 4 | # set of benchmarks. 5 | 6 | set -e 7 | 8 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" 9 | 10 | declare -i TIMEOUT=600 11 | declare -i SPACE_MB=4096 12 | declare LOG_DUMP="" 13 | declare RESULTS_DIRS="" 14 | declare OUTPUT_FILE="" 15 | declare -i VERBOSE=0 16 | declare -i ERROR=0 17 | declare -a BENCHMARK_ITEMS 18 | declare -i IGNORE_ERRORS=0 19 | PRODUCTION_MERGESAT="" 20 | 21 | get_production_mergesat() { 22 | trap '[ -d "$MERGESAT_TMPD" ] && rm -rf "$MERGESAT_TMPD"' EXIT 23 | COPY_PWD=${PWD} 24 | MERGESAT_TMPD=$(mktemp -d) 25 | pushd "$MERGESAT_TMPD" 26 | git clone https://github.com/conp-solutions/mergesat.git mergesat 27 | 28 | if [ -z "$PRODUCTION_MERGESAT" ]; then 29 | pushd mergesat 30 | PRODUCTION_MERGESAT="mergesat-production-$(git describe)" 31 | PRODUCTION_MERGESAT="$COPY_PWD/$PRODUCTION_MERGESAT" 32 | popd 33 | fi 34 | 35 | pushd mergesat 36 | make r -j $(nproc) 37 | cp build/release/bin/mergesat "$PRODUCTION_MERGESAT" 38 | popd 39 | popd 40 | } 41 | 42 | get_benchmark() { 43 | pushd "$SCRIPT_DIR" &>/dev/null 44 | mkdir -p benchmarks 45 | cd benchmarks 46 | 47 | # some SAT 2020 benchmarks 48 | [ -r "prime2209-84.cnf.xz" ] || wget --content-disposition https://gbd.iti.kit.edu/file/af66c2b2ff8a9cd900d9f2f79e53f6a7 49 | [ -r "fclqcolor-18-14-11.cnf.gz.CP3-cnfmiter.cnf.xz" ] || wget --content-disposition https://gbd.iti.kit.edu/file/72a1b82b2c1f17b0e5e0d4a44937d848 50 | [ -r "k2fix_gr_2pinvar_w8.shuffled.cnf.xz" ] || wget --content-disposition https://gbd.iti.kit.edu/file/b400f2362d15334aa6d05ef99e315fc1 51 | [ -r "3bitadd_32.cnf.gz.CP3-cnfmiter.cnf.xz" ] || wget --content-disposition https://gbd.iti.kit.edu/file/3d38ffe08887da6cbe9b17ce50c4b34c 52 | [ -r "Timetable_C_437_E_62_Cl_29_S_28.cnf.xz" ] || wget --content-disposition https://gbd.iti.kit.edu/file/8e905dfa09f45f7f50099f70cc38714c 53 | [ -r "tseitingrid7x185_shuffled.cnf.xz" ] || wget --content-disposition https://gbd.iti.kit.edu/file/4a3bee9d892a695c3d63191f4d1fbdff 54 | 55 | declare -a PRE_BENCHMARK_ITEMS=( 56 | "prime2209-84.cnf.xz" 57 | "fclqcolor-18-14-11.cnf.gz.CP3-cnfmiter.cnf.xz" 58 | "k2fix_gr_2pinvar_w8.shuffled.cnf.xz" 59 | "3bitadd_32.cnf.gz.CP3-cnfmiter.cnf.xz" 60 | "tseitingrid7x185_shuffled.cnf.xz" 61 | ) 62 | 63 | for benchmark in "${PRE_BENCHMARK_ITEMS[@]}"; do 64 | BENCHMARK_ITEMS+=("$PWD/$benchmark") 65 | done 66 | 67 | popd &>/dev/null 68 | } 69 | 70 | usage() { 71 | cat </dev/null; then 94 | echo "error: failed to find tool $tool" 95 | fi 96 | done 97 | 98 | # do we want to package Riss(for Coprocessor) or Sparrow as well? 99 | while getopts "b:P:vy" OPTION; do 100 | case $OPTION in 101 | b) 102 | BENCHMARKDIR="$OPTARG" 103 | BENCHMARKURLFILE="" 104 | ;; 105 | P) 106 | PRODUCTION_MERGESAT="$OPTARG" 107 | ;; 108 | v) 109 | VERBOSE=$((VERBOSE + 1)) 110 | ;; 111 | y) 112 | IGNORE_ERRORS=1 113 | ;; 114 | *) 115 | usage 116 | exit 1 117 | ;; 118 | esac 119 | done 120 | shift "$((OPTIND - 1))" 121 | declare -r TIMEOUT 122 | declare -r SPACE_MB 123 | 124 | # in case no benchmark directory is specified, get a small benchmark 125 | if [ "$BENCHMARKDIR" = "$SCRIPT_DIR"/benchmarks ] && [ -z "$RESULTS_DIRS" ]; then 126 | get_benchmark 127 | else 128 | PREBENCHMARKS=() 129 | fi 130 | 131 | if [ -n "$PRODUCTION_MERGESAT" ] && [ -x "$PRODUCTION_MERGESAT" ]; then 132 | echo "Using solver '$PRODUCTION_MERGESAT' as reference" 133 | else 134 | echo "Getting upstream solver for comparison" 135 | get_production_mergesat 136 | fi 137 | 138 | declare -a COMPARE_SOLVER="$@" 139 | echo "Solver to analyze: ${COMPARE_SOLVER[*]}" 140 | 141 | # only walk through non-default benchmark directory 142 | if [ "${#BENCHMARK_ITEMS[@]}" -eq 0 ]; then 143 | BENCHMARK_ITEMS=($(find "${BENCHMARKDIR}" -type f | head -n 10)) 144 | fi 145 | for benchmarkitem in "${BENCHMARK_ITEMS[@]}"; do 146 | # check if we should abort 147 | if [ -n "$STOPFILE" ]; then 148 | echo "Checking stopfile '$STOPFILE' ..." 149 | if [ -r "$STOPFILE" ]; then 150 | echo "... abort benchmark due to existing stopfile, and removing it" 151 | rm -f "$STOPFILE" 152 | break 153 | fi 154 | fi 155 | benchmark="$(realpath "$benchmarkitem")" 156 | # solve benchmark for all solvers 157 | echo "" 158 | [ "$VERBOSE" -gt 0 ] && echo "Test benchmark: $benchmark" 159 | STATUS=0 160 | tools/check-solver-behavior.sh "$benchmarkitem" "${COMPARE_SOLVER[@]}" $PRODUCTION_MERGESAT || STATUS=$? 161 | if [ "$STATUS" -ne 0 ]; then 162 | ERROR=1 163 | # abort early, we found a diff already 164 | break 165 | fi 166 | done 167 | 168 | echo "Compare status '$ERROR' (with solver '$PRODUCTION_MERGESAT' (after $SECONDS seconds)" 169 | 170 | [ "$IGNORE_ERRORS" -eq 0 ] && exit 0 171 | exit "$ERROR" 172 | -------------------------------------------------------------------------------- /tools/container-default-command.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright Norbert Manthey, 2019 4 | 5 | # This script is executed as default in the container 6 | 7 | # Default location is defined by environment variable INPUT_CNF 8 | INPUT_CNF=${INPUT_CNF:-} 9 | 10 | # In case that variable is not given, we might have a CNF stored in S3 11 | if [ -z "$INPUT_CNF" ] 12 | then 13 | if ! command -v aws &> /dev/null 14 | then 15 | echo "error: cannot find tool 'aws', abort" 16 | exit 1 17 | fi 18 | 19 | # Get file basename 20 | PROBLEM=$(basename ${COMP_S3_PROBLEM_PATH}) 21 | 22 | # Get file from S3 23 | aws s3 cp s3://"${S3_BKT}"/"${COMP_S3_PROBLEM_PATH}" /tmp/"$PROBLEM" 24 | 25 | INPUT_CNF=/tmp/"$PROBLEM" 26 | fi 27 | 28 | 29 | # Final check wrt input file 30 | if [ ! -r "$INPUT_CNF" ] 31 | then 32 | echo "error: cannot read input cnf '$INPUT_CNF'" 33 | exit 1 34 | fi 35 | 36 | # Actually run the solver on the resulting input CNF 37 | /opt/mergesat/build/release/bin/mergesat "$INPUT_CNF" 38 | -------------------------------------------------------------------------------- /tools/dockerfile/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fedora:36 2 | 3 | # Install basic MergeSat requirements for static linking 4 | RUN yum -y update && \ 5 | yum -y install apt-utils automake file g++ gcc git glibc-static libstdc++-static make 6 | 7 | # Install SAT competition 2022 dependencies 8 | RUN yum -y install cmake curl gfortran iproute iputils python python-pip unzip 9 | RUN yum -y install openssh-server openmpi-devel python3-pip 10 | # ... also install python dependencies 11 | RUN pip3 install awscli boto3 flask pytz polling2 supervisor waitress 12 | 13 | # Import and build the solver 14 | ADD . /opt/mergesat 15 | 16 | # Clean solver 17 | RUN cd /opt/mergesat && make clean 18 | RUN rm -rf /opt/mergesat/build 19 | 20 | # Build solver from scratch 21 | RUN cd /opt/mergesat && make r 22 | 23 | # Check whether the binary is statically linked 24 | RUN file /opt/mergesat/build/release/bin/mergesat 25 | 26 | # Enable using transparent huge pages via glibc tunables, since 2.35 27 | ENV GLIBC_TUNABLES=glibc.malloc.hugetlb=1 28 | 29 | # Run the solver with the environment variable parameters 30 | CMD /opt/mergesat/tools/container-default-command.sh 31 | -------------------------------------------------------------------------------- /tools/eda-ai/README: -------------------------------------------------------------------------------- 1 | MergeSat (EDA-AI version), Norbert Manthey, Johannes Fichte, 2021 2 | 3 | This package contains tools to solve CNF formulas with MergeSat. 4 | 5 | ## Quick Start 6 | 7 | The following steps allow to solve a CNF INPUT_FILE: 8 | 9 | ``` 10 | ./build.sh # run once 11 | ./binary/run_config*.sh "$INPUT_FILE" # run selected configuration on CNF 12 | ``` 13 | 14 | ## MergeSat in the EDA AI package 15 | 16 | This package contains several configurations of the MergeSat solver. Each 17 | configuration package wlil select a single one. Hence, the instructions in this 18 | README file are generic, especially the step to solve the CNF. 19 | -------------------------------------------------------------------------------- /tools/eda-ai/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | 4 | SELECTED_CONFIGURATION=1 # could be 1, 2 or 3 5 | 6 | # locate the script to be able to call related scripts 7 | SCRIPT=$(realpath "$0") 8 | SCRIPTDIR=$(dirname "$SCRIPT") 9 | 10 | # fail on error 11 | set -e 12 | 13 | mkdir -p "$SCRIPTDIR"/binary 14 | OUTPUT_DIR=$(realpath "$SCRIPTDIR"/binary) 15 | 16 | rsync -avz "$SCRIPTDIR"/code/mergesat/ "$OUTPUT_DIR"/mergesat-src/ 17 | 18 | pushd "$SCRIPTDIR"/binary/mergesat-src 19 | make r BUILD_TYPE=simp VERB= -j $(nproc) 20 | cp build/release/bin/mergesat "$OUTPUT_DIR"/ 21 | cd "$OUTPUT_DIR" 22 | rm -rf mergesat-src 23 | popd 24 | 25 | cp "$SCRIPTDIR"/code/mergesat/tools/eda-ai/run_config"$SELECTED_CONFIGURATION".sh "$OUTPUT_DIR"/ 26 | 27 | ls binary 28 | -------------------------------------------------------------------------------- /tools/eda-ai/create-package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | 4 | # locate the script to be able to call related scripts 5 | SCRIPT=$(realpath "$0") 6 | SCRIPTDIR=$(dirname "$SCRIPT") 7 | 8 | declare -r START_DIR="$PWD" 9 | 10 | # fail on error 11 | set -e 12 | 13 | # get work directory 14 | trap '[ -d "$WORKDIR" ] && rm -rf "$WORKDIR"' EXIT 15 | WORKDIR=$(mktemp -d) 16 | 17 | # create code dir 18 | CODE_DIR="$WORKDIR"/code 19 | mkdir -p "$CODE_DIR" 20 | 21 | # copy full content into code directory 22 | git clone "$SCRIPTDIR"/../.. "$CODE_DIR"/mergesat 23 | 24 | # get dependencies, if not there already: Caution: this can drop state 25 | pushd "$CODE_DIR"/mergesat 26 | git submodule update --init --recursive 27 | git clean -xfd || true 28 | git submodule foreach --recursive git clean -xfd || true 29 | popd 30 | 31 | # create required links in root directory 32 | pushd "$WORKDIR" 33 | ln -s code/mergesat/license.txt license.txt 34 | ln -s code/mergesat/README readme.txt 35 | cp -r "$SCRIPTDIR"/build.sh . 36 | popd 37 | 38 | # log git version 39 | pushd "$SCRIPTDIR" 40 | echo "Package git version:" > "$WORKDIR"/VERSION 41 | git describe || git show -s --pretty=oneline >> "$WORKDIR"/VERSION 42 | GIT_VERSION="$(git describe 6> /dev/null || true)" 43 | [ -n "$GIT_VERSION" ] && GIT_VERSION="-$GIT_VERSION" 44 | [ -z "$GIT_VERSION" ] && GIT_VERSION="-unknown" 45 | echo "Submodules:" >> "$WORKDIR"/VERSION 46 | git submodule status >> "$WORKDIR"/VERSION 47 | echo "Git remotes:" >> "$WORKDIR"/VERSION 48 | git remote -v | grep origin || true >> "$WORKDIR"/VERSION 49 | popd 50 | 51 | declare -r ZIP_NAME="mergesat${GIT_VERSION}.zip" 52 | 53 | # remove git history, as it will be large, and other files 54 | pushd "$CODE_DIR" 55 | rm -rf mergesat/.git 56 | rm -f "$ZIP_NAME" 57 | rm -rf binary/* 58 | rm -rf doc/description 59 | popd 60 | 61 | # zip to overall package 62 | pushd "$WORKDIR" 63 | zip -r -y -9 "$ZIP_NAME" * 64 | 65 | # copy archive back to workdir 66 | cp "$ZIP_NAME" "$START_DIR" 67 | 68 | # leave work directory 69 | popd 70 | -------------------------------------------------------------------------------- /tools/eda-ai/license.txt: -------------------------------------------------------------------------------- 1 | MergeSat -- Copyright (c) 2021, Norbert Manthey 2 | 3 | This file lists the license for the MergeSat package for EDA AI 4 | 5 | ### MergeSat License ### 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a 8 | copy of this software and associated documentation files (the 9 | "Software"), to deal in the Software without restriction, including 10 | without limitation the rights to use, copy, modify, merge, publish, 11 | distribute, sublicense, and/or sell copies of the Software, and to 12 | permit persons to whom the Software is furnished to do so, subject to 13 | the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /tools/eda-ai/run_config1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Tuned EDA AI Configuration: 4 | 5 | 6 | # locate the script to be able to call related scripts 7 | SCRIPT=$(realpath "$0") 8 | SCRIPTDIR=$(dirname "$SCRIPT") 9 | 10 | # fail on error 11 | set -e 12 | 13 | INPUT_FILE="$1" 14 | 15 | if [ ! -r "$INPUT_FILE" ]; then 16 | echo "Cannot read input file $INPUT_FILE, abort" 17 | exit 1 18 | fi 19 | 20 | exec "$SCRIPTDIR"/mergesat \ 21 | -VSIDS-init-lim=10000\ 22 | -VSIDS-lim=30000000\ 23 | -no-almost-pure\ 24 | -ccmin-mode=2\ 25 | -ccnr-change-time=2000\ 26 | -ccnr-change-time-inc=1\ 27 | -ccnr-change-time-inc-inc=0.2\ 28 | -ccnr-conflict-ratio=0.4\ 29 | -no-ccnr-initial\ 30 | -ccnr-ls-mems=50000000\ 31 | -no-ccnr-mediation\ 32 | -ccnr-percent-ratio=0.8987846297972459\ 33 | -ccnr-restart-gap=300\ 34 | -ccnr-switch-heuristic=500\ 35 | -ccnr-up-time-ratio=0.2\ 36 | -chrono=100\ 37 | -cl-lim=20\ 38 | -cla-decay=0.9990000000000001\ 39 | -confl-to-chrono=4000\ 40 | -core-size-lim=480195073\ 41 | -core-size-lim-inc=0.1\ 42 | -elim\ 43 | -gc-frac=0.20000000000000023\ 44 | -grow=0\ 45 | -inprocess-delay=2.0\ 46 | -inprocess-init-delay=-1\ 47 | -inprocess-learnt-level=2\ 48 | -inprocess-penalty=2\ 49 | -lbd-avg-compare-limit=0.8000000000000004\ 50 | -lcm\ 51 | -lcm-core\ 52 | -lcm-delay=1000\ 53 | -lcm-delay-inc=1000\ 54 | -lcm-dup-buffer=16\ 55 | -lcm-reverse\ 56 | -max-act-bump=100\ 57 | -max-lbd-calc=100\ 58 | -max-simp-cls=2147483647\ 59 | -max-simp-steps=40000000000\ 60 | -min-step-size=0.06000000000000003\ 61 | -phase-saving=1\ 62 | -pre\ 63 | -pref-assumpts\ 64 | -rfirst=100\ 65 | -rinc=2.0\ 66 | -rnd-freq=0.0\ 67 | -rnd-init=0\ 68 | -rnd-seed=9.16482529999E7\ 69 | -rtype=2\ 70 | -simp-gc-frac=0.49999999999999994\ 71 | -sls-clause-lim=507381039\ 72 | -sls-var-lim=-1\ 73 | -step-size=0.40000000000000013\ 74 | -step-size-dec=1.0E-4\ 75 | -sub-lim=268761228\ 76 | -use-backup-trail\ 77 | -use-ccnr\ 78 | -use-rephasing\ 79 | -var-decay=0.8000000000000004\ 80 | -var-decay-conflicts=5000\ 81 | -vsids-c=12000000\ 82 | -vsids-p=3000000000 \ 83 | "$INPUT_FILE" 84 | -------------------------------------------------------------------------------- /tools/eda-ai/run_config2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Tuned EDA AI Configuration: 4 | 5 | 6 | # locate the script to be able to call related scripts 7 | SCRIPT=$(realpath "$0") 8 | SCRIPTDIR=$(dirname "$SCRIPT") 9 | 10 | # fail on error 11 | set -e 12 | 13 | INPUT_FILE="$1" 14 | 15 | if [ ! -r "$INPUT_FILE" ]; then 16 | echo "Cannot read input file $INPUT_FILE, abort" 17 | exit 1 18 | fi 19 | 20 | exec "$SCRIPTDIR"/mergesat \ 21 | -VSIDS-init-lim=10000\ 22 | -VSIDS-lim=30000000\ 23 | -no-almost-pure\ 24 | -ccmin-mode=2\ 25 | -ccnr-change-time=2000\ 26 | -ccnr-change-time-inc=1\ 27 | -ccnr-change-time-inc-inc=0.2\ 28 | -ccnr-conflict-ratio=0.4\ 29 | -no-ccnr-initial\ 30 | -ccnr-ls-mems=50000000\ 31 | -no-ccnr-mediation\ 32 | -ccnr-percent-ratio=0.9\ 33 | -ccnr-restart-gap=300\ 34 | -ccnr-switch-heuristic=500\ 35 | -ccnr-up-time-ratio=0.2\ 36 | -chrono=100\ 37 | -cl-lim=20\ 38 | -cla-decay=0.9990000000000001\ 39 | -confl-to-chrono=4000\ 40 | -core-size-lim=50000\ 41 | -core-size-lim-inc=0.1\ 42 | -elim\ 43 | -gc-frac=0.20000000000000023\ 44 | -grow=0\ 45 | -inprocess-delay=2.0\ 46 | -inprocess-init-delay=-1\ 47 | -inprocess-learnt-level=2\ 48 | -inprocess-penalty=2\ 49 | -lbd-avg-compare-limit=0.8000000000000004\ 50 | -lcm\ 51 | -lcm-core\ 52 | -lcm-delay=1000\ 53 | -lcm-delay-inc=1000\ 54 | -lcm-dup-buffer=16\ 55 | -lcm-reverse\ 56 | -max-act-bump=100\ 57 | -max-lbd-calc=100\ 58 | -max-simp-cls=2147483647\ 59 | -max-simp-steps=40000000000\ 60 | -min-step-size=0.06000000000000003\ 61 | -phase-saving=2\ 62 | -pre\ 63 | -pref-assumpts\ 64 | -rfirst=100\ 65 | -rinc=2.0\ 66 | -rnd-freq=0.0\ 67 | -rnd-init=0\ 68 | -rnd-seed=9.16482529999E7\ 69 | -rtype=2\ 70 | -simp-gc-frac=0.49999999999999994\ 71 | -sls-clause-lim=-1\ 72 | -sls-var-lim=-1\ 73 | -step-size=0.40000000000000013\ 74 | -step-size-dec=1.0E-4\ 75 | -sub-lim=1000\ 76 | -use-backup-trail\ 77 | -use-ccnr\ 78 | -use-rephasing\ 79 | -var-decay=0.8000000000000004\ 80 | -var-decay-conflicts=5000\ 81 | -vsids-c=12000000\ 82 | -vsids-p=3000000000 \ 83 | "$INPUT_FILE" 84 | -------------------------------------------------------------------------------- /tools/eda-ai/run_config3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Tuned EDA AI Configuration: 4 | 5 | 6 | # locate the script to be able to call related scripts 7 | SCRIPT=$(realpath "$0") 8 | SCRIPTDIR=$(dirname "$SCRIPT") 9 | 10 | # fail on error 11 | set -e 12 | 13 | INPUT_FILE="$1" 14 | 15 | if [ ! -r "$INPUT_FILE" ]; then 16 | echo "Cannot read input file $INPUT_FILE, abort" 17 | exit 1 18 | fi 19 | 20 | exec "$SCRIPTDIR"/mergesat \ 21 | -VSIDS-init-lim=1302817790\ 22 | -VSIDS-lim=30000000\ 23 | -no-almost-pure\ 24 | -ccmin-mode=2\ 25 | -ccnr-change-time=2000\ 26 | -ccnr-change-time-inc=1\ 27 | -ccnr-change-time-inc-inc=0.2\ 28 | -ccnr-conflict-ratio=0.4\ 29 | -no-ccnr-initial\ 30 | -ccnr-ls-mems=50000000\ 31 | -no-ccnr-mediation\ 32 | -ccnr-percent-ratio=0.9\ 33 | -ccnr-restart-gap=300\ 34 | -ccnr-switch-heuristic=500\ 35 | -ccnr-up-time-ratio=0.2\ 36 | -chrono=100\ 37 | -cl-lim=20\ 38 | -cla-decay=0.9990000000000001\ 39 | -confl-to-chrono=4000\ 40 | -core-size-lim=50000\ 41 | -core-size-lim-inc=0.1\ 42 | -elim\ 43 | -gc-frac=1.7917893266839732E-4\ 44 | -grow=0\ 45 | -inprocess-delay=2.0\ 46 | -inprocess-init-delay=-1\ 47 | -inprocess-learnt-level=2\ 48 | -inprocess-penalty=2\ 49 | -lbd-avg-compare-limit=0.8000000000000004\ 50 | -lcm\ 51 | -lcm-core\ 52 | -lcm-delay=1000\ 53 | -lcm-delay-inc=1000\ 54 | -lcm-dup-buffer=16\ 55 | -lcm-reverse\ 56 | -max-act-bump=100\ 57 | -max-lbd-calc=100\ 58 | -max-simp-cls=2147483647\ 59 | -max-simp-steps=40000000000\ 60 | -min-step-size=0.06000000000000003\ 61 | -phase-saving=2\ 62 | -pre\ 63 | -pref-assumpts\ 64 | -rfirst=100\ 65 | -rinc=2.0\ 66 | -rnd-freq=0.0\ 67 | -rnd-init=0\ 68 | -rnd-seed=9.16482529999E7\ 69 | -rtype=2\ 70 | -simp-gc-frac=0.0021144031760272014\ 71 | -sls-clause-lim=-1\ 72 | -sls-var-lim=-1\ 73 | -step-size=0.40000000000000013\ 74 | -step-size-dec=1.0E-4\ 75 | -sub-lim=1000\ 76 | -use-backup-trail\ 77 | -use-ccnr\ 78 | -use-rephasing\ 79 | -var-decay=0.4985624980489927\ 80 | -var-decay-conflicts=5000\ 81 | -vsids-c=12000000\ 82 | -vsids-p=3000000000\ 83 | "$INPUT_FILE" 84 | -------------------------------------------------------------------------------- /tools/eda-ai/run_config_default.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Tuned EDA AI Configuration: 4 | 5 | 6 | # locate the script to be able to call related scripts 7 | SCRIPT=$(realpath "$0") 8 | SCRIPTDIR=$(dirname "$SCRIPT") 9 | 10 | # fail on error 11 | set -e 12 | 13 | INPUT_FILE="$1" 14 | 15 | if [ ! -r "$INPUT_FILE" ]; then 16 | echo "Cannot read input file $INPUT_FILE, abort" 17 | exit 1 18 | fi 19 | 20 | exec "$SCRIPTDIR"/mergesat \ 21 | "$INPUT_FILE" 22 | -------------------------------------------------------------------------------- /tools/format-style.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script helps to apply the style of this project to the code base. 4 | # The command can be run on the current tip of the git history, or based on 5 | # the git history after changes have already been merged -- fixing the style 6 | # of all involved commits. 7 | # 8 | # Usage: 9 | # format-style.sh [BASE_COMMIT_ID] 10 | # 11 | 12 | # Get to repository base 13 | cd $(dirname "${BASH_SOURCE[0]}")/.. 14 | 15 | declare -i STATUS=0 16 | 17 | declare -a TOOL_CANDIDATES=("clang-format-6.0" "clang-format") 18 | 19 | for TOOL in "${TOOL_CANDIDATES[@]}" 20 | do 21 | if ! command -v "$TOOL" &> /dev/null 22 | then 23 | echo "error: could not find clang-format, abort" 24 | exit 1 25 | else 26 | break 27 | fi 28 | done 29 | 30 | echo "info: use clang format, version: $("$TOOL" --version)" 31 | 32 | if [ -n "${1:-}" ]; then 33 | BASE_COMMIT="$1" 34 | TIP_COMMIT="$(git rev-parse --short HEAD)" 35 | echo "run formating for git history starting with base commit: $BASE_COMMIT" 36 | echo "started process with git commit $TIP_COMMIT" 37 | # TODO: check whether commit $BASE_COMMIT exists in the current branch 38 | 39 | # apply format command for each commit in the series 40 | git rebase -i --autosquash --exec 'tools/format-style.sh' $BASE_COMMIT || STATUS=$? 41 | if [ "$STATUS" -ne 0 ]; then 42 | echo "WARNING: make sure to fix the git history after this failed 'git rebase' command, executed on commit '$TIP_COMMIT' !" 43 | echo "" 44 | echo "Fix each commit, and run 'git rebase --continue' to fix the whole series. Take care of merge-conflicts, too!" 45 | fi 46 | else 47 | # run the actual command on the commit itself 48 | find minisat -type f -name "*.cc" -o -name "*.h" | xargs clang-format -i || STATUS=$? 49 | fi 50 | 51 | exit $STATUS 52 | -------------------------------------------------------------------------------- /tools/inject-thp-glibc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright Norbert Manthey, 2020 4 | # 5 | # Note: this script should only be run in a docker container! 6 | # You might make your system unusable, as your glibc is replaced 7 | # 8 | # Build glibc, add THP patches on top. Finally, install glibc 9 | 10 | # in case something goes wrong, notify! 11 | set -ex 12 | 13 | INSTALL=false 14 | if [ "$1" == "install" ] 15 | then 16 | INSTALL=true 17 | fi 18 | 19 | build_glibc() 20 | { 21 | # build mergesat 22 | pushd glibc 23 | mkdir -p build 24 | cd build 25 | ../configure --host=x86_64-linux-gnu --prefix=/usr/lib/x86_64-linux-gnu --libdir=/usr/lib/x86_64-linux-gnu --enable-add-ons=libidn,"" --without-selinux --enable-stackguard-randomization --enable-obsolete-rpc --with-pkgversion="Ubuntu GLIBC 2.27-0ubuntu11-thp" --enable-kernel=2.6.32 --enable-systemtap --enable-multi-arch 26 | # ../configure --host=x86_64-linux-gnu --prefix=/usr/lib/x86_64-linux-gnu --enable-add-ons=libidn,"" --without-selinux --enable-stackguard-randomization --enable-obsolete-rpc --with-pkgversion="Ubuntu GLIBC 2.27-0ubuntu11-thp" --enable-kernel=2.6.32 --enable-systemtap --enable-multi-arch 27 | make -j $(nproc) 28 | popd 29 | } 30 | 31 | install_glibc() 32 | { 33 | # install glibc 34 | pushd glibc 35 | mkdir -p build 36 | cd build 37 | make install 38 | popd 39 | } 40 | 41 | get_glibc_227() 42 | { 43 | [ -d glibc ] || git clone git://sourceware.org/git/glibc.git glibc 44 | pushd glibc 45 | git checkout glibc-2.27 46 | popd 47 | } 48 | 49 | patch_glibc_227_thp() 50 | { 51 | [ -d thp ] || git clone https://github.com/conp-solutions/thp.git thp 52 | 53 | pushd glibc 54 | # apply patches in order 55 | for p in $(ls ../thp/ubuntu18.04-thp-2.27/*.patch | sort -V) 56 | do 57 | echo $p 58 | git apply "$p" 59 | done 60 | popd 61 | } 62 | 63 | get_glibc_227 64 | patch_glibc_227_thp 65 | 66 | build_glibc 67 | 68 | if [ "$INSTALL" = "true" ] 69 | then 70 | install_glibc 71 | else 72 | echo "Will not install glibc" 73 | fi 74 | -------------------------------------------------------------------------------- /tools/ipasir_template/LIBS: -------------------------------------------------------------------------------- 1 | -lm -pthread 2 | -------------------------------------------------------------------------------- /tools/ipasir_template/LINK: -------------------------------------------------------------------------------- 1 | g++ 2 | -------------------------------------------------------------------------------- /tools/ipasir_template/makefile: -------------------------------------------------------------------------------- 1 | #-----------------------------------------------------------------------# 2 | #- GLOBAL DEFS ---------------------------------------------------------# 3 | #-----------------------------------------------------------------------# 4 | 5 | # Keep this as generic as possible. 6 | 7 | NAME=mergesat 8 | 9 | #-----------------------------------------------------------------------# 10 | # Solver signatures have to be both valid file names and C symbols. 11 | # Since Picosat uses a dash '-' for the package name, we have to 12 | # differentiate between with (directory / package name) and without 13 | # dash (the signature). 14 | 15 | SIG=$(NAME) 16 | DIR=$(NAME) 17 | TARGET=libipasir$(SIG).a 18 | 19 | #-----------------------------------------------------------------------# 20 | 21 | CXX=g++ 22 | CXXFLAGS=-Wall -DNDEBUG -O3 23 | 24 | #-----------------------------------------------------------------------# 25 | #- REQUIRED TOP RULES --------------------------------------------------# 26 | #-----------------------------------------------------------------------# 27 | 28 | all: $(TARGET) 29 | 30 | clean: 31 | rm -f *.o *.a 32 | make -C $(DIR) clean 33 | rm -rf $(DIR)/build 34 | 35 | #-----------------------------------------------------------------------# 36 | #- INVISIBLE INTERNAL SUB RULES ----------------------------------------# 37 | #-----------------------------------------------------------------------# 38 | 39 | libipasir$(SIG).a: .FORCE 40 | @# 41 | @# configure and build library 42 | @# 43 | make -C $(DIR) lr 44 | @# 45 | @# copy library 46 | @# 47 | cp $(DIR)/build/release/lib/lib$(NAME).a $(TARGET) 48 | 49 | #-----------------------------------------------------------------------# 50 | 51 | .FORCE: 52 | .PHONY: all clean 53 | -------------------------------------------------------------------------------- /tools/make-ipasir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # make-starexec.sh, Norbert Manthey, 2019 3 | # 4 | # build the starexec package from the current git branch 5 | 6 | # make sure we notice failures early 7 | set -e -x 8 | 9 | # make sure we know where the code is 10 | SOLVERDIR=$(pwd) 11 | 12 | if [ ! -x "$SOLVERDIR"/tools/make-starexec.sh ] 13 | then 14 | echo "Error: script has to be called from base directory, abort!" 15 | exit 1 16 | fi 17 | 18 | # make sure we clean up 19 | trap 'rm -rf $TMPD' EXIT 20 | TMPD=$(mktemp -d) 21 | 22 | # create the project directory 23 | pushd "$TMPD" 24 | 25 | mkdir mergesat 26 | cd mergesat 27 | 28 | # copy template 29 | cp -r $SOLVERDIR/tools/ipasir_template/* . 30 | 31 | # copy actual source by using the git tree, only the current branch 32 | git clone "$SOLVERDIR" --single-branch mergesat 33 | pushd mergesat 34 | git checkout $BRANCH 35 | git gc 36 | git prune 37 | git remote remove origin || true 38 | git remote add origin https://github.com/conp-solutions/mergesat.git 39 | popd 40 | 41 | # Generate a license stub 42 | echo "Note, sub-packages might come with different licenses!" > LICENSE 43 | 44 | cd .. 45 | 46 | # compress 47 | zip -r -y -9 mergesat-ipasir.zip * 48 | 49 | # jump back and move mergesat-ipasir.zip here 50 | popd 51 | mv "$TMPD"/mergesat-ipasir.zip . 52 | -------------------------------------------------------------------------------- /tools/make-starexec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # make-starexec.sh, Norbert Manthey, 2019 3 | # 4 | # build the starexec package from the current git branch 5 | 6 | # make sure we notice failures early 7 | set -e -x 8 | 9 | get_riss () 10 | { 11 | local arg="$1" 12 | local -r CALLDIR=$(pwd) # we need to store the package here 13 | 14 | # is $arg a directory (to riss)? 15 | if [ -d "$arg" ] 16 | then 17 | pushd "$arg" 18 | 19 | # build the solver and select the latest version 20 | ./scripts/make-starexec.sh 21 | RISSZIP=$(ls Riss*.zip | sort -V | tail -n 1) 22 | 23 | # move Riss zip file 24 | mkdir -p "$CALLDIR"/Riss 25 | mv $RISSZIP "$CALLDIR"/Riss/Riss.zip 26 | 27 | popd 28 | return 0 29 | fi 30 | 31 | # is $arg a commit ID to clone from github? 32 | git ls-remote https://github.com/conp-solutions/riss.git "$arg" || true 33 | COMMIT=$(git ls-remote https://github.com/conp-solutions/riss.git "$arg" | awk '{print $1}') 34 | [ -n "$COMMIT" ] || return 35 | 36 | mkdir -p "$CALLDIR"/Riss-clone 37 | pushd "$CALLDIR"/Riss-clone 38 | 39 | git clone https://github.com/conp-solutions/riss.git 40 | cd riss 41 | git checkout -b "mergesat-build" "$COMMIT" 42 | 43 | # build the solver and select the latest version 44 | ./scripts/make-starexec.sh 45 | RISSZIP=$(ls Riss*.zip | sort -V | tail -n 1) 46 | 47 | # move Riss zip file 48 | mkdir -p "$CALLDIR"/Riss 49 | mv $RISSZIP "$CALLDIR"/Riss/Riss.zip 50 | 51 | popd 52 | # clean up cloned solver 53 | rm -rf "$CALLDIR"/Riss-clone 54 | } 55 | 56 | get_sparrow () 57 | { 58 | local arg="$1" 59 | local SPARROWDIR= 60 | local -r CALLDIR=$(pwd) # we need to store the package here 61 | 62 | # is $arg a directory (to sparrow)? 63 | if [ -d "$arg" ] 64 | then 65 | pushd "$arg" 66 | 67 | # clean the solver and zip it 68 | make clean 69 | zip -r -y -9 Sparrow.zip * 70 | 71 | # move Sparrow zip file 72 | mkdir -p "$CALLDIR"/Sparrow 73 | mv Sparrow.zip "$CALLDIR"/Sparrow/Sparrow.zip 74 | 75 | popd 76 | return 0 77 | fi 78 | 79 | # is $arg a commit ID to clone from github? 80 | git ls-remote https://github.com/adrianopolus/Sparrow.git "$arg" || true 81 | COMMIT=$(git ls-remote https://github.com/adrianopolus/Sparrow.git "$arg" | awk '{print $1}') 82 | [ -n "$COMMIT" ] || return 83 | 84 | mkdir -p "$CALLDIR"/Sparrow-clone 85 | pushd "$CALLDIR"/Sparrow-clone 86 | 87 | git clone https://github.com/adrianopolus/Sparrow.git 88 | cd Sparrow 89 | git checkout -b "mergesat-build" "$COMMIT" 90 | 91 | # clean the solver and zip it 92 | make clean 93 | zip -r -y -9 Sparrow.zip * 94 | 95 | # move Sparrow zip file 96 | mkdir -p "$CALLDIR"/Sparrow 97 | mv Sparrow.zip "$CALLDIR"/Sparrow/Sparrow.zip 98 | 99 | popd 100 | # clean up cloned solver 101 | rm -rf "$CALLDIR"/Sparrow-clone 102 | } 103 | 104 | # make sure we know where the code is 105 | SOLVERDIR=$(pwd) 106 | BRANCH=$(git rev-parse --short HEAD) 107 | 108 | if [ ! -x "$SOLVERDIR"/tools/make-starexec.sh ] 109 | then 110 | echo "Error: script has to be called from base directory, abort!" 111 | exit 1 112 | fi 113 | 114 | # check for being on a branch 115 | if [ -z "$BRANCH" ] 116 | then 117 | echo "Error: failed to extract a git branch, abort!" 118 | exit 1 119 | fi 120 | 121 | GIT_DETAILED_VERSION="$(git describe)" 122 | [ -n "$GIT_DETAILED_VERSION" ] && GIT_DETAILED_VERSION="-${GIT_DETAILED_VERSION}" 123 | ZIP_NAME="MergeSAT${GIT_DETAILED_VERSION}.zip" 124 | 125 | RISSOPT="" 126 | SPARROWOPT="" 127 | # do we want to package Riss(for Coprocessor) or Sparrow as well? 128 | while getopts "r:s:" OPTION; do 129 | case $OPTION in 130 | r) 131 | RISSOPT="$OPTARG" 132 | ;; 133 | s) 134 | SPARROWOPT="$OPTARG" 135 | ;; 136 | *) 137 | echo "Unknown options provided" 138 | ;; 139 | esac 140 | done 141 | 142 | 143 | # make sure we clean up 144 | trap 'rm -rf $TMPD' EXIT 145 | TMPD=$(mktemp -d) 146 | 147 | # create the project directory 148 | pushd "$TMPD" 149 | 150 | # copy template 151 | cp -r $SOLVERDIR/tools/starexec_template/* . 152 | 153 | # copy actual source by using the git tree, only the current branch 154 | git clone "$SOLVERDIR" --single-branch mergesat 155 | pushd mergesat 156 | git checkout $BRANCH 157 | git gc 158 | git prune 159 | git remote remove origin || true 160 | git remote add origin https://github.com/conp-solutions/mergesat.git 161 | popd 162 | 163 | # get the other packages? 164 | [ -z "$RISSOPT" ] || get_riss "$RISSOPT" 165 | [ -z "$SPARROWOPT" ] || get_sparrow "$SPARROWOPT" 166 | 167 | # Generate a license stub 168 | echo "Note, sub-packages might come with different licenses!" > LICENSE 169 | 170 | # compress 171 | zip -r -y -9 "$ZIP_NAME" * 172 | 173 | # jump back and move MergeSAT.zip here 174 | popd 175 | mv "$TMPD"/"$ZIP_NAME" . 176 | -------------------------------------------------------------------------------- /tools/par2-table.sh: -------------------------------------------------------------------------------- 1 | # Generate par2 table for files in 2 directories, for files that exist in both 2 | # directories. The script targets gzipped log files. Furthermore, the script 3 | # assumes each basename of a log (and hence formula) exists exactly once. 4 | # Furthermore, the output formas of the competition (^s SAT|UNSAT) is considered, 5 | # and runtime is extracted from the fifth parameter of the line "^c CPU". 6 | # 7 | # For formula , the log with name .log.gz is assumed, i.e. the suffix .log.gz 8 | # will be dropped when reporting names. 9 | # 10 | # Note, this script can be used to generate data to be used for plotting XY plots 11 | # or cactus plots. 12 | # 13 | # Example call, to run with timeout=1800 seconds: 14 | # TIMEOUT=1800 ./par2-table.sh 15 | 16 | DIR1="$1" 17 | DIR2="$2" 18 | 19 | # check briefly whether directories exist 20 | [ -d "$DIR1" ] || exit 1 21 | [ -d "$DIR2" ] || exit 1 22 | 23 | # for now, let's use 900s as a timeout, if no other TIMEOUT=... variable is specified 24 | declare -r TIMEOUT="${TIMEOUT:-900}" 25 | 26 | # other metrics (# solved, par2) 27 | declare -i SOLVED1=0 28 | declare -i SOLVED2=0 29 | declare -i TOTAL=0 30 | PAR2_1=0.0 31 | PAR2_2=0.0 32 | 33 | # print header 34 | D1="$(basename "$(realpath "$DIR1")")" 35 | D2="$(basename "$(realpath "$DIR2")")" 36 | 37 | echo "formula $D1 $D2" 38 | 39 | MISMATCHED="" 40 | # consider all files in first directory 41 | for log in $(ls $DIR1/*.log.gz) 42 | do 43 | name=$(basename $log) 44 | 45 | # skip, if file is not present in second directory 46 | [ -r "$DIR2/$name" ] || continue 47 | 48 | formula=$(basename $name .log.gz) 49 | 50 | TOTAL=$((TOTAL+1)) 51 | 52 | # get first info, extract CPU time, or use twice the timeout in case there is no SAT/UNSAT 53 | INFO1="$(zgrep -e "^s SAT" -e "^s UNSAT" -e "^c CPU" $log)" 54 | TIME1=$(echo "$INFO1" | awk -v t=$TIMEOUT '/c CPU/ {if($5 < t) {print $5} else {print 2*t}}') 55 | echo "$INFO1" | grep -q -e "^s SAT" -e "^s UNSAT" || TIME1=$((2*TIMEOUT)) 56 | [ -n "$TIME1" ] || TIME1=$((2*TIMEOUT)) 57 | RC1=0 58 | echo "$INFO1" | grep -q -e "^s SAT" && RC1=10 59 | echo "$INFO1" | grep -q -e "^s UNSAT" && RC1=20 60 | 61 | [ -z "$(echo $TIME1 | awk -v t=$TIMEOUT '{ if ($1 <= t) print $1}')" ] || SOLVED1=$((SOLVED1 + 1)) 62 | 63 | log2="$DIR2/$name" 64 | INFO2="$(zgrep -e "^s SAT" -e "^s UNSAT" -e "^c CPU" "$log2")" 65 | TIME2=$(echo "$INFO2" | awk -v t=$TIMEOUT '/c CPU/ {if($5 < t) {print $5} else {print 2*t}}') 66 | echo "$INFO2" | grep -q -e "^s SAT" -e "^s UNSAT" || TIME2=$((2*TIMEOUT)) 67 | [ -n "$TIME2" ] || TIME2=$((2*TIMEOUT)) 68 | [ -z "$(echo $TIME2 | awk -v t=$TIMEOUT '{ if ($1 <= t) print $1}')" ] || SOLVED2=$((SOLVED2 + 1)) 69 | RC2=0 70 | echo "$INFO2" | grep -q -e "^s SAT" && RC2=10 71 | echo "$INFO2" | grep -q -e "^s UNSAT" && RC2=20 72 | 73 | # print csv line 74 | echo "$formula $TIME1 $TIME2" 75 | PAR2_1="$(echo "$PAR2_1 + $TIME1" | bc)" 76 | PAR2_2="$(echo "$PAR2_2 + $TIME2" | bc)" 77 | 78 | if [ $RC1 -eq 10 -a $RC2 -eq 20 ] || [ $RC1 -eq 20 -a $RC2 -eq 10 ] 79 | then 80 | echo "SAT/UNSAT mismatch on $formula ($RC1 vs $RC2)" 1>&2 81 | MISMATCHED+=" $formula" 82 | fi 83 | done 84 | 85 | # print other stats 86 | echo -e "\ntotal files: $TOTAL" 87 | echo -e "\nsolved $SOLVED1 $SOLVED2" 1>&2 88 | echo -e "\npar2 $PAR2_1 $PAR2_2" 1>&2 89 | [ -z "$MISMATCHED" ] || echo -e "\nmismatch formulas: $MISMATCHED" 1>&2 90 | -------------------------------------------------------------------------------- /tools/run_in_container.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright Norbert Manthey, 2019 4 | 5 | # Run commands inside container 6 | 7 | set -ex 8 | DOCKERFILE="$1" # Dockerfile 9 | shift 10 | 11 | USER_FLAGS="-e USER="$(id -u)" -u=$(id -u)" 12 | 13 | # disable getting the source again 14 | if [ -z "$1" ] || [ "$1" = "sudo" ] 15 | then 16 | USER_FLAGS="" 17 | shift 18 | fi 19 | 20 | if [ ! -r "$DOCKERFILE" ] 21 | then 22 | echo "cannot find $DOCKERFILE (in $(realpath .)), abort" 23 | exit 1 24 | fi 25 | 26 | DOCKERFILE_DIR=$(dirname "$DOCKERFILE") 27 | CONTAINER="${CONTAINER:-}" 28 | [ -n "$CONTAINER" ] || CONTAINER=$(docker build -q -f "$DOCKERFILE" "$DOCKERFILE_DIR") 29 | 30 | echo "running in container: $CONTAINER" 31 | 32 | docker run \ 33 | -it \ 34 | $USER_FLAGS \ 35 | -v $HOME:$HOME \ 36 | -v /tmp/build_output:/tmp/build_output \ 37 | -w $(pwd) \ 38 | ${DOCKER_EXTRA_ARGS} \ 39 | "$CONTAINER" "$@" 40 | -------------------------------------------------------------------------------- /tools/starexec_template/bin/starexec_run_2threads: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Run mergesat with simplification, and emitting a proof. 4 | # The proof is written to the file in the directory specified in the second 5 | # argument, in a file called "proof.out". 6 | 7 | # call solver from the directory where this script is located 8 | SOLVERDIR="$(dirname "${BASH_SOURCE[0]}" )" 9 | 10 | TMPDIR=$2 11 | if [ -n "${DEFAULT_MERGESAT_TMPDIR:-}" ] 12 | then 13 | TMPDIR=$(realpath "${DEFAULT_MERGESAT_TMPDIR:-}") 14 | fi 15 | 16 | # Call the solver in its default configuration, which uses 2 threads 17 | "$SOLVERDIR"/mergesat "$1" -verb=0 -drup-file="$TMPDIR"/proof.out 18 | -------------------------------------------------------------------------------- /tools/starexec_template/bin/starexec_run_bve_gates: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Run mergesat with simplification, and emitting a proof. 4 | # The proof is written to the file in the directory specified in the second 5 | # argument, in a file called "proof.out". 6 | 7 | # call solver from the directory where this script is located 8 | SOLVERDIR="$(dirname "${BASH_SOURCE[0]}" )" 9 | 10 | TMPDIR=$2 11 | if [ -n "${DEFAULT_MERGESAT_TMPDIR:-}" ] 12 | then 13 | TMPDIR=$(realpath "${DEFAULT_MERGESAT_TMPDIR:-}") 14 | fi 15 | 16 | # Use syntactic gate detection during BVE 17 | "$SOLVERDIR"/mergesat "$1" -cores=1 -verb=0 -bve-gates -drup-file="$TMPDIR"/proof.out 18 | -------------------------------------------------------------------------------- /tools/starexec_template/bin/starexec_run_bve_semgates: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Run mergesat with simplification, and emitting a proof. 4 | # The proof is written to the file in the directory specified in the second 5 | # argument, in a file called "proof.out". 6 | 7 | # call solver from the directory where this script is located 8 | SOLVERDIR="$(dirname "${BASH_SOURCE[0]}" )" 9 | 10 | TMPDIR=$2 11 | if [ -n "${DEFAULT_MERGESAT_TMPDIR:-}" ] 12 | then 13 | TMPDIR=$(realpath "${DEFAULT_MERGESAT_TMPDIR:-}") 14 | fi 15 | 16 | # Use gate detection during BVE, as well as use unit propaation to find gates 17 | "$SOLVERDIR"/mergesat "$1" -cores=1 -verb=0 -bve-gates -bve-sem-gates -drup-file="$TMPDIR"/proof.out 18 | -------------------------------------------------------------------------------- /tools/starexec_template/bin/starexec_run_thread1: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Run mergesat with simplification, and emitting a proof. 4 | # The proof is written to the file in the directory specified in the second 5 | # argument, in a file called "proof.out". 6 | 7 | # call solver from the directory where this script is located 8 | SOLVERDIR="$(dirname "${BASH_SOURCE[0]}" )" 9 | 10 | TMPDIR=$2 11 | if [ -n "${DEFAULT_MERGESAT_TMPDIR:-}" ] 12 | then 13 | TMPDIR=$(realpath "${DEFAULT_MERGESAT_TMPDIR:-}") 14 | fi 15 | 16 | # Run default configuration of MergeSat, when using only a single thread 17 | "$SOLVERDIR"/mergesat "$1" -cores=1 -verb=0 -drup-file="$TMPDIR"/proof.out 18 | -------------------------------------------------------------------------------- /tools/starexec_template/starexec_build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # starexec_build.sh, Norbert Manthey, 2019 3 | # 4 | # build MergeSAT, and SparrowToMergeSAT in case the package contains the dependencies 5 | 6 | set -x 7 | 8 | echo "Build MergeSAT" 9 | uname -a 10 | 11 | # For Sparrow2MergeSAT, we need Sparrow, as well as Coprocessor 12 | # in case we have the Sparrow package, build it as well 13 | # As it seems to strugle with the more recent compiler, build it first 14 | if [ -d Sparrow ] 15 | then 16 | echo "Building Sparrow ..." 17 | # let's use a more recent toolchain 18 | scl disable devtoolset-7 bash || true 19 | # show environment 20 | which gcc || true 21 | gcc -v || true 22 | # build Sparrow 23 | pushd Sparrow 24 | unzip Sparrow.zip 25 | make -j $(nproc) 26 | popd 27 | 28 | # make sparrow binary available to starexec 29 | cp Sparrow/sparrow bin/ 30 | fi 31 | 32 | 33 | # let's use a more recent toolchain 34 | scl enable devtoolset-7 bash || true 35 | 36 | which gcc || true 37 | gcc -v || true 38 | 39 | echo "Build MergeSAT" 40 | pushd mergesat 41 | 42 | # by now, we need a "minisat" link to build 43 | ln -s . minisat || true 44 | 45 | # build 46 | make AR=gcc-ar 2>&1 47 | 48 | # provide build artifact to starexec 49 | cp build/release/bin/mergesat ../bin/ 50 | popd 51 | 52 | # In case we have the Riss package, build it as well 53 | # As Riss is build via it's starexec_build script, which might 54 | # change the environment further, build it last 55 | if [ -d Riss ] 56 | then 57 | # build Sparrow 58 | pushd Riss 59 | unzip Riss.zip 60 | ./starexec_build 61 | popd 62 | 63 | # make coprocessor binary available to starexec 64 | cp Riss/bin/coprocessor bin/ 65 | fi 66 | 67 | # show produced files 68 | ls bin 69 | -------------------------------------------------------------------------------- /utils: -------------------------------------------------------------------------------- 1 | minisat/utils --------------------------------------------------------------------------------