├── .autotools ├── .cproject ├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ ├── linux.yml │ ├── osx.yml │ └── windows.yml ├── .gitignore ├── .project ├── .travis.yml ├── ALIRE ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── README.md ├── README_MTVariants ├── appveyor.yml ├── configure.ac ├── ddd ├── .gitignore ├── AdditiveMap.hpp ├── Cache.hh ├── DDD.cpp ├── DDD.h ├── DED.cpp ├── DED.h ├── DataSet.h ├── FixObserver.cpp ├── FixObserver.hh ├── History.txt ├── Hom.cpp ├── Hom.h ├── Hom_Basic.cpp ├── Hom_Basic.hh ├── IntDataSet.cpp ├── IntDataSet.h ├── MLCache.hh ├── MLHom.cpp ├── MLHom.h ├── MLSHom.cpp ├── MLSHom.h ├── Makefile.am ├── MemoryManager.h ├── SDD.cpp ├── SDD.h ├── SDED.cpp ├── SDED.h ├── SHom.cpp ├── SHom.h ├── UniqueTable.h ├── UniqueTableId.hh ├── google │ ├── AUTHORS │ ├── COPYING │ ├── README │ ├── sparse_hash_map │ ├── sparse_hash_set │ ├── sparsehash │ │ ├── densehashtable.h │ │ ├── hashtable-common.h │ │ ├── libc_allocator_with_realloc.h │ │ ├── sparseconfig.h │ │ └── sparsehashtable.h │ ├── sparsetable │ ├── template_util.h │ └── type_traits.h ├── hashfunc.hh ├── init.hh ├── process.cpp ├── process.hpp ├── statistic.cpp ├── statistic.hpp └── util │ ├── configuration.hh │ ├── dotExporter.cpp │ ├── dotExporter.h │ ├── ext_hash_map.hh │ ├── hash_set.hh │ ├── hash_support.hh │ ├── map.hh │ ├── set.hh │ ├── tbb_hash_map.hh │ └── vector.hh ├── demo ├── .gitignore ├── Makefile.am ├── PermuteVar.cpp ├── PermuteVar.hh ├── PlusPlus.cpp ├── PlusPlus.hh ├── README ├── SetVar.cpp ├── SetVar.hh ├── SwapMLHom.cpp ├── SwapMLHom.hh ├── hanoi │ ├── .gitignore │ ├── Makefile.am │ ├── doc │ │ ├── Makefile │ │ ├── PNota.sty │ │ ├── abstract.tex │ │ ├── bibliography.bib │ │ ├── conclu.tex │ │ ├── encoding.tex │ │ ├── hanoi_doc.tex │ │ ├── hom.tex │ │ ├── intro.tex │ │ ├── llncs.cls │ │ ├── perfs.tex │ │ └── tool.tex │ ├── hanoiHom.cpp │ ├── hanoiHom.hh │ ├── hanoi_v1.cpp │ ├── hanoi_v1_bis.cpp │ ├── hanoi_v1_ter.cpp │ ├── hanoi_v2.cpp │ ├── hanoi_v3.cpp │ ├── hanoi_v4.cpp │ ├── hanoi_v5.cpp │ ├── hanoi_v6.cpp │ ├── hanoi_v7.cpp │ ├── hanoi_v8.cpp │ └── hanoi_v9.cpp ├── morpion │ ├── .gitignore │ ├── Makefile.am │ ├── hom │ │ ├── const.cpp │ │ ├── const.hpp │ │ ├── general_v2.cpp │ │ ├── general_v2.hpp │ │ ├── notew.cpp │ │ ├── notew.hpp │ │ ├── play.cpp │ │ ├── play.hpp │ │ ├── winner.cpp │ │ └── winner.hpp │ ├── morpionv2.cpp │ └── readme ├── tst1.cpp ├── tst10.cpp ├── tst11.cpp ├── tst12.cpp ├── tst13.cpp ├── tst14.cpp ├── tst15.cpp ├── tst2.cpp ├── tst3.cpp ├── tst4.cpp ├── tst5.cpp ├── tst6.cpp ├── tst7.cpp ├── tst8.cpp └── tst9.cpp ├── doc ├── .gitignore ├── Doxyfile.in ├── Makefile.am ├── footer.html ├── mainpage.dox └── manuel.ps ├── m4 └── ax_boost_base.m4 ├── tag.sh └── website └── index.html /.autotools: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 43 | 44 | 83 | 84 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "04:00" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | name: Linux Build 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: tag version date 17 | run: /bin/sh ./tag.sh 18 | - name: Install packages 19 | run: sudo apt-get install doxygen graphviz ; 20 | - name: autoreconf 21 | run: autoreconf -vfi 22 | - name: Prepare install folder 23 | run: mkdir usr && mkdir usr/local 24 | - name: configure 25 | run: ./configure --prefix=$PWD/usr/local/ || cat config.log 26 | - name: make lib 27 | run: cd ddd ; make -j ; cd .. 28 | - name: make demo 29 | run: make -j 30 | - name: make install 31 | run: make install 32 | - name: prepare artefact 33 | run: rm usr/local/lib/libDDD_d* ; tar cvzf linux.tgz usr/ ; mv linux.tgz website/ 34 | - name: make dist 35 | run: make dist ; mv ddd*.tar.gz website/ ; 36 | - name: make doc 37 | run: cd doc ; make ; cd .. ; mv doc/libddd.html/ website/ ; 38 | - name: Deploy to GitHub Pages 39 | uses: JamesIves/github-pages-deploy-action@v4 40 | with: 41 | branch: gh-pages # The branch the action should deploy to. 42 | folder: website/ # The folder the action should deploy. 43 | clean: true # Automatically remove deleted files from the deploy branch 44 | single-commit: true 45 | - name: Trigger libITS 46 | uses: mvasigh/dispatch-action@main 47 | with: 48 | # You should create a personal access token and store it in your repository 49 | token: ${{ secrets.NOTIF_PAT }} 50 | repo: libITS 51 | owner: lip6 52 | event_type: ${{ runner.os }} 53 | -------------------------------------------------------------------------------- /.github/workflows/osx.yml: -------------------------------------------------------------------------------- 1 | name: OSX build 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: macos-latest 13 | 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | - name: tag version date 18 | run: /bin/sh ./tag.sh 19 | - name: Install packages 20 | run: brew install gcc@12 autoconf automake libtool binutils ; 21 | - name: autoreconf 22 | run: autoreconf -vfi 23 | - name: Prepare install folder 24 | run: mkdir usr && mkdir usr/local 25 | - name: configure 26 | run: ./configure --prefix=$PWD/usr/local/ AR='gcc-ar-12' NM='gcc-nm-12' RANLIB='gcc-ranlib-12' CXX='g++-12' CC='gcc-12' || cat config.log 27 | - name: make lib 28 | run: cd ddd ; make -j ; cd .. 29 | - name: make demo 30 | run: make -j 31 | - name: make install 32 | run: make install 33 | - name: prepare artefact 34 | run: rm usr/local/lib/libDDD_d* ; tar cvzf osx.tgz usr/ ; mv osx.tgz website/ 35 | - name: Deploy to GitHub Pages 36 | uses: JamesIves/github-pages-deploy-action@v4 37 | with: 38 | branch: osx # The branch the action should deploy to. 39 | folder: website/ # The folder the action should deploy. 40 | clean: true # Automatically remove deleted files from the deploy branch 41 | single-commit: true 42 | - name: Trigger libITS 43 | uses: mvasigh/dispatch-action@main 44 | with: 45 | # You should create a personal access token and store it in your repository 46 | token: ${{ secrets.NOTIF_PAT }} 47 | repo: libITS 48 | owner: lip6 49 | event_type: ${{ runner.os }} 50 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: windows build 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: windows-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: install packages 17 | run: C:\msys64\usr\bin\bash -lc "PATH+=:/mingw64/bin ; pacman --noconfirm -S mingw-w64-x86_64-gcc mingw-w64-x86_64-autotools mingw-w64-x86_64-pkg-config p7zip base-devel libtool" 18 | - name: configure and make 19 | run: C:\msys64\usr\bin\bash -lc "PATH+=:/mingw64/bin ; cd /D/a/libDDD/libDDD ; autoreconf -vfi && ./configure --prefix=/D/a/libDDD/libDDD/usr/local/ --enable-nolto --enable-mingw-native && make -j 4 && make install || cat config.log" 20 | - name: package zip 21 | run: C:\msys64\usr\bin\bash -lc "cd /D/a/libDDD/libDDD ; rm usr/local/lib/libDDD_d* ; tar -a -c -f windows.zip usr/ ; mkdir site ; mv windows.zip site/" 22 | - name: Upload Artifacts # The project is then uploaded as an artifact named 'site'. 23 | uses: actions/upload-artifact@v4 24 | with: 25 | name: site 26 | path: site/ 27 | 28 | deploy: 29 | needs: [build] # The second job must depend on the first one to complete before running, and uses ubuntu-latest instead of windows. 30 | 31 | runs-on: ubuntu-latest 32 | steps: 33 | - name: Checkout 34 | uses: actions/checkout@v4 35 | with: 36 | persist-credentials: false 37 | - name: Download Artifacts # The built project is downloaded into the 'site' folder. 38 | uses: actions/download-artifact@v4 39 | with: 40 | name: site 41 | - name: move to website 42 | run: ls -lah ; mkdir -p windows ; cp windows.zip windows/ ; ls -lah windows/ 43 | - name: Deploy 44 | uses: JamesIves/github-pages-deploy-action@v4 45 | with: 46 | branch: Windows 47 | folder: windows/ # The deployment folder should match the name of the artifact. Even though our project builds into the 'build' folder the artifact name of 'site' must be placed here. 48 | clean: true # Automatically remove deleted files from the deploy branch 49 | single-commit: true 50 | - name: Trigger libITS 51 | uses: mvasigh/dispatch-action@main 52 | with: 53 | # You should create a personal access token and store it in your repository 54 | token: ${{ secrets.NOTIF_PAT }} 55 | repo: libITS 56 | owner: lip6 57 | event_type: Windows 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/*.o 2 | **/*.a 3 | **/*.Po 4 | **/*.lo 5 | **/*.la 6 | **/.libs/ 7 | **/.dirstamp 8 | /install-sh 9 | /libtool 10 | /ltmain.sh 11 | /Makefile 12 | /missing 13 | /compile 14 | /config.guess 15 | /config.log 16 | /config.status 17 | /config.sub 18 | /configure 19 | /depcomp 20 | **/Makefile.in 21 | /ddd-*.tar.gz 22 | m4/*.m4 23 | **/autom4te.cache/ 24 | /ar-lib 25 | /aclocal.m4 26 | **/.deps/ 27 | /usr/ 28 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | libddd 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.linuxtools.cdt.autotools.core.genmakebuilderV2 10 | 11 | 12 | 13 | 14 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 15 | clean,full,incremental, 16 | 17 | 18 | ?name? 19 | 20 | 21 | 22 | org.eclipse.cdt.make.core.append_environment 23 | true 24 | 25 | 26 | org.eclipse.cdt.make.core.buildArguments 27 | 28 | 29 | 30 | org.eclipse.cdt.make.core.buildCommand 31 | make 32 | 33 | 34 | org.eclipse.cdt.make.core.buildLocation 35 | ${workspace_loc:/libddd}/build-build_libits 36 | 37 | 38 | org.eclipse.cdt.make.core.contents 39 | org.eclipse.cdt.make.core.activeConfigSettings 40 | 41 | 42 | org.eclipse.cdt.make.core.enableAutoBuild 43 | false 44 | 45 | 46 | org.eclipse.cdt.make.core.enableCleanBuild 47 | true 48 | 49 | 50 | org.eclipse.cdt.make.core.enableFullBuild 51 | true 52 | 53 | 54 | org.eclipse.cdt.make.core.stopOnError 55 | true 56 | 57 | 58 | org.eclipse.cdt.make.core.useDefaultBuildCmd 59 | true 60 | 61 | 62 | 63 | 64 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 65 | 66 | 67 | 68 | 69 | 70 | org.eclipse.cdt.core.cnature 71 | org.eclipse.cdt.core.ccnature 72 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 73 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 74 | org.eclipse.linuxtools.cdt.autotools.core.autotoolsNatureV2 75 | 76 | 77 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | sudo: false 3 | dist: focal 4 | 5 | matrix: 6 | include: 7 | # Linux GCC Builds 8 | - os: linux 9 | compiler: gcc 10 | addons: &gcc10 11 | apt: 12 | sources: ['ubuntu-toolchain-r-test'] 13 | packages: ['g++-10', 'gcc-10', 'doxygen', 'graphviz'] 14 | env: GCCVER='10' CXX_COMPILER='g++-10' C_COMPILER='gcc-10' 15 | 16 | # 4/ OSX GCC Builds 17 | - os: osx 18 | osx_image: xcode11.2 19 | compiler: gcc 20 | addons: 21 | homebrew: 22 | packages: 23 | - gcc 24 | env: GCCVER='9' CXX_COMPILER='g++-9' C_COMPILER='gcc-9' 25 | 26 | cache: 27 | directories: 28 | - /var/cache/apt/archives 29 | 30 | before_script: 31 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export TARGETBRANCH=osx ; fi 32 | - cd ${TRAVIS_BUILD_DIR} 33 | - export CXX=${CXX_COMPILER} 34 | - export CC=${C_COMPILER} 35 | # linux only 36 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export AR=gcc-ar-${GCCVER} ; fi 37 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export RANLIB=gcc-ranlib-${GCCVER} ; fi 38 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export NM=gcc-nm-${GCCVER} ; fi 39 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export TARGETBRANCH=gh-pages ; fi 40 | 41 | script : 42 | - /bin/sh ./tag.sh 43 | - autoreconf -vfi 44 | - mkdir usr && mkdir usr/local 45 | - ./configure --enable-nolto --prefix=$PWD/usr/local/ || cat config.log 46 | - cd ddd 47 | - make -j 48 | - cd .. 49 | - make -j 50 | - make install 51 | - tar cvzf $TRAVIS_OS_NAME.tgz usr/ 52 | - mv $TRAVIS_OS_NAME.tgz website/ 53 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make dist ; mv ddd*.tar.gz website/ ; fi 54 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cd doc ; make ; cd .. ; mv doc/libddd.html/ website/ ; fi 55 | 56 | 57 | deploy: 58 | provider: pages 59 | skip_cleanup: true 60 | github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard 61 | local_dir: website/ 62 | target_branch: $TARGETBRANCH 63 | on: 64 | branch: master 65 | 66 | 67 | after_deploy: 68 | - curl -s -X POST -H "Content-Type:application/json" -H "Accept:application/json" -H "Travis-API-Version:3" -H "Authorization:token $APITOKEN" -d '{"request":{"message":"Triggered by LibDDD build.","branch":"master"}}' https://api.travis-ci.org/repo/lip6%2FlibITS/requests 69 | -------------------------------------------------------------------------------- /ALIRE: -------------------------------------------------------------------------------- 1 | CONTENU 2 | alire : ce fichier 3 | src : contient la bibiotheque DDD 4 | demo: contient des exemples de programmes 5 | doc : contient un manuel de reference 6 | 7 | INSTALLATION 8 | 1. Aller dans le repertoire src 9 | 2. Compiler la bibiotheque DDD : make 10 | 3. Deplacer les fichiers *.h et libDDD.a a votre gout 11 | 12 | EXEMPLE 13 | Dans le repertoire demo 6 exemples de programme vous sont propose. Le Makefile vous permet directement de compiler un ou tous ces exemples : 14 | - la commande make produit 6 executables tsti.exe pour i=1..6 15 | - la commande make tsti.exe produit l'executable tsti.exe pour i=1..6 16 | 17 | PROBLEME 18 | Envoyez moi un mail : couvreur@labri.fr 19 | 20 | 21 | COMPILATION AVEC STL MODIFIE (INSTRUMENTE) 22 | 23 | 1- compile the sources of the application with options: 24 | -D INST_STL (or #define INST_STL before including any DDD library include file) 25 | -isystem where dir is libddd/STLProf 26 | 27 | 2- link with libDDD_i.a 28 | 29 | Examples in demo: 30 | 31 | For instance in tst6.cpp, 32 | - #include "MemoryManager.h" has been added 33 | 34 | - A call to 'MemoryManager::pstats();' has been added at the end 35 | of the main() 36 | 37 | The obtained trace is (// are added comments): 38 | 39 | Each entry of the hash table is found using the hash function. Entries are 40 | the beginning of the chained list of elements. The performance of a hash function 41 | is good if the ratio / is 42 | kept low. The table of statistics by homomorphism can help determine the 'bad' 43 | hash functions. 44 | 45 | The statistics on the hash table describes the average number of jumps in the 46 | hash table when searching for an element. 47 | 48 | ///////////////////////////////// begin trace ///////////////////////////////// 49 | 50 | * 51 | Cache Stats : size=35 // size of the cache 52 | nb jump in hash table : 43/nbsearch 41=1.04878 // / 53 | 54 | Cache hit ratio : 13.6364% // Hit/Misses stats on the cache 55 | * 56 | GHom Stats : size unicity table = 25 // number of stored homomorphisms 57 | NbInsertion(25)*100/NbAccess(32) = 78 // hit misses ie percent of insertion in hom table 58 | 59 | ---------------- MAPPING Jumps on GHOM -------------- 60 | Hom LeftConcat --> 26/20= 1.3 // / 61 | Hom PermuteFin --> 3/2= 1.5 62 | Hom PermuteDown --> 2/2= 1 63 | Hom Compose --> 5/4= 1.25 64 | Hom Permute --> 1/1= 1 65 | Hom Identity --> 1/1= 1 66 | Hom PermuteUp --> 2/2= 1 67 | 68 | ----- END MAPPING Jumps on GHOM, reseting table ----- 69 | * 70 | GDDS : size unicity table =43 // nb DDD nodes in the unicity table 71 | Average nb jump in hash table : 1.33898 // average jump in hash table 72 | NbInsertion(43)*100/NbAccess(59) = 72 // hit misses ie percent of insertion in DDD table 73 | 74 | 75 | ///////////////////////////////// end trace ///////////////////////////////// 76 | 77 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Authors : 2 | Yann Thierry-Mieg (2003-), Jean-Michel Couvreur (2001), and Denis Poitrenaud (2001) 3 | Contributors : 4 | Maximilien Colange (2009-2012) : split-equiv, arithmetic manipulation 5 | Alexandre Hamez < LIP6 and LRDE (EPITA), Alexandre.Hamez@lip6.fr > (2006-2009): maintenance, multi-threading, rewrite rules 6 | Vincent Beaudenon < LIP6 > (2004-2005) : serialisation, user (not strong) homomorphisms 7 | Fran�ois Br�ant < LIP6 > (2004) : INST_STL, multi-target build 8 | Samuel Charron < LRDE (EPITA) > (2005-2006) : tests -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | version 1.4 : January 2008. Release includes auto-saturation mechanisms and homomorphism rewrite rules. 2 | * homomorphisms Skip predicate added 3 | * rewriting rules implmented to produce dynamic saturation effect 4 | * local apply mechanisms and related rules 5 | * hanoi example added to repository 6 | * INST_STL removed from build (was broken with gcc > 3.3 anyway) 7 | 8 | version 1.3 : May 2007. Release includes support for additive Edge valued DDD and SDD 9 | * various cleanups and rewrites for compliance with gcc >= 4.1 10 | * minor updates to allow build on 64 bit architectures 11 | * added tests using uttk 12 | * include a dot export example 13 | 14 | Version 1.2 : January 2006. Release includes the fixpoint construction for homomorphisms. 15 | * include serialization and user homomorphisms 16 | * Cleaned up includes 17 | * Added doxygen documentation 18 | * Changed hash functions 19 | * Some efficiency speedup 20 | 21 | Version 1.1 : November 2004. First semi-public release of the libDDD. Release includes SDD. 22 | * Uses autotools for build procedure, tested on Mac, linux, cygwin. 23 | * Compiles in three variants : 24 | ** libddd.a, the optimized version, 25 | ** libddd_d.a version with debugging symbols activated, 26 | ** libddd_otfg.a a version with experimental on the fly garbage collection 27 | * Optionally, using gcc in versions 3.1, 3.2 or 3.3, it is possible to activate build of INST_STL version, modify src/Makefile.am for this. 28 | 29 | Pre 1.0 : 2001-2003. Beta versions of the pure DDD library. Version 0.99 was version number for some time. 30 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = ddd demo 2 | 3 | EXTRA_DIST = doc 4 | 5 | # We use some external m4 macros 6 | ACLOCAL_AMFLAGS = -I m4 7 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lip6/libDDD/bed76e621f6d0696f3d326a729ff18a16309e811/NEWS -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | see README.rmd 2 | 3 | (autoconf likes to have a README file) 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | What is libDDD ? 2 | 3 | libDDD is a C++ library for manipulation of decision diagrams. 4 | 5 | Main features include: 6 | 7 | * Flexible and powerful encoding of operations using inductive homomorphisms 8 | * Support for hierarchy of the description with SDD 9 | * Automatic support for saturation style algorithms 10 | * A priori unbounded integer domain variables 11 | * Rich expressivity with equiv-split mechanism 12 | * Weak ordering constraint allowing to store variable length decision paths 13 | * Supports both Data Decision Diagrams which are integer valued and Hierarchical Set Decision Diagrams. 14 | 15 | libDDD is distributed under the terms of LGPL. 16 | 17 | Please see [our main website](https://lip6.github.io/ITSTools-web/libddd.html) for more details. 18 | 19 | The [distribution for libDDD by itself is here](https://lip6.github.io/libDDD/index.html) 20 | 21 | [Documentation for libDDD](https://lip6.github.io/libDDD/libddd.html/index.html) is available here 22 | 23 | 24 | -------------------------------------------------------------------------------- /README_MTVariants: -------------------------------------------------------------------------------- 1 | To build, simply run 2 | 3 | ./configure 4 | make 5 | 6 | By default, the library "src/libddd.a" is built using optimized flags. 7 | 8 | Some options you can activate to build other library variants : 9 | 10 | --enable-debug : activates build of debug versions of all libraries activated : src/libddd_d.a src/libddd_mt_d.a src/libddd_par_d.a etc.. 11 | 12 | --enable-evddd : activates build of edge valued variant of library "src/libddd_ev.a". Currently built in non reentrant mode. 13 | 14 | Multi-threaded and reentrant variants below require the open-source library Threading Building Blocks TBB from intel. If this library is not installed in your system folders, you should specify include path using the CPPFLAGS variable. 15 | 16 | For instance, if tbb was built in /home/scott/tbb/ : 17 | 18 | ./configure --enable-reentrant CPPFLAGS="-I /home/scott/tbb/include" 19 | 20 | --enable-reentrant : activates build of reentrant library version "src/libddd_mt.a", adapted to multi-threaded applications. 21 | 22 | --enable-parallel : activates build of internally "src/libddd_par.a" multi-threaded variant. Saturation procedures then run faster on multi-core architectures. User programs can try this variant interchangeably with the default version. However, flag -D PARALLEL_DD must be defined when including libddd headers. 23 | 24 | For instance, to get parallel mode try : 25 | [ythierry@octopus trunk]$ ./configure --enable-parallel --with-libtbbinc=/home/ythierry/tbb20_017oss_src/include/ --with-libtbbbin=/home/ythierry/tbb20_017oss_src/build/linux_em64t_gcc_cc4.2.2_libc2.6.1_kernel2.6.22.9_release/ 26 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | build: 2 | verbosity: minimal 3 | 4 | build_script : 5 | - '%BASH_PATH% -lc "echo $PATH ; which g++"' 6 | - '%BASH_PATH% -lc "cd $APPVEYOR_BUILD_FOLDER; autoreconf -vfi && ./configure --prefix=$(pwd)/usr/local/ --enable-nolto --enable-mingw-native && make && make install "' 7 | - '%BASH_PATH% -lc "cd $APPVEYOR_BUILD_FOLDER; 7z a -tzip windows.zip usr/ "' 8 | 9 | 10 | environment : 11 | MSYSTEM: MINGW64 12 | BASH_PATH: C:\msys64\usr\bin\bash 13 | 14 | 15 | artifacts: 16 | - path: windows.zip 17 | name: windows.zip 18 | 19 | -------------------------------------------------------------------------------- /ddd/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | -------------------------------------------------------------------------------- /ddd/AdditiveMap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __ADDITIVEMAP_HH__ 2 | #define __ADDITIVEMAP_HH__ 3 | 4 | #include 5 | #include "ddd/util/hash_support.hh" 6 | 7 | template > 8 | class AdditiveMap { 9 | 10 | typedef std::vector > mapType; 11 | 12 | mapType map; 13 | 14 | public: 15 | typedef typename mapType::value_type value_type; 16 | typedef typename mapType::const_iterator const_iterator; 17 | typedef typename mapType::iterator iterator; 18 | AdditiveMap(){}; 19 | 20 | // delegate iterator operations to map 21 | const_iterator end() const { return map.end(); } 22 | const_iterator begin() const { return map.begin();} 23 | 24 | iterator find (const K & key) { 25 | iterator res = map.begin(); 26 | while (res != map.end()) { 27 | if (EqualKey () (res->first,key)) 28 | return res; 29 | ++res; 30 | } 31 | return res; 32 | } 33 | 34 | int addAll (const AdditiveMap & other) { 35 | return addAll(other.begin(),other.end()); 36 | } 37 | 38 | // adds a set of mappings 39 | // returns the number of sums computed 40 | int addAll (const_iterator begin,const_iterator end) { 41 | int count = 0; 42 | for ( ; begin != end ; ++ begin ) { 43 | const value_type & val = *begin; 44 | if (add (val.first,val.second) ) 45 | ++count; 46 | } 47 | return count; 48 | } 49 | 50 | // adds value to the value mapped to key 51 | // returns true if sum was actually used, false if normal insertion performed 52 | bool add (const K & key, const V & value) { 53 | typename mapType::iterator it = find(key); 54 | if ( it != map.end() ) { 55 | // found it 56 | it->second = it->second + value ; 57 | return true; 58 | } else { 59 | map.push_back(std::make_pair(key,value)); 60 | return false; 61 | } 62 | } 63 | // removes value to the value mapped to key 64 | // returns true if difference - was actually used, false if nothing performed 65 | bool remove (const K & key, const V & value) { 66 | typename mapType::iterator it = find(key); 67 | if ( it != map.end() ) { 68 | // found it 69 | it->second = it->second - value ; 70 | return true; 71 | } else { 72 | return false; 73 | } 74 | } 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /ddd/Cache.hh: -------------------------------------------------------------------------------- 1 | #ifndef _CACHE_HH_ 2 | #define _CACHE_HH_ 3 | 4 | #include "ddd/util/configuration.hh" 5 | 6 | template 7 | < 8 | typename FuncType 9 | , typename ParamType 10 | , typename ResType 11 | , typename EvalFunc=int 12 | > 13 | class Cache 14 | { 15 | private: 16 | mutable size_t peak_; 17 | 18 | typedef typename hash_map< std::pair, ResType >::type 19 | hash_map; 20 | hash_map cache_; 21 | 22 | public: 23 | Cache () : peak_ (0) {}; 24 | Cache (size_t s) : peak_ (0), cache_ (s) {}; 25 | 26 | /** clear the cache, discarding all values. */ 27 | void clear (bool keepstats = false) { 28 | peak(); 29 | cache_.clear(); 30 | } 31 | 32 | size_t peak () const { 33 | size_t s = size(); 34 | if ( peak_ < s ) 35 | peak_ = s; 36 | return peak_; 37 | } 38 | 39 | 40 | size_t size () const { 41 | return cache_.size(); 42 | } 43 | 44 | ResType eval (const FuncType & func, const ParamType & param) const { 45 | return func.eval(param); 46 | } 47 | 48 | bool 49 | should_insert (const FuncType & ) const 50 | { 51 | return true; 52 | } 53 | 54 | std::pair 55 | insert(const FuncType& hom, const ParamType& node) 56 | { 57 | bool found; 58 | 59 | { // lock on current bucket 60 | typename hash_map::const_accessor access; 61 | found = cache_.find ( access, std::make_pair(hom,node)); 62 | if (found) 63 | return std::make_pair(false, access->second); 64 | } // end of lock on the current bucket 65 | 66 | // wasn't in cache 67 | ResType result = eval(hom, node); 68 | if (should_insert (hom)) 69 | { 70 | // lock on current bucket 71 | typename hash_map::accessor access; 72 | bool insertion = cache_.insert ( access, std::make_pair(hom,node)); 73 | if (insertion) { 74 | // should happen except in MT case 75 | access->second = result; 76 | } 77 | return std::make_pair(insertion,result); 78 | } 79 | else 80 | return std::make_pair (false, result); 81 | } 82 | 83 | #ifdef HASH_STAT 84 | std::map get_hits() const { return cache_.get_hits(); } 85 | std::map get_misses() const { return cache_.get_misses(); } 86 | std::map get_bounces() const { return cache_.get_bounces(); } 87 | #endif // HASH_STAT 88 | }; 89 | 90 | #endif /* _CACHE_HH_ */ 91 | -------------------------------------------------------------------------------- /ddd/DED.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | /* -*- C++ -*- */ 24 | #ifndef DED_H 25 | #define DED_H 26 | 27 | #include 28 | #include "ddd/DDD.h" 29 | #include "ddd/Hom.h" 30 | #include "ddd/util/hash_support.hh" 31 | 32 | class _DED; 33 | class GDDD; 34 | class GHom; 35 | 36 | /******************************************************************************/ 37 | namespace DED { 38 | GDDD add(const d3::set::type &); 39 | 40 | /* Memory Manager */ 41 | unsigned int statistics(); 42 | void pstats(bool reinit=true); 43 | size_t peak(); 44 | void garbage(); 45 | }; 46 | 47 | 48 | #ifdef EVDDD 49 | GHom pushEVDDD(int v); 50 | #endif 51 | 52 | #endif 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /ddd/DataSet.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | #ifndef __DATASET_H__ 24 | #define __DATASET_H__ 25 | 26 | #include 27 | 28 | /// This class is an abstraction of a set of data. 29 | /// Set Decision Diagrams SDD arcs are labeled by a DataSet *, canonization of SDD requires 30 | /// a set-based interface (union, intersection, set difference), ability to compute a hash key 31 | /// and test two sets for equality for unicity table purposes, and test for emptiness as SDD are 32 | /// both zero suppresed (no path lead to GSDD::null), and empty-set suppressed (no arc labeled by 33 | /// empty_set is represented) 34 | /// 35 | /// Additional interface is provided to query/examine the structure, in particular set_size to 36 | /// is required to compute the full set size of an SDD, and print (although this last is not essential) 37 | /// 38 | /// Concrete DataSet classes should derive from DataSet and fulfill the contract FOR THEIR OWN TYPE 39 | /// hard or dynamic casting the argument into one's own type is the recommended behavior 40 | /// 41 | /// \todo recent experiments with V. Beaudenon show maybe some behavior should be put here, 42 | /// for instance set_intersect is always empty if incompatible types are compared. 43 | class DataSet 44 | { 45 | public : 46 | /// destructor 47 | virtual ~DataSet() {}; 48 | /// returns a new instance copy of this 49 | virtual DataSet *newcopy () const = 0; 50 | /// returns a new instance with elements = this inter b 51 | virtual DataSet *set_intersect (const DataSet & b) const = 0; 52 | /// returns a new instance with elements = this union b 53 | virtual DataSet *set_union (const DataSet & b) const = 0; 54 | /// returns a new instance with elements = this setminus b 55 | virtual DataSet *set_minus (const DataSet & b) const = 0; 56 | /// returns true if this is the empty set 57 | virtual bool empty() const = 0; 58 | /// returns a pointer to an instance of the empty set 59 | virtual DataSet *empty_set() const = 0; 60 | /// Compares two sets for equality. 61 | virtual bool set_equal(const DataSet & b) const =0; 62 | /// Compares two sets with a total order. 63 | virtual bool set_less_than (const DataSet & b) const =0; 64 | /// \return the size (number of elements) in a set 65 | virtual long double set_size() const = 0; 66 | /// returns a hash function, used in the SDD hash function computation 67 | virtual size_t set_hash() const =0; 68 | /// returns a formatted string description of the set 69 | virtual void set_print (std::ostream &os) const =0; 70 | /// for memory management : if your DataSet references no GDD,GHom,GSDD,GShom, mark() should do nothing 71 | virtual void mark() const = 0; 72 | #ifdef EVDDD 73 | virtual DataSet *normalizeDistance(int n) const =0; 74 | virtual int getMinDistance() const = 0; 75 | #endif 76 | 77 | }; 78 | 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /ddd/FixObserver.cpp: -------------------------------------------------------------------------------- 1 | #include "FixObserver.hh" 2 | 3 | #include 4 | 5 | namespace fobs { 6 | 7 | class DefaultObserver : public FixObserver { 8 | public: 9 | DefaultObserver (): FixObserver () {} 10 | 11 | bool should_interrupt (const GSDD &, const GSDD &) { return false; } 12 | bool should_interrupt (const GDDD &, const GDDD &) { return false; } 13 | bool was_interrupted () const { return false; } 14 | void update (const GSDD & , const GSDD & ) {} 15 | void update (const GDDD & , const GDDD & ) {} 16 | }; 17 | 18 | static FixObserver * obs = NULL; 19 | 20 | void 21 | set_fixobserver (FixObserver * o) 22 | { 23 | delete obs; 24 | obs = o; 25 | } 26 | 27 | FixObserver * 28 | get_fixobserver () 29 | { 30 | if (obs == NULL) 31 | obs = new DefaultObserver (); 32 | return obs; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /ddd/FixObserver.hh: -------------------------------------------------------------------------------- 1 | #ifndef FIXOBSERVER_HH_ 2 | #define FIXOBSERVER_HH_ 3 | 4 | /// forward declarations 5 | class GSDD; 6 | class GDDD; 7 | 8 | namespace fobs { 9 | 10 | class FixObserver { 11 | public: 12 | FixObserver (){} 13 | virtual ~FixObserver () {} 14 | 15 | /// \warning: if should_interrult() returns true, then it MUST return true 16 | /// at least until the next call to update(). 17 | /// The attribute is_interrupted is here for this purpose: it can be set to 18 | /// true only by should_interrupt and to false only by update, and 19 | /// is_interrupted => should_interrupt returns true 20 | virtual bool should_interrupt (const GSDD & after, const GSDD & before) = 0; 21 | virtual bool should_interrupt (const GDDD & after, const GDDD & before) = 0; 22 | virtual bool was_interrupted () const = 0; 23 | virtual void update (const GSDD & after, const GSDD & before) = 0; 24 | virtual void update (const GDDD & after, const GDDD & before) = 0; 25 | }; 26 | 27 | FixObserver * 28 | get_fixobserver (); 29 | 30 | void 31 | set_fixobserver (FixObserver *); 32 | 33 | } 34 | 35 | #endif /// ! FIXOBSERVER_HH_ 36 | -------------------------------------------------------------------------------- /ddd/History.txt: -------------------------------------------------------------------------------- 1 | 5/25/2004: 2 | - Added/Modified Makefiles to generate all version of the library: 3 | - libDDD.a : optimized 4 | - libDDD_d.a : debug info 5 | - libDDD_p.a : profiling info (compiled with -pg option, then use with gprof) 6 | - libDDD_i.a : instrumented STL for profiling hash tables 7 | 8 | 9 | - Added instrumented hash table in STL: directory is libddd/STLProf 10 | To use it, link with libDDD_i.a and 11 | 12 | - DDD.[h,cpp] 13 | - Added functions: 14 | size_t nbsons() const; 15 | return the number of sons of the current node. 16 | void pstats(bool reinit=true); 17 | print statistics on the use of the hash table 18 | if reinit is false, then the counter are not 19 | reinitialized. 20 | 21 | - DED.[h,cpp] 22 | static void pstats(bool reinit=true); 23 | prints hit/misses cache ratio 24 | prints average number of jumps in the hash table 25 | if reinit=false, reinitialize the counters 26 | virtual bool shouldCache(); 27 | part of the optimization that avoid caching nodes 28 | with only one son. 29 | (check GDDD DED::eval()) 30 | 31 | - Hom.[h,cpp] 32 | static void pstats(bool reinit=true); 33 | 34 | - MemoryManager.h 35 | static void pstats(bool reinit=true); 36 | This one calls all the pstats functions in the others 37 | storages. Should be used to get all the stats 38 | 39 | - UniqueTable.h 40 | hash_map-->hash_set (minor change) 41 | void pstat(bool reinit=true); 42 | 43 | 44 | To compile with instrumented STL: 45 | 1- compile the sources of the application with options: 46 | -D INST_STL (or #define INST_STL before including any DDD library include file) 47 | -isystem where dir is libddd/STLProf 48 | 49 | 2- link with libDDD_i.a 50 | 51 | Examples in demo: 52 | 53 | For instance in tst6.cpp, 54 | - #include "MemoryManager.h" has been added 55 | 56 | - A call to 'MemoryManager::pstats();' has been added at the end 57 | of the main() 58 | 59 | The obtained trace is (// are added comments): 60 | 61 | Each entry of the hash table is found using the hash function. Entries are 62 | the beginning of the chained list of elements. The performance of a hash function 63 | is good if the ratio / is 64 | kept low. The table of statistics by homomorphism can help determine the 'bad' 65 | hash functions. 66 | 67 | The statistics on the hash table describes the average number of jumps in the 68 | hash table when searching for an element. 69 | 70 | ///////////////////////////////// begin trace ///////////////////////////////// 71 | 72 | * 73 | Cache Stats : size=35 // size of the cache 74 | nb jump in hash table : 43/nbsearch 41=1.04878 // / 75 | 76 | Cache hit ratio : 13.6364% // Hit/Misses stats on the cache 77 | * 78 | GHom Stats : size unicity table = 25 // number of stored homomorphisms 79 | NbInsertion(25)*100/NbAccess(32) = 78 // hit misses ie percent of insertion in hom table 80 | 81 | ---------------- MAPPING Jumps on GHOM -------------- 82 | Hom LeftConcat --> 26/20= 1.3 // / 83 | Hom PermuteFin --> 3/2= 1.5 84 | Hom PermuteDown --> 2/2= 1 85 | Hom Compose --> 5/4= 1.25 86 | Hom Permute --> 1/1= 1 87 | Hom Identity --> 1/1= 1 88 | Hom PermuteUp --> 2/2= 1 89 | 90 | ----- END MAPPING Jumps on GHOM, reseting table ----- 91 | * 92 | GDDS : size unicity table =43 // nb DDD nodes in the unicity table 93 | Average nb jump in hash table : 1.33898 // average jump in hash table 94 | NbInsertion(43)*100/NbAccess(59) = 72 // hit misses ie percent of insertion in DDD table 95 | 96 | 97 | ///////////////////////////////// end trace ///////////////////////////////// 98 | 99 | -------------------------------------------------------------------------------- /ddd/Hom_Basic.hh: -------------------------------------------------------------------------------- 1 | #ifndef __HOM_BASIC__H_ 2 | #define __HOM_BASIC__H_ 3 | 4 | #include "ddd/DDD.h" 5 | #include "ddd/Hom.h" 6 | #include "ddd/SDD.h" 7 | #include "ddd/SHom.h" 8 | 9 | 10 | // keep paths where variable var is equal to val 11 | GHom varEqState (int var, int val) ; 12 | // keep paths where variable var is NOT equal to val 13 | GHom varNeqState (int var, int val) ; 14 | // keep paths where variable var is strictly greater than val 15 | GHom varGtState (int var, int val) ; 16 | // keep paths where variable var is strictly < val 17 | GHom varLtState (int var, int val) ; 18 | // keep paths where variable var is <= to val 19 | GHom varLeqState (int var, int val) ; 20 | // keep paths where variable var is >= to val 21 | GHom varGeqState (int var, int val) ; 22 | // set a var to a constant 23 | GHom setVarConst (int var, int val) ; 24 | // increment or decrement the value of var by val 25 | GHom incVar (int var, int val) ; 26 | 27 | // keep paths where variable var is equal to val 28 | GHom varEqVar (int var, int var2) ; 29 | // keep paths where variable var is NOT equal to var2 30 | GHom varNeqVar (int var, int var2) ; 31 | // keep paths where variable var is strictly greater than var2 32 | GHom varGtVar (int var, int var2) ; 33 | // keep paths where variable var is strictly < var2 34 | GHom varLtVar (int var, int var2) ; 35 | // keep paths where variable var is <= to var2 36 | GHom varLeqVar (int var, int var2) ; 37 | // keep paths where variable var is >= to var2 38 | GHom varGeqVar (int var, int var2) ; 39 | 40 | #include 41 | 42 | /// an explicit representation of a state 43 | typedef std::vector state_t; 44 | /// A visitor callback function 45 | typedef std::function callback_t; 46 | /// Explicit conversion : visit every path in the DDD (variable ids are removed) 47 | void iterate (const GDDD & node, callback_t * cb); 48 | /// Explicit conversion : visit every path in the DDD (variable ids are removed) 49 | void iterate (const GSDD & node, callback_t * cb); 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /ddd/IntDataSet.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | 24 | #include "ddd/IntDataSet.h" 25 | 26 | 27 | // static initialization 28 | UniqueTable > IntDataSet::canonical = UniqueTable > (); 29 | 30 | const std::vector * IntDataSet::empty_ = canonical(std::vector(0)); 31 | 32 | IntDataSet::marktable_t IntDataSet::marktable = marktable_t(); 33 | 34 | 35 | void IntDataSet::garbage () { 36 | // sweep phase 37 | for(canonical_it di=canonical.table.begin();di!=canonical.table.end();){ 38 | if(marktable.find(*di) == marktable.end() ){ 39 | canonical_it ci=di; 40 | di++; 41 | const std::vector *g=(*ci); 42 | canonical.table.erase(ci); 43 | delete g; 44 | }else { 45 | di++; 46 | } 47 | } 48 | marktable.clear(); 49 | } 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /ddd/MLCache.hh: -------------------------------------------------------------------------------- 1 | #ifndef _MLCACHE_HH_ 2 | #define _MLCACHE_HH_ 3 | 4 | #include "ddd/util/configuration.hh" 5 | 6 | 7 | template 8 | < 9 | typename MLHomType 10 | , typename NodeType 11 | , typename HomNodeMapType 12 | > 13 | class MLCache 14 | { 15 | private: 16 | mutable size_t peak_; 17 | 18 | typedef typename hash_map< std::pair, HomNodeMapType >::type 19 | hash_map; 20 | hash_map cache_; 21 | 22 | public: 23 | MLCache () : peak_ (0) {}; 24 | 25 | /** clear the cache, discarding all values. */ 26 | void clear (bool keepstats = false) { 27 | peak(); 28 | cache_.clear(); 29 | } 30 | 31 | size_t peak () const { 32 | size_t s = size(); 33 | if ( peak_ < s ) 34 | peak_ = s; 35 | return peak_; 36 | } 37 | 38 | 39 | size_t size () const { 40 | return cache_.size(); 41 | } 42 | 43 | std::pair 44 | insert(const MLHomType& hom, const NodeType& node) 45 | { 46 | bool found; 47 | 48 | { // lock on current bucket 49 | typename hash_map::const_accessor access; 50 | found = cache_.find ( access, std::make_pair(hom,node)); 51 | if (found) 52 | return std::make_pair(false, access->second); 53 | } // end of lock on the current bucket 54 | 55 | // wasn't in cache 56 | HomNodeMapType result = hom.eval(node); 57 | // lock on current bucket 58 | typename hash_map::accessor access; 59 | bool insertion = cache_.insert ( access, std::make_pair(hom,node)); 60 | if (insertion) { 61 | // should happen except in MT case 62 | access->second = result; 63 | } 64 | return std::make_pair(insertion,result); 65 | } 66 | 67 | #ifdef HASH_STAT 68 | std::map get_hits() const { return cache_.get_hits(); } 69 | std::map get_misses() const { return cache_.get_misses(); } 70 | std::map get_bounces() const { return cache_.get_bounces(); } 71 | #endif // HASH_STAT 72 | }; 73 | 74 | #endif /* _MLCACHE_HH_ */ 75 | -------------------------------------------------------------------------------- /ddd/MLSHom.h: -------------------------------------------------------------------------------- 1 | #ifndef __MLSHOM__H__ 2 | #define __MLSHOM__H__ 3 | 4 | #include "ddd/AdditiveMap.hpp" 5 | #include "ddd/SHom.h" 6 | 7 | class MLShom; 8 | 9 | typedef AdditiveMap SHomNodeMap; 10 | typedef AdditiveMap SHomHomMap; 11 | 12 | class _MLShom; 13 | 14 | class MLShom { 15 | 16 | /// By definition, as homomorphism are linear, (h+g) (d) = h(d) + g(d) ; 17 | /// Where g,h are homomorphisms and d is a SDDD. 18 | friend MLShom operator+(const MLShom &,const MLShom &); 19 | /// The real implementation class. All true operations are delagated on this pointer. 20 | /// Construction/destruction take care of ensuring concret is only instantiated once in memory. 21 | const _MLShom* concret; 22 | 23 | public : 24 | 25 | /// Elementary homomorphism Identity, defined as a constant. 26 | /// id(d) = 27 | static const MLShom id; 28 | 29 | /// Default public constructor. 30 | /// Builds Identity homomorphism : forall d in DDD, id(d) = d 31 | MLShom():concret(id.concret){}; 32 | 33 | MLShom(const GShom &h); 34 | MLShom (const GShom & up, const MLShom & down); 35 | MLShom (const _MLShom &); 36 | MLShom (_MLShom *); 37 | MLShom (const _MLShom *); 38 | 39 | 40 | /// Create variable/value pair and left concatenate to a homomorphism. 41 | /// h(var,val,g) (d) = DDD(var,val) ^ g(d). 42 | /// In other words : var -- val -> g 43 | /// \param var the variable index 44 | /// \param val the value associated to the variable 45 | /// \param h the homomorphism to apply on successor node. Default is identity, so is equivalent to a left concatenation of a DDD(var,val). 46 | MLShom(int var, const DataSet & val, const MLShom &h=MLShom::id); 47 | 48 | virtual ~MLShom(); 49 | 50 | 51 | bool operator<(const MLShom &h) const {return concret(concret)); }; 58 | 59 | /// The computation function responsible for evaluation over a node. 60 | /// Users should not directly use this. Normal behavior is to use operator() 61 | /// that encapsulates this call with operation caching. 62 | SHomNodeMap eval(const GSDD &) const ; 63 | /// cache calls to eval 64 | SHomNodeMap operator() (const GSDD &) const; 65 | 66 | 67 | /// Collects and destroys unused homomorphisms. Do not call this directly but through 68 | /// MemoryManager::garbage() as order of calls (among GSDD::garbage(), GShom::garbage(), 69 | /// SDED::garbage()) is important. 70 | static void garbage(); 71 | 72 | }; 73 | 74 | /// Composition by union of two homomorphisms. 75 | /// This commutative operation computes a homomorphism 76 | /// that evaluates as the sum of two homomorphism. 77 | /// 78 | /// Semantics : (h1 + h2) (d) = h1(d) + h2(d). 79 | MLShom operator+(const MLShom &,const MLShom &); 80 | 81 | class _MLShom { 82 | /// For garbage collection. 83 | /// Counts the number of times a _MLHom is referenced from the context of an MLHom. 84 | mutable int refCounter; 85 | /// For garbage collection. Used in the two phase garbage collection process. 86 | /// A Shom that is not marked after the first pass over the unicity table, will 87 | /// be sweeped in the second phase. Outside of garbage collection routine, marking 88 | /// should always bear the value false. 89 | mutable bool marking; 90 | 91 | /// open access to container class MLHom. 92 | friend class MLShom; 93 | 94 | /// For garbage collection. Used in first phase of garbage collection. 95 | virtual void mark() const{}; 96 | 97 | 98 | public: 99 | _MLShom (int ref=0) : refCounter(ref),marking(false) {} 100 | /** test if caching should be done : default means should cache */ 101 | virtual bool shouldCache () const { return true ; } 102 | 103 | /// Virtual Destructor. 104 | virtual ~_MLShom(){}; 105 | virtual SHomNodeMap eval(const GSDD &) const = 0; 106 | 107 | /** unique table trivia */ 108 | virtual size_t hash() const = 0; 109 | virtual bool operator==(const _MLShom &h) const=0; 110 | // for use by unique table : return new MyConcreteClassName(*this); 111 | virtual _MLShom * clone () const =0 ; 112 | 113 | }; 114 | 115 | class StrongMLShom : public _MLShom { 116 | public : 117 | 118 | bool operator==(const _MLShom &h) const; 119 | 120 | virtual bool operator==(const StrongMLShom &) const=0; 121 | 122 | SHomNodeMap eval(const GSDD &) const ; 123 | 124 | /// User defined behavior is input through this function 125 | virtual SHomHomMap phi (int var,const DataSet & val) const=0; 126 | virtual SHomNodeMap phiOne () const=0; 127 | 128 | }; 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /ddd/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libDDD.la \ 2 | libDDD_d.la 3 | 4 | MYSRCDIR= $(abs_top_srcdir)/ddd 5 | 6 | ddddir = $(pkgincludedir) 7 | ddd_hdrs = DataSet.h \ 8 | Cache.hh \ 9 | DDD.h \ 10 | DED.h \ 11 | FixObserver.hh \ 12 | Hom.h \ 13 | Hom_Basic.hh \ 14 | MemoryManager.h \ 15 | MLCache.hh \ 16 | SDD.h \ 17 | SDED.h \ 18 | SHom.h \ 19 | UniqueTable.h \ 20 | UniqueTableId.hh \ 21 | IntDataSet.h \ 22 | hashfunc.hh \ 23 | MLHom.h \ 24 | MLSHom.h \ 25 | statistic.hpp \ 26 | process.hpp \ 27 | AdditiveMap.hpp \ 28 | init.hh 29 | 30 | utildir = $(pkgincludedir)/util 31 | util_hdrs = util/dotExporter.h \ 32 | util/configuration.hh \ 33 | util/ext_hash_map.hh \ 34 | util/hash_support.hh \ 35 | util/hash_set.hh \ 36 | util/tbb_hash_map.hh \ 37 | util/vector.hh \ 38 | util/set.hh \ 39 | util/map.hh \ 40 | google/sparse_hash_map \ 41 | google/sparse_hash_set \ 42 | google/sparsetable \ 43 | google/template_util.h \ 44 | google/type_traits.h \ 45 | google/sparsehash/densehashtable.h \ 46 | google/sparsehash/hashtable-common.h \ 47 | google/sparsehash/libc_allocator_with_realloc.h \ 48 | google/sparsehash/sparseconfig.h \ 49 | google/sparsehash/sparsehashtable.h 50 | 51 | EXTRA_DIST = google/AUTHORS google/COPYING google/README 52 | 53 | nobase_ddd_HEADERS = $(ddd_hdrs) $(util_hdrs) 54 | 55 | srcs = DED.cpp \ 56 | Cache.hh \ 57 | DDD.cpp \ 58 | FixObserver.cpp \ 59 | Hom.cpp \ 60 | Hom_Basic.cpp \ 61 | SDED.cpp \ 62 | SDD.cpp \ 63 | SHom.cpp \ 64 | IntDataSet.cpp \ 65 | MLHom.cpp \ 66 | MLSHom.cpp \ 67 | statistic.cpp \ 68 | process.cpp \ 69 | util/dotExporter.cpp 70 | 71 | # Flags for TBB 72 | if WITH_LIBTBBINC_PATH 73 | TBBINC_FLAGS=-I $(LIBTBB_INC) 74 | endif 75 | 76 | 77 | # standard version 78 | libDDD_la_SOURCES = $(ddd_hdrs) $(util_hdrs) $(srcs) 79 | libDDD_la_CPPFLAGS = -g -O3 -Wall -DNDEBUG $(TBBINC_FLAGS) -I $(abs_top_srcdir) 80 | 81 | # debug version 82 | libDDD_d_la_SOURCES = $(ddd_hdrs) $(util_hdrs) $(srcs) 83 | libDDD_d_la_CPPFLAGS = -g -O0 -Wall $(TBBINC_FLAGS) -I $(abs_top_srcdir) 84 | -------------------------------------------------------------------------------- /ddd/SDED.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | /* -*- C++ -*- */ 24 | #ifndef SDED_H 25 | #define SDED_H 26 | 27 | #include 28 | #include "ddd/util/set.hh" 29 | 30 | #include "ddd/DataSet.h" 31 | #include "ddd/util/hash_support.hh" 32 | 33 | class GSDD; 34 | 35 | /******************************************************************************/ 36 | namespace SDED{ 37 | GSDD add(const d3::set::type &); 38 | 39 | /* Memory Manager */ 40 | unsigned int statistics(); 41 | void pstats(bool reinit=true); 42 | size_t peak(); 43 | void garbage(); 44 | }; 45 | 46 | 47 | // Library internal: square_union (cf FORTE'05) 48 | void 49 | square_union (std::map &res,const GSDD & s, DataSet* d); 50 | 51 | #ifdef EVDDD 52 | GShom pushEVSDD(int v); 53 | #endif 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /ddd/UniqueTable.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | /* -*- C++ -*- */ 24 | #ifndef UNIQUETABLE_H 25 | #define UNIQUETABLE_H 26 | 27 | #include 28 | #include 29 | #include "ddd/util/hash_support.hh" 30 | #include "ddd/util/hash_set.hh" 31 | 32 | 33 | #ifdef REENTRANT 34 | #include "tbb/queuing_mutex.h" 35 | #include "tbb/mutex.h" 36 | #endif 37 | 38 | 39 | 40 | /// This class implements a unicity table mechanism, based on an STL hash_set. 41 | /// Requirements on the contained type are thus those of hash_set. 42 | template 43 | class UniqueTable{ 44 | 45 | private: 46 | 47 | #ifdef REENTRANT 48 | // typedef tbb::queuing_mutex table_mutex_t; 49 | typedef tbb::mutex table_mutex_t; 50 | table_mutex_t table_mutex_; 51 | #endif 52 | 53 | public: 54 | /// Constructor, builds a default table. 55 | UniqueTable() 56 | #ifdef REENTRANT 57 | : 58 | table_mutex_() 59 | #endif 60 | { 61 | #ifndef REENTRANT 62 | #ifndef USE_STD_HASH 63 | table.set_deleted_key(NULL); 64 | #endif 65 | #endif 66 | } 67 | 68 | UniqueTable(size_t s): 69 | #ifdef REENTRANT 70 | table_mutex_(), 71 | #endif 72 | table (s) 73 | { 74 | #ifndef REENTRANT 75 | #ifndef USE_STD_HASH 76 | table.set_deleted_key(NULL); 77 | #endif 78 | #endif 79 | } 80 | 81 | /// Typedef helps hide implementation type (currently gnu gcc's hash_set). 82 | typedef typename d3::hash_set::type Table; 83 | /// The actual table, operations on the UniqueTable are delegated on this. 84 | Table table; // Unique table of GDDD 85 | 86 | /* Canonical */ 87 | /// The application operator, returns the address of the value already in 88 | /// the table if it exists, or inserts and returns the address of the value inserted. 89 | /// \param _g the pointer to the value we want to find in the table. 90 | /// \return the address of an object stored in the UniqueTable such that (*_g == *return_value) 91 | const T* 92 | operator()(const T &_g) 93 | { 94 | #ifdef REENTRANT 95 | table_mutex_t::scoped_lock lock(table_mutex_); 96 | #endif 97 | 98 | typename Table::const_iterator it = table.find(&_g); 99 | if (it != table.end() ) { 100 | return *it; 101 | } else { 102 | T * clone = unique::clone() (_g); 103 | std::pair ref=table.insert(clone); 104 | assert(ref.second); 105 | ((void)ref); 106 | return clone; 107 | } 108 | } 109 | 110 | /// Returns the current number of filled entries in the table. 111 | size_t 112 | size() const 113 | { 114 | return table.size(); 115 | } 116 | 117 | #ifdef HASH_STAT 118 | std::map get_hits() const { return table.get_hits(); } 119 | std::map get_misses() const { return table.get_misses(); } 120 | std::map get_bounces() const { return table.get_bounces(); } 121 | #endif // HASH_STAT 122 | }; 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /ddd/google/AUTHORS: -------------------------------------------------------------------------------- 1 | opensource@google.com 2 | 3 | -------------------------------------------------------------------------------- /ddd/google/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /ddd/google/sparsehash/libc_allocator_with_realloc.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // --- 31 | 32 | #ifndef UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_ 33 | #define UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_ 34 | 35 | #include 36 | #include // for malloc/realloc/free 37 | #include // for ptrdiff_t 38 | #include // for placement new 39 | 40 | _START_GOOGLE_NAMESPACE_ 41 | 42 | template 43 | class libc_allocator_with_realloc { 44 | public: 45 | typedef T value_type; 46 | typedef size_t size_type; 47 | typedef ptrdiff_t difference_type; 48 | 49 | typedef T* pointer; 50 | typedef const T* const_pointer; 51 | typedef T& reference; 52 | typedef const T& const_reference; 53 | 54 | libc_allocator_with_realloc() {} 55 | libc_allocator_with_realloc(const libc_allocator_with_realloc&) {} 56 | ~libc_allocator_with_realloc() {} 57 | 58 | pointer address(reference r) const { return &r; } 59 | const_pointer address(const_reference r) const { return &r; } 60 | 61 | pointer allocate(size_type n, const_pointer = 0) { 62 | return static_cast(malloc(n * sizeof(value_type))); 63 | } 64 | void deallocate(pointer p, size_type) { 65 | free(p); 66 | } 67 | pointer reallocate(pointer p, size_type n) { 68 | return static_cast(realloc(p, n * sizeof(value_type))); 69 | } 70 | 71 | size_type max_size() const { 72 | return static_cast(-1) / sizeof(value_type); 73 | } 74 | 75 | void construct(pointer p, const value_type& val) { 76 | new(p) value_type(val); 77 | } 78 | void destroy(pointer p) { p->~value_type(); } 79 | 80 | template 81 | libc_allocator_with_realloc(const libc_allocator_with_realloc&) {} 82 | 83 | template 84 | struct rebind { 85 | typedef libc_allocator_with_realloc other; 86 | }; 87 | }; 88 | 89 | // libc_allocator_with_realloc specialization. 90 | template<> 91 | class libc_allocator_with_realloc { 92 | public: 93 | typedef void value_type; 94 | typedef size_t size_type; 95 | typedef ptrdiff_t difference_type; 96 | typedef void* pointer; 97 | typedef const void* const_pointer; 98 | 99 | template 100 | struct rebind { 101 | typedef libc_allocator_with_realloc other; 102 | }; 103 | }; 104 | 105 | template 106 | inline bool operator==(const libc_allocator_with_realloc&, 107 | const libc_allocator_with_realloc&) { 108 | return true; 109 | } 110 | 111 | template 112 | inline bool operator!=(const libc_allocator_with_realloc&, 113 | const libc_allocator_with_realloc&) { 114 | return false; 115 | } 116 | 117 | _END_GOOGLE_NAMESPACE_ 118 | 119 | #endif // UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_ 120 | -------------------------------------------------------------------------------- /ddd/google/sparsehash/sparseconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NOTE: This file is for internal use only. 3 | * Do not use these #defines in your own program! 4 | */ 5 | 6 | /* Namespace for Google classes */ 7 | #define GOOGLE_NAMESPACE ::google 8 | 9 | /* the location of the header defining hash functions */ 10 | #define HASH_FUN_H 11 | 12 | /* the namespace of the hash<> function */ 13 | #define HASH_NAMESPACE std 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #define HAVE_INTTYPES_H 1 17 | 18 | /* Define to 1 if the system has the type `long long'. */ 19 | #define HAVE_LONG_LONG 1 20 | 21 | /* Define to 1 if you have the `memcpy' function. */ 22 | #define HAVE_MEMCPY 1 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #define HAVE_STDINT_H 1 26 | 27 | /* Define to 1 if you have the header file. */ 28 | // #define HAVE_SYS_TYPES_H 1 29 | 30 | /* Define to 1 if the system has the type `uint16_t'. */ 31 | #define HAVE_UINT16_T 1 32 | 33 | /* Define to 1 if the system has the type `u_int16_t'. */ 34 | // #define HAVE_U_INT16_T 1 35 | 36 | /* Define to 1 if the system has the type `__uint16'. */ 37 | /* #undef HAVE___UINT16 */ 38 | 39 | /* The system-provided hash function including the namespace. */ 40 | #define SPARSEHASH_HASH HASH_NAMESPACE::hash 41 | 42 | /* Stops putting the code inside the Google namespace */ 43 | #define _END_GOOGLE_NAMESPACE_ } 44 | 45 | /* Puts following code inside the Google namespace */ 46 | #define _START_GOOGLE_NAMESPACE_ namespace google { 47 | -------------------------------------------------------------------------------- /ddd/hashfunc.hh: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* Based on a file written by Alexandre Duret-Lutz for Spot, */ 8 | /* Alexandre.Duret-Lutz@lip6.fr */ 9 | /* */ 10 | /* This program is free software; you can redistribute it and/or modify */ 11 | /* it under the terms of the GNU Lesser General Public License as */ 12 | /* published by the Free Software Foundation; either version 3 of the */ 13 | /* License, or (at your option) any later version. */ 14 | /* This program is distributed in the hope that it will be useful, */ 15 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 16 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 17 | /* GNU LEsserGeneral Public License for more details. */ 18 | /* */ 19 | /* You should have received a copy of the GNU Lesser General Public License */ 20 | /* along with this program; if not, write to the Free Software */ 21 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 22 | /* */ 23 | /****************************************************************************/ 24 | #ifndef __DDD_MISC_HASHFUNC_HH 25 | #define __DDD_MISC_HASHFUNC_HH 26 | 27 | /******************************************************************************/ 28 | 29 | #include 30 | 31 | namespace ddd 32 | { 33 | /// \addtogroup hash_funcs Hashing functions 34 | /// \ingroup misc_tools 35 | /// @{ 36 | 37 | /// \brief Thomas Wang's 32 bit hash function. 38 | /// 39 | /// Hash an integer amongst the integers. 40 | /// http://www.concentric.net/~Ttwang/tech/inthash.htm 41 | inline size_t 42 | wang32_hash(size_t key) 43 | { 44 | // We assume that size_t has at least 32bits. 45 | key += ~(key << 15); 46 | key ^= (key >> 10); 47 | key += (key << 3); 48 | key ^= (key >> 6); 49 | key += ~(key << 11); 50 | key ^= (key >> 16); 51 | return key; 52 | } 53 | 54 | /// Another of Wang's fast hash with a magic number. 55 | /// good for (sequence of) integers 56 | inline uint32_t int32_hash(uint32_t a) { 57 | a = (a ^ 61) ^ (a >> 16); 58 | a = a + (a << 3); 59 | a = a ^ (a >> 4); 60 | a = a * 0x27d4eb2d; 61 | a = a ^ (a >> 15); 62 | return a; 63 | } 64 | 65 | 66 | /// \brief Knuth's Multiplicative hash function. 67 | /// 68 | /// This function is suitable for hashing values whose 69 | /// high order bits do not vary much (ex. addresses of 70 | /// memory objects). Prefer spot::wang32_hash() otherwise. 71 | /// http://www.concentric.net/~Ttwang/tech/addrhash.htm 72 | inline size_t 73 | knuth32_hash(size_t key) 74 | { 75 | // 2654435761 is the golden ratio of 2^32. The right shift of 3 76 | // bits assumes that all objects are aligned on a 8 byte boundary. 77 | return (key >> 3) * 2654435761U; 78 | } 79 | /// @} 80 | } 81 | 82 | #endif // DDD_MISC_HASHFUNC_HH 83 | -------------------------------------------------------------------------------- /ddd/init.hh: -------------------------------------------------------------------------------- 1 | #ifndef _D3_MANAGER_HH_ 2 | #define _D3_MANAGER_HH_ 3 | 4 | #ifdef PARALLEL_DD 5 | #include "tbb/task_scheduler_init.h" 6 | #endif 7 | 8 | namespace d3 { 9 | 10 | class init 11 | { 12 | private: 13 | 14 | #ifdef PARALLEL_DD 15 | tbb::task_scheduler_init tbb_init_; 16 | #endif 17 | 18 | public: 19 | 20 | init() 21 | #ifdef PARALLEL_DD 22 | : 23 | tbb_init_() 24 | #endif 25 | { 26 | } 27 | 28 | ~init() 29 | { 30 | } 31 | }; 32 | 33 | } // namespace d3 34 | 35 | #endif /* _D3_MANAGER_HH_ */ 36 | -------------------------------------------------------------------------------- /ddd/process.cpp: -------------------------------------------------------------------------------- 1 | #include "process.hpp" 2 | 3 | // for clock 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #if defined(__linux__) || defined(LINUX) || defined(linux) || defined(__CYGWIN__) || defined(cygwin) 12 | #define USE_PROC_MEM 1 13 | #elif defined (__GLIBC__) 14 | #define USE_MALLINFO 1 15 | #elif defined (__MINGW32__) || defined (__MINGW64 ) 16 | #define USE_WIN32_API 1 17 | #else 18 | #define OS_APPLE 1 19 | #endif 20 | 21 | #if OS_APPLE // use mach function 22 | # include 23 | # include 24 | #elif USE_PROC_MEM 25 | # include 26 | #elif USE_MALLINFO 27 | # include 28 | #elif USE_WIN32_API 29 | #include "windows.h" 30 | #include "psapi.h" 31 | #endif 32 | 33 | 34 | 35 | using namespace std; 36 | 37 | namespace process { 38 | 39 | 40 | #ifdef USE_PROC_MEM 41 | static size_t page_mult_ = 0; 42 | static size_t page_mult () { 43 | if (! page_mult_) { 44 | size_t page_size = sysconf(_SC_PAGESIZE); 45 | page_mult_ = page_size / 1024; 46 | } 47 | return page_mult_; 48 | } 49 | #endif 50 | 51 | 52 | double getTotalTime() { 53 | double val = (double) clock(); 54 | return (val*1000.0 / CLOCKS_PER_SEC) / 1000; 55 | 56 | } 57 | 58 | 59 | /***************************************************************************** 60 | * Return total amount of bytes allocated. 61 | *****************************************************************************/ 62 | unsigned long 63 | MemoryUsed( void ) 64 | { 65 | #ifdef USE_PROC_MEM 66 | { 67 | size_t total_size, rss_size; 68 | 69 | FILE* file = fopen("/proc/self/statm", "r"); 70 | if (!file) { 71 | std::cerr << "Unsupported OS : Linux detected but /proc not available to obtain process memory usage. Will report 0." << std::endl; 72 | return 0; 73 | } 74 | int res = fscanf(file, "%zu %zu", &total_size, &rss_size); 75 | (void) fclose(file); 76 | if (res != 2) 77 | return 0; 78 | return rss_size * page_mult(); 79 | } 80 | #elif USE_MALLINFO 81 | 82 | // Per delorie.com: 83 | // Example: 84 | // struct mallinfo info = mallinfo(); 85 | // printf("Memory in use: %d bytes\n", info.usmblks + info.uordblks); 86 | // printf("Total heap size: %d bytes\n", info.arena); 87 | struct mallinfo meminfo; 88 | meminfo = mallinfo(); 89 | return meminfo.usmblks; 90 | 91 | #elif OS_APPLE 92 | 93 | // Use Mach functions. 94 | task_basic_info machInfo = { 0 }; 95 | mach_port_t machTask = mach_task_self(); 96 | mach_msg_type_number_t machCount = TASK_BASIC_INFO_COUNT; 97 | if ( task_info( machTask, TASK_BASIC_INFO, reinterpret_cast(&machInfo), &machCount ) == KERN_SUCCESS ) 98 | // Return value is in bytes 99 | return ((double) machInfo.resident_size) / 1000; 100 | else { 101 | std::cerr << "Detected Apple OS to obtain process memory usage, but call to kernel failed. Will report 0." << std::endl; 102 | return 0; // error 103 | } 104 | #elif USE_WIN32_API 105 | PROCESS_MEMORY_COUNTERS pmc; 106 | GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)); 107 | SIZE_T physMemUsedByMe = pmc.WorkingSetSize; 108 | 109 | return physMemUsedByMe / 1024 ; 110 | #else 111 | std::cerr << "Unsupported OS to obtain process memory usage. Will report 0." << std::endl; 112 | return 0; // unsupported 113 | 114 | #endif 115 | } 116 | 117 | 118 | 119 | /** in Bytes */ 120 | size_t getResidentMemory() { 121 | static bool memAvailable = true; 122 | if (memAvailable) { 123 | unsigned long val = MemoryUsed(); 124 | if (val == 0) 125 | memAvailable = false; 126 | return val ; 127 | } 128 | return 0; 129 | } 130 | 131 | 132 | } // namespace process 133 | -------------------------------------------------------------------------------- /ddd/process.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __PROCESS_H__ 2 | #define __PROCESS_H__ 3 | 4 | // for size_t 5 | #include 6 | 7 | 8 | namespace process { 9 | 10 | // rely on "times" 11 | double getTotalTime (); 12 | 13 | size_t getResidentMemory () ; 14 | 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /ddd/statistic.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | #include 24 | #include 25 | #include "ddd/SDD.h" 26 | #include "ddd/DDD.h" 27 | 28 | 29 | 30 | typedef enum {CSV, LATEX} OutputType; 31 | 32 | class Statistic { 33 | /// number of final states 34 | long double nb_Stat; 35 | /// number of final DDD nodes 36 | long double DDD_size; 37 | /// number of final SDD nodes 38 | long double SDD_size; 39 | /// peak DDD unicity table size 40 | long double DDD_peak_size; 41 | /// peak DDD unicity table size 42 | long double SDD_peak_size; 43 | /// total time 44 | double total_time; 45 | /// resident mem (kb) 46 | size_t memory; 47 | /// Hom final 48 | double nbHom; 49 | /// SHom final 50 | double nbShom; 51 | /// DDD cache 52 | double ddd_cache; 53 | /// SDD cache peak 54 | double sdd_cache; 55 | /// Mode : include SDD or not 56 | bool isPureDDD; 57 | /// Mode : outputType 58 | OutputType style; 59 | /// Name of this statistic 60 | std::string stat_name; 61 | 62 | /// Size of SHom cache 63 | size_t shom_cache; 64 | 65 | /// show peak 66 | bool show_peak; 67 | /// load from a SDD 68 | void load (const SDD & s); 69 | /// load from a DDD 70 | void load (const DDD & s); 71 | public: 72 | 73 | /// Create a statistic for the current SDD s, style LATEX by default. 74 | /// The statistic is sampled and stored, this call triggers SDD mode (more columns). 75 | /// \param s the SDD used for final node and state count. 76 | /// \param name the row name (first column) 77 | /// \param style use LATEX for formatted latex table or CSV to import in excel or gnumeric. 78 | /// \param show_peak if you want to show peak size instead of current size for caches 79 | Statistic (const SDD & s, const std::string & name, OutputType style=LATEX, bool show_peak = true); 80 | /// Create a statistic for the current DDD s, style LATEX by default. 81 | /// The statistic is sampled and stored, this call triggers DDD mode (less columns). 82 | /// \param s the DDD used for final node and state count. 83 | /// \param name the row name (first column) 84 | /// \param style use LATEX for formatted latex table or CSV to import in excel or gnumeric. 85 | /// \param show_peak if you want to show peak size instead of current size for caches 86 | Statistic (const DDD & s, const std::string & name, OutputType style=LATEX, bool show_peak = true); 87 | 88 | /// Print column headers, using current style. 89 | /// For latex this also outputs a header (\begin document etc...). 90 | void print_header (std::ostream & os); 91 | 92 | /// Print trailer. 93 | /// The trailer includes a key to reading the columns. In latex mode it also closes the document. 94 | void print_trailer (std::ostream & os, bool withLegend=true); 95 | 96 | /// Print a line for current statistic. 97 | /// To produce tables call print_header once then print_line for all your statistics. 98 | void print_line (std::ostream &os); 99 | 100 | /// Convenience print a table. 101 | /// Useful if you have a single stat to show. 102 | /// Calls print_header,print_line,print_trailer in this order. 103 | void print_table (std::ostream & os); 104 | 105 | /// Print a legend to the table. 106 | /// give interpretation for row headers 107 | void print_legend (std::ostream & os); 108 | 109 | /// Setter for style. 110 | void setStyle (OutputType style); 111 | 112 | /// Accessors. 113 | double getTime() const { return total_time; } 114 | long double getNbStates () const { return nb_Stat; } 115 | 116 | }; 117 | 118 | -------------------------------------------------------------------------------- /ddd/util/configuration.hh: -------------------------------------------------------------------------------- 1 | #ifndef _D3_CONFIGURATION_HH_ 2 | #define _D3_CONFIGURATION_HH_ 3 | 4 | #ifdef PARALLEL_DD 5 | #ifndef REENTRANT 6 | #define REENTRANT 7 | #endif 8 | #endif 9 | 10 | #include "ddd/util/hash_support.hh" 11 | #include "ddd/util/ext_hash_map.hh" 12 | #include "ddd/util/tbb_hash_map.hh" 13 | 14 | 15 | template 16 | < 17 | typename Key, 18 | typename Data, 19 | typename HashKey = d3::util::hash, 20 | typename EqualKey = d3::util::equal 21 | > struct hash_map 22 | { 23 | # ifdef REENTRANT 24 | typedef tbb_hash_map type; 25 | # else 26 | typedef ext_hash_map type; 27 | #endif 28 | }; 29 | 30 | namespace conf 31 | { 32 | 33 | template 34 | < 35 | typename T 36 | > 37 | struct allocator 38 | { 39 | typedef typename std::allocator type; 40 | }; 41 | 42 | } // conf 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /ddd/util/dotExporter.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2004-2008 Yann Thierry-Mieg */ 6 | /* */ 7 | /* This program is free software; you can redistribute it and/or modify */ 8 | /* it under the terms of the GNU Lesser General Public License as */ 9 | /* published by the Free Software Foundation; either version 3 of the */ 10 | /* License, or (at your option) any later version. */ 11 | /* This program is distributed in the hope that it will be useful, */ 12 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 13 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 14 | /* GNU LEsserGeneral Public License for more details. */ 15 | /* */ 16 | /* You should have received a copy of the GNU Lesser General Public License */ 17 | /* along with this program; if not, write to the Free Software */ 18 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 19 | /* */ 20 | /****************************************************************************/ 21 | 22 | #ifndef __DOTEXPORTER__H__ 23 | #define __DOTEXPORTER__H__ 24 | 25 | 26 | #include "ddd/SDD.h" 27 | #include "ddd/DDD.h" 28 | using namespace std; 29 | 30 | 31 | /* exports a SDD g into the file specified by path. 32 | * If hierarchical is true, single dot file is produced with dashed lines to represent arc values. 33 | * The default produces one graph xxx.dot with SDD and another with DDD d3XXX.dot 34 | */ 35 | int exportDot(const GSDD & g, const string & path="test",bool hierarchical=false, bool multiT=true); 36 | 37 | 38 | /* Exports the full unique table of SDD into a dot file specified by path. 39 | * Highlights nodes that belong to the SDD provided. 40 | * NB : avoid if unique table size is too large... 41 | **/ 42 | void exportUniqueTable ( const GSDD & d, const string & path="table" ); 43 | 44 | class dotExporter; 45 | 46 | /** a more evolved API for highlighting parts of a graph **/ 47 | class dotHighlight { 48 | class dotExporter * de; 49 | public: 50 | virtual ~dotHighlight (); 51 | // prepares to export in file named "path" 52 | dotHighlight (const string & path); 53 | // Call this to empty the "known nodes" lists 54 | void initialize (const string & path); 55 | // Sets the vars to be aligned 56 | void setVarAlignment (bool isAligned); 57 | // This adds an SDD node and all sons to a graph 58 | void addSDD (const GSDD & g); 59 | // This adds an SDD node and names it with the provided label 60 | void addSDD (const GSDD & g, const string &label); 61 | // This changes the color of a node and sons 62 | void setColor(const GSDD & g, const string & color); 63 | // This creates the actual file 64 | void exportDot(); 65 | }; 66 | 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /ddd/util/hash_set.hh: -------------------------------------------------------------------------------- 1 | #ifndef _HASH_SET_HH_ 2 | #define _HASH_SET_HH_ 3 | 4 | #ifndef USE_STD_HASH 5 | #include 6 | #else 7 | #include 8 | #endif 9 | 10 | #include "ddd/util/configuration.hh" 11 | 12 | namespace d3 { 13 | 14 | template 15 | < 16 | typename Key 17 | , typename Hash = d3::util::hash 18 | , typename Compare = d3::util::equal 19 | , typename Allocator = typename conf::allocator::type 20 | > 21 | struct hash_set 22 | { 23 | #ifndef USE_STD_HASH 24 | typedef typename google::sparse_hash_set type; 25 | #else 26 | typedef typename std::unordered_set type; 27 | #endif 28 | }; 29 | 30 | } // namespace d3 31 | 32 | #endif /* _SET_HH_ */ 33 | -------------------------------------------------------------------------------- /ddd/util/map.hh: -------------------------------------------------------------------------------- 1 | #ifndef _MAP_HH_ 2 | #define _MAP_HH_ 3 | 4 | #include 5 | #include 6 | 7 | #include "ddd/util/configuration.hh" 8 | 9 | namespace d3 { namespace util 10 | { 11 | 12 | template 13 | < 14 | typename Key 15 | , typename Data 16 | , typename Compare = std::less 17 | , typename Allocator = typename conf::allocator< std::pair >::type 18 | > 19 | struct map 20 | { 21 | typedef typename std::map type; 22 | }; 23 | 24 | }} // namespace d3::util 25 | 26 | #endif /* _MAP_HH_ */ 27 | -------------------------------------------------------------------------------- /ddd/util/set.hh: -------------------------------------------------------------------------------- 1 | #ifndef _SET_HH_ 2 | #define _SET_HH_ 3 | 4 | #include 5 | 6 | #include "ddd/util/configuration.hh" 7 | 8 | namespace d3 { 9 | 10 | template 11 | < 12 | typename Key 13 | , typename Compare = std::less 14 | , typename Allocator = typename conf::allocator::type 15 | > 16 | struct set 17 | { 18 | typedef typename std::set type; 19 | }; 20 | 21 | 22 | template 23 | < 24 | typename Key 25 | , typename Compare = std::less 26 | , typename Allocator = typename conf::allocator::type 27 | > 28 | struct multiset 29 | { 30 | typedef typename std::multiset type; 31 | }; 32 | 33 | 34 | 35 | 36 | } // namespace d3 37 | 38 | #endif /* _SET_HH_ */ 39 | -------------------------------------------------------------------------------- /ddd/util/tbb_hash_map.hh: -------------------------------------------------------------------------------- 1 | #ifndef _CONCURRENT_HASH_MAP_HH_ 2 | #define _CONCURRENT_HASH_MAP_HH_ 3 | 4 | #ifdef REENTRANT 5 | 6 | #include 7 | #include 8 | 9 | #include "ddd/util/hash_support.hh" 10 | 11 | template 12 | < 13 | typename Key, 14 | typename Data, 15 | typename HashKey = d3::util::hash, 16 | typename EqualKey = d3::util::equal 17 | > 18 | struct tbb_hash_map 19 | { 20 | struct hash_compare 21 | { 22 | bool 23 | equal( const Key& k1, const Key& k2) 24 | { 25 | return EqualKey()(k1,k2); 26 | } 27 | 28 | size_t 29 | hash( const Key& k) 30 | { 31 | return HashKey()(k); 32 | } 33 | 34 | }; 35 | 36 | // Types 37 | typedef tbb::mutex mutex; 38 | typedef tbb::concurrent_hash_map internal_hash_map; 39 | typedef typename internal_hash_map::iterator iterator; 40 | typedef typename internal_hash_map::const_iterator const_iterator; 41 | typedef typename internal_hash_map::size_type size_type; 42 | typedef typename internal_hash_map::accessor accessor; 43 | typedef typename internal_hash_map::const_accessor const_accessor; 44 | 45 | // Attributes 46 | internal_hash_map map_; 47 | mutex map_mutex_; 48 | 49 | // Methods 50 | tbb_hash_map() 51 | : 52 | map_(), 53 | map_mutex_() 54 | { 55 | } 56 | 57 | iterator 58 | begin() 59 | { 60 | return map_.begin(); 61 | } 62 | 63 | const_iterator 64 | begin() const 65 | { 66 | return map_.begin(); 67 | } 68 | 69 | iterator 70 | end() 71 | { 72 | return map_.end(); 73 | } 74 | 75 | const_iterator 76 | end() const 77 | { 78 | return map_.end(); 79 | } 80 | 81 | size_type 82 | size() const 83 | { 84 | return map_.size(); 85 | } 86 | 87 | bool 88 | empty() const 89 | { 90 | return map_.empty(); 91 | } 92 | 93 | void 94 | clear() 95 | { 96 | // non reentrant method, need to lock the hash_map 97 | mutex::scoped_lock lock(map_mutex_); 98 | map_.clear(); 99 | } 100 | 101 | bool 102 | find( const_accessor& result, const Key& key) const 103 | { 104 | return map_.find(result,key); 105 | } 106 | 107 | bool 108 | find( accessor& result, const Key& key) 109 | { 110 | return map_.find(result,key); 111 | } 112 | 113 | bool 114 | insert( const_accessor& result, const Key& key) 115 | { 116 | return map_.insert(result,key); 117 | } 118 | 119 | bool 120 | insert( accessor& result, const Key& key) 121 | { 122 | return map_.insert(result,key); 123 | } 124 | 125 | bool 126 | erase( const Key& key) 127 | { 128 | return map_.erase(key); 129 | } 130 | 131 | }; 132 | 133 | #endif // REENTRANT 134 | 135 | #endif /* _CONCURRENT_HASH_MAP_HH_ */ 136 | -------------------------------------------------------------------------------- /ddd/util/vector.hh: -------------------------------------------------------------------------------- 1 | #ifndef _VECTOR_HH_ 2 | #define _VECTOR_HH_ 3 | 4 | #include 5 | 6 | #include "ddd/util/configuration.hh" 7 | 8 | namespace d3 { namespace util 9 | { 10 | 11 | template 12 | < 13 | typename T 14 | , typename Allocator = typename conf::allocator::type 15 | > 16 | struct vector 17 | { 18 | typedef typename std::vector type; 19 | }; 20 | 21 | }} // namespace d3::util 22 | 23 | 24 | #endif /* _VECTOR_HH_ */ 25 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /tst1 2 | /tst2 3 | /tst3 4 | /tst4 5 | /tst5 6 | /tst6 7 | /tst7 8 | /tst8 9 | /tst9 10 | /tst10 11 | /tst11 12 | /tst12 13 | /tst14 14 | /tst15 15 | /Makefile 16 | -------------------------------------------------------------------------------- /demo/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = hanoi morpion 2 | 3 | noinst_PROGRAMS = tst1 tst2 tst3 tst4 tst5 tst6 tst7 tst8 tst9 tst10 tst11 tst12 tst14 tst15 #tst13 4 | 5 | # Flags for TBB 6 | if WITH_LIBTBBINC_PATH 7 | TBBINC_FLAGS=-I $(LIBTBB_INC) 8 | endif 9 | 10 | if WITH_LIBTBBBIN_PATH 11 | TBBBIN_FLAGS=-L $(LIBTBB_BIN) 12 | endif 13 | 14 | DDD_SRCDIR = $(top_srcdir) 15 | DDD_BUILDDIR = $(top_builddir)/ddd 16 | 17 | AM_CPPFLAGS = -I $(DDD_SRCDIR) -g -Wall $(TBBINC_FLAGS) 18 | AM_LDFLAGS = $(LDFLAGS) 19 | AM_LDFLAGS += $(STATICFLAGS) 20 | LDADD = $(DDD_BUILDDIR)/libDDD_d.la 21 | 22 | if REENTRANT 23 | AM_LDFLAGS += -ltbb $(TBBBIN_FLAGS) 24 | endif 25 | 26 | PLUSPLUS = PlusPlus.hh PlusPlus.cpp 27 | SETVAR = SetVar.hh SetVar.cpp 28 | SWAPVAR = PermuteVar.hh PermuteVar.cpp 29 | SWAP_MLHOM = SwapMLHom.hh SwapMLHom.cpp 30 | 31 | tst1_SOURCES = tst1.cpp 32 | tst2_SOURCES = tst2.cpp 33 | tst3_SOURCES = tst3.cpp $(PLUSPLUS) 34 | tst4_SOURCES = tst4.cpp $(PLUSPLUS) 35 | tst5_SOURCES = tst5.cpp $(SETVAR) 36 | tst6_SOURCES = tst6.cpp $(SWAPVAR) 37 | tst7_SOURCES = tst7.cpp 38 | tst8_SOURCES = tst8.cpp 39 | tst9_SOURCES = tst9.cpp 40 | tst10_SOURCES = tst10.cpp $(PLUSPLUS) 41 | tst11_SOURCES = tst11.cpp 42 | tst12_SOURCES = tst12.cpp 43 | tst14_SOURCES = tst14.cpp 44 | tst15_SOURCES = tst15.cpp $(SWAP_MLHOM) 45 | #tst13_SOURCES = tst13.cpp 46 | #tst13_LDADD = $(DDD_BUILDDIR)/libDDD_ev.a 47 | #tst13_CPPFLAGS = -I $(DDD_SRCDIR) -g -Wall -D EVDDD 48 | # tst2_CPPFLAGS = 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /demo/PermuteVar.cpp: -------------------------------------------------------------------------------- 1 | #include "PermuteVar.hh" 2 | 3 | /***********************************************************/ 4 | /* Define the strongHom Permute : var1,var2 = var2,var1 */ 5 | /* using 3 strongHoms : PermuteUp, PermuteDown, PermuteFin */ 6 | /***********************************************************/ 7 | 8 | // ********************************************** 9 | class PermuteUp:public StrongHom { 10 | int var, val; // var1 <= var2 11 | public: 12 | PermuteUp(int vr, int vl):var(vr),val(vl) {} 13 | 14 | GDDD phiOne() const { 15 | return GDDD::top; 16 | } 17 | 18 | GHom phi(int vr, int vl) const { 19 | return GHom(vr,vl,GHom(var,val)); 20 | } 21 | 22 | size_t hash() const { 23 | return var+val+400; 24 | } 25 | 26 | bool operator==(const StrongHom &s) const { 27 | PermuteUp* ps = (PermuteUp*)&s; 28 | return (var == ps->var && val == ps->val); 29 | } 30 | _GHom * clone () const { return new PermuteUp(*this); } 31 | }; 32 | 33 | // ********************************************** 34 | class PermuteDown:public StrongHom { 35 | int var, val; // var1 <= var2 36 | public: 37 | PermuteDown(int vr, int vl):var(vr),val(vl) {} 38 | 39 | GDDD phiOne() const { 40 | return GDDD::top; 41 | } 42 | 43 | GHom phi(int vr, int vl) const { 44 | if (var == vr) 45 | return GHom(0,vl,GHom(vr,val)); 46 | if (var != vr) 47 | return GHom(PermuteUp(vr,vl)) & GHom(this); 48 | return GHom::id; 49 | } 50 | 51 | size_t hash() const { 52 | return var+val+300; 53 | } 54 | 55 | bool operator==(const StrongHom &s) const { 56 | PermuteDown* ps = (PermuteDown*)&s; 57 | return var == ps->var && val == ps->val; 58 | } 59 | _GHom * clone () const { return new PermuteDown(*this); } 60 | }; 61 | 62 | 63 | // ********************************************** 64 | class PermuteFin:public StrongHom { 65 | int var; // var1 <=> var2 66 | public: 67 | PermuteFin(int vr):var(vr) {} 68 | 69 | GDDD phiOne() const { 70 | return GDDD::one; 71 | } 72 | 73 | GHom phi(int, int vl) const { 74 | return GHom(var,vl); 75 | } 76 | 77 | size_t hash() const { 78 | return var+200; 79 | } 80 | 81 | bool operator==(const StrongHom &s) const { 82 | PermuteFin* ps = (PermuteFin*)&s; 83 | return var == ps->var; 84 | } 85 | _GHom * clone () const { return new PermuteFin(*this); } 86 | }; 87 | 88 | // ********************************************** 89 | class Permute:public StrongHom { 90 | int var1, var2; // var1 <=> var2 91 | public: 92 | Permute(int v1, int v2):var1(v1),var2(v2) {} 93 | 94 | GDDD phiOne() const { 95 | return GDDD::one; 96 | } 97 | 98 | GHom phi(int vr, int vl) const { 99 | if (var1 == vr) 100 | return GHom(PermuteFin(var1)) & GHom(PermuteDown(var2,vl)); 101 | if (var2 == vr) 102 | return GHom(PermuteFin(var2)) & GHom(PermuteDown(var1,vl)); 103 | return GHom(vr,vl,GHom(this)); 104 | } 105 | 106 | size_t hash() const { 107 | return var1+var2+100; 108 | } 109 | 110 | bool operator==(const StrongHom &s) const { 111 | Permute* ps = (Permute*)&s; 112 | return var1 == ps->var1 && var2 == ps->var2; 113 | } 114 | _GHom * clone () const { return new Permute(*this); } 115 | }; 116 | 117 | // User function : Construct a Hom for a Strong Hom _SetVar 118 | GHom permute(int var1,int var2){return Permute(var1,var2);}; 119 | -------------------------------------------------------------------------------- /demo/PermuteVar.hh: -------------------------------------------------------------------------------- 1 | #ifndef __PERMUTE_HH__ 2 | #define __PERMUTE_HH__ 3 | 4 | #include "ddd/Hom.h" 5 | 6 | // User function : Construct a Hom 7 | // Will permute or swap the value of var1 and var2 8 | // e.g. v1=2 & v2=3 =>> v1=3 & v2=2 9 | GHom permute(int var1,int var2); 10 | 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /demo/PlusPlus.cpp: -------------------------------------------------------------------------------- 1 | #include "PlusPlus.hh" 2 | #include "ddd/hashfunc.hh" 3 | 4 | // Increment the first value of var 5 | class _plusplus:public StrongHom { 6 | int var; 7 | public: 8 | _plusplus(int vr):var(vr) {}; 9 | 10 | GDDD phiOne() const { 11 | return GDDD::one; 12 | } 13 | 14 | GHom phi(int vr, int vl) const { 15 | if (vr == var) 16 | return GHom(vr,vl+1); 17 | else 18 | return GHom(vr,vl,GHom(this)); 19 | } 20 | 21 | size_t hash() const { 22 | return ddd::wang32_hash(var); 23 | } 24 | 25 | bool operator==(const StrongHom &s) const { 26 | _plusplus* ps = (_plusplus*)&s; 27 | return var == ps->var; 28 | } 29 | 30 | _GHom * clone () const { return new _plusplus(*this); } 31 | }; 32 | 33 | GHom plusplus(int vr){return _plusplus(vr);}; 34 | 35 | 36 | // Increment the first value of var 37 | class _plusplusAll:public StrongHom { 38 | int var; 39 | public: 40 | _plusplusAll(int vr):var(vr) {}; 41 | 42 | GDDD phiOne() const { 43 | return GDDD::one; 44 | } 45 | 46 | GHom phi(int vr, int vl) const { 47 | if (vr == var) 48 | return GHom(vr,vl+1,GHom(this)); 49 | else 50 | return GHom(vr,vl,GHom(this)); 51 | } 52 | 53 | size_t hash() const { 54 | return ddd::wang32_hash(var); 55 | } 56 | 57 | bool operator==(const StrongHom &s) const { 58 | _plusplusAll* ps = (_plusplusAll*)&s; 59 | return var == ps->var; 60 | } 61 | 62 | _GHom * clone () const { return new _plusplusAll(*this); } 63 | }; 64 | 65 | GHom plusplusAll(int vr){return _plusplusAll(vr);}; 66 | 67 | /// increment the value of the next variable 68 | class _plusplusFirst:public StrongHom { 69 | public: 70 | _plusplusFirst() {} 71 | 72 | GDDD phiOne() const { 73 | return GDDD::one; 74 | } 75 | 76 | GHom phi(int vr, int vl) const { 77 | return GHom(vr,vl+1); 78 | } 79 | 80 | size_t hash() const { 81 | return 23; 82 | } 83 | 84 | bool operator==(const StrongHom&) const { 85 | return true; 86 | } 87 | _GHom * clone () const { return new _plusplusFirst(*this); } 88 | }; 89 | 90 | /// User function : Construct a Hom for a Strong Hom _plusplus 91 | GHom plusplusFirst(){return _plusplusFirst();}; 92 | -------------------------------------------------------------------------------- /demo/PlusPlus.hh: -------------------------------------------------------------------------------- 1 | #ifndef __PLUSPLUS_HH 2 | #define __PLUSPLUS_HH 3 | 4 | #include "ddd/Hom.h" 5 | // User function : Construct a Hom for a Strong Hom _plusplus 6 | // Increments the value of the first occurrence of var 7 | GHom plusplus(int vr); 8 | 9 | // Increments the value of all occurrences of var 10 | GHom plusplusAll(int vr); 11 | 12 | // Increments the value the next variable 13 | GHom plusplusFirst(); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /demo/README: -------------------------------------------------------------------------------- 1 | This folder contains simple examples designed to get you started with libDDD. 2 | 3 | The Makefile.am shows how to set flags to compile on either the debug version (libddd_d.a compiled with -g -o0) or the standard optimized libddd.a. 4 | 5 | ** tst1 : 6 | 7 | A simple example exhibiting terminal constants, definition of DDD variables, and use of the basic set theory operators over DDD. 8 | 9 | ** tst2 : 10 | 11 | This example introduces some library provided homomorphisms for concatenation, use of constants... 12 | 13 | ** tst3 : 14 | 15 | This examples shows how to define a custom homomorphism to increment a variable. 16 | 17 | ** tst4 : 18 | 19 | A variant over the previous example which increments all variables. 20 | 21 | ** tst5 : 22 | 23 | An example of a more complex homomorphism combination to assign the value of a variable to another using swap, up and down. (see icatpn'02 paper for a description). 24 | 25 | ** tst6 : 26 | 27 | A variant over the previous to swap the value of two variables in a single pass. 28 | 29 | ** tst7 : 30 | 31 | A simple example showing how to invoke the garbage collector. 32 | 33 | ** tst8 : 34 | 35 | A simple example exhibiting how to carry operations inside homomorphisms. 36 | It also shows how to use Statistics class to produce tables of stats. 37 | 38 | ** tst9 : 39 | 40 | A small test, that raised a bug in an old version of the library. 41 | // FIXME : we should move this from demo/ to test/ folder. 42 | 43 | ** tst10 : 44 | 45 | A small example showing the use of a fixpoint to produce a saturation effect. 46 | This example does not use skip_variable of auto-saturation (available with libDDD >= 1.4) 47 | 48 | ** tst11 : 49 | 50 | A complex test, added by V. Beaudenon, that raised a bug in an old version of the library. 51 | // FIXME : we should move this from demo/ to test/ folder. 52 | 53 | ** tst12 : 54 | 55 | A example exhibiting the use of edge valued DDD in EVDDD mode. 56 | It also shows how to use the dotExporter functionality to produce dot graphs of DDD. 57 | 58 | This example is meant to be compared with the behavior of tst13. 59 | // FIXME : tst12 and tst13 could use more comments. 60 | 61 | ** tst13 : 62 | 63 | The same example exhibiting the use of edge valued DDD in EVDDD mode. 64 | We use the library defined special variable DISTANCE to indicate we use distance nodes. 65 | You must edit Makefile.am to build tst13, and also build libddd_ev.a which is not built by default, by editing src/Makefile.am. 66 | 67 | 68 | -------------------------------------------------------------------------------- /demo/SetVar.cpp: -------------------------------------------------------------------------------- 1 | #include "SetVar.hh" 2 | 3 | /********************************************************/ 4 | /* Define the strongHom _SetVar : var2 = var1 */ 5 | /* using 3 strongHoms : _SetCst, _SetVarUp, _SetVarDown */ 6 | /********************************************************/ 7 | 8 | class _SetCst:public StrongHom { 9 | int var, val; 10 | public: 11 | _SetCst(int vr, int vl):var(vr),val(vl) {} 12 | 13 | GDDD phiOne() const { 14 | return GDDD::one; 15 | } 16 | 17 | GHom phi(int vr, int vl) const { 18 | if (var == vr) 19 | return GHom(vr,val); 20 | else 21 | return GHom(vr,vl,GHom(this)); 22 | } 23 | 24 | size_t hash() const { 25 | return var+val; 26 | } 27 | 28 | bool operator==(const StrongHom &s) const { 29 | _SetCst* ps = (_SetCst*)&s; 30 | return var == ps->var && val == ps->val; 31 | } 32 | 33 | _GHom * clone () const { return new _SetCst(*this); } 34 | }; 35 | 36 | // ********************************************** 37 | class _SetVarUp:public StrongHom { 38 | int var, val; 39 | public: 40 | _SetVarUp(int vr, int vl):var(vr),val(vl) {} 41 | 42 | GDDD phiOne() const { 43 | return GDDD::top; 44 | } 45 | 46 | GHom phi(int vr, int vl) const { 47 | return GHom(vr,vl,GHom(var,val)); 48 | } 49 | 50 | size_t hash() const { 51 | return var+val; 52 | } 53 | 54 | bool operator==(const StrongHom &s) const { 55 | _SetVarUp* ps = (_SetVarUp*)&s; 56 | return var == ps->var && val == ps->val; 57 | } 58 | 59 | _GHom * clone () const { return new _SetVarUp(*this); } 60 | }; 61 | 62 | // ********************************************** 63 | class _SetVarDown:public StrongHom { 64 | int var1, var2; // var1 <= var2 65 | public: 66 | _SetVarDown(int v1, int v2):var1(v1),var2(v2) {} 67 | 68 | GDDD phiOne() const { 69 | return GDDD::top; 70 | } 71 | 72 | GHom phi(int vr, int vl) const { 73 | if (var2 == vr) 74 | return GHom(var1,vl,GHom(vr,vl)); 75 | else 76 | return GHom(_SetVarUp(vr,vl)) & GHom(this); 77 | } 78 | 79 | size_t hash() const { 80 | return var1+var2; 81 | } 82 | 83 | bool operator==(const StrongHom &s) const { 84 | _SetVarDown* ps = (_SetVarDown*)&s; 85 | return var1 == ps->var1 && var2 == ps->var2; 86 | } 87 | _GHom * clone () const { return new _SetVarDown(*this); } 88 | }; 89 | 90 | // ********************************************** 91 | class _SetVar:public StrongHom { 92 | int var1, var2; // var1 <= var2 93 | public: 94 | _SetVar(int v1, int v2):var1(v1),var2(v2) {} 95 | 96 | GDDD phiOne() const { 97 | return GDDD::one; 98 | } 99 | 100 | GHom phi(int vr, int vl) const { 101 | if (var2 == vr) 102 | return GHom(vr,vl,_SetCst(var1,vl)); 103 | if (var1 != vr) 104 | return GHom(vr,vl,GHom(this)); 105 | return _SetVarDown(var1, var2); 106 | } 107 | 108 | size_t hash() const { 109 | return var1+var2; 110 | } 111 | 112 | bool operator==(const StrongHom &s) const { 113 | _SetVar* ps = (_SetVar*)&s; 114 | return var1 == ps->var1 && var2 == ps->var2; 115 | } 116 | _GHom * clone () const { return new _SetVar(*this); } 117 | }; 118 | 119 | // User function : Construct a Hom for a Strong Hom _SetVar 120 | GHom setCst(int var,int val){return _SetCst(var,val);}; 121 | GHom setVar(int var1,int var2){return _SetVar(var1,var2);}; 122 | -------------------------------------------------------------------------------- /demo/SetVar.hh: -------------------------------------------------------------------------------- 1 | #ifndef __SET_VAR_HH__ 2 | #define __SET_VAR_HH__ 3 | 4 | #include "ddd/Hom.h" 5 | // User functions : Construct hom 6 | 7 | // Assign val to the first occurrence of variable var 8 | GHom setCst(int var,int val); 9 | // Assign the value of variable var2 to var1, order insensitive. 10 | GHom setVar(int var1,int var2); 11 | 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /demo/SwapMLHom.cpp: -------------------------------------------------------------------------------- 1 | #include "SwapMLHom.hh" 2 | #include "ddd/MLHom.h" 3 | #include "ddd/Hom_Basic.hh" 4 | 5 | class _SwapQuery : public StrongMLHom { 6 | int var; 7 | int val; 8 | int vset; 9 | public: 10 | _SwapQuery(int vr, int vl, int vrs): var(vr), val(vl), vset(vrs) {} 11 | 12 | // actually not useful currently 13 | bool skip_variable(int v) const { 14 | return v != var; 15 | } 16 | 17 | HomNodeMap phiOne() const { 18 | HomNodeMap res; 19 | std::cerr << "MLHom should not reach this point" << std::endl; 20 | assert(false); 21 | return res; 22 | } 23 | 24 | HomHomMap phi(int vr, int vl) const { 25 | // the skip_variable mechanism is not implemented yet, so this is mandatory 26 | if (vr == var) { 27 | GHom homup = GHom(vset, vl); 28 | GHom homdown = GHom(vr, val, GHom::id); 29 | 30 | HomHomMap ret; 31 | ret.add(homup, homdown); 32 | return ret; 33 | } else { 34 | HomHomMap ret; 35 | ret.add(GHom::id, MLHom(vr, vl, *this)); 36 | return ret; 37 | } 38 | } 39 | 40 | size_t hash() const { 41 | return d3::util::hash()(var) * d3::util::hash()(val) ^ d3::util::hash()(vset); 42 | } 43 | 44 | bool operator==(const StrongMLHom &s) const { 45 | const _SwapQuery * ss = (const _SwapQuery *)&s; 46 | return var == ss->var && val == ss->val && vset == ss->vset; 47 | } 48 | 49 | _MLHom * clone() const { 50 | return new _SwapQuery(*this); 51 | } 52 | }; 53 | 54 | /** 55 | get down the DDD until a variable is found, then uses a MLHom 56 | */ 57 | class _Swap : public StrongHom { 58 | int var1; 59 | int var2; 60 | public: 61 | _Swap(int v1, int v2) : var1(v1), var2(v2) {} 62 | 63 | // affects only the swapped variables 64 | bool skip_variable(int vr) const { 65 | return (vr != var1) && (vr != var2); 66 | } 67 | 68 | GDDD phiOne() const { 69 | return GDDD::one; 70 | } 71 | 72 | GHom phi(int vr, int vl) const { 73 | if (vr == var1) { 74 | return MLHom(_SwapQuery(var2, vl, var1)); 75 | } else if (vr == var2) { 76 | return MLHom(_SwapQuery(var1, vl, var2)); 77 | } else { // should not happen, due to skip 78 | assert(false); 79 | return GHom::id; 80 | } 81 | } 82 | 83 | size_t hash() const { 84 | return 18043*(var1^(var2+1)); 85 | } 86 | 87 | void print (std::ostream & os) const { 88 | os << "[ Swap(" << DDD::getvarName(var1) << "," << DDD::getvarName(var2) << ") ]"; 89 | } 90 | 91 | bool operator==(const StrongHom &s) const { 92 | _Swap* ps = (_Swap*)&s; 93 | return var1 == ps->var1 && var2 == ps->var2; 94 | } 95 | _GHom * clone () const { return new _Swap(*this); } 96 | }; 97 | 98 | GHom Swap(int i,int j) { 99 | if (i == j) { 100 | return GHom::id; 101 | } 102 | return _Swap(std::min(i, j), std::max(i, j)); 103 | } 104 | -------------------------------------------------------------------------------- /demo/SwapMLHom.hh: -------------------------------------------------------------------------------- 1 | #ifndef SWAP_HH 2 | #define SWAP_HH 3 | 4 | #include "ddd/Hom.h" 5 | 6 | /// swaps values of variables at i and j 7 | GHom Swap(int i, int j); 8 | 9 | #endif -------------------------------------------------------------------------------- /demo/hanoi/.gitignore: -------------------------------------------------------------------------------- 1 | /hanoi_v1 2 | /hanoi_v1_bis 3 | /hanoi_v1_ter 4 | /hanoi_v2 5 | /hanoi_v3 6 | /hanoi_v4 7 | /hanoi_v5 8 | /hanoi_v6 9 | /hanoi_v7 10 | /hanoi_v8 11 | /hanoi_v9 12 | /Makefile 13 | -------------------------------------------------------------------------------- /demo/hanoi/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = hanoi_v1 \ 2 | hanoi_v1_bis \ 3 | hanoi_v1_ter \ 4 | hanoi_v2 \ 5 | hanoi_v3 \ 6 | hanoi_v4 \ 7 | hanoi_v5 \ 8 | hanoi_v6 \ 9 | hanoi_v7 \ 10 | hanoi_v8 \ 11 | hanoi_v9 12 | 13 | DDD_SRCDIR = $(top_srcdir) 14 | DDD_BUILDDIR = $(top_builddir)/ddd 15 | 16 | # Flags for TBB 17 | if WITH_LIBTBBINC_PATH 18 | TBBINC_FLAGS=-I $(LIBTBB_INC) 19 | endif 20 | 21 | if WITH_LIBTBBBIN_PATH 22 | TBBBIN_FLAGS=-L $(LIBTBB_BIN) 23 | endif 24 | 25 | AM_CPPFLAGS = -I $(DDD_SRCDIR) -Wall -Wextra -O3 $(TBBINC_FLAGS) 26 | AM_LDFLAGS = $(LDFLAGS) 27 | AM_LDFLAGS += $(STATICFLAGS) 28 | LDADD = $(DDD_BUILDDIR)/libDDD.la 29 | 30 | if REENTRANT 31 | AM_LDFLAGS += -ltbb $(TBBBIN_FLAGS) 32 | endif 33 | 34 | HOMFILE = hanoiHom.hh hanoiHom.cpp 35 | 36 | hanoi_v1_SOURCES = hanoi_v1.cpp $(HOMFILE) 37 | hanoi_v1_bis_SOURCES = hanoi_v1_bis.cpp $(HOMFILE) 38 | hanoi_v1_ter_SOURCES = hanoi_v1_ter.cpp $(HOMFILE) 39 | hanoi_v2_SOURCES = hanoi_v2.cpp $(HOMFILE) 40 | hanoi_v3_SOURCES = hanoi_v3.cpp $(HOMFILE) 41 | hanoi_v4_SOURCES = hanoi_v4.cpp $(HOMFILE) 42 | hanoi_v5_SOURCES = hanoi_v5.cpp $(HOMFILE) 43 | hanoi_v6_SOURCES = hanoi_v6.cpp $(HOMFILE) 44 | hanoi_v7_SOURCES = hanoi_v7.cpp $(HOMFILE) 45 | hanoi_v8_SOURCES = hanoi_v8.cpp $(HOMFILE) 46 | hanoi_v9_SOURCES = hanoi_v9.cpp 47 | 48 | -------------------------------------------------------------------------------- /demo/hanoi/doc/Makefile: -------------------------------------------------------------------------------- 1 | # Tools 2 | TEXI2DVI = texi2dvi 3 | TEXI2PDF = $(TEXI2DVI) --pdf 4 | DVIPS = dvips 5 | TAR = tar 6 | GZIP = gzip -9 7 | DOT2PS = dot -Tps 8 | 9 | # Sources 10 | TEX_MASTERS = hanoi_doc.tex 11 | TEX_INCLUDED = intro.tex encoding.tex hom.tex tool.tex perfs.tex conclu.tex bibliography.bib 12 | hanoi_doc_FIGURES = 13 | hanoi_doc_DOTS = 14 | hanoi_doc_JPGS = 15 | ALL_FIGURES = $(hanoi_doc_FIGURES) 16 | ALL_JPGS = $(hanoi_doc_JPGS) 17 | ALL_DOTS = $(hanoi_doc_DOTS) 18 | EXTRA_DIST = hanoi_doc.html bibliography.bib 19 | 20 | DVI_MASTERS = $(TEX_MASTERS:.tex=.dvi) 21 | PS_MASTERS = $(TEX_MASTERS:.tex=.ps) 22 | PDF_MASTERS = $(TEX_MASTERS:.tex=.pdf) 23 | HTML_MASTERS = $(TEX_MASTERS:.tex=.html) 24 | hanoi_doc_EPS_FIGURES = $(hanoi_doc_FIGURES:.fig=.eps) 25 | hanoi_doc_PDF_FIGURES = $(hanoi_doc_FIGURES:.fig=.pdf) 26 | hanoi_doc_EPS_DOTS = $(hanoi_doc_DOTS:.dot=.eps) 27 | hanoi_doc_PDF_DOTS = $(hanoi_doc_DOTS:.dot=.pdf) 28 | hanoi_doc_EPS_JPGS = $(hanoi_doc_JPGS:.jpg=.eps) 29 | hanoi_doc_PDF_JPGS = $(hanoi_doc_JPGS) 30 | ALL_EPS_FIGURES = $(ALL_FIGURES:.fig=.eps) 31 | ALL_PDF_FIGURES = $(ALL_FIGURES:.fig=.pdf) 32 | ALL_EPS_DOTS = $(ALL_DOTS:.fig=.eps) 33 | ALL_PDF_DOTS = $(ALL_DOTS:.fig=.pdf) 34 | ALL_EPS_JPGS = $(ALL_JPGS:.jpg=.eps) 35 | ALL_PDF_JPGS = $(ALL_JPGS) 36 | 37 | # What should be distributed? 38 | DIST_DEPS = Makefile $(TEX_MASTERS) $(TEX_INCLUDED) $(DVI_MASTERS) \ 39 | $(ALL_FIGURES) $(ALL_EPS_FIGURES) $(PDF_MASTERS) $(EXTRA_DIST) \ 40 | $(ALL_JPGS) $(ALL_DOTS) 41 | DIST = $(DIST_DEPS) hanoi_doc*.png 42 | 43 | # Name for the tarball. 44 | PACKAGE = hanoi_doc-04 45 | 46 | #for makeindex 47 | IDX_FILE := $(shell ls $(DOCUMENT).idx 2>/dev/null) 48 | ifneq ($(IDX_FILE),) 49 | IND_FILE := $(DOCUMENT).ind 50 | endif 51 | 52 | 53 | .POSIX: 54 | 55 | # Phony targets 56 | all: dvi ps # pdf html 57 | 58 | dvi: $(DVI_MASTERS) 59 | ps: $(PS_MASTERS) 60 | pdf: $(PDF_MASTERS) 61 | html: $(HTML_MASTERS) 62 | 63 | .PHONY: all dvi ps pdf clean mostlyclean dist 64 | 65 | mostlyclean: 66 | rm -f *.aux *.log *.toc *~ *.haux *.htoc *.bbl *.blg 67 | 68 | clean: mostlyclean 69 | rm -f $(DVI_MASTERS) $(PS_MASTERS) $(PDF_MASTERS) $(HTML_MASTERS) 70 | rm -f $(ALL_EPS_FIGURES) $(ALL_PDF_FIGURES) *.gif *.png 71 | 72 | dist: $(DIST_DEPS) 73 | rm -rf $(PACKAGE) 74 | mkdir $(PACKAGE) 75 | cp -rfp $(DIST) $(PACKAGE) 76 | $(TAR) chof - $(PACKAGE) | $(GZIP) -c >$(PACKAGE).tar.gz 77 | rm -rf $(PACKAGE) 78 | 79 | 80 | 81 | # Inference rules 82 | .SUFFIXES: .tex .dvi .pdf .ps .fig .eps .dot .jpg .html 83 | # 84 | # Generate a .ind file from the .idx file. 85 | # 86 | 87 | %.ind : %.idx 88 | makeindex $< 89 | 90 | .tex.dvi: 91 | if ($(TEXI2DVI) --version) >/dev/null 2>&1; then \ 92 | $(TEXI2DVI) $<; \ 93 | else \ 94 | latex $< && \ 95 | bibtex $* && \ 96 | latex $< && \ 97 | latex $<; \ 98 | fi 99 | .dvi.pdf: 100 | dvipdf $< $@ 101 | .dvi.ps: 102 | $(DVIPS) -o $@ $< 103 | .fig.eps: 104 | fig2dev -L eps $< $@ 105 | .jpg.eps: 106 | convert $< $@ 107 | .fig.pdf: 108 | case $< in \ 109 | imp*) \ 110 | $(MAKE) ${@:.pdf=.eps}; \ 111 | epstopdf --outfile=$@ ${@:.pdf=.eps};; \ 112 | *) \ 113 | fig2dev -L pdf -p x $< $@;; \ 114 | esac 115 | .dot.eps: 116 | $(DOT2PS) -o $@ $< 117 | .eps.pdf: 118 | epstopdf --outfile=$@ $< 119 | 120 | .tex.html: 121 | hevea -fix -O article.hva png.hva $< 122 | imagen -png -mag 2000 $* 123 | 124 | # Dependencies 125 | hanoi_doc.dvi hanoi_doc.ps hanoi_doc.html: $(hanoi_doc_EPS_FIGURES) \ 126 | $(hanoi_doc_EPS_DOTS) $(hanoi_doc_EPS_JPGS) $(TEX_INCLUDED) 127 | hanoi_doc.pdf: $(hanoi_doc_PDF_FIGURES) $(hanoi_doc_PDF_DOTS) \ 128 | $(hanoi_doc_PDF_JPGS) $(TEX_INCLUDED) 129 | -------------------------------------------------------------------------------- /demo/hanoi/doc/abstract.tex: -------------------------------------------------------------------------------- 1 | 2 | \begin{abstract} 3 | This document presents a dedicated solution of the Hanoi Towers 4 | puzzle, and is meant as a tutorial for the use of DDD and SDD. A 5 | naive version is first elaborated, then it is progressively refined to 6 | introduce saturation, and SDD. The reader should also be consulting 7 | the source code for the example, provided in the distribution. 8 | 9 | \end{abstract} 10 | -------------------------------------------------------------------------------- /demo/hanoi/doc/bibliography.bib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lip6/libDDD/bed76e621f6d0696f3d326a729ff18a16309e811/demo/hanoi/doc/bibliography.bib -------------------------------------------------------------------------------- /demo/hanoi/doc/conclu.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lip6/libDDD/bed76e621f6d0696f3d326a729ff18a16309e811/demo/hanoi/doc/conclu.tex -------------------------------------------------------------------------------- /demo/hanoi/doc/encoding.tex: -------------------------------------------------------------------------------- 1 | \section{Encoding the states using SDD} 2 | \label{sec:cod} 3 | 4 | Let $p$ designate the number of poles or towers, and $d$ designate the 5 | number of disks. 6 | 7 | We essentially have two possible encodings of the state : 8 | \begin{itemize} 9 | \item We use $p$ variables $v_1 .. v_p$ representing the poles, the domain of each 10 | variable will be states a pole can reach, which is bounded by $2^d$ 11 | (each disk is on the pole or not). It is immediately obvious that this 12 | high upper bound may lead to a huge number of arcs. Furthermore, we 13 | have a strong dependency between our variables in this schema, since a 14 | given disk can only be on one pole at a given time. These are bad 15 | characteristics of an encoding. 16 | \item We use $d$ variables $v_1..v_d$ representing the disks, each one has a domain 17 | $1..p$ which tells which pole the disk is on in this state. This 18 | encoding puts reasonable bounds on the number of arcs per node, and 19 | promotes the relative independence of the different disk states. This 20 | is the encoding we will use. 21 | \end{itemize} 22 | 23 | The second problem is variable order, which we know is often critical 24 | when using decision diagrams. There does not seem to be reason to 25 | shuffle the variables, as the problem is very symmetric. If we chose a 26 | natural order for disks, we still have the choice of putting the 27 | smallest disk at the top or at the bottom of the DD. 28 | Although it may seem there is little difference between the two, much 29 | depends on the algorithm we will use to generate the state-space. 30 | 31 | For BFS style iterations it does not really matter which disk is at 32 | the top of structure, however, saturation can profit from having the 33 | smaller disk at the bottom of the structure. Indeed, a movement of a 34 | given disk is only constrained by the state of the smaller disks. Thus 35 | the smallest disk has no constraints on its movement in any 36 | state. Putting smaller disks near the leaves of the structure will 37 | help discover states faster as we will see. 38 | 39 | The initial state is thus encoded by the DDD : \\ 40 | $v_d \fireseq{0} \ldots v_2 \fireseq{0} v_1 \fireseq{0} 1$ \\ 41 | where $v_d$ represents the state of the largest disk. 42 | -------------------------------------------------------------------------------- /demo/hanoi/doc/hanoi_doc.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lip6/libDDD/bed76e621f6d0696f3d326a729ff18a16309e811/demo/hanoi/doc/hanoi_doc.tex -------------------------------------------------------------------------------- /demo/hanoi/doc/hom.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lip6/libDDD/bed76e621f6d0696f3d326a729ff18a16309e811/demo/hanoi/doc/hom.tex -------------------------------------------------------------------------------- /demo/hanoi/doc/intro.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lip6/libDDD/bed76e621f6d0696f3d326a729ff18a16309e811/demo/hanoi/doc/intro.tex -------------------------------------------------------------------------------- /demo/hanoi/doc/perfs.tex: -------------------------------------------------------------------------------- 1 | \begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c|c|c|c|} 2 | \hline 3 | & & & \multicolumn{2}{c|}{v1} & \multicolumn{2}{c|}{v2} & \multicolumn{2}{c|}{v3} & \multicolumn{2}{c|}{v4} \\ 4 | \cline{4-11} 5 | $d$ & States & Final & peak & cache & peak & cache & peak & cache & peak & cache \\ 6 | \hline 7 | 2 & 9 & 3 & 34 & 104 & 33 & 53 & 29 & 46 & 29 & 45 \\ 8 | 3& 27 & 4 & 139 & 383 & 88 & 161 & 61 & 124 & 51 & 84 \\ 9 | 5 & 243 & 6 & 1388 & 3407 & 458 & 947 & 285 &703 &95 & 162 \\ 10 | 7 & 2187 & 8 & 8964 & 22162 & 2092 & 4901 &1229 & 3422 & 139 &240 \\ 11 | 10 & 59049 & 11 & 94392 & 269049 & 18019 &52019 & 10165 &33764 &205 & 357 \\ 12 | \hline 13 | \end{tabular} 14 | -------------------------------------------------------------------------------- /demo/hanoi/doc/tool.tex: -------------------------------------------------------------------------------- 1 | \section{Experimental results} 2 | \label{sec:perf} 3 | 4 | We report here on performances, for the fixed parameter number of 5 | poles $p=3$ (the original problem). 6 | 7 | \input{perfs.tex} 8 | 9 | -------------------------------------------------------------------------------- /demo/hanoi/hanoiHom.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lip6/libDDD/bed76e621f6d0696f3d326a729ff18a16309e811/demo/hanoi/hanoiHom.cpp -------------------------------------------------------------------------------- /demo/hanoi/hanoiHom.hh: -------------------------------------------------------------------------------- 1 | #ifndef __HANOI_HOM_HH__ 2 | #define __HANOI_HOM_HH__ 3 | 4 | #include 5 | #include 6 | #include "ddd/Hom.h" 7 | #include "ddd/SHom.h" 8 | #include "ddd/statistic.hpp" 9 | 10 | // Global constants. 11 | // we use one DDD variable per ring, ring 0 is the topmost, 12 | // and is stored at the bottom of the DDD 13 | extern int NB_RINGS ; 14 | // Each variable domain is {0,1,2} expressing the pole the variable is on 15 | extern int NB_POLES ; 16 | 17 | // name the DDD variables for prettier print. 18 | void initName() ; 19 | 20 | // int -> string 21 | std::string toString (int i); 22 | // float -> string 23 | std::string toString (double i); 24 | 25 | // moves ring "ring" from pole ori to pole dest if possible. 26 | GHom swap_pole ( int ring, int ori, int dest ) ; 27 | 28 | // attempt to move a ring to all other poles. Origin pole is read from the structure. 29 | // returns strictly successors 30 | GHom move_ring ( int ring ) ; 31 | 32 | // attempt to move a ring to all other poles. Origin pole is read from the structure. 33 | // equivalent behavior to (move_ring + id), i.e. adds to existing states 34 | GHom move_ring_id ( int ring ) ; 35 | 36 | // move the ring "ring" and all rings above it (below in the encoding) using a fixpoint. 37 | // Adds to existing states similarly to move_ring_id. 38 | // Normally the user will just call move_ring_sat (NB_RING -1). 39 | GHom move_ring_sat ( int ring ) ; 40 | 41 | // move all the rings using a fixpoint. Generic version with no "ring" parameter. 42 | // Adds to existing states similarly to move_ring_id. 43 | GHom move_ring_sat_gen () ; 44 | 45 | // move all the rings using a fixpoint. Uses recursive calls to the explicit saturate function 46 | // Adds to existing states similarly to move_ring_id. 47 | GHom saturate () ; 48 | 49 | // SDD application to saturate. 50 | // Used in the case there is only one SDD variable that contains the whole ring problem. 51 | // Uses saturate (see above) internally. 52 | GShom saturateSDD_singleDepth (); 53 | 54 | // SDD application to saturate when working with IntDataSet SDD. 55 | // Used in the single depth case, i.e. all SDD variables have domain Natural (IntDataSet) 56 | // Builds upon saturate version for DDD. 57 | GShom saturateSDD_IntData (); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /demo/hanoi/hanoi_v1.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | /** An example resolution of the famous towers of Hanoi puzzle. * 24 | * This variant uses only DDD and no saturation */ 25 | #include 26 | #include 27 | #include 28 | #include 29 | using namespace std; 30 | 31 | #include "ddd/DDD.h" 32 | #include "ddd/DED.h" 33 | #include "ddd/MemoryManager.h" 34 | #include "ddd/init.hh" 35 | #include "hanoiHom.hh" 36 | // #include "tbb/task_scheduler_init.h" 37 | 38 | 39 | int 40 | main(int argc, char **argv) 41 | { 42 | if (argc == 2) 43 | { 44 | NB_RINGS = atoi(argv[1]); 45 | } 46 | 47 | d3::init init; 48 | // tbb::task_scheduler_init init; 49 | 50 | // Define a name for each variable 51 | initName(); 52 | 53 | // The initial state 54 | // User program variables should be DDD not GDDD, to prevent their garbage collection 55 | DDD M0 = DDD::one ; 56 | // construct an initial state for the problem, all rings are on pole 0 57 | for (int i=0; i events; 68 | for (int i=0 ; i < NB_RINGS ; i++) 69 | { 70 | // No tricks used : consider all 6 = NB_POLES * (NB_POLES-1) events per ring 71 | // ie 3 poles : 0->1, 0->2, 1->2, 1->0, 2->1, 2->0 72 | for (int ori = 0; ori < NB_POLES ; ori++ ) 73 | { 74 | for (int dest = 0; dest < NB_POLES ; dest++ ) 75 | { 76 | if (ori != dest) 77 | { 78 | events.push_back(swap_pole(i,ori,dest)); 79 | } 80 | } 81 | } 82 | } 83 | 84 | // Fixpoint over events + Id 85 | DDD ss, tmp = M0; 86 | do { 87 | ss = tmp; 88 | for ( vector::reverse_iterator it = events.rbegin(); it != events.rend(); ++it) 89 | { 90 | tmp = tmp + (*it) (tmp); 91 | } 92 | } while (ss != tmp); 93 | 94 | // stats 95 | Statistic S = Statistic(ss,"hanoiv1." + toString(NB_RINGS) + "." + toString(NB_POLES),CSV); 96 | S.print_header(std::cout); 97 | S.print_line(std::cout); 98 | 99 | } 100 | -------------------------------------------------------------------------------- /demo/hanoi/hanoi_v1_bis.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | /** An example resolution of the famous towers of Hanoi puzzle. * 24 | * This variant uses only DDD and no saturation */ 25 | #include 26 | #include 27 | #include 28 | #include 29 | using namespace std; 30 | 31 | #include "ddd/DDD.h" 32 | #include "ddd/DED.h" 33 | #include "ddd/MemoryManager.h" 34 | #include "hanoiHom.hh" 35 | 36 | int 37 | main(int argc, char **argv) 38 | { 39 | if (argc == 2) 40 | { 41 | NB_RINGS = atoi(argv[1]); 42 | } 43 | 44 | // Define a name for each variable 45 | initName(); 46 | 47 | // The initial state 48 | // User program variables should be DDD not GDDD, to prevent their garbage collection 49 | DDD M0 = DDD::one ; 50 | // construct an initial state for the problem, all rings are on pole 0 51 | for (int i=0; i union_hom; 64 | 65 | for (int i=0 ; i < NB_RINGS ; i++) 66 | { 67 | // No tricks used : consider all 6 = NB_POLES * (NB_POLES-1) events per ring 68 | // ie 3 poles : 0->1, 0->2, 1->2, 1->0, 2->1, 2->0 69 | for (int ori = 0; ori < NB_POLES ; ori++ ) 70 | { 71 | for (int dest = 0; dest < NB_POLES ; dest++ ) 72 | { 73 | if (ori != dest) 74 | { 75 | union_hom.insert(swap_pole(i,ori,dest)); 76 | } 77 | } 78 | } 79 | } 80 | 81 | union_hom.insert(GHom::id); 82 | events = GHom::add(union_hom); 83 | 84 | // Fixpoint over events + Id 85 | DDD ss, tmp = M0; 86 | do { 87 | ss = tmp; 88 | tmp = events(tmp); 89 | } while (ss != tmp); 90 | 91 | // stats 92 | Statistic S = Statistic(ss,"hanoiv1bis." + toString(NB_RINGS) + "." + toString(NB_POLES),CSV); 93 | S.print_header(std::cout); 94 | S.print_line(std::cout); 95 | 96 | } 97 | -------------------------------------------------------------------------------- /demo/hanoi/hanoi_v1_ter.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | /** An example resolution of the famous towers of Hanoi puzzle. * 24 | * This variant uses only DDD and no saturation */ 25 | #include 26 | #include 27 | #include 28 | #include 29 | using namespace std; 30 | 31 | #include "ddd/DDD.h" 32 | #include "ddd/DED.h" 33 | #include "ddd/MemoryManager.h" 34 | #include "ddd/init.hh" 35 | #include "hanoiHom.hh" 36 | 37 | int 38 | main(int argc, char **argv) 39 | { 40 | if (argc == 2) 41 | { 42 | NB_RINGS = atoi(argv[1]); 43 | } 44 | 45 | d3::init init; 46 | 47 | // Define a name for each variable 48 | initName(); 49 | 50 | // The initial state 51 | // User program variables should be DDD not GDDD, to prevent their garbage collection 52 | DDD M0 = DDD::one ; 53 | // construct an initial state for the problem, all rings are on pole 0 54 | for (int i=0; i union_hom; 64 | for (int i=0 ; i < NB_RINGS ; i++) 65 | { 66 | // No tricks used : consider all 6 = NB_POLES * (NB_POLES-1) events per ring 67 | // ie 3 poles : 0->1, 0->2, 1->2, 1->0, 2->1, 2->0 68 | for (int ori = 0; ori < NB_POLES ; ori++ ) 69 | { 70 | for (int dest = 0; dest < NB_POLES ; dest++ ) 71 | { 72 | if (ori != dest) 73 | { 74 | union_hom.insert(swap_pole(i,ori,dest)); 75 | } 76 | } 77 | } 78 | } 79 | union_hom.insert(GHom::id); 80 | 81 | Hom events = fixpoint( (GHom::add(union_hom))); 82 | DDD ss = events(M0); 83 | 84 | // stats 85 | Statistic S = Statistic(ss,"hanoiv1ter." + toString(NB_RINGS) + "." + toString(NB_POLES),CSV); 86 | S.print_header(std::cout); 87 | S.print_line(std::cout); 88 | 89 | } 90 | -------------------------------------------------------------------------------- /demo/hanoi/hanoi_v2.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | /** An example resolution of the famous towers of Hanoi puzzle. * 24 | * This variant uses only DDD and no saturation, * 25 | * but starts operations when the ring is reached */ 26 | 27 | 28 | #include 29 | #include 30 | #include 31 | using namespace std; 32 | 33 | #include "ddd/DDD.h" 34 | #include "ddd/DED.h" 35 | #include "ddd/MemoryManager.h" 36 | #include "hanoiHom.hh" 37 | 38 | 39 | int main(int argc, char **argv){ 40 | if (argc == 2) { 41 | NB_RINGS = atoi(argv[1]); 42 | } 43 | 44 | // Define a name for each variable 45 | initName(); 46 | 47 | // The initial state 48 | // User program variables should be DDD not GDDD, to prevent their garbage collection 49 | DDD M0 = GDDD::one ; 50 | // construct an initial state for the problem, all rings are on pole 0 51 | for (int i=0; i events; 61 | for (int i=0 ; i < NB_RINGS ; i++) { 62 | // Consider one event per ring, it will split into the possible moves when it reaches the ring 63 | // ie : ev = \Sum_{i \neq j} swap_pole (ring,i,j) 64 | // with swap_pole defined as in hanoi_v1 65 | events.insert(move_ring(i)); 66 | } 67 | 68 | DDD ss = fixpoint( GHom::add(events) + GHom::id ) (M0); 69 | // Fixpoint over events + Id 70 | // DDD ss, tmp = M0; 71 | // do { 72 | // ss = tmp; 73 | // for (vector::reverse_iterator it = events.rbegin(); it != events.rend(); ++it) { 74 | // tmp = tmp + (*it) (tmp); 75 | // } 76 | // } while (ss != tmp); 77 | 78 | // stats 79 | Statistic S = Statistic(ss,"hanoiv2." + toString(NB_RINGS) + "." + toString(NB_POLES),CSV); 80 | S.print_header(std::cout); 81 | S.print_line(std::cout); 82 | } 83 | -------------------------------------------------------------------------------- /demo/hanoi/hanoi_v3.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | 24 | /** An example resolution of the famous towers of Hanoi puzzle. * 25 | * v1 : This variant uses only DDD and no saturation, * 26 | * v2 : but starts operations when the ring is reached * 27 | * v3 : additionally, events add to the current state space, instead of returning only successors 28 | * i.e. Id is also applied at the appropriate level */ 29 | 30 | 31 | #include 32 | #include 33 | #include 34 | using namespace std; 35 | 36 | #include "ddd/DDD.h" 37 | #include "ddd/DED.h" 38 | #include "ddd/MemoryManager.h" 39 | #include "hanoiHom.hh" 40 | 41 | int main(int argc, char **argv){ 42 | if (argc == 2) { 43 | NB_RINGS = atoi(argv[1]); 44 | } 45 | 46 | // Define a name for each variable 47 | initName(); 48 | 49 | // The initial state 50 | // User program variables should be DDD not GDDD, to prevent their garbage collection 51 | DDD M0 = GDDD::one ; 52 | // construct an initial state for the problem, all rings are on pole 0 53 | for (int i=0; i events; 63 | for (int i=0 ; i < NB_RINGS ; i++) { 64 | // Consider one event per ring, it will split into the possible moves when it reaches the ring 65 | // ie : ev = \Sum_{i \neq j} swap_pole (ring,i,j) 66 | // with swap_pole defined as in hanoi_v1 67 | events.push_back(move_ring_id(i)); 68 | } 69 | 70 | // Fixpoint over events + Id 71 | DDD ss, tmp = M0; 72 | do { 73 | ss = tmp; 74 | for (vector::reverse_iterator it = events.rbegin(); it != events.rend(); ++it) { 75 | // no need to cumulate previous states, the event relation does it for us 76 | tmp = (*it) (tmp); 77 | } 78 | } while (ss != tmp); 79 | 80 | // stats 81 | Statistic S = Statistic(ss,"hanoiv3." + toString(NB_RINGS) + "." + toString(NB_POLES),CSV); 82 | S.print_header(std::cout); 83 | S.print_line(std::cout); 84 | } 85 | -------------------------------------------------------------------------------- /demo/hanoi/hanoi_v4.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | /** An example resolution of the famous towers of Hanoi puzzle. * 24 | * v4 : This variant uses only DDD and saturation, * 25 | */ 26 | 27 | 28 | #include 29 | #include 30 | #include 31 | using namespace std; 32 | 33 | #include "ddd/DDD.h" 34 | #include "ddd/DED.h" 35 | #include "ddd/MemoryManager.h" 36 | #include "hanoiHom.hh" 37 | 38 | 39 | int main(int argc, char **argv){ 40 | if (argc == 2) { 41 | NB_RINGS = atoi(argv[1]); 42 | } 43 | 44 | // Define a name for each variable 45 | initName(); 46 | 47 | // The initial state 48 | // User program variables should be DDD not GDDD, to prevent their garbage collection 49 | DDD M0 = GDDD::one ; 50 | // construct an initial state for the problem, all rings are on pole 0 51 | for (int i=0; i events; 61 | // Consider one single event that recursively fires all events 62 | events.push_back(move_ring_sat(NB_RINGS-1)); 63 | 64 | // Fixpoint over events + to saturate topmost node 65 | DDD ss, tmp = M0; 66 | do { 67 | ss = tmp; 68 | for (vector::reverse_iterator it = events.rbegin(); it != events.rend(); ++it) { 69 | // no need to cumulate previous states, the event relation does it for us 70 | tmp = (*it) (tmp); 71 | } 72 | } while (ss != tmp); 73 | 74 | // stats 75 | Statistic S = Statistic(ss,"hanoiv4." + toString(NB_RINGS) + "." + toString(NB_POLES),CSV); 76 | S.print_header(std::cout); 77 | S.print_line(std::cout); 78 | 79 | } 80 | -------------------------------------------------------------------------------- /demo/hanoi/hanoi_v5.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | /** An example resolution of the famous towers of Hanoi puzzle. * 24 | * v5 : This variant uses only DDD and saturation, * 25 | * it exploits the fact that the same transition relation is applied to each ring to remove all args from move_ring 26 | */ 27 | 28 | 29 | #include 30 | #include 31 | #include 32 | using namespace std; 33 | 34 | #include "ddd/DDD.h" 35 | #include "ddd/DED.h" 36 | #include "ddd/MemoryManager.h" 37 | #include "hanoiHom.hh" 38 | 39 | 40 | int main(int argc, char **argv){ 41 | if (argc == 2) { 42 | NB_RINGS = atoi(argv[1]); 43 | } 44 | 45 | // Define a name for each variable 46 | initName(); 47 | 48 | // The initial state 49 | // User program variables should be DDD not GDDD, to prevent their garbage collection 50 | DDD M0 = GDDD::one ; 51 | // construct an initial state for the problem, all rings are on pole 0 52 | for (int i=0; i events; 62 | // Consider one single event that recursively fires all events 63 | events.push_back(move_ring_sat_gen()); 64 | 65 | // Fixpoint over events + to saturate topmost node 66 | DDD ss, tmp = M0; 67 | do { 68 | ss = tmp; 69 | for (vector::reverse_iterator it = events.rbegin(); it != events.rend(); ++it) { 70 | // no need to cumulate previous states, the event relation does it for us 71 | tmp = (*it) (tmp); 72 | } 73 | } while (ss != tmp); 74 | 75 | // stats 76 | Statistic S = Statistic(ss,"hanoiv5." + toString(NB_RINGS) + "." + toString(NB_POLES),CSV); 77 | S.print_header(std::cout); 78 | S.print_line(std::cout); 79 | } 80 | -------------------------------------------------------------------------------- /demo/hanoi/hanoi_v6.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | /** An example resolution of the famous towers of Hanoi puzzle. * 24 | * v5 : This variant uses only DDD and saturation, * 25 | * it exploits the fact that the same transition relation is applied to each ring to remove all args from move_ring 26 | * v6 : saturation improved : the test no_ring_above resaturates before returning 27 | */ 28 | 29 | 30 | #include 31 | #include 32 | #include 33 | using namespace std; 34 | 35 | #include "ddd/DDD.h" 36 | #include "ddd/DED.h" 37 | #include "ddd/MemoryManager.h" 38 | #include "hanoiHom.hh" 39 | 40 | 41 | int main(int argc, char **argv){ 42 | if (argc == 2) { 43 | NB_RINGS = atoi(argv[1]); 44 | } 45 | 46 | // Define a name for each variable 47 | initName(); 48 | 49 | // The initial state 50 | // User program variables should be DDD not GDDD, to prevent their garbage collection 51 | DDD M0 = GDDD::one ; 52 | // construct an initial state for the problem, all rings are on pole 0 53 | for (int i=0; i reach fixpoint over transition relation 63 | DDD ss = saturate() (M0); 64 | 65 | // stats 66 | Statistic S = Statistic(ss,"hanoiv6." + toString(NB_RINGS) + "." + toString(NB_POLES),CSV); 67 | S.print_header(std::cout); 68 | S.print_line(std::cout); 69 | } 70 | -------------------------------------------------------------------------------- /demo/hanoi/hanoi_v7.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | /** An example resolution of the famous towers of Hanoi puzzle. * 24 | * v7 : This variant introduces the use of SDD * 25 | * A single SDD variable is used, the program builds upon v6. * 26 | */ 27 | 28 | 29 | #include 30 | #include 31 | #include 32 | using namespace std; 33 | 34 | #include "ddd/DDD.h" 35 | #include "ddd/DED.h" 36 | #include "ddd/MemoryManager.h" 37 | #include "ddd/init.hh" 38 | #include "hanoiHom.hh" 39 | 40 | 41 | int main(int argc, char **argv){ 42 | if (argc == 2) { 43 | NB_RINGS = atoi(argv[1]); 44 | } 45 | 46 | d3::init init; 47 | 48 | // Define a name for each variable 49 | initName(); 50 | 51 | // The initial state 52 | // User program variables should be DDD not GDDD, to prevent their garbage collection 53 | DDD M0 = GDDD::one ; 54 | // construct an initial state for the problem, all rings are on pole 0 55 | for (int i=0; i reach fixpoint over transition relation 68 | SDD ss = saturateSDD_singleDepth() (M1) ; 69 | 70 | // stats 71 | Statistic S = Statistic(ss,"hanoiv7." + toString(NB_RINGS) + "." + toString(NB_POLES),CSV); 72 | S.print_header(std::cout); 73 | S.print_line(std::cout); 74 | } 75 | -------------------------------------------------------------------------------- /demo/hanoi/hanoi_v8.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | /** An example resolution of the famous towers of Hanoi puzzle. * 24 | * v8 : This variant exhibits the use IntDataSet based SDD, emphasizing the differences with DDD. 25 | * Compare this to v6 which is very similar for DDD. 26 | */ 27 | 28 | 29 | #include 30 | #include 31 | #include 32 | using namespace std; 33 | 34 | #include "ddd/IntDataSet.h" 35 | #include "ddd/DDD.h" 36 | #include "ddd/DED.h" 37 | #include "ddd/MemoryManager.h" 38 | #include "ddd/init.hh" 39 | #include "hanoiHom.hh" 40 | 41 | 42 | int main(int argc, char **argv){ 43 | if (argc == 2) { 44 | NB_RINGS = atoi(argv[1]); 45 | } 46 | d3::init init; 47 | 48 | // Define a name for each variable 49 | initName(); 50 | 51 | // The initial state 52 | // User program variables should be DDD not GDDD, to prevent their garbage collection 53 | SDD M0 = GSDD::one ; 54 | // construct an initial state for the problem, all rings are on pole 0 55 | IntDataSet s (vector (1,0) ); 56 | for (int i=0; i reach fixpoint over transition relation 69 | SDD ss = saturateSDD_IntData() (M0) ; 70 | 71 | // stats 72 | Statistic S = Statistic(ss,"hanoiv8." + toString(NB_RINGS) + "." + toString(NB_POLES),CSV); 73 | S.print_header(std::cout); 74 | S.print_line(std::cout); 75 | } 76 | -------------------------------------------------------------------------------- /demo/morpion/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | -------------------------------------------------------------------------------- /demo/morpion/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = morpionv2 2 | 3 | 4 | DDD_SRCDIR = $(top_srcdir) 5 | DDD_BUILDDIR = $(top_builddir)/ddd 6 | 7 | AM_CPPFLAGS = -I $(DDD_SRCDIR) $(BOOST_CPPFLAGS) -g -Wall $(TBBINC_FLAGS) 8 | AM_LDFLAGS = $(LDFLAGS) 9 | AM_LDFLAGS += $(STATICFLAGS) 10 | LDADD = $(DDD_BUILDDIR)/libDDD_d.la 11 | 12 | 13 | morpionv2_SOURCES = \ 14 | hom/notew.cpp \ 15 | hom/play.cpp \ 16 | hom/winner.cpp \ 17 | hom/general_v2.cpp \ 18 | hom/const.cpp \ 19 | morpionv2.cpp 20 | 21 | 22 | noinst_HEADERS = \ 23 | hom/notew.hpp \ 24 | hom/play.hpp \ 25 | hom/winner.hpp \ 26 | hom/general_v2.hpp \ 27 | hom/const.hpp 28 | -------------------------------------------------------------------------------- /demo/morpion/hom/const.cpp: -------------------------------------------------------------------------------- 1 | // author : S. Hong,Y.Thierry-Mieg 2 | // date : Jan 2009 3 | #include "const.hpp" 4 | 5 | 6 | // Const variable 7 | size_t NBCELL ; 8 | int STATE_SYSTEM_CELL ; 9 | size_t LINE ; 10 | size_t COLUMN ; 11 | -------------------------------------------------------------------------------- /demo/morpion/hom/const.hpp: -------------------------------------------------------------------------------- 1 | // author : S. Hong,Y.Thierry-Mieg 2 | // date : Jan 2009 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | extern size_t NBCELL; 9 | extern int STATE_SYSTEM_CELL; 10 | extern size_t LINE; 11 | extern size_t COLUMN; 12 | 13 | // players 14 | /** 15 | * 16 | */ 17 | enum game_status_type 18 | { 19 | TO_PA = -1 /// Player A to play 20 | , TO_PB = -2 /// Player B to play 21 | , EMPTY = -1 /// Ligne Vide 22 | , PA = 0 /// Joueur A 23 | , PB = 1 /// Joueur B 24 | }; 25 | 26 | // Type definition 27 | typedef int** array_type; 28 | -------------------------------------------------------------------------------- /demo/morpion/hom/general_v2.cpp: -------------------------------------------------------------------------------- 1 | // author : S. Hong,Y.Thierry-Mieg 2 | // date : Jan 2009 3 | #include "general_v2.hpp" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | 11 | #include "notew.hpp" 12 | #include "play.hpp" 13 | #include "winner.hpp" 14 | 15 | 16 | 17 | // The player designated plays in a free cll, if any are available. 18 | Hom 19 | PlayAnyFreeCell () 20 | { 21 | std::set nextAAset; 22 | 23 | for ( size_t i = 0; i < NBCELL; ++i ) 24 | { 25 | nextAAset.insert ( Play ( i ) ); 26 | } 27 | 28 | return GHom::add ( nextAAset ); 29 | } 30 | 31 | 32 | 33 | 34 | Hom 35 | generateLineWinner(size_t max, game_status_type player) 36 | { 37 | std::set winAAset; 38 | 39 | /* For each line configuration of the grid game, where i is the line number and j the column number */ 40 | for(size_t i=0;i winAAset; 59 | 60 | /* For each column configuration of the grid game, where j is the line number and i the column */ 61 | for(size_t i=0;i winAAset; 79 | 80 | 81 | /* First Cross configuration */ 82 | size_t i=0; 83 | Hom cell_1 = CheckCellWinner ( player, (i + (i*max)) ); 84 | Hom cell_2 = CheckCellWinner ( player, (((max - 1 - i) + (i*max) ) ) ); 85 | for(i=1;i (2003-), Jean-Michel Couvreur (2001), and Denis Poitrenaud (2001) , (C) 2009 8 | // 9 | // Copyright: See COPYING file that comes with this distribution 10 | // 11 | // 12 | 13 | #include "hom/notew.hpp" 14 | 15 | /** 16 | * An inductive homomorphism 17 | */ 18 | 19 | class _NoteWinner: public StrongHom 20 | { 21 | private: 22 | /** 23 | * Liste of member variables = homomorphism parameters 24 | */ 25 | game_status_type player; // The player taking the cell : 0 or 1 26 | public: 27 | 28 | /** 29 | * The constructor binds the homomorphism parameters 30 | */ 31 | _NoteWinner ( game_status_type p ) 32 | : player ( p ) 33 | { 34 | } 35 | 36 | /** 37 | * Define the target variable to skip in the current route in apply 38 | */ 39 | bool 40 | skip_variable ( int vr ) const 41 | { 42 | return vr != STATE_SYSTEM_CELL; 43 | } 44 | 45 | /** 46 | * PHI [1] : called if the terminal 1 is encountered, returns a constant DDD 47 | */ 48 | GDDD 49 | phiOne() const 50 | { 51 | return DDD::top; 52 | } 53 | 54 | /** 55 | * PHI [vr,vl] : called on each arc labeled with "vl" when the homomorphism is applied to a node 56 | * of variable "vr" such that vr is NOT skipped. 57 | * When the hom is applied to a node this function is called for each arc, and the result 58 | * (a homomorphism) is applied to the successor node pointed by the arc. 59 | * vr ==> Variable of current node 60 | * vl ==> arc label (an integer) of current arc 61 | */ 62 | GHom 63 | phi ( int vr, int vl ) const 64 | { 65 | if ( vl < 0 ) 66 | { 67 | /* Check if there is no winner : Game in run */ 68 | return GHom ( vr, player, GHom::id ); // e-(joueur)-> ID 69 | } 70 | else if ( vl == player ) 71 | { 72 | /* If there already exist a winner, we keep the way only if the winner is the same */ 73 | return GHom ( vr, vl, GHom::id ); // e-(vl)-> ID 74 | } 75 | else 76 | { 77 | /* Two different winner have been found : no possible configuration */ 78 | return GHom ( DDD::null ); // Cut the way (0) 79 | } 80 | } 81 | 82 | /** 83 | * Hash function used for unique table storage. 84 | */ 85 | size_t 86 | hash() const 87 | { 88 | // hash function should exhibit reasonable spread and involve as many parameters as possible. 89 | return 4123 * (player + 2) ; 90 | } 91 | 92 | /** 93 | * Overloading StrongHom default print with a customized pretty-print 94 | */ 95 | void 96 | print ( std::ostream & os ) const 97 | { 98 | os << "Note Winner(player:" << player << " )"; 99 | } 100 | 101 | /** 102 | * Overload of operator== necessary for unique table storage 103 | * argument is typed StrongHom as == is part of StrongHom contract, simlarly to java's bool equals(Object) 104 | */ 105 | bool 106 | operator== ( const StrongHom &s ) const 107 | { 108 | // direct "hard" cast to own type is ok, type checks already made in library 109 | const _NoteWinner& ps = dynamic_cast ( s ); 110 | // basic comparator behavior, just make sure you put all attributes there. 111 | return player == ps.player ; 112 | } 113 | 114 | /** 115 | * Clone current homomorphism, used for unique storage. 116 | */ 117 | _GHom * 118 | clone () const 119 | { 120 | return new _NoteWinner ( *this ); 121 | } 122 | }; 123 | 124 | 125 | /** 126 | * Factory of _TakeCellWithCheckWinner Instance 127 | */ 128 | Hom 129 | NoteWinner ( game_status_type player ) 130 | { 131 | return GHom (_NoteWinner ( player ) ); 132 | } 133 | 134 | -------------------------------------------------------------------------------- /demo/morpion/hom/notew.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // C++ Interface: hom_notew 3 | // 4 | // Description: 5 | // 6 | // 7 | // Author: Yann Thierry-Mieg (2003-), Jean-Michel Couvreur (2001), and Denis Poitrenaud (2001) , (C) 2009 8 | // 9 | // Copyright: See COPYING file that comes with this distribution 10 | // 11 | // 12 | 13 | #pragma once 14 | 15 | #include "ddd/DDD.h" 16 | #include "ddd/Hom.h" 17 | #include "hom/const.hpp" 18 | 19 | /** 20 | * Factory of _TakeCellWithCheckWinner Instance 21 | */ 22 | Hom 23 | NoteWinner ( game_status_type player ); 24 | -------------------------------------------------------------------------------- /demo/morpion/hom/play.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // C++ Interface: hom_play 3 | // 4 | // Description: 5 | // 6 | // 7 | // Author: Yann Thierry-Mieg (2003-), Jean-Michel Couvreur (2001), and Denis Poitrenaud (2001) , (C) 2009 8 | // 9 | // Copyright: See COPYING file that comes with this distribution 10 | // 11 | // 12 | 13 | #pragma once 14 | 15 | #include "ddd/DDD.h" 16 | #include "ddd/Hom.h" 17 | #include "hom/const.hpp" 18 | 19 | Hom 20 | Play ( int c1, game_status_type player); 21 | 22 | Hom 23 | Play ( int c1); 24 | 25 | 26 | -------------------------------------------------------------------------------- /demo/morpion/hom/winner.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // C++ Implementation: hom/winner 3 | // 4 | // Description: 5 | // 6 | // 7 | // Author: Yann Thierry-Mieg (2003-), Jean-Michel Couvreur (2001), and Denis Poitrenaud (2001) , (C) 2009 8 | // 9 | // Copyright: See COPYING file that comes with this distribution 10 | // 11 | // 12 | 13 | #include "hom/winner.hpp" 14 | 15 | /** 16 | * An inductive homomorphism 17 | */ 18 | 19 | class _CheckCellWinner: public StrongHom 20 | { 21 | private: 22 | /** 23 | * Liste of member variables = homomorphism parameters 24 | */ 25 | int cell; // The cell game 26 | game_status_type player; // The player taking the cell : 0 or 1 27 | public: 28 | 29 | /** 30 | * The constructor binds the homomorphism parameters 31 | */ 32 | _CheckCellWinner ( game_status_type p, int c ) 33 | : cell ( c ), player ( p ) 34 | { 35 | } 36 | 37 | /** 38 | * Define the target variable to skip in the current route in apply 39 | */ 40 | bool 41 | skip_variable ( int vr ) const 42 | { 43 | return vr != cell; 44 | } 45 | 46 | // tag this homomorphism as only making selections 47 | bool 48 | is_selector () const 49 | { 50 | return true; 51 | } 52 | 53 | /** 54 | * PHI [1] : called if the terminal 1 is encountered, returns a constant DDD 55 | */ 56 | GDDD 57 | phiOne() const 58 | { 59 | return DDD::top; 60 | } 61 | 62 | /** 63 | * PHI [vr,vl] : called on each arc labeled with "vl" when the homomorphism is applied to a node 64 | * of variable "vr" such that vr is NOT skipped. 65 | * When the hom is applied to a node this function is called for each arc, and the result 66 | * (a homomorphism) is applied to the successor node pointed by the arc. 67 | * vr ==> Variable of current node 68 | * vl ==> arc label (an integer) of current arc 69 | */ 70 | GHom 71 | phi ( int vr, int vl ) const 72 | { 73 | if ( vl == player ) 74 | { 75 | return GHom ( vr, vl, GHom::id ); // e-(joueur)-> ID 76 | } 77 | else 78 | { 79 | return GHom ( DDD::null ); // Cut the way (0) 80 | } 81 | } 82 | 83 | /** 84 | * Hash function used for unique table storage. 85 | */ 86 | size_t 87 | hash() const 88 | { 89 | // hash function should exhibit reasonable spread and involve as many parameters as possible. 90 | std::size_t seed = 4789; 91 | seed ^= (player +3)*9874 + cell*3123; 92 | return seed ; 93 | } 94 | 95 | /** 96 | * Overloading StrongHom default print with a customized pretty-print 97 | */ 98 | void 99 | print ( std::ostream & os ) const 100 | { 101 | os << "checkCellWin(player:" << player << ", cell:" << cell << ")"; 102 | } 103 | 104 | /** 105 | * Overload of operator== necessary for unique table storage 106 | * argument is typed StrongHom as == is part of StrongHom contract, simlarly to java's bool equals(Object) 107 | */ 108 | bool 109 | operator== ( const StrongHom &s ) const 110 | { 111 | // direct "hard" cast to own type is ok, type checks already made in library 112 | const _CheckCellWinner& ps = dynamic_cast ( s ); 113 | // basic comparator behavior, just make sure you put all attributes there. 114 | return player == ps.player && cell == ps.cell ; 115 | } 116 | 117 | /** 118 | * Clone current homomorphism, used for unique storage. 119 | */ 120 | _GHom * 121 | clone () const 122 | { 123 | return new _CheckCellWinner ( *this ); 124 | } 125 | }; 126 | 127 | 128 | /** 129 | * Factory of _TakeCellWithCheckWinner Instance 130 | */ 131 | Hom 132 | CheckCellWinner ( game_status_type player , int cell ) 133 | { 134 | return GHom(_CheckCellWinner ( player, cell )); 135 | } 136 | 137 | 138 | -------------------------------------------------------------------------------- /demo/morpion/hom/winner.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // C++ Interface: hom_winner 3 | // 4 | // Description: 5 | // 6 | // 7 | // Author: Yann Thierry-Mieg (2003-), Jean-Michel Couvreur (2001), and Denis Poitrenaud (2001) , (C) 2009 8 | // 9 | // Copyright: See COPYING file that comes with this distribution 10 | // 11 | // 12 | #pragma once 13 | 14 | #include "ddd/DDD.h" 15 | #include "ddd/Hom.h" 16 | #include "hom/const.hpp" 17 | 18 | /** 19 | * Factory of _TakeCellWithCheckWinner Instance 20 | */ 21 | Hom 22 | CheckCellWinner ( game_status_type player , int cell ); 23 | -------------------------------------------------------------------------------- /demo/morpion/morpionv2.cpp: -------------------------------------------------------------------------------- 1 | // author : S. Hong,Y.Thierry-Mieg // date : Jan 2009 2 | #include 3 | #include 4 | //#include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "hom/general_v2.hpp" 10 | #include "hom/const.hpp" 11 | #include "hom/notew.hpp" 12 | 13 | 14 | 15 | // SDD utilities to output stats and dot graphs 16 | #include "ddd/util/dotExporter.h" 17 | #include "ddd/statistic.hpp" 18 | 19 | /* A Modifier avec les standard de Boost */ 20 | void usage() { 21 | cout << "Morpion Game; package " << PACKAGE_STRING <" << endl; 30 | cout << " NB_LINE : The number of Cell Game into one line (Morpion game is a square), by default it 3 for have a game 3x3" << endl; 31 | } 32 | 33 | void bugreport () { 34 | cerr << "Bugreport contact : silien.hong@lip6.fr " << PACKAGE_BUGREPORT < winners; 66 | winners[PA] = CheckIsWinner (PA); 67 | winners[PB] = CheckIsWinner (PB); 68 | 69 | // Initialisation of no winner configuration 70 | Hom noWinner = CheckNoWinner(); 71 | cout << "\nPrint the initial DDD Graph : " << endl; 72 | cout << initial << endl; 73 | cout << "\nMake the fix point for Grid Tic Tac Toe ["<< LINE << "," << COLUMN <<"] :\nIt can take a long time ... please wait ..." << std::endl ; 74 | /* ALGO : 75 | * For each player : 76 | * 1) We can play only if there is no winner configuration 77 | * 2) If there is one winner A or B, we note into the globally state of the system that the current configuration is blocked 78 | */ 79 | Hom fullT2 = 80 | fixpoint 81 | ( ( ( ( (NoteWinner(PA) & winners[PA]) 82 | + (NoteWinner(PB) & winners[PB]) 83 | + noWinner 84 | ) 85 | & nextAA)) 86 | + Hom::id 87 | ); 88 | 89 | 90 | DDD reachable = fullT2 (initial); 91 | std::cout << "Exporting the DDD Graph into morpion.dot file" << std::endl; 92 | exportDot(SDD(0,reachable),"morpion"); 93 | Statistic S2 = Statistic(reachable, "morpion" , CSV); // can also use LaTeX instead of CSV 94 | std::cout << "Statistic Generation of Morpion Space State" << std::endl; 95 | S2.print_table(std::cout); 96 | 97 | 98 | 99 | 100 | 101 | return EXIT_SUCCESS; 102 | } 103 | -------------------------------------------------------------------------------- /demo/tst1.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | #include 24 | using namespace std; 25 | 26 | #include "ddd/DDD.h" 27 | #include "ddd/MemoryManager.h" 28 | #include "ddd/statistic.hpp" 29 | 30 | typedef enum {A, B, C, D,E, F, G} var; 31 | var variables; 32 | const char* vn[]= {"A", "B", "C", "D", "E", "F", "G"}; 33 | 34 | void initName() { 35 | for (int i=A; i<=G; i++) 36 | DDD::varName(i,vn[i]); 37 | } 38 | 39 | int main(){ 40 | // Define a name for each variable 41 | initName(); 42 | 43 | // Constants null, one , top 44 | cout <<"*****************************"<<1> ="<B-2-><1> ="<A-1-><1> + A-2->B-1-><1> ="<< endl<A-1-><1> + A-2->B-2-><1>"<< endl<c ="<< endl< 2 | #include 3 | #include 4 | 5 | #include "ddd/IntDataSet.h" 6 | #include "ddd/DDD.h" 7 | #include "ddd/SDD.h" 8 | #include "ddd/SDED.h" 9 | #include "ddd/MemoryManager.h" 10 | 11 | #include "ddd/statistic.hpp" 12 | 13 | int 14 | main(int argc, char** argv) 15 | { 16 | 17 | int size = 100; 18 | if( argc == 2 ) 19 | { 20 | size = atoi(argv[1]); 21 | } 22 | 23 | SDD c = SDD::null; 24 | for( int i = 0 ; i < size ; ++i ) 25 | { 26 | std::vector local_vec; 27 | local_vec.push_back(i); 28 | IntDataSet local_ids(local_vec); 29 | c = c + SDD(3,local_ids); 30 | } 31 | 32 | SDD b = SDD::null; 33 | for( int i = 0 ; i < size ; ++i ) 34 | { 35 | std::vector local_vec; 36 | local_vec.push_back(i); 37 | IntDataSet local_ids(local_vec); 38 | b = b + SDD(2,local_ids,c); 39 | } 40 | 41 | SDD a = SDD::null; 42 | for( int i = 0 ; i < size ; ++i ) 43 | { 44 | std::vector local_vec; 45 | local_vec.push_back(i); 46 | IntDataSet local_ids(local_vec); 47 | a = a + SDD(1,local_ids,b); 48 | } 49 | 50 | Statistic S = Statistic(a,"tst11"); 51 | 52 | S.print_line(std::cout); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /demo/tst13.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | #include 24 | using namespace std; 25 | 26 | #include "ddd/DDD.h" 27 | #include "ddd/DED.h" 28 | #include "ddd/MemoryManager.h" 29 | #include "ddd/dotExporter.h" 30 | 31 | 32 | typedef enum {A, B, C} var; 33 | var variables; 34 | char* vn[]= {"A", "B", "C"}; 35 | 36 | 37 | void initName() { 38 | for (int i=A; i<=C; i++) 39 | DDD::varName(i,vn[i]); 40 | } 41 | 42 | 43 | int main(){ 44 | // Define a name for each variable 45 | initName(); 46 | 47 | // See example from FMCAD'2002 Ciardo, Radu 48 | // A first evDD 49 | DDD ev1 = GDDD(DISTANCE,0,GDDD(A,0,GDDD(DISTANCE,0,GDDD(B,0,GDDD(DISTANCE,0,GDDD(C,0,GDDD(DISTANCE,0))))))) 50 | + GDDD(DISTANCE,0,GDDD(A,0,GDDD(DISTANCE,0,GDDD(B,1,GDDD(DISTANCE,2,GDDD(C,0,GDDD(DISTANCE,0))))))) 51 | + GDDD(DISTANCE,0,GDDD(A,1,GDDD(DISTANCE,1,GDDD(B,0,GDDD(DISTANCE,1,GDDD(C,0,GDDD(DISTANCE,0))))))) 52 | + GDDD(DISTANCE,0,GDDD(A,1,GDDD(DISTANCE,1,GDDD(B,1,GDDD(DISTANCE,0,GDDD(C,1,GDDD(DISTANCE,0))))))) 53 | + GDDD(DISTANCE,0,GDDD(A,2,GDDD(DISTANCE,2,GDDD(B,0,GDDD(DISTANCE,1,GDDD(C,0,GDDD(DISTANCE,0))))))) 54 | + GDDD(DISTANCE,0,GDDD(A,2,GDDD(DISTANCE,2,GDDD(B,1,GDDD(DISTANCE,0,GDDD(C,1,GDDD(DISTANCE,0))))))) ; 55 | // Another evDD 56 | DDD ev2 = GDDD(DISTANCE,0,GDDD(A,0,GDDD(DISTANCE,0,GDDD(B,0,GDDD(DISTANCE,0,GDDD(C,0,GDDD(DISTANCE,0))))))) 57 | + GDDD(DISTANCE,0,GDDD(A,0,GDDD(DISTANCE,0,GDDD(B,0,GDDD(DISTANCE,0,GDDD(C,1,GDDD(DISTANCE,2))))))) 58 | + GDDD(DISTANCE,0,GDDD(A,1,GDDD(DISTANCE,2,GDDD(B,0,GDDD(DISTANCE,0,GDDD(C,0,GDDD(DISTANCE,0))))))) 59 | + GDDD(DISTANCE,0,GDDD(A,1,GDDD(DISTANCE,2,GDDD(B,0,GDDD(DISTANCE,0,GDDD(C,1,GDDD(DISTANCE,2))))))) 60 | + GDDD(DISTANCE,0,GDDD(A,2,GDDD(DISTANCE,1,GDDD(B,0,GDDD(DISTANCE,0,GDDD(C,0,GDDD(DISTANCE,0))))))) 61 | + GDDD(DISTANCE,0,GDDD(A,2,GDDD(DISTANCE,1,GDDD(B,0,GDDD(DISTANCE,0,GDDD(C,1,GDDD(DISTANCE,2))))))) 62 | + GDDD(DISTANCE,0,GDDD(A,2,GDDD(DISTANCE,1,GDDD(B,1,GDDD(DISTANCE,2,GDDD(C,1,GDDD(DISTANCE,0))))))) ; 63 | 64 | DDD ev3 = ev1 + ev2 ; 65 | cout << ev3; 66 | 67 | SDD ev1sdd = SDD(0,ev1); 68 | cout << ev1sdd < 24 | using namespace std; 25 | 26 | #include "ddd/SDD.h" 27 | #include "ddd/DED.h" 28 | #include "ddd/MemoryManager.h" 29 | #include "ddd/statistic.hpp" 30 | 31 | 32 | int main(){ 33 | 34 | std::cout << "sizeof(DDD) " << sizeof(DDD) << std::endl; 35 | std::cout << "sizeof(GDDD) " << sizeof(GDDD) << std::endl; 36 | 37 | 38 | std::cout << "sizeof(SDD) " << sizeof(SDD) << std::endl; 39 | std::cout << "sizeof(GSDD) " << sizeof(GSDD) << std::endl; 40 | 41 | MemoryManager::pstats(); 42 | 43 | return 1; 44 | } 45 | -------------------------------------------------------------------------------- /demo/tst15.cpp: -------------------------------------------------------------------------------- 1 | #include "SwapMLHom.hh" 2 | 3 | int main() { 4 | DDD a(0,0,GDDD(1,1,GDDD(2,3))); 5 | DDD b(0,1,GDDD(1,2,GDDD(2,3))); 6 | DDD c = a + b; 7 | 8 | Hom swap1 = Swap(0,1); 9 | Hom swap2 = Swap(0,2); 10 | Hom swap3 = Swap(2,0); 11 | Hom swap4 = Swap(2,1); 12 | 13 | std::cout << "c: " << std::endl; 14 | std::cout << c << std::endl; 15 | 16 | std::cout << "swap vars 0 and 1 in c: " << std::endl; 17 | std::cout << swap1(c) << std::endl; 18 | 19 | std::cout << "swap vars 0 and 2 in c: " << std::endl; 20 | std::cout << swap2(c) << std::endl; 21 | 22 | std::cout << "swap vars 2 and 0 in c (should be the same as the previous one): " << std::endl; 23 | std::cout << swap3(c) << std::endl; 24 | 25 | std::cout << "swap vars 2 and 1 in c: " << std::endl; 26 | std::cout << swap4(c) << std::endl; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /demo/tst2.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | #include 24 | using namespace std; 25 | 26 | #include "ddd/DDD.h" 27 | #include "ddd/MemoryManager.h" 28 | #include "ddd/statistic.hpp" 29 | 30 | 31 | typedef enum {A, B, C, D,E, F, G} var; 32 | var variables; 33 | const char* vn[]= {"A", "B", "C", "D", "E", "F", "G"}; 34 | 35 | 36 | void initName() { 37 | for (int i=A; i<=G; i++) 38 | DDD::varName(i,vn[i]); 39 | } 40 | 41 | int main(){ 42 | initName(); 43 | // Define DDDs u, v 44 | cout <<"********************"< id *"<id)(u)="<< endl<id)&(f+g)(u)="<< endl<<(Hom(E,2)&(f+g))(u)< 24 | using namespace std; 25 | 26 | #include "ddd/DDD.h" 27 | #include "ddd/MemoryManager.h" 28 | #include "PlusPlus.hh" 29 | #include "ddd/statistic.hpp" 30 | 31 | typedef enum {A, B, C, D,E, F, G} var; 32 | var variables; 33 | const char* vn[]= {"A", "B", "C", "D", "E", "F", "G"}; 34 | 35 | void initName() { 36 | for (int i=A; i<=G; i++) 37 | DDD::varName(i,vn[i]); 38 | } 39 | 40 | int main(){ 41 | initName(); 42 | 43 | cout <<"****************"< : incremente the first value of X *"<(u)="<< endl<(u)="<< endl<(u)="<< endl<(u)="<< endl< 24 | using namespace std; 25 | 26 | #include "ddd/DDD.h" 27 | #include "ddd/MemoryManager.h" 28 | #include "PlusPlus.hh" 29 | #include "ddd/statistic.hpp" 30 | 31 | 32 | typedef enum {A, B, C, D,E, F, G} var; 33 | var variables; 34 | const char* vn[]= {"A", "B", "C", "D", "E", "F", "G"}; 35 | 36 | void initName() { 37 | for (int i=A; i<=G; i++) 38 | DDD::varName(i,vn[i]); 39 | } 40 | 41 | int main(){ 42 | initName(); 43 | 44 | cout <<"****************"< : incremente all values of X *"<(u)="<< endl<(u)="<< endl<(u)="<< endl<(u)="<< endl< 24 | using namespace std; 25 | 26 | #include "ddd/DDD.h" 27 | #include "ddd/MemoryManager.h" 28 | #include "SetVar.hh" 29 | #include "ddd/statistic.hpp" 30 | 31 | 32 | typedef enum {A, B, C, D,E, F, G} var; 33 | var variables; 34 | const char* vn[]= {"A", "B", "C", "D", "E", "F", "G"}; 35 | 36 | void initName() { 37 | for (int i=A; i<=G; i++) 38 | DDD::varName(i,vn[i]); 39 | } 40 | 41 | int main(){ 42 | initName(); 43 | 44 | cout <<"****************"< : set the first value of X to d *"<(u)="<< endl< : set the first value of Y to the first value of Y *"<(u)="<< endl<(u)="<< endl<(u)="<< endl<(u)="<< endl< 24 | using namespace std; 25 | 26 | #include "ddd/DDD.h" 27 | #include "ddd/MemoryManager.h" 28 | #include "PermuteVar.hh" 29 | #include "ddd/statistic.hpp" 30 | 31 | typedef enum {A, B, C, D,E, F, G} var; 32 | var variables; 33 | const char* vn[]= {"A", "B", "C", "D", "E", "F", "G"}; 34 | 35 | void initName() { 36 | for (int i=A; i<=G; i++) 37 | DDD::varName(i,vn[i]); 38 | } 39 | 40 | int main(){ 41 | initName(); 42 | 43 | cout <<"****************"< : permute the first value of X and Y *"<(u)="<< endl< 24 | using namespace std; 25 | 26 | #include "ddd/DDD.h" 27 | #include "ddd/DED.h" 28 | #include "ddd/MemoryManager.h" 29 | #include "ddd/statistic.hpp" 30 | 31 | typedef enum {A, B, C, D,E, F, G} var; 32 | var variables; 33 | const char* vn[]= {"A", "B", "C", "D", "E", "F", "G"}; 34 | 35 | void initName() { 36 | for (int i=A; i<=G; i++) 37 | DDD::varName(i,vn[i]); 38 | } 39 | 40 | int main(){ 41 | // Define a name for each variable 42 | initName(); 43 | 44 | 45 | DDD d1(A,1); 46 | DDD d2(B,2); 47 | d2=d1; 48 | 49 | 50 | Statistic s(d1,"before garbage",CSV); 51 | 52 | MemoryManager::garbage(); 53 | Statistic s2(d2,"after garbage",CSV); 54 | 55 | s.print_header(cout); 56 | s.print_line(cout); 57 | s2.print_line(cout); 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /demo/tst8.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* */ 3 | /* This file is part of libDDD, a library for manipulation of DDD and SDD. */ 4 | /* */ 5 | /* Copyright (C) 2001-2008 Yann Thierry-Mieg, Jean-Michel Couvreur */ 6 | /* and Denis Poitrenaud */ 7 | /* */ 8 | /* This program is free software; you can redistribute it and/or modify */ 9 | /* it under the terms of the GNU Lesser General Public License as */ 10 | /* published by the Free Software Foundation; either version 3 of the */ 11 | /* License, or (at your option) any later version. */ 12 | /* This program is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU LEsserGeneral Public License for more details. */ 16 | /* */ 17 | /* You should have received a copy of the GNU Lesser General Public License */ 18 | /* along with this program; if not, write to the Free Software */ 19 | /*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 20 | /* */ 21 | /****************************************************************************/ 22 | 23 | #include 24 | using namespace std; 25 | 26 | #include "ddd/DDD.h" 27 | #include "ddd/DED.h" 28 | #include "ddd/Hom.h" 29 | #include "ddd/MemoryManager.h" 30 | #include "ddd/statistic.hpp" 31 | 32 | typedef enum {A, B, C, D,E, F, G} var; 33 | var variables; 34 | const char* vn[]= {"A", "B", "C", "D", "E", "F", "G"}; 35 | 36 | void initName() { 37 | for (int i=A; i<=G; i++) 38 | DDD::varName(i,vn[i]); 39 | } 40 | 41 | 42 | // Apply the hom f to the first occurrence of var 43 | class _sub:public StrongHom { 44 | int var; 45 | // We use the type GHom (instead of Hom) in the attributes of homomorphisms. 46 | // This is necessary to allow correct memory reference counting. 47 | // Similarly use an attribute of type GDDD instead of DDD. 48 | // When using such attributes you must implement mark(). 49 | GHom f; 50 | public: 51 | _sub(int vr,const GHom &g):var(vr),f(g) {}; 52 | 53 | GDDD phiOne() const { 54 | return GDDD::top; 55 | } 56 | 57 | bool skip_variable (int vr) const { 58 | /** this definition is equivalent to placing : 59 | if (vr != var) 60 | return GHom(vr,vl,this); 61 | * at the top of phi() function. 62 | * However it enables library optimizations when defined as "skip".*/ 63 | return var != vr; 64 | } 65 | 66 | GHom phi(int vr, int vl) const { 67 | // implicitly vr == var because of skip_variable definition. 68 | return f&GHom(vr,vl); 69 | } 70 | 71 | size_t hash() const { 72 | return (size_t) var + f.hash(); 73 | } 74 | 75 | bool operator==(const StrongHom &s) const { 76 | const _sub & ps = (const _sub&)s; 77 | return (var == ps.var)&&(f == ps.f); 78 | } 79 | 80 | _GHom * clone () const { return new _sub(*this); } 81 | 82 | void mark() const { 83 | // must implement mark function if attributes of type GHom or GDDD 84 | f.mark(); 85 | } 86 | }; 87 | 88 | // User function : Construct a Hom 89 | GHom applyToVar (int vr,const GHom &g){return _sub(vr,g);}; 90 | 91 | int main(){ 92 | initName(); 93 | 94 | cout <<"****************"<(u)="<< endl<(u)="<< endl<(u)="<< endl<(u)="<< endl< 24 | using namespace std; 25 | 26 | #include "ddd/DDD.h" 27 | #include "ddd/DED.h" 28 | #include "ddd/MemoryManager.h" 29 | #include "ddd/statistic.hpp" 30 | 31 | typedef enum {A, B, C, D,E, F, G} var; 32 | var variables; 33 | const char* vn[]= {"A", "B", "C", "D", "E", "F", "G"}; 34 | 35 | void initName() { 36 | for (int i=A; i<=G; i++) 37 | DDD::varName(i,vn[i]); 38 | } 39 | 40 | int main(){ 41 | // Define a name for each variable 42 | initName(); 43 | 44 | DDD d1=(DDD(A,5,6) ^ DDD(B,5,7)); 45 | DDD d2=(DDD(A,5) ^ DDD(B,6,8)); 46 | 47 | DDD d =d1-d2; 48 | // [ A(5) B(5) ] 49 | // [ A(6) T ] 50 | 51 | cout<<"d1="< 2 | Please comment this page and report errors about it on 3 | the RefDocComments page. 4 |
5 | Generated on $datetime for $projectname by doxygen $doxygenversion
6 | 7 | 8 | -------------------------------------------------------------------------------- /doc/mainpage.dox: -------------------------------------------------------------------------------- 1 | /// \mainpage 2 | /// 3 | /// \section overview The Data Decision Diagram Library 4 | /// 5 | /// libDDD is a data decision diagram library. It provides algorithms and data 6 | /// structures to implement symbolic manipulation of data, in particular in the 7 | /// context of model-checking. It offers support for Hierarchical Set Decision Diagrams, 8 | /// and the simpler Data Decision Diagrams. Operations on theses structures are 9 | /// both efficiently and elegantly encoded as Homomorphisms. 10 | /// 11 | /// See ddd.lip6.fr for more 12 | /// information about this project. 13 | /// 14 | /// \section thisdoc Introduction 15 | /// 16 | /// This document describes all the public data structures and functions 17 | /// of libDDD. This aims to be a reference manual, not a tutorial. 18 | /// 19 | /// Although some effort has been invested in creating these doxy pages, 20 | /// the actual source files often contain more comments which are not doxy-compliant. 21 | /// 22 | /// 23 | /// \section pointers Handy starting points 24 | /// 25 | /// Most user functionality is found in the files: 26 | /// 27 | /// For SDD: SDD.h (Basic set operations) SHom.h (Homomorphisms) 28 | /// 29 | /// For DDD: DDD.h (Basic set operations) Hom.h (Homomorphisms) 30 | /// 31 | /// Then, as a starting point, have a look at the pages GSDD, and GShom. 32 | /// 33 | /// Remember that garbage collection should be done by invoking MemoryManager::garbage(). 34 | /// 35 | /// Some useful annex functionality can be found in statistic.hpp and util/dotExporter.h 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /m4/ax_boost_base.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AX_CHECK_BOOST], 2 | [ 3 | AC_LANG_PUSH([C++]) 4 | 5 | AC_CHECK_HEADER([boost/version.hpp],, [AC_MSG_WARN([ 6 | Cannot find Boost headers. If they are installed on an unusuall path on 7 | your system, please run configure with the suitable CPPFLAGS and LDFLAGS 8 | options. For instance if it is installed in /opt/boost/ please use: 9 | 10 | ./configure CPPFLAGS="-I/opt/boost/include" LDFLAGS="-L/opt/boost/lib" 11 | ])]) 12 | 13 | AC_CACHE_CHECK([whether Boost version is >= $1], [ac_cv_boost_recent], 14 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 15 | @%:@include 16 | ]], [[ 17 | #if BOOST_VERSION >= $2 18 | // Everything is okay 19 | #else 20 | # error Boost version is too old 21 | #endif 22 | ]])],[ 23 | ac_cv_boost_recent=yes 24 | ],[ 25 | ac_cv_boost_recent=no 26 | ])]) 27 | if test "x$ac_cvboost_recent" = xno; then 28 | AC_MSG_WARN([Boost appears to be too old. We need version $1 or more recent.]) 29 | else 30 | AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) 31 | fi 32 | 33 | AC_LANG_POP([C++]) 34 | ]) 35 | -------------------------------------------------------------------------------- /tag.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | DD=`date +'%Y%m%d%H%M%S'` 4 | sed -i configure.ac -e "s/1\.9\.0/1.9.0.$DD/" 5 | cd website 6 | sed -i index.html -e "s/DATETIME/$DD/" 7 | cd .. 8 | -------------------------------------------------------------------------------- /website/index.html: -------------------------------------------------------------------------------- 1 |

Download page for LibDDD

2 | 3 |

4 | Our main page is still hosted at lip6 : DDD homepage 5 |

6 | 7 |

8 | Download the latest distribution here : ddd-1.9.0 latest 9 |

10 | 11 |

12 | Developer documentation with Doxygen is published here. 13 |

14 | 15 |

16 | Download the latest artifacts here (result of make install) : 17 |

28 |

29 | 30 |

This page and these artifacts are built using GitHub Actions. We thank GitHub for providing hosting and compilation time for these artifacts.

31 | 32 |

This software is made available under the terms of Gnu LGPL

33 | 34 |

Contact author : Yann .Thierry-Mieg@lip6.fr

35 | --------------------------------------------------------------------------------